playMaker

Author Topic: Re-creating the gameplay of 'Calmfall' [SOLVED]  (Read 2539 times)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re-creating the gameplay of 'Calmfall' [SOLVED]
« on: July 04, 2017, 08:10:47 PM »
So I've started looking at simple arcade games on the Play/App Store and attempting to understand/ recreate their functionality in Playmaker- just for learning purposes!

I came across a little game called 'Calmfall': https://play.google.com/store/apps/details?id=com.nucooky.nonfreefall&hl=en_GB

I can understand how most functionality could be recreated in Playmaker, EXCEPT for the bricks themselves.

How would one go about creating such a system, which understands how to align various shapes of block together into a perfect tower?

Any takers?
« Last Edit: July 06, 2017, 03:35:58 PM by ItzArranT »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Re-creating the gameplay of 'Calmfall'
« Reply #1 on: July 05, 2017, 07:39:23 AM »
What do you mean? If you handcraft the levels, it's fairly simple, if you want them to be randomly generated, that's a whole new story.
Available for Playmaker work

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Re-creating the gameplay of 'Calmfall'
« Reply #2 on: July 05, 2017, 08:24:47 AM »
Essentially it's randomly generating interlocking shapes.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Re-creating the gameplay of 'Calmfall'
« Reply #3 on: July 05, 2017, 04:52:37 PM »
Ok. First make an array of objects (shapes) you want to use, asymmetrical shapes times four (for every 90 degrees rotation) and symmetrical times two (for every 180 degrees rotation). You need to make multiple copies of those objects with different centers. What do i mean by that? By default, a submarine shaped object a la tetris (horizontally joined three "squares" with one above the middle one) would have its center somewhere in the middle of the of the object which ia not what we need. We need three different centers for aligning (i'll explain later why), one in the left "square", one in the upper "square", and one in the right "square". You can to that by childing the object under an empty object and then setting its position locally. Don't forget to put colliders, but don't enable any physics yet.

Now the play area is basically a grid of cells of the same dimension, so your objects need to be properly sized to fit.

Make a grid of wanted dimension and put a trigger (i think on trigger stay would be ok) in center of every cell and put them in the array too.

You need borders too, they are also cells that go around the play area cells. Do the same thing but put them in a different array.

Now comes the magic, get the first (lower-left) cell from the array, check if the trigger is active (if there is an object on it already, it won't be in the first cell, of course). If not, select a random object from the shapes array and put it in the lower left cell by setting position of a parent object. Now check the border grid, if it's triggered, the shape is outside the play area, it doesn't fit. Remove it, and get another one from the shapes array. When the border grid is passed, get the next play area cell. If it's occupied, go to next one. Don't forget to check if any of the shapes are overlapping by checking if they trigger each other. Rinse and repeat to the top, enable physics and start game.

We made the shapes with different centers so the rotated objects would match the grid and all possible rotations are tested.

To make variety, you can make a get next loop get a shape from a different array every time (ie, make an array for every shape).

If something is not clear, i can make a graphical representation. Cheers.
Available for Playmaker work

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Re-creating the gameplay of 'Calmfall'
« Reply #4 on: July 05, 2017, 04:58:12 PM »
Amazing reply krmko- exceptionally explained!

Have you tried this approach already? Either way I'll be doing so myself and will let you know how it goes.

I'll keep the thread "un-solved" for now ;)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Re-creating the gameplay of 'Calmfall'
« Reply #5 on: July 05, 2017, 05:37:55 PM »
A couple questions:

1) Why do symmetrical shapes not require times four variants also? Surely it would make sense for a symmetrical shape such as the 'submarine' to exist in four 90 degree rotation variants?

2) Does each rotated version of the same shape also require X different versions of itself with different centres?

I.e. for the submarine block, there would be 12 variations in total (4 for rotation and 3 differing versions of each rotation for different centres)?

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Re-creating the gameplay of 'Calmfall'
« Reply #6 on: July 06, 2017, 02:49:50 AM »
Sorry, i was writing from a cellphone, so i couldn't be a bit more specific.

1) Actually, i should have used the term rotational symmetry. "Submarine" is not rotational symmetrical, it is differently shaped with 90, 180, 270 and 360 rotation. However, shapes like square, or two, three, or four squares joined into a row or column are shaped the same in 180 and 360 degrees, and 90 and 270, so only two are needed.

2) The way i imagined it, yes. I'm not quite sure if there's a simpler way. Sure, it requires a lot of work, but once it's set up you good to go, you can easily add new shapes, limit the tower height etc.
Available for Playmaker work

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Re-creating the gameplay of 'Calmfall'
« Reply #7 on: July 06, 2017, 07:02:34 AM »
In fairness you've been pretty specific so far!

What would be the best way to check if the trigger is active? So far I've created a simple 5x5 grid of empty game objects which each have an 'Is Trigger' box collider and a simple, two-state FSM which use:

State 1) Trigger Event
State 2) Sent Event to Game Manager "Cell Is Filled".

Although I'm unsure how best to proceed.  I understand the logic but I'm uncertain how best to reflect that in an FSM...
« Last Edit: July 06, 2017, 07:07:55 AM by ItzArranT »

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Re-creating the gameplay of 'Calmfall'
« Reply #8 on: July 06, 2017, 03:19:29 PM »
I'll write in a day or two, i'm sick. For cell is not filled use next frame event and check "action sequence" state. That way, the action are done sequentially, first the trigger check is done, if the box is filled, then go to next one, if not, next frameevent start next action, getting objects from array.
Available for Playmaker work

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
Re: Re-creating the gameplay of 'Calmfall'
« Reply #9 on: July 06, 2017, 03:35:48 PM »
Sorry to hear that krmko.

I'll mark the thread as solved for now but definitely get in touch once you're fighting fit again!

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Re-creating the gameplay of 'Calmfall' [SOLVED]
« Reply #10 on: July 09, 2017, 01:19:13 PM »
Sorry for the delay. Have you tried any of this?
Available for Playmaker work