playMaker

Author Topic: Grid Positions (ArrayMaker) [Solved]  (Read 1063 times)

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Grid Positions (ArrayMaker) [Solved]
« on: November 09, 2020, 06:59:07 PM »
Hope everyone is having a fantastic day so far!

I'm creating a word game which is going great, I can select a word then click submit to see if it exists, if it does those letters (actually game objects) are destroyed. When these letters are initially created I loop through an array of hard coded positions to spawn them in place (probably not the best way to do this).

Here is the challenging part, how to get the letters above the letters that were destroyed to drop down (for example in the image below the U, D in the first column to land on top of the bottom L).

I'll eventually use translate to move the letters (or a tween) but for now I need help figuring out how to manage the system that will control these objects to fall in place.

I'm starting with a 3 arrays (9 spots to learn) which are for the rows of game objects (letters), Im using arraymaker)):

The first array is 1 (which has 3 items): 0,1,2
The second array is 2 (which has 3 items): 0,1,2
The third array is 3 (which has 3 items): 0,1,2

I now have 3 array's with 3 game objects in each.

1: 0,1,2
2: 0,1,2
3: 0,1,2

This is where I have no idea what to do from this point forward can anyone help?
« Last Edit: November 11, 2020, 09:17:47 AM by Kodagames »
Have I said how much I love playmaker!!! This is one amazing tool

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Re: Grid Positions (ArrayMaker)
« Reply #1 on: November 10, 2020, 07:54:48 AM »
Ok so I’ve decided to go even simpler to try and learn how to do this with just one column with 3 items (basic cubes).

1 array: 0,1,2

Once I click on item 1, destroy it, have item 0 take item 1’s position.
Hoping to solve it 😁
Have I said how much I love playmaker!!! This is one amazing tool

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Grid Positions (ArrayMaker)
« Reply #2 on: November 10, 2020, 11:12:34 AM »
Hi.
Its probably best to use a fsm for each row.

Also index should represent the vertical and 0 should be on the bottom.

After letters are removed, loop thru the array.

In the loop 1st check if empty
if empty set a bool 'empty found' to true.(before the loop 'empty found' should be set to false.)
and loop back to check the next one.

if not empty do a bool test 'empty found'
If false loop back to check the next one.
If True send a event to that object to move down 1, then remove from the current index and place to the previous index.
Also set 'empty found' to false.

if your loop ends and 'empty found' is true, it means that you need to add a new letter to the last index.

After animation loop thru again, do this until all index have an item.

A different way might be using objects and gravity.
for example if a row has 3 height, have 6 letters
The 1st 3 visible and the other 3 above are hidden by a mask.

Then after selecting the letters and 'destroying them, use Array List Remove to remove the letters from the list

Then add new letters to the array and above the other letters until you have 6 again (3 visible and 3 visible in grid)

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Re: Grid Positions (ArrayMaker)
« Reply #3 on: November 10, 2020, 05:31:01 PM »
Hi @djaydino,

Thank you soo much for helping me through this!!! (I've been avoiding learning it for some time now but I have to do it)

I created an FSM for each row. I'm doing the 3 x 3 grid and all of the FSMs are on the same object.

I now have:

FSM row1 (Im adding cubes to array list column1)
FSM row2 (Im adding cubes to array list column2)
FSM row3 (Im adding cubes to array list column3)

I now have 3 FSM's and 3 Array List Proxy's

2,2,2
1,1,1
0,0,0

What action would I use to check if empty?
« Last Edit: November 10, 2020, 05:34:17 PM by Kodagames »
Have I said how much I love playmaker!!! This is one amazing tool

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Grid Positions (ArrayMaker)
« Reply #4 on: November 11, 2020, 05:24:56 AM »
Hi.
Well it depends on what you use on the arrays

You could for example use strings array.(and have the letter in the array)
Then if you destroy 1 set the value to * (for example)
then when you loop thru, do a string compare.

or gameobject array (containing the letter objects)
Then use game object is null

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Re: Grid Positions (ArrayMaker)
« Reply #5 on: November 11, 2020, 09:17:22 AM »
Hi djaydino,

I should have mentioned Im using Game Objects so Game Object Is Null is perfect, thank you again!

I think Ive almost got it solved.. still working on it though.

The different way you mentioned using gravity works pretty nice and is much easier to implement for sure so I might go this route for now then come back to the other way because Im sure I'll need it in the future.

I really want to say thank you for being sooo helpful, you are alright my friend! I've learned so much from you and this game wouldnt be possible without your help (hats off to you!).
Have I said how much I love playmaker!!! This is one amazing tool