-
need help :(
hi looking for help with this code
Code:
onClipEvent (load) {
power = 1;
yspeed = 0;
xspeed = 0;
friction = 0.95;
gravity = 0.1;
thrust = 0.75;
radius = 10;
}
onClipEvent (enterFrame) {
xspeed *= friction;
yspeed += gravity;
_y += yspeed;
_x += xspeed;
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
if (Key.isDown(Key.UP)) {
yspeed -= power*thrust;
}
if (Key.isDown(Key.DOWN)) {
yspeed += power*thrust;
}
if (Key.isDown(Key.SPACE)) {
_root.player.player_beaming.gotoAndStop(2);
} else {
_root.player.player_beaming.gotoAndStop(1);
}
while (_root.world1_1_walls.hitTest(_x, _y+radius, true)) {
_y--;
}
while (_root.world1_1_walls.hitTest(_x, _y-radius, true)) {
_y++;
}
while (_root.world1_1_walls.hitTest(_x-radius, _y, true)) {
_x++;
}
while (_root.world1_1_walls.hitTest(_x+radius, _y, true)) {
_x--;
}
}
the above code works fine, but but when my player hits the wall in certain places it seems to remove the player movie clip... can someone please help?
The one that smiles when things go wrong, Has thought of someone to blame it on
-
When speed exceeds the width of the wall the clip moves outside...
Maybe you can adapt this...
Code:
onClipEvent (load) {
power = 1;
yspeed = 0;
xspeed = 0;
friction = 0.95;
gravity = 0.1;
thrust = 0.75;
radius = 10;
xnew = _x;
ynew = _y;
xmin = _root.world1_1_walls._x + radius;
xmax = _root.world1_1_walls._x + _root.world1_1_walls._width - radius;
ymin = _root.world1_1_walls._y + radius;
ymax = _root.world1_1_walls._y + _root.world1_1_walls._height - radius;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
xspeed -= power;
}
if (Key.isDown(Key.RIGHT)) {
xspeed += power;
}
if (Key.isDown(Key.UP)) {
yspeed -= power * thrust;
}
if (Key.isDown(Key.DOWN)) {
yspeed += power * thrust;
}
xspeed *= friction;
yspeed += gravity;
xnew += xspeed;
ynew += yspeed;
if (Key.isDown(Key.SPACE)) {
_root.player.player_beaming.gotoAndStop(2);
} else {
_root.player.player_beaming.gotoAndStop(1);
}
xnew = Math.min(xmax, Math.max(xmin, xnew));
_x = xnew;
ynew = Math.min(ymax, Math.max(ymin, ynew));
_y = ynew;
}
-
The one that smiles when things go wrong, Has thought of someone to blame it on
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|