UWSP - Flash Game
I took a Flash game development class at UW - Stevens Point. We made a game that you would walk around an old haunted hospital to find the ghosts that haunt it. Our game was 3D and you had to dodge flying bats that were inside the hospital. There were also ghost nurses that walked around you. We used a multidemonsional array to keep track of the trees, hospital beds, and walls that you could not walk into. This project really helped with my use of arrays.
This snippet shows how I looked for the keyboard events. Each key event had the character changing a direction so I also changed the direction the character was looking. During this process I also had to check when the character hit a wall so they wouldn’t go out of the playing field. You can throw cans with the mouse so when the character moved around the screen I also had to move the gun object around the screen so that the mouse would have cans thrown from the correct spots.
function moveCharacter() {
if(Key.isDown(39)) {//right
if(outScreen.player._currentframe > 11 && outScreen.player._currentframe < 22) {
outScreen.player.play();
} else {
outScreen.player.gotoAndPlay("Side");
}
outScreen.player._xscale = -9;
outScreen.player._x += walkSpeed;
dx += .9;
}else if(Key.isDown(37)) {//left
if(outScreen.player._currentframe > 11 && outScreen.player._currentframe < 22) {
outScreen.player.play();
} else {
outScreen.player.gotoAndPlay("Side");
}
outScreen.player._xscale = 9;
outScreen.player._x -= walkSpeed;
dx -= .5;
}else if(Key.isDown(38)) {//up
if(outScreen.player._currentframe > 23 && outScreen.player._currentframe < 32) {
outScreen.player.play();
} else {
outScreen.player.gotoAndPlay("Up");
}
outScreen.player._y -= walkSpeed;
dy -= .5;
} else if(Key.isDown(40)) {//down
if(outScreen.player._currentframe > 0 && outScreen.player._currentframe < 10) {
outScreen.player.play();
} else {
outScreen.player.gotoAndPlay("Down");
}
outScreen.player._y += walkSpeed;
dy += .5;
}
outScreen.gun._x = outScreen.player._x + 110 + (outScreen.player._x / 4);
outScreen.gun._y = outScreen.player._y + 14 + (outScreen.player._y / 4);;
}
You can try it out if you would like.