How do I tidy up keypress and variable ranges?

Just started using Construct 2? Post your questions here

Post » Sun Dec 27, 2015 11:32 pm

R0J0hound wrote:Probably something like this to set column 1 to column 0:

set array at (1,0) to array.at(0,0)
set array at (1,1) to array.at(0,1)
set array at (1,2) to array.at(0,2)
set array at (1,3) to array.at(0,3)
set array at (1,4) to array.at(0,4)
...
set array at (1,array.height-1) to array.at(0,array.height-1)


But that just screams "use a loop", so...

repeat array.height times
---set array at (1,loopindex) to array.at(0,loopindex)

Thank you so much!! I can't thank you enough for helping me with those loops, I've learned a lot from this. Here's the finishing code:
Image

That keeps a second columns (I changed it around so they're columns rather than how I had it with rows, too hard for me to visualize!) updating and I just update the score like so:
Image

Works well so far! Any side-effects I might encounter, performance-wise?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Post » Mon Dec 28, 2015 12:03 am

I've also sorted out the max-ammo by using the third column:
Image
I set the ammo amount in the first condition, and force the amount in column 0 to not exceed the amount in column 2, seems okay!

Haven't quite worked out if all of this will work when ammo is depleted by firing, I'll find out soon enough though!
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,248

Previous

Return to Beginner's Questions

Who is online

Users browsing this forum: JaredX and 1 guest