• Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

About this blog

A journal of my progress on Cops & Robbers

Entries in this blog

Ok, so that plan failed...

So it's been several months since I was last properly programming and so I am extremely rusty. So I have decided to go back a step and start a new project that I should be able to complete over this Easter holiday.

This is the prefect time to start a new project since I only have a handful of exams to revise for and have recently quit my job - plenty of free time [grin].

My new project is going to be a Snake clone that I am currently calling Glo-worm. My goal in this project is to get animations working and my idea was to show this off by having the worm glowing - hence the name Glo-worm [smile].

So far I have my blank project with SDL, FMOD set up and so I have a blank window. But before I go any further I need to get a plan written down...

Thanks for reading

Killing In The Name

So, the xmas holidays have finally started for me [grin]. Unfortunately, I've got some assignments to do over these holidays. So in between doing those and relaxing after a busy term there won't be much time left for game development.

However, the next step I want to take is to rewrite Cops & Robbers from scratch as I was having a problem with playing animations, which I think is from not having a well structured system in place. I've seen a couple of things in various articles that I want to implement. (Some rather simple like having everything derive from an Entity class which will save me writing a lot of GetX(), GetY() GetImage() type functions [rolleyes]).

So, in the free time I do have I'm going to plan Cops & Robbers properly so that come the Easter holidays I can program it. I may post my plan as I go along to get any advice from your kind selves about obvious problems that I may not see.

Anyway, thanks for reading.

One Month Off

Make that more like three months [grin]. Not much progress on Cops & Robbers this past week. I managed to make a small improvement on the framerate when the player has the cannon but that's about it [rolleyes].

My plan over the next few months is for this to take a back seat for a while. I would like to try and get the more complex enemy AI, that I had planned, to work. This is so that I can see the pitfalls that I may encounter when I do a complete rewrite of Cops & Robbers over Xmas (if I have time). I have also seen some things in tutorials that might be quite useful (e.g having everything inherit from an Entity class). Other things I plan to do over this term is to brush up on some general computer science knowledge.

Anyway, thanks for everyone's support over the past few months. And I hope to be back at Xmas [smile].

Thanks for reading


I found the problem I was having [grin]. I hadn't defined a copy constructor for the Animation class [rolleyes] so when I was copying the temporary Animation to my AnimationManager class it was performing a shallow copy (I think these are the correct terms). I also had to iron out a couple of other kinks with the AnimationManager class.

Also, I can only handle animations with a 32 x 32 frame and 11 frames because I have to put an empty frame and animation of the same size so that the real ones can be copied over in the copy constructor. So that is definitly something I will need to improve for the next game. (As an aside that seems to be the way these games have gone - kind of bumble through adding something new and then improving it in the next game when I know more about what needs to done and the caveats etc. [smile])

There is, however, quite a bit of tinkering to do with the animations because it causes horrific slowdown. But hopefully I should be able to get that done before uni starts and then this will have to take a back seat for a few months.

Thanks for reading

PS Thanks for the couple of messages of support I received. They were much appreciated.
Not much done recently, I'm starting to lose motivation. Anyway, I've been trying to get animations working (for explosions) but I keep on running into problem after problem. I'll keep trying...

Thanks for reading
Not much done recently, unfortunately. I'm just slowly implementing the cannon one step at a time. At the moment, I can pick up the cannon icon, subsequently change the player's image and then drop the cannon after 10 seconds. I am also thinking about adding tanks as an extra type of enemy but this might be a bit extraneous. I'll see though...

Thanks for reading
Here is the first demo for Cops & Robbers! (Source code included) [grin] So, what do you think?

Quite a few small things done today. First, I managed to get money implemented so that when you go to the pick up point you 'carry' some money (determined by the game timer) and then when you reach the drop off point that money gets added to your total money.

Second, I added arrows to point you in the direction of the target if it is offscreen. (I may make this a bit batter and have it align itself with the target. At the moment, it's just halfway across that side of the screen)

Third, I made movement a little better. Previously you could overlap the tiles because I was checking the midpoint of the leading side. (This was because sometimes the tile being checked was wrong so that some 'passable' blocks seemed 'impassable'). To solve the overlapping problem, I just reset the player's y value.

Fourth, I was having problems with the game slowing down a lot after ~5 minutes. I realised that I wasn't releasing the 'string image' (for writing on the banner) before reloading it again. This cut the slowdown to occuring after ~10 minutes. Then, I changed the collision detection function to accept pointers-to-SDL_Rect instead of the SDL_Rect themselves. This cut me down to about 12/13 minutes. Then, I finally realised that what was causing the slowdown was the fact I was reloading the 'string image' file every time. So I now have two. One which is always clear and is applied to the 'string image' every time. It was immediately noticeable that this worked beacuse the WHOLE GAME ran faster [lol]. I had thought the player's car was slow because I had set the velocity too low but that wasn't the case [smile].

Finally, I updated the menu for quiting and changed the colours around on the other menus (still placeholder though).

So next, I'm onto step 7 (formally known as step 6) - the cannon! [grin]

Any comments would be greatly appreciated.
Thanks for reading

Take Me Out

I now have targets [grin].

At the moment the game just switches between 2 predetermined (one will be predetermined anyway - the bank) when you collide with the target. (Jesus, I can never get collision detection to work first time! It makes my head hurt [sad].) I also, re-made the level and the camera follows the player plus I got rid of a couple of bugs (e.g. game timer not pausing when you press Esc and the menu pops up).

But there is one bug that I thought I had gotten rid of when making Breakout! The alt-tab problem. At the moment I know it detects alt-tab because the music pauses but the player keeps on moving. The strange thing is I have the exact same code for minimising or clicking away from the window which works! Does anyone have any ideas?

Anyway, I will hopefully have the first demo up in a couple of days. Just need to add random drop-off points and money.

Thanks for reading

Walking Backwards

Sooo, steps 2 (menu), 3 (loading & displaying level) and 4 (font & timer) went without a hitch but when I was working my way through step 5 (movement and collision detection) it all went wrong!

The first problem I encountered was that some of the tiles that should be passable weren't. So I went back to check my level editor and when loading the tile types I hadn't set them correctly. However, changing this wouldn't affect the level itself because the tiles were already saved with their old passable values. So, after messing around trying to change the carefully change the values in the text file (that went horribly wrong [rolleyes]) and various other things (including trying to get it to save and load as a binary file) I just went back to my original text implementation. Would it work again? Would it hell! But now I finally have it working. Instead of one file stream, I have two separate streams (one input, one output) for saving and loading which is probably a safer idea [smile]. (But I still have to completely remake the level [sad])

The other problem I had was trying to get frame-independent movement (i.e instead of just capping the frame-rate using SDL_Delay I tried to use a delta-time approach in various guises) but that just resulted in stuttery animation so I have left it for this game. (I'm also not entirely sure on the advantages - more research required).

So, the next things I have to do are: re-make the level, then complete step 5 by having the camera follow the player when he reaches the edge of the screen and I will also try to add Azh321's idea of going from the bank to a safehouse (this will probably just be a random tile next to a house tile) to get money. Then that will be the first demo [grin].

Thanks for reading
Just a quick update today.

So now I have, for each step of the plan, got rough class outlines for each class I will need. Some are much rougher than others, for example, I'm considering having an Animation class that will be a member of Player (for a firing animation) and Enemy (for an explosion animation). It will contain several SDL_Surfaces for each frame and when called it will just return the current frame. But at the moment I have no idea if this will work. So I decided to get started with the game with what I've got and iron out any kinks as I go. (I am still learning after all [lol]). I have got step 1 completed [smile].

I have also used my level editor to draw the whole level (it's been stitched together as the level is a bit larger than one screen):

Thanks for reading
Any comments?

Plans III

Now that I know how my next game is going to play I think I'll write it down here for all to see [smile].

It's based on Pac Man but instead of a chomping yellow circle I'm going to swap it for a robber and instead of ghosts I'm going to have cops. So I have (rather imaginatively) called the game Cops & Robbers [wink].

There will be a few differences from Pac Man other than just artwork. First, the idea of the game is to see how long the player can survive for (so I will need to brush up on my timer knowledge). Second, the level is going to be bigger than one screen (to get experience dealing with conditional scrolling). And third, the powerup is a cannon that will constantly fire once collected and when one cop is destroyed, two will be respawned (possibly with speed increases) to increase the difficulty.

I already have a very basic level editor working that can scroll through tiles, place tiles, save and load. However, I will need to iron out a couple of problems if I release it (it's not very easy to use so it may not be worth releasing [rolleyes]).

As for the game itself, I have first gone through and made a rough plan of the parts that I'm unsure how to make (e.g. Enemy AI) and the classes I will need. I also have a step-by-step plan of how I'm going to build the game:

1) Basic set-up (SDL, FMOD etc) with all five gamestates. Just pressing enter goes through each one. (i.e. Intro-->Title-->Level-->High Score-->Game Over-->Quit)

2) Implement a menu so that Title can go to Level or High Score and also Level will ask the player if they want to quit before going back to Title.

3) Load and display the level (should be trivial as already done this for the level editor)

4) Timers (i.e. displaying the player's survival time). This will also need a font.

5) Player Movement with collision detection

6) Cannon (ie. firing and placing on the level)

7) Enemy AI (inc. going to Game Over and collision with bullets)

8) High Scores (implemented in Escape From Space-Prison Lambda so should be easy to add)

9) Polish

Now I'm going through making more detailed plans for each step. So far I've planned steps 1-3 but future steps will need substeps. So I've got a lot to do before I touch any more code...

Thanks for reading
Any comments?

So Here We Are II

Here is the final version of Escape From Space-Prison Lambda! [grin]

This has some improved graphics and sounds and a proper introduction and ending. No new gameplay, I'm afraid, so if you played the final demo there isn't much point in playing this.

I decided not to go with images for outlining the story in the end and have just printed some writing over a background with the game's font. It doesn't look brilliant but it's better than the rubbish I was drawing. (I had actually drawn most of the frames but realised it looked awful [razz]).

Over the next few days, I'm going to start planning out my Pac Man clone. At the moment I am renaming it Cops & Robbers and the player has to see how long they can survive beafore they are caught. That's the rough plan anyway.

I was also thinking that, as an interim project, I will write a level editor for the game so that I can solidify the base of my code. (Make sure I'm error checking etc.)

Anyway thanks for reading and I hope you enjoy the game.

One Of These Days

So, after searching the forums for an answer to the sound delay I found out that it was a common problem and that people suggested to use FMOD. So I did [smile]. So far it's been quite easy to use, although because I didn't plan in advance all the sounds, I just have them all as global variables which probably isn't ideal.

Also, I managed to update most of the graphics that were already in the game (e.g enemies) and have done the messages for game over and game complete. Now it's just to draw the intro and ending cutscenes. I keep on thinking it might be easier to just type out the introduction and ending scenes as prose instead of pictures but I've persevered so far. Mind you 'so far' is one incomplete frame...

The story is this: a remorseful prisoner is up for parole but gets denied. Then, while he's working in the prison library, he sees two detectives fly in and forget to lock their ship. So he manages to escape in their ship and that's when he gets chased. At the moment I have this storyboarded as 17 frames with some of the backgrounds reused. The ending is 8 frames and has the prisoner realising that what he has just done is wrong and hands himself in.

I also still have to do the music for the intro (will also be used for the title and high score screens) and the level. And sound effects for lasers and explosions as well.

So, still quite a bit to do before the final release.

Thanks for reading

PS I'm still taking feedback on the game itself. Any bugs etc. Link

PPS My current thinking for my next project is to stick with a Pac Man clone but use something different to Pac Man and the ghosts (at the moment I'm thinking a cops and robbers theme). Also I think I will have the levels bigger than one screen so that I can learn to do scrolling dependent on the player's movement.
Here is the final demo for Escape from Space-Prison Lambda! (EDIT:Link fixed). Please play it and tell me what you think [wink]. Too easy? Too hard?

The controls are LEFT/RIGHT to move left and right and SPACE to fire your weapon. It's got 10 levels, mostly placeholder art and all placeholder sound effects. There will be some music in the final release but it was causing the game to pause between gamestates. There is also a slight delay between the weapon firing and the sound effect sounding so I may have to use something other than SDL_mixer for sound [rolleyes].

Now, I am going into the lengthy process of sprucing up the graphics and getting some nice sound effects for the final release. I have no idea how long this will take me [rolleyes].

While, I'm doing this I will start to think about my next project (a Pac-Man clone according to my original plan but it may be something else) and start getting some real, detailed plans down. However, with uni starting again in about a month's time and having a really busy first term it won't be finished (or maybe even started) by christmas. Oh well...

Thanks for reading and I hope you enjoy the game

Feeling Good

I have nearly finished now [smile]. Well, gameplay wise anyway. Here is the list of stuff I needed to do for gameplay:

1) Have enemies flash when hit and put in a bullet 'explosion'
2) Make asteroids never stop
3) Finish LevelEnd gamestate (i.e show the number of each enemy destoyed, the points per enemy and a total score (also hit% possibly)) (EDIT: And a 'press space/enter to continue' message)
4) Finish GameOver gamestate (offer the player to restart level for a points deduction or to quit and have some sort of prompt for initials)
5) Different bullet types (EDIT: including stronger and faster bullets), loaded from a file (also missiles possibly)
6) Give the different enemies different bullets (load this from the enemy file)
7) Different levels, loaded from a file
8) Boss

Out of these I have done 1 (but I felt there was no need for a bullet explosion), 3 (without the breakdown of what enemies have been destroyed), 4 (without the offer to restart the level), 5 (without missiles), 6 and 7.

So I have made quite a few compromises [rolleyes]. The second item I should be able to add in the enemy file by having the asteroids final position offscreen. However, I will need to make sure that it isn't counted when seeing if the level is finished (currently the level is complete when all the enemies have been destroyed). I might also leave the boss out as I have very little idea how to implement it now without making a mess of the code.

So, now I just need to make levels and tweak stats for enemies, weapons etc. After I have done this I will release another demo [smile]. Just to make sure the game isn't too easy or too hard.

Then I will go about improving all the graphics and adding sounds and music (actually I'll have placeholder sounds and music for the demo so it's just a case of finding the right sounds. Also, last time I had a problem with the sound being slightly delayed by a second or two). This will probably take a very long time as my artistic ability is poor and there are a lot of things to draw [depressed].

Overall, I'm pleased I've managed to get all this done since my last post and am looking forward to releasing the game [grin].

Thanks for reading.
Here is another demo of Escape From Space-Prison Lambda! [grin]

I apologise for the placeholder art [headshake] but I thought it would be better to release something to get people's thoughts on the gameplay. At the moment there is just one level that repeats forever. It contains one of each type of enemy. At the moment they are all the same apart from colour. They are:
Blue = Police Cruiser (standard everything)
Grey = Police Van (slow, doesn't fire, always tries to capture, high HP)
Green = Army Fighter (fast, fires more often than cruiser)
Brown = Asteroid (slow, doesn't fire, doesn't capture, in the final game it won't stop either)
I would like to know what you think of the enemies are they too fast/too slow/fire too often/not often enough/too strong/too weak etc?

The enemy stats and image file names are loaded from a text file now so any changes to stats should be easy to do. This has been the major thing I have added today along with a (very quick) explosion animation.

Here is a list of things that I still need to do (more for myself because at the moment it feels like I'm just flitting about from one thing to the next):

1) Have enemies flash when hit and put in a bullet 'explosion'
2) Make asteroids never stop
3) Finish LevelEnd gamestate (i.e show the number of each enemy destoyed, the points per enemy and a total score (also hit% possibly)) (EDIT: And a 'press space/enter to continue' message)
4) Finish GameOver gamestate (offer the player to restart level for a points deduction or to quit and have some sort of prompt for initials)
5) Different bullet types (EDIT: including stronger and faster bullets), loaded from a file (also missiles possibly)
6) Give the different enemies different bullets (load this from the enemy file)
7) Different levels, loaded from a file
8) Boss

Image Improvements
1) All the screens: title screen, game over screen, high score screen (EDIT: And intro screens - at the moment is just says 1 and 2)
2) All the ships: cruiser, van, fighter, asteroid, player, boss
3) All the bullets: (should just need one and then recolour)
4) Ship and bullet explosions
5) Font
6) Introduction and Ending scenes

1) Background music
2) Explosion
3) Bullet firing

It's also getting to the point where, like in Breakout, I feel like I'm just throwing code together to get whatever I'm doing to work. This is, again, probably because I didn't plan is as much detail as I should have (particularly in designing classes). But next time...next time it will be perfect...hopefully [rolleyes].

Thanks for reading.
Any comments on the demo would be much appreciated.


Wow, a whole week without an entry. So you've probably guessed I haven't done much work on Escape From Space-Prison Lambda. And you'd be right[grin]! Apart from today I haven't done anything on it for the past week due to a mixture of procastination and going home for a few days.

But today, I feel I have accomplished quite a bit [smile]. I have the HighScore class working (ie writing scores to file, printing scores on screen etc) and so the High Score screen is also working.

I have also started on the GameOver and LevelEnd gamestates. The GameOver gamestate is pretty much done. It has Game Over written on the background and shows you your score and will take your initials. This isn't obvious however so I will need to have a flashing square or something to prompt the player. This then adds the score to the High Scores and sends you to the High Score screen.

I have just started on the LevelEnd gamestate. At the moment it just has a scrolling background and after the user presses enter or space it goes back to the LevelStart gamestate.

I need to work a bit on the continuity because when the level restarts the bullets are still left there and the player would carry on moving if you were moving when the level ended. This last one has been fixed though.

Finally, in my slowly improving graphics news. Here is the title screen I have so far (thank god ESCAPE and SPACE have the same letters in pretty much the same order [grin]) and the font (which may need a bit more work done).

Thanks for reading

The Hardest Part

After a couple of days of not doing anything (every time I thought about what I had to do next, I just couldn't be bothered), I managed overcome the procrastination and managed to do a little bit of work on the game.

I now have an AddScore function for the HighScore class which will also test to see if the score given is good enough to be added to the high score. Also, I can now write scores to the file and I have started on having the ability to print scores to the screen.

So far, for this I have a rough alphabet and numbers drawn up (these will need improving later on - as with all the images) and the clipping rectangles are generated when the font is loaded. The Font's Print() function takes a string and then switching through each character I can select the right clipping region to apply to the screen surface. So I can print the player's initials but I still need to find a way to print the scores (probably using stringstreams like in Breakout).

Next, I hope to finish of the HighScoreScreen and then I will start on the LevelEnd and GameOver gamestates. After which I will release a demo [smile].

Finally, I have decided that I will slowly improve the graphics doing it little and often. At the moment I am drawing the title screen again one letter at a time. Hopefully, this will mean by the time the game is finished then there will be some halfway acceptable graphics.

Thanks for reading


Plenty done this past few days [smile]. I have the enemies now charging the player and if they are alongside the player (but not touching) they leave out of the bottom of the screen and then re-enter a bit later.

I also have player and enemy health along with the player's health bar. This went surprisingly smoothly. [smile]

Finally, I have started on High Scores. At the moment I have a global HighScore object which contains a of Score. Score itself contains a string for the player's initials and an unsigned int for the player's score. The current high scores are loaded from a file in the HighScore constructor. And I also have to ability to sort the Scores (which will be needed when a new score is added) and also to see if one Score is higher than another.

So the only things needed for high scores are the ability to add a score, write scores back to the file and to render the scores on the screen. This last will need me to be able to draw an alphabet on the screen.

Other things I still need to do are the GameOver and LevelEnd gamestates, going through more than one level (and loading a level from file), different movement patterns for enemies, adding more enemies and a boss (also load from file). Also, I will need artwork for the Introduction, enemies and ship explosions (which I will also need to implement), background music and sound effects. Blimey, didn't realise I still had so much to do!

I will put up another demo for download when I have the GameOver and LevelEnd gamestates in so that people can test the mechanics are okay and not unfair for whatever reason.

Thanks for reading
I started implementing the enemies' CHARGING state which will now try and pull the player to the top of the screen. This gives the player the chance to destroy any enemies that are pulling it and then the player will move back to the bottom of the screen.

At the moment, I have the enemies in the CHARGING state moving towards the player and when they collide they enter the PULLING state where the velocities of both the enemy and the player change.

Then in the main loop, if the player is moving up and there are no enemies pulling them, the player's velocity is reversed until they reach the bottom of the screen again.

The problem I have at the moment is that when the enemy collides with the left or right edges of the player then the enemy enters the PULLING state but it hthen becomes harder to destroy the enemies. This is because the player can only move a bit at a time and this may be unfair (but then again it might make sense if you consider it a tractor beam). I already ignore collisions to the back of the player as it is impossible to destroy anything behind you but with left and right collisions it's not impossible just quite hard.

So I'm in two minds as to keep left/right collisions as pulling the player and sort out the movement or to do something else (e.g leave the screen like I plan to do for when enemies are below the player). Does anyone have any ideas?

Thanks for reading
Finally got pixel perfect collision working today [smile]! After a couple of days of trying this and that it now finally works!

The way I do it is that when there is an overlap along one of the four edges (for some reason I was also checking corners probably because I should have done it for Breakout where there would be a different action but here it doesn't matter). Then I go through the corrseponding edge of the bullet image and find the first non-transparent pixel. I then convert from bullet image coordinates to screen image coordinates and then to ship image coordinates. Then I check this pixel on the screen image to see if it's non-transparent as well and if it is. Collision!

I also solved a bug, which I hadn't noticed before where the enemies wouldn't exit the RELOADING state (added so that the enemy doesn't fire all its bullets at once producind one really long one) which was due to a mathematical error.

Next, I will give the player and enemies health (so that it isn't one-shot kill) and a health bar for the player. Or I will try to get enemies charging at the player in order to capture him (this will result in instant game over I think) so that I have a complete enemy and then I can generate the different types. Or I will add scoring and high scores. What a choice! [grin]

Thanks for reading
The first demo of Escape from Space-Prison Lambda is released! This is just showing what I have done so far and any input would be much appreciated [wink].

Since my last post I have added the ability to have more than one enemy on the screen at once as well as both the player and enemies being able to fire.

Some things I will need to add are pixel-perfect collisions. This is because at the moment the enemies and player are very clearly not precisely hit when they are destroyed.

Next, I hope to add enemy charging and re-entering so that the Enemy class is pretyy much complete. Then I can start adding the different enemies and look at ways to load both enemies and levels from a file.

Also, here is the source code for anyone who wants to look. (I would also appreciate if someone could check I'm not doing anything ill-advised [wink]).

Thanks for reading
Today, I managed to redraw the player and enemy graphics that I have at the moment and I'm pleased with how they've turned out. However, I may have to scale them down a bit (at the moment they are 64x64) depening on how many enemies I want on screen at once. Here's a screenshot:

The enemy is at the top and is the standard police car and the player is on the bottom. The player can be moved with the arrow keys and the enemy moves in from off-screen and stops when it reaches its destination.

I also thought of another type of enemy to add: Asteroids. These will just fly down the screen from top to bottom pretty quickly to keep the player on their toes. I may also need to think of more weapons (I have three at the moment) but I won't be too bothered if I can't think of any more.

Next, I plan to get more than one enemy on screen at once and then after that I hope to get weapons firing [grin].

Thanks fro reading

Our Velocity II

A problem today unfortunately [sad]. I have started with adding an enemy. The Enemy has its own constructor so that any image can be loaded. I also have two states: ENTERING and STATIONARY. The idea being that the enemy starts offscreen in the ENTERING state and when it reaches its final point (m_FinalX, m_FinalY) it will stop.

To get the Enemy going in the right direction I take the differences (m_X - m_FinalX) and the same for y. This gives me a vector going from inital to final positions. But so that it doesn't jump in one step I find the unit vector in this direction by dividing through by the length of the vector. I then use the components of the unit vector as the x and y velocities of the Enemy. (All of this is done in the constructor).

However, to get the nesseccary precision I use floats for everything (otherwise m_VelX and m_VelY equal zero). But then this gives me the problem that when checking to see if the Enemy has reached its final point it is never *exactly* there. It is always out by a few decimal places and so it never goes to the STATIONARY state.

I've tried recalculating the vector in an UpdateEnemy() function but that just leads to the Enemy vibrating about the final point.

Here's the code:

// Enemy::Enemy(SDL_Surface* image, int x, int y)
// -- Enemy constructor so that any image can be loaded
Enemy::Enemy(SDL_Surface* image, float x, float y, float finalX, float finalY)
// Assign all the arguments given
m_Image = image;
m_X = x;
m_Y = y;
m_FinalX = finalX;
m_FinalY = finalY;

// Start with entering
m_State = ENTERING;

// Start the Enemy going in the right direction
// Find the components of the vector to the final point
float delta_x = (m_FinalX - m_X);
float delta_y = (m_FinalY - m_Y);

// Find the length of this vector
float length = sqrt( pow(delta_x, 2) + pow(delta_y, 2) );

// Get the components of the unit vector in this direction
// These are the velocities to use
m_VelX = delta_x / length;
m_VelY = delta_y / length;

// void Enemy::UpdateEnemy()
// -- Updates the enemy's state (inc. velocity etc)
void Enemy::UpdateEnemy()
// Change the state if nesseccary
if ( (m_State == ENTERING) && (m_X == m_FinalX) && (m_Y == m_FinalY) )

if (m_State == STATIONARY)
m_VelX = 0;
m_VelY = 0;

I will also post this in the forums, see if I can get any help there as well.

Thanks for reading

EDIT: Now solved thanks to WanMaster. Now I just check to make sure the difference between m_X and m_FinalX is less than 0.1.


Today, I first made sure the LevelStart gamestate changes to the LevelPlay gamestate after a short delay. Although I will need to add the text that says 'LEVEL #' later on.

I also managed to add the Ship base class and the Player class (it's only method being an UpdatePosition() function that checks to see if the player has gone off the edge of the screen) and so have a moving player on the screen.

Tomorrow, I will either try to add an enemy or get the player to start shooting. Shooting shouldn't be too hard to add, it would just require adding a completely new class. Whereas if I add an enemy I already have the foundation for it. I'll see what I think tomorrow.

Thanks for reading
Sign in to follow this  
  • Advertisement