Some Nice movement

heya, im creating a new project

a game thats something like this:
http://www.armorgames.com/games/armorheroes_popup.html

but i need a nice movement for jumping and stuff

the left and right is easy

i made a little script but can someone make it with jumping?

 
onClipEvent(load){
walkspeed = 0;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)) {
_x -= _root.walkspeed
_root.hero.gotoAndPlay("walkleft");
}
if (Key.isDown(Key.LEFT)) {
 _x += _root.walkspeed
_root.hero.gotoAndPlay("walkright");
 }
}

thats it :slight_smile:

thnx ^^

Why dont you try Nathan’s platform tutorial here.


onClipEvent (load) {
	walkspeed = 0;
	jump = 6;
	grav = 0;
	jumpin = false;
	fall = true;
}
onClipEvent (enterFrame) {
	trace(jump);
	if (jumpin) {
		jump += 2;
		_y -= jump;
		if (jump>=16) {
			jumpin = false;
		}
	}
	if (!this.hitTest(_root.ground) && !jumpin) {
		fall = true;
		grav++;
	}
	if (fall) {
		_y += grav;
	}
	if (this.hitTest(_root.ground)) {
		fall = false;
		grav = 0;
		jump = 0;
		jumpin = false;
	}
	if (Key.isDown(Key.LEFT)) {
		_x -= walkspeed;
		_root.hero.gotoAndPlay("walkleft");
	}
	if (Key.isDown(Key.LEFT)) {
		_x += walkspeed;
		_root.hero.gotoAndPlay("walkright");
	}
	if (Key.isDown(Key.UP)) {
		if (!fall && !jumpin) {
			jumpin = true;
			fall = false;
		}
	}
}

Maybe something like that?

ai thnx :smiley:

it works :D:D:D:D ■■■■ ur a genious joppe

(as always) :stuck_out_tongue: ur always here to help me :stuck_out_tongue: thnx man

if there’s anything i can do for u just ask :stuck_out_tongue:

:stuck_out_tongue: i love it people give simple codes and there genious lol

hehe yeah I noticed that… BUT… I let them have a shot at glory… But you know I may just be a good person…

hehe im going to start giving all codes away that people ask for and maybe i could get some recognition =(

why wouldnt you help people?

sorry jop…:cantlook:
here is my version, it’s just very simple and will need tweaking… but useable:
the game runs off this code

var moveHorizontalSpeed:Number = 1;
var moveVerticalSpeed:Number = 1;
var space:Number = 5;
var launchInit:Number = -10;
var mapScrollDist:Number = 100;
k.onEnterFrame = function() {
    Key.isDown(Key.SPACE) && !jumping ? (yLaunch=this._y, jumping=jumpSpeed=launchInit) : this._y>=yLaunch && jumpSpeed>0 ? (this._y=yLaunch, jumpSpeed=launchInit, jumping=false) : jumping ? (this._y += jumpSpeed++, this.gotoAndStop("jump")) : null;
    this._y -= yspeed=moveVerticalSpeed*(Key.isDown(Key.UP)-Key.isDown(Key.DOWN));
    Key.isDown(Key.LEFT) && this._x<0+mapScrollDist && g.getBounds(_root).xMin<0+moveHorizontalSpeed ? g._x += moveHorizontalSpeed : Key.isDown(Key.RIGHT) && this._x>Stage.width-mapScrollDist && g.getBounds(_root).xMax>Stage.width-moveHorizontalSpeed ? g._x -= moveHorizontalSpeed : this._x -= speed=moveHorizontalSpeed*(Key.isDown(Key.LEFT)-Key.isDown(Key.RIGHT));
    speed != 0 ? ((this._xscale=speed<0 ? 100 : -100), (!jumping ? this.gotoAndStop("walk") : null)) : yspeed ? (!jumping ? this.gotoAndStop("walk") : null) : (!jumping ? this.gotoAndStop("idle") : null);
    while (this._y<g._y && !g.h.hitTest(this._x, this._y, true) && !jumping) {
        this._y++;
    }
    while (this._y>g._y && !g.h.hitTest(this._x, this._y, true) && !jumping) {
        this._y--;
    }
    while (!g.h.hitTest(this._x-space, this._y, true) && !jumping) {
        this._x++;
    }
    while (!g.h.hitTest(this._x+space, this._y, true) && !jumping) {
        this._x--;
    }
};

tjat’s pretty complicated for beginners, nathan:)
nice one joppe:) simple and effective

hehe, yeah I thought that… but its simple to me… I guess i forgot how hard it is to grasp as

thnx nathan :slight_smile:

ok i’ll tell u it 2 then :stuck_out_tongue: Nathan ur a genious too man!!! thnx :smiley: :p:p:p

Actually Nathans the only genious of us too. I learnt how to do the jumping while reading his tutorial. Had no idea before :wink: