playMaker

Author Topic: How to create cubes in a grid? [SOLVED]  (Read 4638 times)

pustur

  • Guest
How to create cubes in a grid? [SOLVED]
« on: April 08, 2012, 03:26:28 PM »
hello, i'm new to playmaker and i have a question.
i'm making my first game, minesweeper, and i started with some javascript codes before discovering playmaker. so i have a script that instantiate a grid made of cubes (this will be the map).

this is the javascript code that generate the map.

Code: [Select]
#pragma strict
var width : int = 9;   // width and height of the grid can be changed here
var height : int = 9;
var map = Array(width, height);     // I don't know if i'll use this...
private var i : int;
private var j : int;
var unpressedCell : Transform;    // This is the cube that's not jet been pressed

function Awake () {
for(i=0; i<width; i++){ //Instantiate the cubes in the map
for(j=0; j<height; j++){
Instantiate(unpressedCell, Vector3(i*2, j*2, 0), Quaternion.identity);
}
}
}

now i want to know, is this possible to do with playmaker?
how do i do the cycles?
how to increase the i and j variables and use them for the position of the cubes?
how to do this on the awake function?

excuse my english, and thanks in advice :P
« Last Edit: April 11, 2012, 02:13:44 PM by pustur »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to create cubes in a grid?
« Reply #1 on: April 09, 2012, 04:06:11 AM »
Hi,

 Please find a working scene for you to study. I strongly suggest that you go first through all the videos and tutorials provided in by playmaker to get used to the way playmaker is working, then open that scene ( else it will be overwhelming).

basically, Playmaker has all the building blocks ( actions ) for you to work with variables.

 iteration unfortunately, is a somewhat problematic in playmaker because if you want the iteration to happen as in a for loop, you will hit a warning for infinite looping between states and transitions.  I have therefore created a delay event that prevent this infinite loop warning. but the downside it that the instantiation now takes time.

 Get back to this thread if you have question about how this was done. I'll happily answer more in details about a particular start or set up.

Bye,

 Jean

pustur

  • Guest
Re: How to create cubes in a grid?
« Reply #2 on: April 09, 2012, 07:12:02 AM »
thanks for your reply, i figured out how to instantiate the cubes as you can see here:
http://i1264.photobucket.com/albums/jj493/pstrnil/Schermata2012-04-09a124033-2.png

yes, i runned in the infinite loop problem, at the beginning the map stopped generating before i wanted, then i found this option in the preferences menu and i increased the value, i think it's pretty risky but at least i don't have the delay problem.



thanks again for your time ^^