Search Unity

Snake game

Discussion in 'Getting Started' started by maliyshock, Oct 25, 2020.

Thread Status:
Not open for further replies.
  1. maliyshock

    maliyshock

    Joined:
    Dec 28, 2018
    Posts:
    4
    So I decided to create my first snake game. But I would like to generate obstacles on the level.
    The problem is that there could be situations when obstacles create some corridor take a look at the schema to get the idea https://monosnap.com/file/EaW1gyGA5pQFAiLwEfgZjUqqxPATOq
    In this situation, there is no possible way to eat the thing by a snake and do not die.

    So I would like to create some kind of a map of the level and script, which can understand where on the level are places to safely put the snake food item.

    And right now I have no idea how to do that. Any guesses?
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I would just keep it simple, and require that the food always have at least 3 empty spaces around it. That, plus not using a lot of long skinny obstacles, should make it almost always possible to get the food.

    If you're still bothered by the very low chance that an impossible level is generated, then you might want to give the snake some way to eat through an obstacle, but make this a special trick it can do only once per level.
     
  3. maliyshock

    maliyshock

    Joined:
    Dec 28, 2018
    Posts:
    4
    Thank you! Yep, today I woke up with the same idea about checking space around the food.
     
  4. maliyshock

    maliyshock

    Joined:
    Dec 28, 2018
    Posts:
    4

    Attached Files:

  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I do...

    That's why. ;)

    Adjust the lights to your lighting. The default lights are pretty stark.
     
    matthewdaniel69 likes this.
Thread Status:
Not open for further replies.