Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Collsion with for loop sprites

Author
Message
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 8th Jun 2011 19:42
okay to make multiple sprites you would make a for loop so that is what i did. lets say the object in the for loop that you are creating is a food. how can i get my player to make it delete it or when he collides with it it sets the score up one then deletes it i got the scoring system up but i cant get the player to collide with a for loop sprite. here is my for loop
shoudnt that make the a delete?
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 8th Jun 2011 20:30 Edited at: 8th Jun 2011 20:33
The program design here is not good because you try to mix two phases of the program that don't belong together. Loading the image and creating the sprites in random positions belongs into the game initialization phase. That you should do only once, before playing the game really starts, for example before the main game loop. The collision detection, on the other hand, belongs into the "playing the game" phase, inside the main game loop.

If all this code is inside the game loop, then if you manage to delete a sprite, in the next game loop you immediately recreate it, since your for loop runs again and makes all the sprites again with the dbSprite command. So the deleted sprites just keep coming back - although they may be immediately deleted again but that doesn't change the fact that the code needs some redesign. Here is a quick start:



If that doesn't help, then we need to see more of the code to be able to help you more.

Maybe you can also have a look at the (more advanced) Dark Invaders tutorial for some game design ideas.
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 8th Jun 2011 23:49
Yes thank you Mireben this has been very helpfull i will look closer at the dark invaders tutorial

Login to post a reply

Server time is: 2024-10-02 17:26:50
Your offset time is: 2024-10-02 17:26:50