Multistage Snake Game

Get help using Construct 2

Post » Wed Apr 17, 2013 3:19 am

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: http://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!!
B
2
Posts: 2
Reputation: 254

Post » Wed Apr 17, 2013 3:48 am

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.
B
21
S
7
G
5
Posts: 89
Reputation: 5,967

Post » Wed Apr 17, 2013 4:14 am

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: http://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...
B
2
Posts: 2
Reputation: 254

Post » Wed Apr 17, 2013 7:28 am

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
B
21
S
7
G
5
Posts: 89
Reputation: 5,967

Post » Sat Jun 29, 2013 7:01 am

[QUOTE=cyblix] 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: http://gyazo.com/c3dba51adae65770142c16247420246e
[/QUOTE]
You my Sir saved me loads of headaches with this! Thanks a lot :)
B
5
Posts: 4
Reputation: 258


Return to How do I....?

Who is online

Users browsing this forum: abdalghani, imothep85, LeFuji, makkancs, Marxally, Virpoja and 22 guests