Basics: Animating more than 1 thing at the time

I got a Question about how you would code a Bullet or something like that.
Could be easy, but the problem is to make it move, while the main character is moving, too.
Only way I could imagine to do it would be using “Ticks”, I guess.
Something like

float BulletspeedX = 10;
float BulletspeedY = -10;

void loop{
Bullettick();
DoCharacterThings();
}

void Bullettick(){
BulletX = BulletX + BulletspeedX;
BulletY = BulletY + BulletspeedY;}

Are there other ways to do it?
Is there a easy way to do 2 Animations simultaneously?

See the wizard example:

But yes, basically you just update everything inside your loop and then when you’re done draw to the screen at whatever your desired framerate is. The core library already wraps that up really nice for you with if nextFrame() and setFrameRate though.

1 Like

Your technically in charge of multi-tasking… technically everything you are doing is happening “simultaneously” UNTIL you send the update to the screen.

2 Likes

There is one good site with numerous design patterns for games out there.

Try,
http://gameprogrammingpatterns.com/

Specifically you might look at an event-queue.
http://gameprogrammingpatterns.com/event-queue.html