At 6/21/06 05:38 PM, takumidesh wrote:
i think it would be better if you let the ball roll down hills and the camera should follow the ball but dont listen to me im a noob
Oh yeah I forgot the code in the ball.
onClipEvent (load) {
grav = 0;
// sets falling speed
speed = 7;
// sets movement speed
jumpHeight = 15;
// sets height that you can jump
scale = _xscale;
// sets size
slowfall = .8;
// sets glide
}
onClipEvent (enterFrame) {
// happens every frame
grav++;
// makes you fall faster
_y += grav;
// makes your _y go up by the varaible grav
while (_root.ground.hitTest(_x, _y, true)) {
// when this is touching the ground
_y--;
// makes the y keep on going up, this enables slopes
grav = 0;
// make it so you dont fall
}
if (Key.isDown(68)) {
// when the d key is down
_x += speed;
// makes the x go up by the speed
_xscale = scale;
// makes it face right
if (_root.ground.hitTest(_x, _y+3, true)) {
// if it is touching the ground
this.gotoAndStop(1);
// goes to frame 1
} else {
// otherwise
this.gotoAndStop(2);
// stops at frame 2
}
} else if (Key.isDown(65)) {
// if that isnt happening and the a key is pressed
_x -= speed;
// makes the x go gown by the speed
_xscale = -scale;
// makes it face left
if (_root.ground.hitTest(_x, _y+3, true)) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
// see other code for movign right
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79)) {
// if this is touching the ground and o isnt pressed
this.gotoAndStop(3);
// stops at frame 3
}
}
if (Key.isDown(83)) {
// if the s key is down
grav *= slowfall;
// slows down the gravity by multiplying it by the slowfall varialbe
}
if (Key.isDown(79) && !Key.isDown(87) && !Key.isDown(65) && !Key.isDown(68)) {
// if 0 is down, and a s d w arent
this.gotoAndStop(4);
// goes to frame 4
}
if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true)) {
// if w is pressed and it is touching the ground
grav = -jumpHeight;
// makes gravity negative jumpheight, causes jump
_y -= 4;
// makes the y go up by 3
this.gotoAndStop(2);
// stops on frame 2
}
if (_root.ground.hitTest(_x+(_width/2), _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2), _y-((_height/6)*4), true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2), _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2), _y-((_height/6)*4), true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height, true)) {
grav = 2;
}
// these all check for 2 points along the sides and top, to see if it is hitting a wall
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_x -= 10;
} else if (Key.isDown(Key.LEFT)) {
_x += 10;
}
}
onClipEvent(enterFrame) {
if(Key.isDown(Key.DOWN)) {
_y -= 10
}
if(Key.isDown(Key.UP)) {
_y += 10
}
}