I've created a new game that I want you guys at flash kit to look over before I submit it to another site. It's called Virus, basicaly, you move around you virus with the arrow keys avoiing computer defenders.
The counter on the right is a measure of how dense the defenders will fall. I have it stop at 50, but I tink I'll lower it to the point where it's raining defenders.
Nice to see your starting out making flash games, even with a very simple concept, I do like these sorts of games, had a bit of a problem when going back to the main menu once I died (on purpose), tis somewhat easy! Maybe adding some sprites that make it a little more interesting, perhaps press the 'space bar' and a semi transparent area appears around your virus that 'infects' the defenders (maybe turn them red too) but forces u to get close to them to get points, like you infected it or something, thats pretty simple to add!!
Overall a good start though!!
One thing that would be good in this game is a point-to-point distance calcultor so that you don't need to use the slow hitTest() function in flash...I'm presuming that your using hitTest()...this would make adding something like the infecting idea really simple too!
Maybe i'm rambling n you like it just the way it is...whatever, keep making 'em
I quickly wrote this out for you, hope you like it, it has perfect point-to-point hitTesting using Math.sqrt() and itterates through the defenders using a loop so that its much faster than hitTest()...any questions just ask!!!
Code:
///////////////////////////////////////////////////////////////////
// set variables
///////////////////////////////////////////////////////////////////
// number of defenders
var defenderCount = 20;
// speed of defenders
var defenderSpeed = 5;
// speed of virus
var virusSpeed = 5;
// if virus has hit a defender : boolean
var fHitVirus = false;
// depth management ;)
var depth;
// distance to defender itterated through loop : getDefenderPos()
var distance;
///////////////////////////////////////////////////////////////////
// add the virus to the stage - 'virus' linkage in library
///////////////////////////////////////////////////////////////////
addVirus = function () {
tHldr = attachMovie("virus", "virus", depth++);
tHldr._x = 275;
tHldr._y = 300;
};
///////////////////////////////////////////////////////////////////
// add the defenders to the stage - 'defender' linkage in library
///////////////////////////////////////////////////////////////////
addDefenders = function () {
for (var i = 0; i<_root.defenderCount; i++) {
tHldr = attachMovie("defender", "defender_"+i, depth++);
tHldr._x = random(530)+10;
tHldr._y = random(380)-300;
tHldr.onEnterFrame = function() {
if (fHitVirus == false) {
this._y += _root.defenderSpeed;
}
if (this._y>400) {
this._y -= 410;
this._x = random(530)+10;
}
};
}
};
///////////////////////////////////////////////////////////////////
// test the positions
///////////////////////////////////////////////////////////////////
getDefenderPos = function () {
var dx;
var dy;
for (var i = 0; i<_root.defenderCount; i++) {
dx = virus._x-_root["defender_"+i]._x;
dy = virus._y-_root["defender_"+i]._y;
distance = Math.sqrt(dx*dx+dy*dy);
// set distances for hitTesting surrouning areas!!!
// use else...if(distance<=40), to add the infection
// thing I stated in the thread
if (distance<=20) {
fHitVirus = true;
trace("virus colliding with defender_"+i);
}
}
};
///////////////////////////////////////////////////////////////////
// function for controlling the virus
///////////////////////////////////////////////////////////////////
controlVirus = function () {
if (fHitVirus == false) {
if (Key.isDown(Key.LEFT)) {
virus._x -= virusSpeed;
} else if (Key.isDown(Key.RIGHT)) {
virus._x += virusSpeed;
}
if (Key.isDown(Key.UP)) {
virus._y -= virusSpeed;
} else if (Key.isDown(Key.DOWN)) {
virus._y += virusSpeed;
}
}
};
///////////////////////////////////////////////////////////////////
// onEnterFrame functions
///////////////////////////////////////////////////////////////////
onEnterFrame = function () {
getDefenderPos();
controlVirus();
};
///////////////////////////////////////////////////////////////////
// init functions
///////////////////////////////////////////////////////////////////
addVirus();
addDefenders();
I have attached an fla/swf if you prefer to just take that! Good Luck
Thanks for the comments guys! the current main menu is just a place holder, I'll be working on a more graphical one today. Along with that I'll probaly add more features like: A point system, the ability to kill defenders, and bonuses flying around the screen. And it defininatly needs to be harder.
RipX: I'll take your suggestions on the hitTests. I was thinking of doing something like that since I'm only working with circles
The counter on the right is a measure of how dense the defenders will fall. I have it stop at 50, but I tink I'll lower it to the point where it's raining defenders.
Ah I see! Well I recommend making that counter either start lower, or fall quicker to make it harder. Also I think you should let it go right down to 0 or worse to make it get extremely difficult.
OK, I updated the game to include: A point system (counter on the right, you gain 5 points from bytes and 50 from files), stealth mode (you can spend 300 points for 10 seconds of invisibilty by pressing space) and the game now becomes even more difficult over time. I still need to add a preloader, a better menu adn an instructions page.
everyone loves a beef up on the effects!!
i would suggest some simple enhanced graphics for your enemies, but you can put all sorts of things for your single player
the reson you dont want a bunchof effects for your enemies is because flash doesnt like tons of movieclips (as i am rapidly finding out, and no bitmap functions to help me out )
for even faster collision detections, put some extra if statements so to eleminate the need of testing collisions for a good number of your enemies
idea: use alpha or masking on your enemies to limit vision (unless you're worried about performance)
HitTest shape flag will work just as well wouldnt it? I mean since you dont need the point of intersection for anything else so why waist time calculating it? You just want to know if the 2 shapes hit and to stop the game?