ForumsProgramming ForumNEED HELP- platform game jumping problem

6 2917
rino
offline
rino
27 posts
Nomad

I have code (below) that allows the character to move so that it alows it to rotate to the ground, but now I'am try to make him jump but it does not seem to work, if you could please help adjust the code so that the character can jump, it would be alot of help

onClipEvent (load) {
this.dir = 1;
function updateBB ()
{
while (!_root.ground.hitTest (_root.bb._x, _root.bb._y, true))
{
_root.bb._y++;
}
while (_root.ground.hitTest (_root.bb._x, _root.bb._y, true))
{
_root.bb._y--;
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT))
{
this._x += 10;
this.dir = 1;
}
if (Key.isDown (Key.LEFT))
{
this._x -= 10;
this.dir = -1;
}
while (!_root.ground.hitTest (this._x, this._y, true))
{
this._y += 5;
}
while (_root.ground.hitTest (this._x, this._y, true))
{
this._y--;
}
//see A
//_root.cc._y = this._y;
_root.bb._x = this._x + (20 * this.dir);
_root.bb._y = this._y;
updateBB ();
rot1 = Math.atan2 (_root.bb._y - this._y, _root.bb._x - this._x);
this._rotation = rot1 * 180 / Math.PI;
if (this.dir == -1)
{
this._rotation += 180;
}
this._xscale = this.dir * Math.abs (this._xscale);
updateBB ();
}

  • 6 Replies
staticzone
offline
staticzone
67 posts
Nomad

lol u cant just because their is no command for jump

try this
onClipEvent (load) {
this.dir = 1;
function updateBB ()
{
while (!_root.ground.hitTest (_root.bb._x, _root.bb._y, true))
{
_root.bb._y++;
}
while (_root.ground.hitTest (_root.bb._x, _root.bb._y, true))
{
_root.bb._y--;
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT))
{
this._x += 10;
this.dir = 1;
}
if (Key.isDown (Key.LEFT))
{
this._x -= 10;
this.dir = -1;
}
if (Key.isDown (Key.UP))
{
this._y -= 10;
this.dir = -1;
}
while (!_root.ground.hitTest (this._x, this._y, true))
{
this._y += 5;
}
while (_root.ground.hitTest (this._x, this._y, true))
{
this._y--;
}
//see A
//_root.cc._y = this._y;
_root.bb._x = this._x + (20 * this.dir);
_root.bb._y = this._y;
updateBB ();
rot1 = Math.atan2 (_root.bb._y - this._y, _root.bb._x - this._x);
this._rotation = rot1 * 180 / Math.PI;
if (this.dir == -1)
{
this._rotation += 180;
}
this._xscale = this.dir * Math.abs (this._xscale);
updateBB ();
}



let me know if it works

staticzone
offline
staticzone
67 posts
Nomad

Crap im sry thats not right...

rino
offline
rino
27 posts
Nomad

it does not work

rino
offline
rino
27 posts
Nomad

any idea

staticzone
offline
staticzone
67 posts
Nomad

T[url=http://www.emanueleferonato.com/2007/11/03/creation-of-a-platform-game-with-flash-step-2/]his should help you

sanny
offline
sanny
124 posts
Nomad

I tried it, weird it works by me. :/

Showing 1-6 of 6