First post. I'm just delving into the depths of game code properly and I've reached a stage where I have a game plan, and I have an image assigned to an enemy.
In space invaders the enemies started from a single line and then gradually moved down in a linear progression. I want to start enemies at a 0 point x axis and randomise the y start location then have them moving down in diagonal or straight lines.
So far I have an enemy structure, an image assigned to the enemy and a main application body. I just need to start on the movement routine.
I don't expect hand holding through the whole learning curve, just an idea of what to read up on or snippet routines that are similar to what I'm trying to achieve, which can be best summarised as:
Do you have a timing mechanism built into your game yet? You need a means of calling functions at a chosen, regular frame rate so that object motion and other animation can be done.
I've moved on a bit from there now. I have two functions called main and timer. My main function draws all the objects in starting positions in a loop. For example pseudo-code):
main
for i=0; i < 25; i++
draw image at x,y
timer
xcord=xcord+1
ycord=ycord+1
drawimage
And what happens is one of the images moves (I am assuming it is the last one drawn, so I'm trying to figure out what I need to do to feed the movement into the image array
I'd say, rather something like Object::SetMovement(Vector offset, int frames)
Basically, you pass a vector for the movements, and how many (logical) frames that movements should take. Actual movement would be done with an update() member function, that advances the objects state by one frame.