Be a Supporter!

double jump?

  • 266 Views
  • 4 Replies
New Topic Respond to this Topic
canada92
canada92
  • Member since: Apr. 11, 2008
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
double jump? 2009-02-24 02:24:34 Reply

ok, my character can jump just fine with this code but i dont know how to make him double jump!
iv tried many different things but nothing works, can someone please help me out here?
i would really appreciate it =]

onClipEvent (load) {
moveSpeed = 15;
}

onClipEvent (enterFrame) {
if(Key.isDown(Key.UP)){
player.gotoAndPlay(3)
}
if (Key.isDown(Key.UP) && !jumping) {
vel_y = 45;
vel_y = 45;
jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;

}
while (_root.ground.hitTest(this._x, this._y, true)) {
vel_y = 0;
_y--
jumping = false;
}
while (_root.ground.hitTest(this._x+15, this._y-10, true)) {
_x--
}
while (_root.ground.hitTest(this._x-15, this._y-10, true)) {
_x++
}
while (_root.ground.hitTest(this._x, this._y-80, true)) {
_y++
}
}
onClipEvent (enterFrame) {
this._y += 16;
}

canada92
canada92
  • Member since: Apr. 11, 2008
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to double jump? 2009-02-24 02:27:15 Reply

oh! and my double jump animation is in frame 4
thanks!!

Deadclever23
Deadclever23
  • Member since: Nov. 27, 2006
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to double jump? 2009-02-24 02:51:55 Reply

Just do it so that if he's at a certain height compared to his original position he can jump again.


"To live is the rarest thing in the world. Most people exist, that is all."
- Oscar Wilde

BBS Signature
canada92
canada92
  • Member since: Apr. 11, 2008
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to double jump? 2009-02-24 03:03:07 Reply

thats easier said than done, im no expert proggramer, sure i might be able to fix up a bit of an error in actionscripting but i dont know how to translate english to flash code -__-"
do yu know along the lines of what code i should be using??
=S

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to double jump? 2009-02-24 04:56:04 Reply

Something like this, but it'll probably need adapting in places

onClipEvent(load){
	moveSpeed=15;
}

onClipEvent(enterFrame){
	this._y+=16;
	if(Key.isDown(Key.UP)){
		if(!jumping){
			player.gotoAndPlay(3);
			vel_y=45;
			jumping=1;
		}
		if(!doublejumping && jumping && _y<_root.ground._y-100){
			player.gotoAndPlay(4);
			vel_y=45;
			doublejumping=1;
		}
	}
	if(jumping || doublejumping){
		vel_y -= 2;
		if(vel_y<=-15){vel_y=-15;}
		this._y-=vel_y;
	}
	while(_root.ground.hitTest(_x,_y,true)){
		vel_y=0;_y--;jumping=doublejumping=0;
	}
	while(_root.ground.hitTest(_x+15,_y-10,true)){
		_x--
	}
	while(_root.ground.hitTest(_x-15,_y-10,true)){
		_x++
	}
	while(_root.ground.hitTest(_x,_y-80,true)){
		_y++
	}
}

- - Flash - Music - Images - -

BBS Signature