playMaker

Author Topic: Pick up bombs in order  (Read 2151 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Pick up bombs in order
« on: January 06, 2014, 03:01:23 PM »
Hi!

In my platformer, I have bombs to pick up. But I need to pick up in order.
For example I pick up bomb 1 and then bomb 2 and so on. And I also have a limit of time to pick up the bomb before it explode. I try to figure it out, but I'm a little bit stuck.

I know how to pick them up and how to make a limit of time before it explode.
The problems is: One bomb at the time will be active, so when I pick up bomb 1 before the time runs out, the next bomb will be active.

I try to use an Int variable. So the bomb 1 has an Int = 1, bomb 2 has an Int = 2, and so on. But it doesn't work as I want.
Can someone explain me a little bit more what I maybe do wrong or if I have forgot something?

Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Pick up bombs in order
« Reply #1 on: January 07, 2014, 12:46:47 AM »
Hi!

Here's how I would tackle it, it sounds like you're pretty close:

I'd attach a separate FSM to each bomb. Bomb 1's FSM would react to the bomb being picked up, probably the same way you have it now. At the end of the timer/explosion sequence, I would add another state to the FSM that sets an integer value (say, "bombnumber" for example) to the next value, which would be 2. (you could also use the "add" function, and add 1, instead of setting it directly to 2. Your preference!)

On bomb 2, add a new FSM identical to the FSM on bomb 1, but add a new start state. Check the value of int "bombnumber" - if it does equal 2, then continue with the FSM for timer/explosion etc. Again, at the end of this FSM, add a a state which sets "bombnumber" to 3, or add one again.

Rinse and repeat for all the bombs you want picked up in order!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pick up bombs in order
« Reply #2 on: January 07, 2014, 04:23:35 AM »
Hi,

 I would also consider ArrayMaker where you can list bombs in order, and you can use this arrayList as a base to check if the user is picking the right bomb.

 Bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Pick up bombs in order
« Reply #3 on: January 07, 2014, 03:01:35 PM »
I think it was exactly what I had in my mind. But I had some problems. But after some tries, I figured it out, so it works now. Do you think I should use global variable or just normal?

jeanfabre:
I would like to try it with ArrayMaker, but I don't know how to use it, because it's no tutorials for it. You should make a step-by-step tutorial on how to use it. :-)
Check out our homepage. http://www.walsberg.no
Or my personal game blog for news about my games. http://retro-tetro.walsberg.no

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Pick up bombs in order
« Reply #4 on: January 10, 2014, 06:52:32 AM »
Hi,

 Yes, I know... :-\ Just can't keep up with everything... Maybe this year I will tackle this properly.

 Bye,

 Jean