Tower upgrading

For questions about using Classic.

Post » Sun May 15, 2011 4:33 am

I going to make a tower defense game with upgrades. This what I Put so far for my event sheet

[code:1927j5s5] Sprite [Level = 1][Attack = 50]
[/code:1927j5s5]

[code:1927j5s5]1. [on "button" clicked] -> [+new action]
sub-event
2. ["Sprite" Value "Level" Equal to 1] -> ["Sprite": Add 50 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
3. ["Sprite" Value "Level" Equal to 2] -> ["Sprite": Add 100 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
4. ["Sprite" Value "Level" Equal to 3] -> ["Sprite": Add 200 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
5. ["Sprite" Value "Level" Equal to 4] -> ["Sprite": Add 400 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
6. ["Sprite" Value "Level" Equal to 5] -> ["Sprite": Add 800 to "Attack"],["Sprite": Add 1 to "Level"],["Text": Set Text to "Sprite('Attack')],[+New Action]
[/code:1927j5s5]

What should i change,add,or delete. Because every time i tested the game, its level jumps to 6
Thanks! :D
B
1
G
1
Posts: 3
Reputation: 431

Post » Sun May 15, 2011 4:58 am

This is due to your order of events.

In event 2, Level is equal to 1. One gets added to Level. Level now equals 2.

In the next event, Level equals 2, because you changed it already in the previous event. So it meets the condition for "Level equal to 2" and the event triggers, which adds 1 to Level. Now it equals three.

In the next event the same thing happens. And so on down the list until you hit six.

So, you could do this a few different ways. The first is you could add another criteria to your conditions to keep them from triggering all in the same tick. I would make another variable called "switch" or something like that, that turns On when you click the button, and turns Off when you level up. That way you can check Switch in your conditions, and if it is Off, then the level-up action won't run. Like this:

[code:puxsx5mi]
+On button clicked
-> Set Switch On
+ Sprite Level = 1
+ Switch = On
-> Level up
-> Set Switch Off
+ Sprite Level = 2
+ Switch = On
-> Level up
-> Set Switch Off

Etc.
[/code:puxsx5mi]

The second way you could do this is to reverse the order of your level code. So it would look like this:

[code:puxsx5mi]
+ On button clicked
+ Level = 5
-> Set level to 6
+ Level = 4
-> Set level to 5

Etc.
[/code:puxsx5mi]

And finally, since it seems you are doing a really simple linear calculation to increase your levels, you could simply do this:

[code:puxsx5mi]
+ On button clicked
-> Add 1 to level
-> Multiply Attack x 2
[/code:puxsx5mi]

And leave it at that.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Jul 29, 2013 6:30 pm

Good Job!
Do you have sample capx.?
Thanks!:)
B
9
S
2
Posts: 82
Reputation: 914

Post » Sat Aug 03, 2013 11:57 pm

@karlmahmen unfortunately this was made in Construct Classic so there likely won't be a CapX (construct 2 version). However, the coding style between Construct 2 and Construct Classic is very similar, so it should be fairly straight-forward for you to re-create in Construct 2.

Hope that helps!
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Thu Aug 15, 2013 12:01 am

@Jayjay Thanks!but iam developing a tower defense game in ios the problem is i cant get the logic of upgrading tower... im so noob :( help

Thanks!:)
B
9
S
2
Posts: 82
Reputation: 914


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests