PDA

View Full Version : vertical shooter help


spork_man22
12-24-2004, 01:32 PM
does anybody know where i could get tutorials to make a vertical shooter type game (kind of like invaders) except where the enemies arent in a block and come at certain patterns and you get money for killing the enemies which you use to purchase upgrades? i know how to do most of the stuff but as far as things like creating enemy wave patterns, having the lasers (or whatever weapons are used) show up and create damage and stuff im lost

thanks

denacioust
12-24-2004, 04:01 PM
try flashkit.com

spork_man22
12-24-2004, 04:37 PM
they have first person shooter stuff there but i didnt see anything about a vertical scrolling shooter

unicycler
12-24-2004, 09:32 PM
To get most of the code that you will need you just need to piece stuff together. Find little parts of code that do part of what you need and piece the together. I just started working on flash again and that is what I do.

spork_man22
12-27-2004, 10:29 PM
ok so i found a tutorial on flashkit for a horizontal shooter so im gonna try and integrate that...now heres the problem...with the code they have it allows rapid fire shooting, i dont want that. i just want it so you press the fire button and it shoots once (until you get better weapons that have rapid fire) so heres the code, and a link to the tutorial i used

http://www.flashkit.com/tutorials/Games/Building-David_Do-598/index.php



this is just a testing code so the instance names will be a bit weird

spaceship(ball)
onClipEvent (load) {
speed = 15;
_root.laser._visible = false;
laserCounter = 1;
// so you change the speed for all directions in one step
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL)) {
laserCounter++;
_root.laser.duplicateMovieClip("laser"+laserCounter, laserCounter);
_root["laser"+laserCounter]._visible = true;
}
if (Key.isDown(Key.LEFT) && (!_root.leftwall.hitTest(_x-speed, _y, true)) && (!_root.rightwall.hitTest(_x-speed, _y, true)) && (!_root.up.hitTest(_x-speed, _y, true)) && (!_root.bottom.hitTest(_x-speed, _y, true))) {
_x -= speed;
}
if (Key.isDown(Key.RIGHT) && (!_root.leftwall.hitTest(_x+speed, _y, true)) && (!_root.rightwall.hitTest(_x+speed, _y, true)) && (!_root.up.hitTest(_x+speed, _y, true)) && (!_root.bottom.hitTest(_x+speed, _y, true))) {
_x += speed;
}
if (Key.isDown(Key.UP) && (!_root.leftwall.hitTest(_x, _y-speed, true)) && (!_root.rightwall.hitTest(_x, _y-speed, true)) && (!_root.up.hitTest(_x, _y-speed, true)) && (!_root.bottom.hitTest(_x, _y-speed, true))) {
_y -= speed;
}
if (Key.isDown(Key.DOWN) && (!_root.leftwall.hitTest(_x, _y+speed, true)) && (!_root.rightwall.hitTest(_x, _y+speed, true)) && (!_root.up.hitTest(_x, _y+speed, true)) && (!_root.bottom.hitTest(_x, _y+speed, true))) {
_y += speed;
}
}



laser
onClipEvent (load) {
laserMoveSpeed = 20;
this._y = _root.ball._y-10;
this._x = _root.ball._x;
}
onClipEvent (enterFrame) {
this._y -= laserMoveSpeed;
if (this._y>600) {
this.removeMovieClip();
}
}
[/code]

Bodadem
12-27-2004, 11:33 PM
I'm sure you could get the desired effect fairly easily with variables, however I'm too tired to write up the code right now. Maybe tomorrow.

spork_man22
12-28-2004, 02:57 AM
i tried changing the command on the fire button to this

if (Key.isDown(Key.CONTROL) && laserCounter<2) {
laserCounter++;
_root.laser.duplicateMovieClip("laser"+laserCounter, laserCounter);
_root["laser"+laserCounter]._visible = true;
}


which now it fires one at a time...but only fires once...then it just does nothing. i tried adding a

if (!Key.isDown(Key.CONTROL) {
laserCounter = 1;
}

into the script which worked except if you press the control button rapidly it just resets the laser over and over again so it never actually finishes a cycle

Bodadem
12-28-2004, 10:23 AM
Make something using variables so that it can't fire if a certain variable is set to 1, and have that variable set to 1 when it fires. Now add into the code for when it sends it takes it away that it sets the variable back. This way, it won't reset by pressing rapidly, and you'll be able to fire after the laser goes offscreen. If you don't understand when I'm saying, tell me so, and I guess I can plop it right in the code for you...

spork_man22
12-28-2004, 10:54 AM
i got it but i didnt add anything onto the beam's code, i tried putting it after the if this.y>600 part but i had the same problem of it firing once then not doing anything so here's what i changed and it works

there's a variable on clipevent (load) that says fired = 0

if (Key.isDown(Key.CONTROL) && fired == 0) {
fired = 1;
lasercontrol.gotoAndPlay(2);
laserCounter++;
_root.laser.duplicateMovieClip("laser"+laserCounter, laserCounter);
_root["laser"+laserCounter]._visible = true;
}
if (!Key.isDown(Key.CONTROL) && fired == 1) {
fired = 0;
}


so that makes them have to press the control button, now i need to figure out a way to regulate how quickly each beam can be fired. meaning i dont want it to be the faster you press the button the more you can fire. i tried adding something under the control key press like

lasercontrol.gotoAndPlay(2) which would send a movie clip with instance name lasercontrol to frame 2 where it would play through 8-9 frames and then theres a script to change fired to 0 and i got rid of the if (!key.isdown) part that normally sets it back to 0 but it didnt work

any suggestions?

Bodadem
12-28-2004, 11:22 AM
Â# Â# if (Key.isDown(Key.CONTROL) && fired == 0) {
Â# Â# Â# Â# fired = 1;
Â# Â# Â# Â# lasercontrol.gotoAndPlay(2);
Â# Â# Â# Â# laserCounter++;
Â# Â# Â# Â# _root.laser.duplicateMovieClip("laser"+laserCounter, laserCounter);
Â# Â# Â# Â# _root["laser"+laserCounter]._visible = true;
Â# Â# }


Is right, but the other part you put is illogical. You need to do what you tried before in the laser, that should work.

onClipEvent (load) {
Â# Â# laserMoveSpeed = 20;
Â# Â# this._y = _root.ball._y-10;
Â# Â# this._x = _root.ball._x;
}
onClipEvent (enterFrame) {
Â# Â# this._y -= laserMoveSpeed;
Â# Â# if (this._y>600) {
Â# Â# Â# Â# _root.SHIP.fired = 0;
Â# Â# Â# Â# this.removeMovieClip();
Â# Â# }
}


Replace SHIP with the instance name of your thing that shoots, and that's the code that should be in your laser.

spork_man22
12-28-2004, 01:28 PM
yes it is very illogical but its the only thing i can get to work....i tried what you suggested and it doesnt work. ill look around for some other tutorials on firing