PDA

View Full Version : game actions


mikeemikeex
06-21-2008, 02:06 PM
hey! i wonder if anyone can help me..

I'm trying to create a simple interface for my own portfolio where I have a little character that walks and jumps about...

I know how to script it to make the little guy walk left and right on key commands and im working on making him jump on a space bar down action.

The thing im struggling with is I want to be able to navigate around the site depending on where the little bloke is. I want to have little doors that are like in the background that when the character is stood in front of them and the user presses the up arrow key... the character then goes to a different part of the website?

how could i do this?
cheers

DiamondDog
06-21-2008, 02:19 PM
Maybe define a rectangular 'zone' around each door, and when the user presses the UP ARROW key, run a 'getDoor' function, which returns the number of the door that your man is closest to?

(Sorry - this is AS3, but easily translates to AS2, I'm sure)


function getDoor():int
{
if((myMan.x > 100) && (myMan.x < 200) && (myMan.y > 50) && (myMan.y < 125) )
{
return 0; // he's within door 0's 'zone'
}
else if ((myMan.x > 300) && (myMan.x < 600) && (myMan.y > 250) && (myMan.y < 400) )
{
return 1; // it's door 1 that's nearest

}
}

Not saying it's the best way, but it's one way that might work.