Basically, store the current time (in ms). Handle input, then update positions, then render. When you loop, calculate the ms passed since last update and pass it to the update and render methods. It's usually referred to as "delta". Rinse and repeat, updating according to calculations done with delta.
use Timer.Tick event - it called each time timer ticks (duh)
or you need something more specific?
You'll need to make interval ~40 msec or so for 25 fps. Possible invoking it from another thread so main window won't get locked for too long
Also it's good idea to use 2D SlimDX or Ogre so you'll get real DirectX and your invaders won't get locked at all - and you'll get real game.
[11:20:20] aerelm: its not fl dev work if you dont have to power through the whole thing on your own
[11:20:32] aerelm: help is for pussy devs like in dota
(05-02-2013, 12:48 PM)utrack Wrote: use Timer.Tick event - it called each time timer ticks (duh)
or you need something more specific?
That sounds spot on. Where can I access that?
Basically, I need my space invaders to move to the right at a constant rate for a period of time, then move down, and then left at a constant rate.
I will also need each shot fired to move upwards or downwards (depending on the firer) at a constant rate until it either leaves the game area or intercepts a valid hitbox (which technically don't exist, as I'll simply check if the shot is within a certain area from the point of origin of each entity).
(05-02-2013, 12:48 PM)utrack Wrote: use Timer.Tick event - it called each time timer ticks (duh)
or you need something more specific?
That sounds spot on. Where can I access that?
Basically, I need my space invaders to move to the right at a constant rate for a period of time, then move down, and then left at a constant rate.
I will also need each shot fired to move upwards or downwards (depending on the firer) at a constant rate until it either leaves the game area or intercepts a valid hitbox (which technically don't exist, as I'll simply check if the shot is within a certain area from the point of origin of each entity).
For the moving part - maybe you'll need UpwardShot and DownwardShot classes ('cause there could be more than one shot at once) with refresh methods and coords properties, and Refresh() will be called by RenewImage procedure which will just add some points when called.
Then for enemies: again classes for each type of enemy and some simple variable as step count, which will be ++'d each frame - and simple "select case" with this variable which will decide which coordinate to change on refresh. After some point it should be zeroed, cause you want them to move in loop.
Then you should get all the instances with their coordinates and place bitmaps using these coords. DOne - frame ready
P.S.: this could work only for uni project, for production better use 2D DX or OpenGL
P.P.S.: this algorithm was written under the influence of beer, and i don't know what performance it'll get. The code will look nicely tho
[11:20:20] aerelm: its not fl dev work if you dont have to power through the whole thing on your own
[11:20:32] aerelm: help is for pussy devs like in dota