Latin Invaders

Leave a comment

I present you Latin Invaders. This was for the Adelaide University Game Development Club – Third Game Jam in 2010.
It took about an hour to adapt the existing code base I had from Space Invaders to fit the theme "Every Letter of the Alphabet"

Story
The Latin character sets from the planeta Marineris.
You are the last line of defence and must shoot them out of the sky.

Theme Usage
I choose instead of using the theme in a subliminal manner to go for the superliminal manner (superliminal is a word from the Simpsons)

How to Play
Left Arrow Key – Moves Left
Right Arrow Key – Moves Right
Space Bar – Fires

Download
I will post a download to the source and Window Binary at a later time.

 

Development

The first step I took was in the InitGame function where it loads the graphics for the Invaders, arrays of SDL_Surfaces were setup to hold the sprites for the Invaders, and setup a for loop to populate this, then changed the existing loading to instead just refer to the some sprites in this array for testing to ensure it rendered correctly. There were 3 structures one for the top set, one for the middle set and one bottom set, which held onto the frames for the particular type of invaders (since there are 3 types). Upon simply commented out or deleting it showed all the use cases. I realised that I could improve the system, I had originally had 2 arrays one for frame 1 and one for frame 2, then I simplified it to be vaderFrames[2][26] but upon realising the structure mentioned earlier took an array of SDL_Surfaces which are the frames so changed it to do vaderFrames[26][2] this allows  it to just go theFramesForVaderZ = invaderFrame[25];. The structure was removed and the code was simplified so each Vader Instance (which has weather its alive or dead), also held a pointer to the frames, which is what the theFramesForVaderZ really is its more invader[25].frames = invaderFrame[25]. That was it, just  fixed hte rendering code to use the new array. The next step was to replace the loading of the player and bonus ship graphics with text instead for added effect.

Cleanup on the data files were performance to removed the unused graphics, since the Bonus ship, invaders and the player graphics were now text based.

Since I had done all my development so far on Microsoft Windows with Visual Studio, I decided to boot up Canonical Ubuntu in Oracle VirtualBox, and quickly found there were a few problems with the Makefile, the first being it always produced SpaceInvaders.exe, so split this into two parts TARGET and EXT (these are variables), the TARGET would be latininvaders and on Windows_NT the EXT would be .exe. The next problem was the run target, on windows launching it with Release\latininvaders.exe is fine but on Linux it should be ./Release/latininvaders so added the RUN command to the if def and yes it uses TARGET and EXT variables.

I was planning on changing the background image with one generated from text but lost motivation and just wanted to get this little project completed. I then ran Radical Image Optimization Tool over certain images to make them smaller. It was quite successfully reduced entire size of all the images and the font to be half the file size of the background image original was. Very nice tool, that I recommend as it features a preview which you can zoom in so you can see the pixels closer to see the differences.

Pangrams Game Idea

Leave a comment

This is an idea I had the night of the Adelaide Unviersity Game Development Club Third GameJam started or possibly the day after. I however had no focus to actually getting around to coding it and since there is also requires art work to match the game play neither the time to waste on trying to draw the stuff my self or finding external resources (I had considered clipart but anyway).

Have not thought of a proper name for the game yet so I have titled it Pangrams.

Enviroment
The game play style is point and click style, you click on the scene to move the character around, you can also click on actions such as “Use” or “Pick Up” and have an inventory. The objective is to collect different objects or perform different actions in a “scene” to complete it. The idea was to have about 4-5 scenes maybe more depending on time and available art work. There would be multiple entry and exit points to the scene.

Theme
The theme comes from that the levels/scenes are constructed from Pangrams, which for those not up to date on bizarre words are “are sentences using every letter of the alphabet at least once. ”

Game Play Example
The first would be depict the most widely known pangram. “The quick brown fox jumps over the lazy dog.” , so there is a Dog lying lets say on a bridge and so you the fox can’t bet past, to leave the right hand side of the screen to go to the next level. You have no current way to get past him so you leave to the left to go to another scene. This scene would be Jackdaws love my big sphinx of quartz. So you have to take a Jackdaws (bird) to a sphinx made out of quartz, upon doing this you get a pogostick (this was Shrubber’s idea). Now you return to the original scene and can jump over the dog with the pogostick.
Ideally here for simplicity the player would not always be a fox, so possibly when apporitate (need a new main character) the player transformers into the another… Maybe this is a artifical reality game, and they change avatar.

List of possible appropriate pangrams:

  • The jay, pig, fox, zebra, and my wolves quack!
  • Wolf zombies quickly spot the jinxed grave
  • Waxy and quivering, jocks fumble pizza.
  • Vamp fox held quartz duck just by wing.
  • How quickly daft jumping zebras vex.
  • The lazy major was fixing Cupid’s broken quiver.

Ideally game play is a whole lot more adventure like if you don’t realise what the panagrams are. The idea was once you compelte one it would flash up with the pangram on the screen.

Sorry, I did implementation this game.

Yet Another Space Invader Clone Progress Update

Leave a comment

This update is very long overdue, the text actually has been sitting in a text file on my computer for quite some time.

It has been a while, currently waiting for a bed to arrive so decided as good as time as anyway to work on my Space Invaders game. A couple of nights ago I did do some work on it, I replaced all the menu graphics with ones Izzy and myself made. I also replaced the bullet and your turrent with ones I made.

My goal for this session is have the bonus ship that flies across the top from time to time, implemented both
in the movement code to allow it to fly as well as the
being able to shoot it. I spent a few moments making a sprite for it using the same style of the turrent

I don’t currently have internet at home/ on my computer so my ability to code is some what reduced.

The idea for handling the when the bonus mothership appears is on start randomly generate a number and store it, and find the perfect spot to decrement this number in, so when it hits 0 then the ship will appear on the screen and travel across it. Considered doing the seed based on time but really not that fussed. The formual I went for in the end was invaderBonusSpawn = ((RAND_MAX – rand()) >> 4) + 400; and then settled on invaderBonus.spawnCount = ((RAND_MAX – rand()) >> 4) + (1000 % rand() );.

Some slightly intresting trick I did is the movement of the bonus ship moves by generating a random number if it is even it will increment the ship by 1.
Comitted my work, at this stage i have spawning, rendering, translating of the bonus invader implemented. The next part is collision detection with the player’s bullet and if detected then increment score and set invader to dead. All up took me about 35 minutes. Most of which was spent playing with the velocity of the bonus invader and the spawning.

The collision detection part was a whole lot easier only took about 15 minutes all up, just required me to track where the collision detection code for the bullet occurs, add the apporiate if statements, and then if it is the bonus ship set the bullet/ship to dead, and increment the score and reset the spawn counter for the bonus ship.

Now for a quick summary of things to do to truely make this project complete is allow the invaders to shoot down at the player, and also implement the shield blocks so you can hide under, and shoot through, and also have them discitergrate when the invaders move through it.

As it stands the current media assets are 1.4MiB, the executable is 16.5KiB, and third party libraries (SDL) are 994KiB.

Okay Nexus will take a look, mainly just used it as a project to figure out ways to setup and use SDL, and how to structure some things, and was just aiming to replicate the basic game play.

Space Invader Clone Progress Update – Day 7

Leave a comment

Day 7

Added Handling varying movemnet speed of the invaders using Microsoft Excel to graph, and calcuate a formalae,
to scale the speed at which the invaders move based on the number of invaders left. So less invaders, the faster they move.

The following was done between between Day 6 and Day 7. was a 15 minute job, to remove a game over variable as its redundant by checking if the number of lives is equal to 0.
Next had to implement the animation of the invaders, each invader graphic has 2 frames, so we alternate between them, I had wrote this code earlier but the limiting code, didn’t
get around to write the limiting code till now, so it was commented out previously.

The idea is to setup so once you clear the invaders it will reset, so revert the invaders, and increment them down a starting position, for the next level.
This was really easy, seperate out the code in the InitGame which initalises each invaders to alive, and the number of invaders alive in total, rows and columns.
After hte last invader is killed, we check if there are no more invaders left, then run this ResetLevel. Added a varible so each time u call ResetLevel(), it will start the invaders from the next line.
And quite proud got that done before midnight, so about two hours maybe two and a half hours of work. That was implemented so now I have have an actual game which, you can keep playing getting more score until game over.

The next step being the bonus ship, which isn’t that tricky or complicated, so will leave that for next time, then invaders firing/ sheild blocks.

Space Invader Clone Progress Update – Day 6

Leave a comment

Day 6

The better late then never progress update.
This is really backlogged entry, since it was actually done after Day 5, i just never got around to writing it up.

First things first, I changed a few things such that it will use the window headers for non debug builds on windows, so you can make a Windows Application rather then Console. (so it doesn’t have a terminal present).

Secondly added the code that causes the game to pause when you Alt+Tab / or in general loose focus of the window.

Thirdly applied the apporitate tweak such that the invaders will move down when they reach the edges of the screen as they move across.

Fourthly added the skeleton for the game over screen, and added a new invadersAlive varible for counting the number of invaders alive in each row. to save computation, and for testing where to take “the bottom of the invaders” from to determine if they have reached the bottom of the screen.

I mentioned in last update that “went they touch the the bottom, you loose a live and it restarts the level”, however after seeing how the arcade version plays, you just get game over when this happens, so lives are just for getting shot at.

Lastly I added the rendering code to display the information to the Game Over screen, and so I did manage to get that all done, and one little code cleanup to remove the need for a specific Boolean for game over. However since i never posted this 🙂 i never considered what I would do next so haven’t done anything since.

Current full list of TO DO: Is limit the movement speed of invaders based on number of Vader left, add the shields that you can hide behind, allow the Vader to shoot you and add the bonus invader

Space Invader Clone Progress Update – Day 5

Leave a comment

The fifth day of development.

First things first i correctly the oops that i forgot to do sooner, which was set the inital number of lives when you start a game.

Implemented a improved EnforceVaderBounds which is responsible for detecting when the Invaders have hit the edges of the screen, and change direction.
Firstly I fixed a slight problem in PlayerShootVaderDetection() which was not doing equality checks on the boundary just > and <. Secondly split up the index calcuation to provide the X index (so column), and added an array which for each column stores the number of invaders remaining alive, and so when one is hit it decrements using the X index from this array.

This allowed the implementation for EnforceVaderBounds(), which provides more accurate ability to bounce off of the sides, instead of just being the first and last column we consider first if the nearest column has invaders left if not we go by the start of the next column.

Using the lovely piece of code below, the right way is the same but goes from 10 to 0.

// Calculates the left most column with any invaders still living.
for (i = 0; i < 11 && invadersAlive == 0; i++);

Next on the todo list was the Pause screen this included creating a new state, and then overcoming a problem. At the time when the state changed we call the deinit method for that state then when we return we call the init. So when going from Game -> Pause we would loose all the information then Pause -> Game would start a new game. The solution was add a boolean to the ChangeState that defines weather this state change is to a cleanState (eg will deinit and init be called), so a un-cleanState would be the pause which leaves the Game State still set. finally added how to draw the pause screen.

Accidentally forgot to commit the 🙂 new files as per usual with new states (like i did with the game state for quite some time)

I had considered a “Demo” as a Windows release but I think i will hold out until final.

Next time: Game Over State, Invader vertical movement so they move down, and went touch the just above you, you loose a live and it restarts the level. Hopefully I will get enough time tomorrow to handle all of that.

Donno Signing Off.

Space Invader Clone Progress Update – Day 4

Leave a comment

Day Four

Skipped an actual day of the week (Did no work on space invaders during the 2nd of December) with other work.

Got into it today, the thing i wanted working today is human movement and firing.

Started by first solving a memory access area I was facing due to not setting a pointer (SDL_Surface) to NULL after freeing it. Added a struct for representing all the invaders on the field, this was as followed, it has a boolean which is is it alive or dead (can be considered as visible or invisible), and the invader instance, this is a pointer to either topInvader, middleInvader or bottomInvader. Each of those 3 are an Invader struct which has a pointer to the surfaces for frame1 and frame2, granted this could really be inline so it doesn’t have to go find the other struct (but this way saves a little bit of memory). The invader struct was created before when the images were to be loaded on the Initialization of the game state.

struct Invader {
SDL_Surface *frame1;
SDL_Surface *frame2;
};
struct InvaderInstance {
struct Invader *invader;
bool alive;
};

Also did some cosmetics changes, fixed some assets, and added the background to the game window, and introduced a structure for the Player information (position and surface), might consider moving score and lives into this. So added the code to load the player image on init, and then display it to the screen, then changed the event handler so escape will quit, left and right will move left and right. Originally I was using the SDL function to Repeat keys so if you hold a key down for a certain time it triggers a repeat which will generate that event multiple times at a set interval, this would of been good as it meant Time Based rather than frame rate depend movement. I then later changed it to be Frame based, so when you hold the arrow key it will remember that and if u keep doing it each frame it will move you a pixel. While reading the SDL documentation I found there is a method called SDL_DisplayFormat which will create a new surface from an existing one but Covert it to use the same modes as the current display. Otherwise each time you bit the surface to the screen it will have to perform the conversion.

Had a kind of big and frustrating setback, a bug in the movement code, it ended up being I had forgotten the break statement after the LEFT arrow key handler so it was then performing the RIGHT arrow key handler. Got side tracked a lot after this thinking how best to handle the Fire event, i had considered making use of a custom ‘user’ SDL event, so, when you press fire it creates the event, puts it on the event queue, and then have a handler so if fire, then we decrease the Y (moving it to the top of the screen), and also then handle the collision detection there, so its in the event handler, and if its not out of screen bound or hit something then Push it back n the queue so it gets called next time. Okay that wasn’t entirely true, that what i have in mind now and i actually like that idea as it moves the detection/handling of a fire into the Event Handler and out of the Rendering code. At the time i was thinking of a Timer which would generate the Fire events every X seconds. At the time of writing this im thinking when i get time I will indeed replace the fire stuff with an event, which it will process in the event handler.

For the collision detection i choose to do 4 prelim condition statements, first consider if the bullet is Inside the frame of invaders so the Bullets Y is below the bottom of the bounding box of all the invaders as a whole, then did if Bullet is pass the top of the invaders, then is it to the left of the bounding box, then to the right. Really i should switch that around so it does the pass the top. last. because if its with in above the bottom, and not within in the x it wll wait till it gets to the top to ignore it, so it will keep doing the y ones then the x, where other way around it will exit sooner on the case where you shoot outside and if you not within the sides (X and X + width), then there is no point of testing if you above it.

Very last thing i did was added the the scoring since Weesals mentioned it, which was quite easy based on the row which the invader we hit is in, add that to the score.

%ATTACHMENT: si_g4.jpg%

So still plenty to do, like the changing of how firing works to use events, make the Vader MOVE, (just a matter of incrementing the position base, and dealing with wrapping bouncing etc), thou Vaders movements are suppose to be timed based on the number left, so should be fun.

Then once that done if they reach the end decrease a life and TRY again, then Vader firing, the shields, loosing a life if a Vader hits you. Also just noticed I initializes the lives to 0 😛 will make that 3 or 5. Oh also forgot I need to do the PAUSE screen, and will need a Game Over screen.

Really want to do the pause screen first, but if the vaders move then, that version can be shared as a demo since it has a some point.

Older Entries