Wednesday, January 19, 2011

Persuading With Pseudocode

Our game idea is Windmills, Pollution, and..NINJAS
You will be able to choose from a boy or girl and control them, left, right, or jumping by the A,D,W keys.
You will be going through the levels collecting windmill parts to save the world.
Whenever you collect them and make it to ninja carriers, you will go to the question portion of the level.

The Character's Movement:
stop();


boss.onRelease=function() {
gotoAndPlay("question1");
}

stop();
//horizonal walking speed related variables
//This is your starting walking speed
_global.landspeed = 0;

//This is your speed limit
_global.landspeedmax = 30;

//This is used to slowly accelerate your hero up to the speed limit
_global.acceleration = .95;

//jump related variables
//Variables to know whether our hero is Jumping or Falling
_global.isJumping = false;
_global.isFalling = true;

//Velocity as mentioned in the Jump Cycle diagram
_global.velocity = 0;

//Tweak this value along with gravity for interesting results
_global.velocitymax = 25;

//Gravity (acceleration) as mentioned in the Jump Cycle diagram
//more gravity (5.0)
//less gravity (.01)
_global.gravity = 1.5;

girl.onEnterFrame = function(){

if(_root.deadzone.hitTest(this)){
//If the hero hits this movieclip called deadzone, which is below the stage's boundary
//go to frame 2, the "You're Dead" frame
_root.gotoAndStop("dead 2");
_root._x = 0;

} else {
//"I'm not dead yet!"

if (!_root.ground.hitTest(this._x, this._y, true) && !_global.isJumping) {
//hero isn't on the ground and isn't jumping - hero fell off a platform or is in freefall
//changing the number below can make hero fall faster or slower based on conditions above
this._y += 10;
}

if (_root.ground.hitTest(this._x, this._y, true) && _global.isFalling) {
//hero is in the falling section of a jump and finally lands back on terra firma
//reset jump counter back to default
_global.velocity = _global.velocitymax;
_global.isJumping = false;
_global.isFalling = false;
}

if(_global.isJumping == true){

//If hero is jumping, move hero's y coordinate

this._y -= _global.velocity;
_global.velocity -= _global.gravity;

if (_global.velocity < 0) {
//hero is starting the descent down
_global.isFalling = true;
}

if (_global.velocity < -_global.velocitymax) {
//this caps (or sets) the hero's terminal velocity
_global.velocity = -_global.velocitymax;
}

} else {

if(Key.isDown(87)){
girl (0, "jump");

//Hero is jumping, velocity is turned on
_global.isJumping = true;
_global.velocity = _global.velocitymax;

}
}

_global.landspeed *= _global.acceleration;

if(Key.isDown(68)) {
girl (0,"right");

if (_global.landspeed < _global.landspeedmax) {

_global.landspeed++;

}

this._x += _global.landspeed;
deadzone._x += _global.landspeed;
_root._x -= _global.landspeed;
this._xscale = 100;

}

if(Key.isDown(65)) {
girl (0,"left");

if (_global.landspeed > -_global.landspeedmax) {

_global.landspeed--;

}

this._x += _global.landspeed;
deadzone._x += _global.landspeed;
_root._x -= _global.landspeed;
this._xscale = -100;

}

if (Math.abs(_global.landspeed) < 1 ) {
//if my hero's speed has slowed down between
//a range of -1 to 1, make the speed stop
//Math.abs (absolute value) statement above would be the same
//as stating if(_global.landspeed > -1 && _global.landspeed < 1)

_global.landspeed = 0;

}
}
}

No comments:

Post a Comment

The New Saw

SAW VII 3D: Movie Trailer. Watch more top selected videos about: Tobin Bell, Gina Holden