[AS2] Move everything
/*
Hi, I'm trying to create a game (as always), what goes very well (also as always), but I got a problem (believe it or not, this is also like it always have been...). The problem is that I want to move everything else, instead of my character, to make it possible to explore larger maps than the screen. My code works fine - but only on the y-axis, I'm really confused! Here is the code that moves the world:
*/
onClipEvent (enterFrame) {
//Stores original coordinates
OldX1 = _x;
OldX2 = _root.hitTester._x;
OldY1 = _y;
OldY2 = _root.hitTester._y;
OldX3 = _root._x;
OldY3 = _root._y;
OldRot =_rotation;
//Handles the key input
if (Key.isDown(65)) {
this._x -= 7;
_root.hitTester._x -= 7;
_root._x += 7;
}
if (Key.isDown(68)) {
this._x += 7;
_root.hitTester._x += 7;
_root._x -= 7;
}
if (Key.isDown(87)) {
this._y -= 7;
_root.hitTester._y -= 7;
_root._y += 7;
}
if (Key.isDown(83)) {
this._y += 7;
_root._y -= 7;
_root.hitTester._y += 7;
}
//Checks if you hit a wall, if you do, reset the coordinates to the original ones
this._rotation = Math.round((Math.atan2(_root._xmouse - this._x, _root._ymouse - this._y)*-180/Math.PI)) +47;
for(var wall=1; wall <= _root.TotalWalls; wall++) {
if (_root.hitTester.hitTest("_root.Wall" + wall)) {
_x = OldX1;
_y = OldY1;
_root._x = OldX3;
_root._y = OldY3;
_root.hitTester._x = OldX2;
_root.hitTester._y = OldY2;
}
if (WeaponEnd.hitTest("_root.Wall" + wall)) {
_rotation = OldRot;
}
}
}
/*
Thanks for helping
*/
|