Looking Ahead?



  • I have a four direction movement based system. The game is a tetris like. Still working on that. The blocks move in a grid, the blocks constantly move down. The blocks stop moving if they hit other blocks or the floor.

    What I want to be able to do is to make sure that when the falling blocks hit the other blocks, the falling blocks only stop when they hit the top of the blocks already there.

    There are a couple ways to do this. I think I have tried them and they don't work as I expect them too.

    Such as:

    for block in falling
    if flxg.collide block, fallen, && block.istouching down

    or something or other like that.

    So. Can I have a sprite constantly check it's position, and if there are other sprites of a certain type in front of it or to the side of it, don't move?



  • hi @xhunterko

    when the falling block reaches the target, create a sprite object at that location. that object should be with zero speed. no need to collide anything. place the falling block back up at the top of the screen and change its color and other stuff to prepare for another falling block. you could create a maze of empty blocks in a x and y grid and then the falling block would move lets say by increments of 32 pixels. then when that falling block reaches a unit that has a full unit underneath it, create the sprite object with its coordinates or better yet, just change that instances color and solid state.

    what i would do is each time a block is added to the scene, i would store its x and y coordinates, its color and instance ID. each time a block object is created, do a var plus one to that total. so the blockCount var is passed at the constructor and do ID = blockCount. also, I would use redBlockCoordinateY, redBlockCoordinateX these vars I would use arrays.

    next, at the Reg class create a var flickerBlocks[x][y] array which represents the blocks on the screen. at the block class you can use if (flickerBlocks[1][1] == 1), if redBlockCoordinateY and redBlockCoordinateX was passed to that class and they both equal one then flicker the object. ID is handy if you want to flicker each block in the order of one to max and also to remove objects.

    so you can do something like... at the block class update()

    for (I in 0...maxID)
    {
    	// IDx and IDy was passed to the block constructor.
    	if (Row[x] = 3 && colorID = 2 && flickerBlocks[IDx][IDy] == 1)
    


  • Hi! Thanks for answering. That looks like a good idea but I'd have no idea how to implement it at all. Since I'm not familiar with arrays OR how they'd work to do such a system. Thanks again though. That just means I need to do arrays for the NEXT iteration of this game. Sigh.

    Thanks again!

    Sorry for taking so long to respond, I've been busy.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.