Multistage Snake Game

0 favourites
  • 5 posts
From the Asset Store
20 high quality click sounds, ready to improve your game's UI instantly
  • hello, for our class we have to make a game by adding a new mechanic into an already existing game. I chose the classic snake game, with a bit of a twist in which the snake has to consume moving enemies. I saw tutorials on youtube and the forum here so I was able to make the general mechanics.

    There are, however, several problems I'm faced with. I have no programming knowledge whatsoever and only started making games using C2 because it was the easiest gamemaking program I can use. so here are some of the problems

    1. This is a multistage so I need some kind of trigger. I was thinking of the snake consuming 5 randomly spawned enemies, in which the "System" will "Go to layout (treasure room)."

    This is basically what I tried: gyazo.com/47bcd6b9f0d3044d20be16a7981807bf

    But nothing happens. I want to make it so that after the snakehead collides with nth number of enemies, it will trigger the game to go the next room, which is the "treasure room." Any help on this?

    2. When I go to the next room, I want to keep the length of the snake same as the previous room, instead of resetting when it goes to the next room. I read somewhere that whenever the layout changes the variables rest but I'm trying to make it so that the snake condition from the previous carries over to the next room.

    These two are basically the most troublesome parts of my project so if anybody can help out, it will be much appreciated!!

  • For the first problem, you could try making EnemyCount into a global variable and then checking it. The problem may be that the instance variables for your enemy object are resetting whenever a new one is created (I'm not positive that is how object creations work, but its worth a try).

    For the second one, you should be able to fix it with a similar method. Move your variable that holds the snake length into a global variable before going to the next layout, and then move it back once the next layout begins.

  • Wow thanks for the help! I've fixed problem number 1. Unfortunately I don't get what you mean by "move the variables that define the length into a global variable" Because the length of the snake is determined by multiple variables which basically look like this: gyazo.com/c3dba51adae65770142c16247420246e

    Do I have to set multiple global variables on "treasure room" with each of these variableS? Sorry if what I'm saying makes no sense whatsoever. Like I said I have no previous programming experience before...

  • Looking at that, I suppose you could just make SnakeCount into a global variable, that way it wouldn't change between layouts. If that doesn't work, then you should create multiple global variables for the different parts.

    Also, you can create your global variables within any of your layouts and they will be available from anywhere.

    Hopefully that helps, if not, perhaps post a link to the .capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wow thanks for the help! I've fixed problem number 1. Unfortunately I don't get what you mean by "move the variables that define the length into a global variable" Because the length of the snake is determined by multiple variables which basically look like this: gyazo.com/c3dba51adae65770142c16247420246e

    You my Sir saved me loads of headaches with this! Thanks a lot :)

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