ForumsProgramming Forumplatform game help

16 8388
rino
offline
rino
27 posts
Nomad

I am making a platform game in AS2 for school and everything works, but the rotation of the character to the ground. The problem is, is that the character hits the symbol box and not the image inside it.So does anyone know how to make it hit the image and not the symbol box around it

Here is the code:

onClipEvent (load) {
speed = 4;
jump = 0;
jumpheight = 9;
gravity = 0.5;
scale = _xscale;
wid = _width/2;
heig = _height/2;

}
onClipEvent (enterFrame) {
_y -= jump;
jump -= gravity;
if (Key.isDown(Key.LEFT)) {
_x -= speed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
_xscale = +scale;
}
while (_root.ground.hitTest(_x, _y+heig, true)) {
_y--;
jump = -5;
inair = false;
if (inair == false && Key.isDown(Key.UP)) {
jump = jumpheight;
inair = true;
}
}
while (_root.ground.hitTest(_x, _y-heig, true)) {
jump = -jump;
_y++;
}
while (_root.ground.hitTest(_x+wid, _y, true)) {
_x--;
}
while (_root.ground.hitTest(_x-wid, _y, true)) {
_x++;
}
}
onClipEvent (enterframe) {
if (_root.ground.hitTest(_root.player[&quotoint"])){
_root.player._rotation -= 1;
trace("hit"
}else{
_root.player._rotation +=1;
trace("not"
}
}

  • 16 Replies
rino
offline
rino
27 posts
Nomad

found this in a website and made so changes

onClipEvent (load) {
var dir = 1;
var jmp:Boolean = false
var grav:Number = 0;
var speed:Number = 5;
var jumpHeight:Number = 12;
var setspeed:Number = speed;
var scale:Number = _xscale;
var ex:Number = 5;
this.gotoAndStop(2);
}
onClipEvent (enterFrame) {
grav++;
_y += grav;
function updateslopedot ()
{
_root.slopedot._y += grav;
while (_root.ground.hitTest (_root.slopedot._x, _root.slopedot._y, true))
{
_root.slopedot._y--;
}
}

while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
jmp = false
}
if (Key.isDown(68))
{
_x += speed;
_xscale = scale;
this.dir = 1;
}
else if (Key.isDown(65))
{
_x -= speed;
_xscale = -scale;
this.dir = -1;
}
if (Key.isDown(87) && _root.ground.hitTest(_x, _y+3, true))
{
grav = -jumpHeight;
_y -= 4;
jmp = true;
}


_root.slopedot._x = this._x + (20 * this.dir);
_root.slopedot._y = this._y;
updateslopedot ();
rot1 = Math.atan2 (_root.slopedot._y - this._y, _root.slopedot._x - this._x);
this._rotation = rot1 * 180 / Math.PI;
deg = rot1 * 180 / Math.PI;
if (this.dir == -1)
{
this._rotation += 180;
}
if (jmp= true && deg>90)
{
this._rotation * .001
}
this._xscale = this.dir * Math.abs (this._xscale);
updateslopedot ();
}

Showing 16-16 of 16