PDA

View Full Version : platform shooting



Mr.Pancake
September 10th, 2005, 08:09 AM
long time ago that i have been making games and i wanted to make a platformer again ....

the problem is that i dont know how to shoot
like if u press space it shoots
can someone help me on this?


this is the guy code:


onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 6;
maxjump = 6;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.SPACE) && jump == true) {
_y -= jumpSpeed;
}
if (air == false) {
jump = true;
jumpcount = 0;
jumpSpeed = 22;
}
if (Key.isDown(Key.SPACE)) {
jumpcount += 1;
}
if (jumpcount> maxjump && jumpSpeed> -2) {
jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe <4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe <4) {
state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe <4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe <4) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}



thnx in advance mr.pancake

Mr.Pancake
November 7th, 2005, 02:27 PM
no reply's can anyone help me on this please?

nathan99
November 7th, 2005, 02:44 PM
havent looked at the shooting yet, but maybe you could look at my FMX04 platforn tut.

also. you can clean ur code up a little bit by this;(tell me if it doesnt work)


onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 6;
maxjump = 6;
}
onClipEvent (enterFrame) {
if (air == true) {
_y += gravity;
state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
_x -= walkSpeed;
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
_x += walkSpeed;
_xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
air = false;
} else {
air = true;
}
if (Key.isDown(Key.SPACE) && jump) {
_y -= jumpSpeed;
}
if (!air) {
jump = true;
jumpcount = 0;
jumpSpeed = 22;
}
if (Key.isDown(Key.SPACE)) {
jumpcount++;
}
if (jumpcount>maxjump && jumpSpeed>-2) {
jumpSpeed -= 2;
}
if (!air && !Key.isDown(Key.LEFT) && !Key.isDown(65) && (_currentframe<4 || _currentframe<4)) {
state = 1;
}
if (Key.isDown(Key.LEFT) && !air && !Key.isDown(65) && _currentframe<4 or Key.isDown(Key.RIGHT) && !air && !Key.isDown(65) && _currentframe<4) {
state = 2;
}
if (!Key.isDown(65)) {
gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}