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 / How to make my player reappear a few seconds later after being destroyed?

Author
Message
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 20th Oct 2009 19:08
I seem to be having trouble with timers.I have two problems but I think they stem from the same source.So If I figure out how to solve one then I think I will be able to solve the other.Well I was working on collision.I'm trying to make it where if my player plane hits a enemy plane they are both destroyed.That part works great.The problem comes in bringing them back.I wanted to make it where after a couple of seconds the player plane would come back.I decided to try to try to make a timer out of two variables. same trick they used in the dark invaders example.But it isn't working for me.Trying to figure out what I did wrong.I put the whole collision function here but I believe I commented well.



It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 20th Oct 2009 19:32
OK to be fair I don't use DGDK I'm just browsing the forums because I'm bored, but your problem could be that as far as I can tell the code is only called when the sprite collides. Once the sprites in question have been deleted won't it just not call that section of code again? So the variable can only be called once.

You could set a "player destroyed" variable. Then in the code have something along these lines:



Just a guess but that bit looked a little odd to me.

It would just go in where

is now.

"A West Texas girl, just like me"
-Bush
Ovan35
15
Years of Service
User Offline
Joined: 25th Sep 2009
Location:
Posted: 20th Oct 2009 20:01
Nope I tried what you suggested but still nothing..The plane will not reappear onto the screen.I thought it might have been the fact that I didn't set an initial value for the variables.. so I went back to the main.cpp and gave the intergers an initial value of 0 but that didn't work either.

It was such a small seed... I needed to find out what was growing inside. And there was only one way to find out. So I decided to raise it.

demons breath
20
Years of Service
User Offline
Joined: 4th Oct 2003
Location: Surrey, UK
Posted: 20th Oct 2009 20:08
Sorry. Well what's the problem? Coming back too quickly or not coming back at all?

"A West Texas girl, just like me"
-Bush
prasoc
15
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 20th Oct 2009 20:35
when they hit, put a variable called "deadTimer" and set it to "dbTimer()"

then check for this each loop:



By the way, that +5000 is the time in miliseconds (5 seconds in this case)


Your signature has been erased by a mod
luke810
18
Years of Service
User Offline
Joined: 4th Sep 2006
Location: United States
Posted: 20th Oct 2009 20:45 Edited at: 20th Oct 2009 20:45
The problem is you iterate your timer only when the sprites are colliding. If you only do so when they are colliding, nothing will happen because you move your sprite under the condition they are colliding. You have to place the respawn timer outside of the conditional statement so that it runs even after the sprite has been moved but before it returns. This is what demon's breath posted, but there are still issues with the implementation. It should be something like:


Login to post a reply

Server time is: 2024-10-01 16:32:37
Your offset time is: 2024-10-01 16:32:37