Im working on a fighting game and this is the script im using, but i feel like its very sloppy and i am starting to have problems adding new things. Below is the script, i was wondering how to duplicate “blood_mc” on a hittest so that the mc appears at the same spot the hittest happened. Also im having trouble with functions, i was trying to have a combonation and make the fireball= true, Im sry if that sounds confusing lol. Also heres the swf of the game im trying to make. http://img292.imageshack.us/my.php?image=sindelgame3dj6.swf W=Up A=Left S=Down D=Right Attack= Click Mouse
MonstersInScene = new Array();
tag = 1000;
function Initialize() {
sindel_mc.step = 15;
sindel_mc.attack = false;
sindel_mc.fireball = false;
sindel_mc.stance = 1;
sindel_mc.crouch = false;
keydown = false;
sindel_mc.uvel = 40;
sindel_mc.gravity = 8;
sindel_mc.jump = false;
}
function Jump() {
if (Key.isDown(65)) {
sindel_mc.stance = 0;
sindel_mc._x -= sindel_mc.step;
} else if (Key.isDown(68)) {
sindel_mc.stance = 1;
sindel_mc._x += sindel_mc.step;
}
if (!sindel_mc.attack) {
if (Key.isDown(83)) {
sindel_mc.gotoAndStop("crouch");
sindel_mc.crouch = true;
} else if (!Key.isDown()) {
sindel_mc.gotoAndStop("jump");
sindel_mc.crouch = false;
}
}
sindel_mc.onMouseDown = function() {
sindel_mc.attack = true;
};
sindel_mc._y -= sindel_mc.uvel;
sindel_mc.uvel -= sindel_mc.gravity;
if (sindel_mc._y+20>ground_mc._y+65) {
sindel_mc.jump = false;
sindel_mc._y = ground_mc._y+65;
sindel_mc.uvel = 40;
}
}
function Movement() {
if (Key.isDown(68)) {
sindel_mc.stance = 1;
sindel_mc._x += sindel_mc.step;
sindel_mc.gotoAndStop("walk");
} else if (Key.isDown(65)) {
sindel_mc.stance = 0;
sindel_mc._x -= sindel_mc.step;
sindel_mc.gotoAndStop("walk");
} else if (Key.isDown(83)) {
sindel_mc.gotoAndStop("crouch");
sindel_mc.crouch = true;
} else if (!Key.isDown()) {
sindel_mc.gotoAndStop("stance");
sindel_mc.crouch = false;
}
if (Key.isDown(87)) {
sindel_mc.gotoAndStop("jump");
sindel_mc.jump = true;
}
sindel_mc.onMouseDown = function() {
sindel_mc.attack = true;
};
}
function fireball() {
if (Key.isDown(90)) {
sindel_mc.gotoAndStop("fireball");
} else if (Key.isDown(90)) {
sindel_mc.gotoAndStop("fireball");
}
}
function Attack() {
if (sindel_mc.jump) {
sindel_mc.gotoAndStop("airkick");
} else {
if (Key.isDown(83)) {
sindel_mc.gotoAndStop("crouchkick");
} else {
sindel_mc.gotoAndStop("punch");
}
}
}
SpawnEnemy = function () {
attachedObj = _root.attachMovie("zombie", "brownzombie"+tag, tag, {_x:615, _y:164});
attachedObj.health = 100;
attachedObj.speed = 5;
attachedObj.hit = false;
attachedObj.alive = true;
attachedObj.gotoFunction = AIZombie;
MonstersInScene.push(attachedObj);
//MonstersInScene
tag++;
};
function AIZombie() {
if (this.alive) {
this.gotoAndStop("walk");
if (sindel_mc._x<=this._x-20) {
this._xscale = 100;
this._x -= this.speed;
} else if (sindel_mc._x>=this._x+20) {
this._x += this.speed;
this._xscale = -100;
}
} else {
this.gotoAndStop("dead");
}
}
function RenderEnemy() {
for (counter=0; counter<MonstersInScene.length; counter++) {
MonstersInScene[counter].gotoFunction();
if (sindel_mc.attack) {
if (sindel_mc.hitTest(MonstersInScene[counter])) {
MonstersInScene[counter].alive = false;
}
}
if (MonstersInScene[counter]._x == null) {
MonstersInScene.splice(counter, 1);
SpawnEnemy();
}
}
}
SpawnEnemy();
Initialize();
sindel_mc.swapDepths(60000);
onEnterFrame = function () {
RenderEnemy();
if (!sindel_mc.attack && !sindel_mc.jump) {
Movement();
}
if (sindel_mc.jump) {
Jump();
}
if (sindel_mc.attack) {
Attack();
}
if (Key.isDown(Key.CONTROL)) {
keydown = true;
} else {
keydown = false;
}
if (sindel_mc.stance == 0) {
sindel_mc._xscale = -100;
} else {
sindel_mc._xscale = 100;
}
};
Key.addListener(_root);
_global.keyCombo = new Array();
_root.onKeyDown = function() {
newKey = Key.getCode();
addToCombo(newKey);
};
function addToCombo(k) {
if (_global.keyCombo.length>=3) {
_global.keyCombo.reverse().pop();
_global.keyCombo.reverse();
}
_global.keyCombo.push(k);
clearInterval(_global.interval);
_global.interval = setInterval(clearArray, 1000);
_root.keysTxt.text = "";
for (var i = 0; i<_global.keyCombo.length; i++) {
_root.keysTxt.text += " "+_global.keyCombo*;
}
checkForCoolMoves();
}
function clearArray() {
while (_global.keyCombo.length>0) {
_global.keyCombo.pop();
}
}
function checkForCoolMoves() {
_root.comboTxt.text = "";
var c = _global.keyCombo;
if (c[0] == 37 && c[1] == 39 && c[2] == 65) {
_root.comboTxt._alpha = 100;a
_root.comboTxt.text = "Chuck Norris round house kick!";
} else if (c[0] == 90 && c[1] == 90 && c[2] == 90) {
sindel_mc.attacks = true;
}
}