Advertisement

drawing sprites

Started by June 22, 2017 04:18 AM
87 comments, last by Tom Sloper 7 years, 4 months ago
7 minutes ago, phil67rpg said:

I am working on a space invaders game.

Do I understand correctly that what you want is for one enemy to appear on the screen and then maybe 10 seconds later another one appears? Or is this about updating the display every 30 milliseconds?

yes I want to draw a sprite then wait and then  redraw another sprite

Advertisement

Why do you want to have a delay?

I want to give the illusion of movement, like in space invaders, the bugs move across the screen.

I also want to know how to clear the high_resolution_clock  command?

3 minutes ago, phil67rpg said:

I also want to know how to clear the high_resolution_clock  command?

What do you mean by clearing the command, and why do you want to do it?

Hello to all my stalkers.

Advertisement

I want to set it to zero, I want to destroy it like  you said in your post, timeUntilSecondSprite.

Thanks. I wanted to be sure that you weren't attempting to periodically add new enemies into the game.

Just out of curiosity, how does everything look if you don't include any timers? Does it all run but just really fast?

5 minutes ago, phil67rpg said:

I want to set it to zero, I want to destroy it like  you said in your post, timeUntilSecondSprite.

I did not say you should destroy anything.

I said how the code you posted works. The variable is created every time the drawScene function is called, and it is destroyed every frame when the drawScene function completes, when the variables exits the function scope.

 

EDIT: Just to add, the current behavior is not what you want. I've explained why, and detailed some changes you shouild try.

Hello to all my stalkers.

2 minutes ago, kseh said:

Thanks. I wanted to be sure that you weren't attempting to periodically add new enemies into the game.

 

That is, in fact, how I interpreted his initial request and attempted example code (adding a new, second sprite after a few seconds).

If the problem you are trying to solve, @phil67rpg, is just moving one sprite across the screen smoothly rather than draw a second sprite a few seconds after the first one, that will require a somewhat different approach.

This topic is closed to new replies.

Advertisement