PDA

View Full Version : Vertical Movement Platformer


scarce
10-03-2009, 04:11 PM
ok, I'm moving my screen vertiaclly...i have it to very a variabhle is made based on the this.vy movement (*characters jumping variable*) this is a problem because if im not jumping, it's not moving...this is my code


if (stage1._y >= 454.5) {
if (theDrop == false) {
this._y = Stage.height / 2;
yMove = Math.round(this.vy - 1);

_root.platform2._y -= yMove;
_root.platform1._y -= yMove;
stage1._y -= yMove;

}
}
if (this._y <= Stage.height / 2) {
theDrop = false;
yMove = Math.round(this.vy - 1);
_root.platform2._y -= yMove;
_root.platform1._y -= yMove;
stage1._y -= yMove;

if (stage1._y > 454.3) {

this._y = Stage.height / 2;
} else if (stage1._y <= 454.3) {
theDrop = true;
this._y += this.vy;
yMove = 0;
}

}


platform1 is the ground, platform 2 is every other platform...here's my collisions just incase you need to see that too...


function heroCollisions(ob) {
if (ob.hitTest(stopper_scroll)) {
ob.vx = 0;
}

if (ob.vy >= 0.5) {
if (_root.platform1.hitTest(ob._x, ob._y, true)) {
eraserOn = 1;
if (jumper == 0) {
kickStop = false;
bok = false;
ob.vy = 0;
ob._y -= g * 3;
ob.jumping = false;
_global.jumpAttack = false;
falling = false;
}
}
while (_root.platform2.hitTest(ob._x, ob._y, true)) {
eraserOn = 2;

if (jumper == 1) {
jumper = 0;
}
if (jumper == 0) {
kickStop = false;
bok = false;
ob.vy = 0;
ob._y -= g * 3;
ob.jumping = false;
_global.jumpAttack = false;
falling = false;
}
}
}
}


I'm getting confused and frustrated please help me. Any questions just ask HELP PLEASE

rrh
10-03-2009, 05:18 PM
Man, I'm getting confused reading that. Let me see if I have this straight.

stage1._y -= yMove;// this is supposed to move your screen

yMove = Math.round(this.vy - 1);// and this sets the speed that the screen moves

ob.vy // so this is the vertical velocity of your character


if im not jumping, it's not moving That does sound like an accurate description of what that code would do, but I have no idea what you would like it to do. Under what conditions do you want it to move, and in what fashion?

scarce
10-03-2009, 11:24 PM
Well if I'm not jumping, I want the stage to still move, like walking up an incline. But if I fall of a platform, not jumping I'm trying to get the screen to move back up.

You see, I have the screen movement based on the jumping of the character so it's a fluid screen move instead of a stiff constant speed. I wanna try to get it figured out to where I fall off or walk off a platform it'll still move appropriately. I'm sure the code I have can even be condensed down.

I have a bit of coding that detecxts if your jumping or falling. if the variable for the jump is less then 0 (negative) the status reads rise, if the variable is above 0 (positive) it reads falling, but only if your not on a platform.

I haven't really used tutorials or anything, kinda just figuring out as I go, but this has had me stumped for to long.



Man, I'm getting confused reading that. Let me see if I have this straight.

stage1._y -= yMove;// this is supposed to move your screen

yMove = Math.round(this.vy - 1);// and this sets the speed that the screen moves

ob.vy // so this is the vertical velocity of your character


That does sound like an accurate description of what that code would do, but I have no idea what you would like it to do. Under what conditions do you want it to move, and in what fashion?

rrh
10-05-2009, 09:03 PM
So are you trying to give the screen its own velocity or something?

Like, the general approach I'd take is something like this:
if the character's absolute y position is less than a minimum value
move screen down the difference between that y position and the minimum

if the character's absolute y position is more than a maximum value
move screen up the difference between that y position and the maximum