ForumsProgramming ForumMaze Game

42 12775
Maaron
offline
Maaron
47 posts
Nomad

Hey everyone,

I'm making a maze game but I'm having a bit of trouble. When you hit the walls you are sent to a different frame where it tells you that you have lost, here is the code for that:

if (Wall.hitTest(Player._x, Player._y, true)) {
gotoAndStop(2);
}

That works fine, it's just the restart button I can't get working, I click on it and nothing happens, here is the code:

Retry.onRelease = function() {
gotoAndStop(1);
}

I have no idea why it won't work, please help me.

  • 42 Replies
Maaron
offline
Maaron
47 posts
Nomad

Or, you could try this:
//Restart Button
Retry_btn.onRelease = function() {
Player_mc._x = 0 //Or wherever the player starts out.
Player_mc._y = 0 //Or wherever the player starts out.
gotoAndStop(1);
}


I tried this one but it did not work, any ideas?
IQAndreas
offline
IQAndreas
299 posts
Peasant

Just wondering, is this referring to the stage moving up and down, or the player?

this._y += 5;

Maaron
offline
Maaron
47 posts
Nomad

Um.... the player. Why?

IQAndreas
offline
IQAndreas
299 posts
Peasant

Well, since I am only familiar with Object Oriented Programming, I'm not sure if using the this keyword inside of a function inside of root will refer to root or the player.

Try changing this to Player_mc and see if it makes any difference.

Or perhaps try this:
//Check If It Touches The Wall
if (Wall_mc.hitTest(Player_mc._x, Player_mc._y, true)) {
Player_mc._x = 0 //Or wherever the player starts out.
Player_mc._y = 0 //Or wherever the player starts out
gotoAndStop(2);
}

Maaron
offline
Maaron
47 posts
Nomad

THANK YOU EVERYONE SO MUCH. I finally got it all working.

Here is the link to the updated one:

[url=http://spamtheweb.com/ul/upload/3808/57466_Maze_Game.swf]

It isn't that good but it is a start. And thank you all again, you guys have helped me so much.

Maaron
offline
Maaron
47 posts
Nomad

One more question, I'm trying to make a pause menu, could you guys help me out with that?

Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

Well, you could just put a big "if" for everything

if(Pause == false)
{
All the code for moving and etc
}
Maaron
offline
Maaron
47 posts
Nomad

So that is saying it isn't paused, what code do I put to make it paused and how do I make it become paused if I say.. push the "P" button on the keyboard?

if(Pause == false)
{
All the code for moving and etc
}
Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

Not much different from what you might have now. Something like

if (Key.isDown(80))
{
Pause = true;
}


80 is the code for "P"
IQAndreas
offline
IQAndreas
299 posts
Peasant

Nice job! I'm glad it worked out.

Now you can try adding more things like moving obstacles and time limits.

Maaron
offline
Maaron
47 posts
Nomad

Not much different from what you might have now. Something like

if (Key.isDown(80))
{
Pause = true;
}

80 is the code for "P"


Thanks, I'll try that soon. How do you find out what all the codes for the keys are.


Nice job! I'm glad it worked out.

Now you can try adding more things like moving obstacles and time limits.


Thanks, I'll start trying to do that kinda stuff soon.
IQAndreas
offline
IQAndreas
299 posts
Peasant

How do you find out what all the codes for the keys are.

Google "ASCII Chart". It is always a really good idea to print one out and have it as a reference when programming.
Maaron
offline
Maaron
47 posts
Nomad

Google "ASCII Chart"


Thanks for that.

But I'm still a little unsure how to do the whole pause menu business, I can't work out what bits I put where.
Ricador
offline
Ricador
3,722 posts
Shepherd

None of this makes sense

I should srlsy consider some programming classes :P

jpx111
offline
jpx111
264 posts
Nomad

@Maaron: Well, you could either make the Menu on a new keyframe and disable all the movement buttons and stop the timer(if there is one)...or you could have the menu, invisible during game play, on a different layer and disable everything movement and timer...
Just two ways I quickly thought of...there's probably other ways...but it should work

@Ricador: lol...yea...once you make something cool, you'll get somewhat obsessed with it :P

Showing 16-30 of 42