Author Topic: Spaceinvader game  (Read 9646 times)

0 Members and 1 Guest are viewing this topic.

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Spaceinvader game
« on: January 01, 2014, 11:43:14 am »
This is my current project
It seems that I am pushing the Prime to its limmits, since it runs slower on the calculator than in the emulator.
This is the raw game, no splach screens or score counting.
I am open for questions and comments

EDIT: After modifying the code and optimizing collision detection it seems to run much faster.
EDIT: Controls is mouse move ship, Enter - fire bullits, Esc - quit
EDIT: Log - change weapon
         Pick up greens for more energy
EDIT: added Alien boss level
EDIT:Some fade in added and levels start outside screen

« Last Edit: January 12, 2014, 12:15:38 pm by Handmixer »

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55851
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Spaceinvader game
« Reply #1 on: January 02, 2014, 05:23:59 pm »
Oh that seems pretty nice so far. Are the graphics placeholders or did you plan to use them? I think a star background would be nice. Also do the graphics use rectangles? If that's the case, that's a quite clever, since DIMGROB sprite data is usually incredibly large compared to if sprites are pre-rendered with RECT_P commands. :)

Btw sorry for not replying sooner, I had a crazy two weeks of work and other activities. >.<

EDIT: Wow this is pretty impressive. I am surprised at the slow on-calc speed, though, considering I had some advanced graphical animations running at over 15 FPS, sometimes much higher (even 3D). I wonder if there isn't some command somewhere that could be slowing the game down considerably or if some for loops could be merged together to reduce the wait (or maybe the amount of bullets on the screen at once reduced to 5-10 max instead of 20)? On the previous firmware, INT() was often the culprit. Or could there be things that could simply be pre-rendered and only updated if necessary? (For example, when you draw the enemy ships, one trick could be to display all of them and all their frames in an extra GROB then instead of drawing each ship individually every loop, you just display the entire GROB in one BLIT command. To update the ship army when one is destroyed or when a  new wave appears, you just do it once an enemy is shot).

Also make sure to remove the WAIT commands for the calc version. :)

One thing I like a lot is how we can use the touch screen to move the ship and ESPECIALLY the explosion at the end, which is very reminiscent from Axe Parser games :).
« Last Edit: January 02, 2014, 08:22:03 pm by DJ Omnimaga »
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline XiiDraco

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 513
  • Rating: +32/-5
  • Forget the numbers, just call me, Recreation.
    • View Profile
    • Black-Lark Games
Re: Spaceinvader game
« Reply #2 on: January 02, 2014, 05:51:15 pm »
I get entirely how the touchscreen works with its lists but, can't get the syntax for lists right on the prime yet. >_< Then again I pretty much never touch the thing now that I'm working on Abandoned. I should make a game for prime but I'm too lazy.

Anyway nice game Handmixer!

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Re: Spaceinvader game
« Reply #3 on: January 03, 2014, 01:58:37 am »
The graphic is predrawn into G3, so that G3 contains all animations. This takes up less space.
In the end of the gameloop there is a WAIT(0.05), this is entirely for the emulator, since it will run to fast.

The gameloop doe contain a lot of FOR-loops for moving, collision detect and rendering, I Think that it may be possible to optimize by reducing to a few FOR loops.

Star background is a good idea. It could be predrawn i G4 and Blit'ed to the render buffer at the beginning of each render cycle

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Spaceinvader game
« Reply #4 on: January 03, 2014, 03:00:53 am »
I don't know a lot about the Prime and your game, but if all Invaders move at the same time and in the same direction, couldn't you have one image with them all instead of separate images so that it is faster to move them all ? And when one is hit, you edit the image, would that be possible ?
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55851
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Spaceinvader game
« Reply #5 on: January 03, 2014, 10:48:07 am »
The graphic is predrawn into G3, so that G3 contains all animations. This takes up less space.
In the end of the gameloop there is a WAIT(0.05), this is entirely for the emulator, since it will run to fast.

The gameloop doe contain a lot of FOR-loops for moving, collision detect and rendering, I Think that it may be possible to optimize by reducing to a few FOR loops.

Star background is a good idea. It could be predrawn i G4 and Blit'ed to the render buffer at the beginning of each render cycle

I think it wouldn't be a big issue to use more space with a larger GROB to store each possible frame of the entire enemy army rather than each ship, since the calculator has over 16 MB of RAM available for the user. Even with the largest possible army it would most likely take 1 MB or less (assuming, for example, that an enemy army takes a 300x200 area and has 8 frames, each pixel taking 2 bytes). The hardest part would probably be to erase destroyed ships, since you would need to apply a RECT_P command on all 8 frames on the destroyed ship, while also updating your matrix data or whatever.

I the worst case scenario, you could always cut down animation frames to save space.

As for the WAIT command, I think a trick would be to use a TICKS command at the start of the frame then another one at the end. Then you just have to use a WAIT command where you substract both resulting ticks value then divide the result, to keep frame rate consistent.
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Re: Spaceinvader game
« Reply #6 on: January 03, 2014, 12:32:17 pm »
Ok, this afternoon I have modified the rendering so that the Whole army is in one GROB.
I was also worried that when 1 alien is killed I had to do 10xRECT and it would affect playing the game, but it hardly does.
I decreased the bombs and bullits to 10, but I think making a queue, rather than a FOR-loop also could reduce som time.
Later I will try to reduce the amount of FOR loops by collecting the movement and the rendering in the same loop.

Thanks for the feedback

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55851
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Spaceinvader game
« Reply #7 on: January 03, 2014, 12:45:54 pm »
Yeah, there could possibly be some minor slowdown when killing an alien, more noticeable if everything moves very smoothly. However, I noticed that Zelda: Windwaker for the GameCube, which is a commercially aclaimed game, also does it, so I guess it's not too bad unless the lag is extreme. :P

By the way, how do we use bombs? ???
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Re: Spaceinvader game
« Reply #8 on: January 03, 2014, 02:32:15 pm »
The file has been updated.

Bombs are dropped by aliens >B)

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55851
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Re: Spaceinvader game
« Reply #9 on: January 03, 2014, 03:13:28 pm »
Ok thanks. I'll try the new version later. :)
In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline MacBernick

  • LV3 Member (Next: 100)
  • ***
  • Posts: 93
  • Rating: +3/-0
    • View Profile
Re: Spaceinvader game
« Reply #10 on: January 03, 2014, 07:54:21 pm »
Nice, the aliens are so cute ^^

But why is this so slow ?
I don't get how you're doing collisions detection. Are you sure it's optimal ?

Offline DJ Omnimaga

  • Former TI programmer
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55851
  • Rating: +3151/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • DJ Omnimaga Music
Re: Spaceinvader game
« Reply #11 on: January 03, 2014, 08:19:44 pm »
I think the slowdown comes from the fact the game allows multiple bullets at once on the screen. I changed the game so only 1 bullet is allowed at once instead of 10 and the game goes much faster. However it becomes incredibly hard lol. I don't get why it runs slow, though, consdiering Trailblazer gets 38 frames per second. It might definitively be worth it to post the code, in case someone here can help optimizing. It could be due to a bug too, such as running the same routine 10 times per loop when it could be ran once. Or maybe the collision method used is that slow?

In case you are wondering where I went, I left Omni back in 2015 to form CodeWalrus due to various reasons explained back then, but I stopped calc dev in 2016 and am now mostly active on the CW Discord server at https://discord.gg/cuZcfcF



Official Website |T-Shirt store | Reverbnation | Facebook | Youtube | Twitter | Spotify

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Re: Spaceinvader game
« Reply #12 on: January 04, 2014, 04:29:13 am »
Collision detection is the problem.
For each frame there is number_of_aliens*possible_number of bullits compares.
I will Work on that to try to improve speed

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Spaceinvader game
« Reply #13 on: January 04, 2014, 04:33:43 am »
Can't you just make a loop on the number of bullets, detect if there is a pixel (so an alien), then guess which alien it is with the position of the bullet ?
« Last Edit: January 04, 2014, 04:33:59 am by Hayleia »
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Handmixer

  • LV2 Member (Next: 40)
  • **
  • Posts: 21
  • Rating: +0/-0
    • View Profile
Re: Spaceinvader game
« Reply #14 on: January 04, 2014, 05:25:21 am »
New version with improved collision detection has been uploaded. Now I just loop the bullits and calculate the position in alien-space. Much better.
Now I will concentrate on the star background and other Things I want in the game.