GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How can I evenly create tiles within a grid and move around like snake.

evertevert Posts: 264Member, PRO
edited May 5 in Working with GS (Mac)

Hey everyone,

I want to create a plane with titles upon a grid of some sorts. Exactly as in this screenshot I made.
My character should be able to move over the tiles automatically forward and swipen to go left and right.
Any idea how to do this in a correct way? Similar to snake but the snake always moves upwards.

Edit: I found this project on the forum: https://forums.gamesalad.com/discussion/95686/project-blocks-development-journey-from-idea-to-trash-can

The way his tiles are is what i would like to do. His snake moves in 4 directions. I want to move up automatically and go left or right.

Thanks in advance.

Comments

  • AlkaPPAlkaPP Posts: 194Member, PRO

    I recommend you to reach out @Two.E and also check out his website gslearn.com . He’s an expert on tables and grids.

    My Gamesalad Games On App Store:

    Greedy Chubby: https://itunes.apple.com/us/app/greedy-chubby/id834371213?ls=1

  • Two.ETwo.E Posts: 572Member

    Thanks for the mention @AlkaPP

    @evert Is this what you want?

    Download here: https://gslearn.com/product/snake-movement/

    Its square/ grid movement. If you don't want to move downwards, simply don't have a rule to move down.

    How it works is that there is an Attribute called Move ID:
    If the value is set to the following:
    1 = Move up
    2 = Move right
    3 = Move Down
    4 = Move Left

    When the player presses any arrow keys, it will change that attribute to the relative value.
    You will also notice that it is set to a value of 2, because I want the snake to start moving to the right when he game starts.

    If you don't want to move downwards, simply do not include logic to change the Move ID to 3. (Down).

    If you want to start by moving up, change the value to 1 (Up).

    Thanks for admiring my previous work - Always amazed how many people message me about that work.

    Hope that helps!

    Best,
    Two.E

  • evertevert Posts: 264Member, PRO

    @Two.E Oh this is great!

    But I do have a bunch of questions about it. As it has been ages that I worked with game salad.

    • How can I make the grid endless upwards? I'm trying to create an endless runner type of game with a snake on a grid going up.

    • How can I adapt this template for iphone?

    • and how do I show tiles for each grid location.

    I purchased your Longlines script, but I can't figure it out at this point.
    Sorry for the loads of questions.

    Thanks in advance.

  • Two.ETwo.E Posts: 572Member

    Thanks for the purchase - Although I don't think that template (Long Lines) is going to achieve what you are looking for. The snake movement template does exactly what you are looking for to provide a solid starting point.

    I would suggest looking at how the snake Head moves. Its simply changing its X and Y position to + / - the size of the square depending on the direction of travel.

    Next, how do we disable it to go downwards -- we simply get rid of the logic that tells it to move down. In the template, its the DOWN Key.

    Then we look at how to make it endless. This is the tricky part. In my opinion, I would look at making the rest of the squares move down (Instead of the Head) and have them wrap. When they reach the bottom, move to top and move back down again.
    I would only have the snake move if its going left or right. This way it is always going to be centred position.

    I am currently super busy for the next 24-36 hours. If I find time, then or afterwards I will see if I can get a better explanation or a demo sorted.

    I would use OverScan, or simply re-build / size the project into iPhone size.


    Feel free to message me if you have any problems or concerns with the long lines template.

    Best,
    Two.E

Sign In or Register to comment.