parasitic
09-18-2009, 05:55 PM
Hey,
I'm new to flash but I decided to make a platform game for my ICT media project. I'm quite pleased with it so far (got working pickups, score, hp bar, platforms) as I've been following youtube and other online tutorials but now I am stucks after 2 days of trying to edit my character code so that it would kill the enemy but nothing works so I'm back to point 0. :mad:
I want my character to be a bit like mario, if it hits the enemy the hp bar will go down, until he dies. This is where I am now.
But I need the character to be able to jump on the enemy and kill him, but only when jump option is used not walking...- Makes sense? : )
Even throwing fire balls to the enemy is better than not being able to kill them at all, but I can't make this happen too :[
I want to keep my existing character actionscript as it works on my ground as well... however it is very confusing...
here's the code:
onClipEvent (load) {
grav = 2;
speed = 8;
jumpHeight = 15;
setspeed = speed;
ex = 5;
}
onClipEvent (enterFrame) {
action = true;
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
if (Key.isDown(39)) {
_x += speed;
if (_root.ground.hitTest(_x, _y+3, true)) {
} else {
}
} else if (Key.isDown(37)) {
_x -= speed;
if (_root.ground.hitTest(_x, _y+3, true)) {
} else {
}
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79) && !Key.isDown(73)) {
}
}
if (Key.isDown(79) && !Key.isDown(32) && !Key.isDown(37) && !Key.isDown(39) && !Key.isDown(73)) {
}
if (Key.isDown(73) && !Key.isDown(32) && !Key.isDown(37) && !Key.isDown(39) && !Key.isDown(79)) {
}
if (Key.isDown(32) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
}
if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
}
if someone could help me out how to make my character kill enemies I would be very happy and I would give you credit at the end of course.
Any solutions at all, even a new actionscript to go in the character panel that makes everything work... I am really desperate at this stage : {
I'm new to flash but I decided to make a platform game for my ICT media project. I'm quite pleased with it so far (got working pickups, score, hp bar, platforms) as I've been following youtube and other online tutorials but now I am stucks after 2 days of trying to edit my character code so that it would kill the enemy but nothing works so I'm back to point 0. :mad:
I want my character to be a bit like mario, if it hits the enemy the hp bar will go down, until he dies. This is where I am now.
But I need the character to be able to jump on the enemy and kill him, but only when jump option is used not walking...- Makes sense? : )
Even throwing fire balls to the enemy is better than not being able to kill them at all, but I can't make this happen too :[
I want to keep my existing character actionscript as it works on my ground as well... however it is very confusing...
here's the code:
onClipEvent (load) {
grav = 2;
speed = 8;
jumpHeight = 15;
setspeed = speed;
ex = 5;
}
onClipEvent (enterFrame) {
action = true;
grav++;
_y += grav;
while (_root.ground.hitTest(_x, _y, true)) {
_y--;
grav = 0;
}
if (Key.isDown(39)) {
_x += speed;
if (_root.ground.hitTest(_x, _y+3, true)) {
} else {
}
} else if (Key.isDown(37)) {
_x -= speed;
if (_root.ground.hitTest(_x, _y+3, true)) {
} else {
}
} else {
if (_root.ground.hitTest(_x, _y+3, true) && !Key.isDown(79) && !Key.isDown(73)) {
}
}
if (Key.isDown(79) && !Key.isDown(32) && !Key.isDown(37) && !Key.isDown(39) && !Key.isDown(73)) {
}
if (Key.isDown(73) && !Key.isDown(32) && !Key.isDown(37) && !Key.isDown(39) && !Key.isDown(79)) {
}
if (Key.isDown(32) && _root.ground.hitTest(_x, _y+3, true)) {
grav = -jumpHeight;
_y -= 4;
}
if (_root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/2), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-(_height/6), true) || _root.ground.hitTest(_x+(_width/2)+ex, _y-_height, true)) {
_x -= speed;
}
if (_root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/2), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-(_height/6), true) || _root.ground.hitTest(_x-(_width/2)-ex, _y-_height, true)) {
_x += speed;
}
if (_root.ground.hitTest(_x, _y-_height-15, true)) {
grav = 1;
}
}
if someone could help me out how to make my character kill enemies I would be very happy and I would give you credit at the end of course.
Any solutions at all, even a new actionscript to go in the character panel that makes everything work... I am really desperate at this stage : {