Tetris Style Game Physics

alexxxhpalexxxhp Member Posts: 161
edited November -1 in Tech Support
I am making a game in the style of tetris but color code based instead of shapes but I cant get the game to destroy actors when all colors match 4 or more. what rules should be applied to tell the game to destroy when 4 of a kind collide... I have tried all different ways and don't seem to work thanks.

Comments

  • alexxxhpalexxxhp Member Posts: 161
    Anyone?
  • SnowSnow Member Posts: 124
    Not everything needs arrays. If for instance you wanted to do connect 4, though this is tricky but say for just horizontal or vertical:

    Each block or piece must obviously be an instance of one parent.
    Say you want a grid based system - map out the coordinates for the grid. Store each number as a value globally (in the scene). Where ever a block lands - it's x or y coordinate will be one of these numbers. The coordinates of the blocks do not have to be dynamically stored or even stored in an array. Rather you make a rule that works like how a score counter works. This is tricky though as I can't explain the logic further.

    Basically, what you want is if 4 blocks overlap or collide with eachother and happen to have the same x or y coordinate - they tick the counter. When the counter hits 4, it deletes the instances that ticked the counter. If a block has been removed that ticked the counter for say a horizontal row (it was deleted in a vertical row) the counter drops a number.

    You might have to have a counter for each row and each column, so that requiring an array won't be necessarily necessary.

    If you want tetris type pieces that fall down which consist of say 4 blocks each like the real tetris. You can have the constructed outside of the scene and simply recycle them. Outside of the screen area they are fixed. When called they are shifted to the area above the screen and are no longer fixed - they are prone to gravity and so fall. The only problem is, they'll fall in perfect formation, but once any block touches a stationary object, the rest will continue to fall until they come to rest.
  • vegasmike1vegasmike1 Member Posts: 192
    You can do it with our arrays, but you need lots of rules, that are nested, as in using the otherwise part of the rule. An array would allow you a much easier method of doing this, true, but you can build it, the question is how many objects and actors are you going to try and put on the screen, 10, 100, 200, that is where you are going to bump into a set of problems with speed and the rule set, its doable but in the end with lots of actors it is going to SLOW down on most devices, and in the end it will performance not the ability to use an array. If you can make a game with few actors, you will do better with performance. But if you really want to make this game, I can help with the logic you need for kind of match game. Its not that hard, but you might want to rethink this idea based on how many actors COULD you have on the screen. I have already done a quick tetris game, and it bogged my iphone down so bad that I just quit the idea. Oh well you cant have you cake and eat it too.
  • alexxxhpalexxxhp Member Posts: 161
    I would like help thanks
  • PhoticsPhotics Member Posts: 4,172
    Did you see Commove?

    That's a game which I think is somewhat similar to Tetris. I explain how to create it in The Unofficial GameSalad Textbook.
  • FranzKellerFranzKeller Member Posts: 517
    There is a demo of a (match 3) puzzle game in the templates somewhere? Cleverly written by one of the GS experts.

    Really, the existing GS logic is strongly leaning toward shooters and platformers.
    (Which I like, so is not a problem)

    but some more "casual game / puzzle" oriented features could be good -
    such as a visual "matrix" object - could be very handy for backgrounds too?

    tile match detection, etc, etc.
  • JackBQuickJackBQuick Member Posts: 524
    FranzKeller said:
    There is a demo of a (match 3) puzzle game in the templates somewhere? Cleverly written by one of the GS experts.

    Have a look at CodeMonkey's Jewel Destruction Template. Please keep in mind that it is not finished and there are still some bugs to fix.

    tshirtbooth and vegasmike1 are right: it isn't impossible to do but it would be very difficult.
Sign In or Register to comment.