Help with snake

0 favourites
  • 6 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hey guys,

    Iv'e been trying to make a snake ai with C2. I saw that gif where the snake ate all the food and ended up filling the whole screen with itself and thought of replicating it.

    I'm having trouble trying to make the snake avoid running into it's own tail.

    I can avoid this if the snake is directly facing a tail segment with the help of line of sight behavior but not when the snake is right next to its own tail not facing it's tail segment.

    I have conditions where 'if food.X greater than snake.X => move right' and so on for all directions for the snake to move automatically. The tail is a square segment which is spawned when 1 food is eaten

    (Take example where the snake is moving up/down and has to move right to get it's food)

    The problem is avoiding the snake from moving right if it has a part of it's tail to it's immediate right, and only move if it's clear.

    If i put a condition 'check if tail is snake.X+10' , the system checks for all the tail parts and even if one tail part is not snake.X+10 the condition lets the snake move even if another tail is snake.X+10.

    Using picked instances makes the snake not move at all for some reason, i think it's cause if no tail meets the picked condition the condition to make the snake move is not met.

    Can anyone help?

    Thanks

  • here is demo made by mlb

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Lordshiva1948

    Thanks , but i can't open it as i've got r168 stable . is there a way to open it in older versions of C2?

  • Lordshiva1948

    That demo is just a button that directs you to the newyorktimes website when clicked. I'm not sure if your trolling or uploaded the wrong capx

  • zenox98

    Thanks , i have come across your tutorial before and used similar techniques to save the positions of the snake. But i'm trying to make a snake artificial intelligence rather than a user controlled one. Thanks anyways.

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