hi there, I’m a graphic design student from Belgium and for my final assignement, I’m working on a multimedia project around Greek mythologie
I wanted to include a little game, so I started by following the tutorial here on the forum (http://www.kirupa.com/developer/mx2004/platform_game.htm), and was able to get it working, but now I’d like to make the “labyrinth” more challenging: I tried to make the screen follow the character vertically (like in this game for example: http://www.kirupa.com/forum/showthread.php?t=290115), but as I’m not so experienced with action script or any form of programming, I didn’t succeed
from what I’ve learned from the tutorial, this should have something to do with the _root._y that should move in the opposite way of the character
sadly I could make the screen go up and down whilst jumping, but it didn’t work if the character fell down by simply walking from the edge and also it made him fall through the ground from time to time, and after a while the screen has moved so far up that the character is placed at the bottom instead of somewhere in the middle
if anyone could help me out with this one, I’d be much obliged
this is a link to the (very, very unfinished) game, it’s only a test version: http://www.stijnvanelst.be/labyrinth_testversie4.html
(you can’t fight until you’ve got the sword, which is somewhere near the right)
and this is the code on my character (which I got mainly from the tutorial)
I only changed the ctrl release code because it didn’t work in the browser, so I changed it a bit, now you stop fighting when you press another button,
and then added _root._y += jump; when jumping
onClipEvent (load) {
jumping = true;
jump = 0
speed = 0;
maxmove = 15;
}
onClipEvent (enterFrame) {
if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
this._y += 6;
}
if (_root.dead) {
this.gotoAndStop(“dead”);
} else {
speed *= .85;
if (speed>0) {
dir = “right”;
} else if (speed<0) {
dir = “left”;
}
if (dir == “right” && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
this._x += speed;
_root._x -= speed;
}
if (dir == “left” && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
this._x += speed;
_root._x -= speed;
}
if (Key.isDown(Key.LEFT)) {
if (speed>-maxmove) {
speed–;
}
this.gotoAndStop(“run”);
this._xscale = -100;
attacking = false;
} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
}
this._xscale = 100;
this.gotoAndStop("run");
attacking = false;
} else if (Key.isDown(Key.CONTROL)) {
if (_root.gotsword == true) {
this.gotoAndStop("attack");
attacking = true;
speed = 0;
}
} else if (speed<1 && speed>-1 && !attacking) {
speed = 0;
this.gotoAndStop("idle");
attacking = false;
}
if (Key.isDown(Key.UP) && !jumping) {
jumping = true;
attacking = false;
}
if (jumping) {
this.gotoAndStop("jump");
this._y -= jump;
_root._y += jump;
jump -= .5;
if (jump<0) {
falling = true;
}
if (jump<-15) {
jump = -15;
}
}
if (_root.ground.hitTest(this._x, this._y, true) && falling) {
jump = 8;
jumping = false;
falling = false;
}
}
}