Me and my friend came up with an idea for a game earlier and started working on it in Flash 8. Not being very Actionscript-savvy, I looked up a tutorial for the basis of the programming since gameplay isn’t really a factor. The tutorial is right here: http://www.kirupa.com/developer/mx2004/platform_game.htm
I implemented the provided actionscript on my prototype in an attempt to make the character move around like I need him to. I tried to implement jumping along with the tutorial, but it did not work. I tried to put the code all together like the tutorial showed me, but the character only falls through the ground even when I implement hitTest events like it says. This is the code I put together out of what it gave me:
onClipEvent (load) {
jumping = true;
speed = 0;
maxmove = 15;
jump = 0;
}
onClipEvent (enterFrame) {
if (_root.dead) {
this.gotoAndStop(“dead”);
} else {
speed *= .85;
if (speed>0) {
dir = “right”;
} else if (speed<0) {
dir = “left”;
}
if (dir == “right”) {
this._x += speed;
_root._x -= speed;
}
if (dir == “left”) {
this._x += speed;
_root._x -= speed;
}
if (Key.isDown(Key.LEFT)) {
if (speed>-maxmove) {
speed–;
}
this.gotoAndStop(“run”);
this._xscale = -100;
} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
}
this._xscale = 100;
this.gotoAndStop(“run”);
} else if (speed<1 && speed>-1 && !attacking) {
speed = 0;
this.gotoAndStop(“idle”);
}
if (Key.isDown(Key.UP) && !jumping) {
jumping = true;
}
if (jumping) {
this.gotoAndStop(“jump”);
this._y -= jump;
jump -= .5;
if (jump<0) {
falling = true;
}
if (jump<-15) {
jump = -15;
}
}
if (speed<1 && speed>-1 && !attacking) {
speed = 0;
this.gotoAndStop(“idle”);
}
}
if (_root.ground.hitTest(this._x, this._y, true) && falling) {
jump = 12;
jumping = false;
falling = false;
}
}
I really need some help getting this to work. My buddy who helped me come up with the game is going into surgery on Sunday and he really wants to see it before then.