0 Favourites

Help with tile shifting game

  • The game I have in mind involves a grid of square tiles. I want to make it so a line of tiles can be shifted. So a row of 1,2,3,4,5 would become 2,3,4,5,1. I've been trying to come up with a way to do this, but it seems all my methods are really inefficient. Can people help me with this? Thanks.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • If you have the tile numbers in an array you can push the first element to the back, then pop the first element.

    [1,2,3,4,5] - Starting array

    [1,2,3,4,5,1] - Push first element to the back

    [2,3,4,5,1] - pop the first element from the front

    Push the last element to the front and pop the last element to go the other way.

  • If you have the tile numbers in an array you can push the first element to the back, then pop the first element.

    [1,2,3,4,5] - Starting array

    [1,2,3,4,5,1] - Push first element to the back

    [2,3,4,5,1] - pop the first element from the front

    Push the last element to the front and pop the last element to go the other way.

    Thanks theubie. I've been doing tutorials that relate to platformers. It makes sense to have a sprite for the main character, each enemy, etc. With what I'm trying to make now though, how would I add conditions to tiles that look the same? I could add them separately and give them different names, but it seems there must be a better way. Do you see what I mean?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)