playMaker

Author Topic: Multi-random cubes  (Read 2487 times)

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Multi-random cubes
« on: October 16, 2013, 04:19:49 AM »
Hi!

I have one blue cube, one red cube and one pink cube. I want them to be placed randomly on the randomSpots I have 16 of, but I will have only two of each color. For example, two blue, two red and two pink. How can I do that?


Thanks! :)
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: Multi-random cubes
« Reply #1 on: October 17, 2013, 01:40:50 AM »
Hi,

 For this, I would recommand using ArrayMaker,

https://hutonggames.fogbugz.com/default.asp?W715

-- maintain a arraylist of your 16th position. You will pick a random position in that list and REMOVE that position so that the next pick will not take one you already choosed.

-- maintain a counter for each cube types and when you generate them, you keep track of what cube color you have already created, a simple int for each colors. You can also maintain that in a hashtable ( using arrayMaker again), and have each cube colors store an int representing the number of cubes on the board of that color.

Start playing around the above concepts, If you have trouble with this let me know.

bye,

 Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Multi-random cubes
« Reply #2 on: October 17, 2013, 06:17:38 AM »
Hi!

Thanks for the answer. :)

I have never used Array before. I have downloaded Arraymaker, but I don't know where to start. You don't need to make it for me, because I want to do it by myself . But if you could tell me what kind of action I should use. And maybe a little step by step. :)
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: Multi-random cubes
« Reply #3 on: October 17, 2013, 07:13:30 AM »
Hi,

 You need to study the examples provided with array maker (on the wiki page), that's your first stop.

then, you'll start to see how it all fits together.

to create arrays or hashtable, there is a menu "playmaker addon" in there you'll be able to add an arraylist or hashtable component where you can start adding values, and work with during runtime as well.

Bye,

Jean

Rabagast

  • Hero Member
  • *****
  • Posts: 683
    • Homepage
Re: Multi-random cubes
« Reply #4 on: October 17, 2013, 10:09:53 AM »
Is it some tutorials somewhere? It's easer to follow tutorials with someone who explain you step by step. It's so difficult to figure out how you do it in the example, because I don't know what's all the actions are and what they do.
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: Multi-random cubes
« Reply #5 on: October 21, 2013, 02:59:58 AM »
Hi,

 Unfortunatly, I have not had time to do proper tutorials.

You should study the samples provided on the ArrayMaker wiki page, and see how it all works this way.

If you have a specific question, don't hesitate, I'll try to explain precisly.

bye,

 Jean