HELP with variables

For questions about using Classic.

Post » Tue Oct 07, 2008 8:48 pm

Hey.

I'm trying to make a game. The player will be able to plant bombs, which blow up a set amount of time (2 seconds) after they are planted. I tried creating a private variable which was set to the TickCount whenever a bomb was created, and an event that constantly checked to see if the tick count had gone 100 above the variable's value (100 ticks @ 50 fps = 2 sec). However, what happened instead was that all of the bombs planted in the first two seconds of the program running would explode at the same time after 2 seconds had finished. I thus assumed that this was because when you create a private variable, it only has one value for the entire object, rather than each instance of the object having its own value. How do I make a variable for each instance of the Bomb object that the player creates?

Thanks.
B
2
G
4
Posts: 10
Reputation: 1,070

Post » Tue Oct 07, 2008 8:56 pm

Checking the tick count won't work. The reason for that is because every time 100 ticks elapse, all existing bombs will be destroyed at that time. Instead of checking the tick count, set a life variable on the bombs to 200. If the value of the variable is over 0, subtract 100 * TimeDelta from the variable. Then, when the life value is equal/less than 0, destroy the bomb. Here's an example: Time Bombs

Hope this helps. :)
Moderator
B
98
S
37
G
19
Posts: 1,584
Reputation: 17,817

Post » Tue Oct 07, 2008 9:09 pm

Well, I already figured out a way to kind of "cheat" at it using the animator. However, I'm sure that will come in handy later---thank you.
B
2
G
4
Posts: 10
Reputation: 1,070

Post » Tue Oct 07, 2008 10:22 pm

Okay, I have another question. What does it mean when the application test window suddenly closes? What causes that?

EDIT: Nevermind, I'll make a new post.
EDIT2: Nevermind again, I figured it out 8)
B
2
G
4
Posts: 10
Reputation: 1,070


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests