A Flash Developer Resource Site

Results 1 to 19 of 19

Thread: [Beta] New game - Virus

  1. #1
    Member
    Join Date
    Nov 2005
    Posts
    32

    [Beta] New game - Virus

    Hi,

    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.

    Virus

    All comments wlecome!

    Thanks,
    -Ean

  2. #2
    Member
    Join Date
    Nov 2006
    Posts
    93
    When the right counter got to 50 it stopped going down.

    Nice though

  3. #3
    Member
    Join Date
    Nov 2005
    Posts
    32
    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.

  4. #4
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    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

    RipX

  5. #5
    Procrastinator
    Join Date
    Oct 2000
    Posts
    26
    Nice background sound. The Main Menu button is not working proper tho.

  6. #6
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    add a preloader or the play button wont work for a wile

  7. #7
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    nice game but make it level based or its to easy

  8. #8
    Less than epic
    Join Date
    Oct 2001
    Posts
    186
    The entire game seems very generic... perhaps you could beef up the graphics to make it look more tron/tech/nerdy

    Otherwise good, simple game

  9. #9
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    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

    RipX
    Attached Files Attached Files

  10. #10
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    I pretty much get over 100 clips being hit tested before any noticable slowdown using AS1..not too bad!!



    RipX

  11. #11
    Member
    Join Date
    Nov 2005
    Posts
    32
    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

  12. #12
    Member
    Join Date
    Nov 2006
    Posts
    93
    Quote Originally Posted by Eastwinn
    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.

    Then we can all see what our best score is :P

  13. #13
    Member
    Join Date
    Nov 2005
    Posts
    32
    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.

  14. #14
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    BitmapData would be very, very useful for this game. It could speed it up a lot and improve collision accuracy and speed.

    RipX, here's a major speed boost for the coding...

    Instead of SQRTing the distance here:

    distance = Math.sqrt(dx*dx+dy*dy);

    And checking for distance<=20 here:

    if (distance<=20) {

    Lose the SQRT:

    distance = dx*dx+dy*dy;

    And square the distance operand:

    if (distance<=400) {

    Same effect achieved without the overhead of a SQRT function!
    http://www.birchlabs.co.uk/
    You know you want to.

  15. #15
    Senior Member
    Join Date
    Jun 2002
    Location
    Manchester, UK
    Posts
    2,357
    Quote Originally Posted by VENGEANCE MX
    BitmapData would be very, very useful for this game. It could speed it up a lot and improve collision accuracy and speed.

    RipX, here's a major speed boost for the coding...

    Instead of SQRTing the distance here:

    distance = Math.sqrt(dx*dx+dy*dy);

    And checking for distance<=20 here:

    if (distance<=20) {

    Lose the SQRT:

    distance = dx*dx+dy*dy;

    And square the distance operand:

    if (distance<=400) {

    Same effect achieved without the overhead of a SQRT function!
    Of course...so obvious but never thought of that! doh!

    RipX

  16. #16
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    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)

  17. #17
    Zombie Coder EvilKris's Avatar
    Join Date
    Jun 2006
    Location
    Fukuoka, Japan.
    Posts
    796
    Nice gameplay but with those graphics it belongs here.
    I'll never go to school again!!

  18. #18
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    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?

  19. #19
    Member
    Join Date
    Nov 2005
    Posts
    32
    Quote Originally Posted by EvilKris
    Nice gameplay but with those graphics it belongs here.
    I'll never go to school again!!
    Rofl..

    I'll be working on the graphics more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center