Avoider Game — Part 12

18 comments

{ 14 comments… read them below or add one }

chris May 31, 2009 at 3:24 pm

Hi,

Thanks for the great tutorials, I have found a slight problem with your finished game. I am not sure if your aware that, you can just position your avatar off the screen and none of the enemies can attack you.

thanks

Michael Williams June 1, 2009 at 4:16 pm

Cheers Chris!

Yep, it’s true. I didn’t notice that at first, but I left it in because I think it’s a good challenge to work out how to fix it yourself :)

Shyne December 8, 2010 at 12:32 pm

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at AvoiderGame()
    at DocumentClass/onRequestStart()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at MenuScreen/onClickStart()

Whenever i try to click that above and also when i download the source files it gives me that error… any idea on how to fix this?

AbdulHadi Hallak January 1, 2011 at 8:58 am

My score is 1880 :D

Sue Swan January 19, 2011 at 9:50 pm

Score: 1950. Seconds: 45. :D

abdulhadi hallak January 27, 2011 at 7:44 pm

you r a lier cuz the top score is 1880 :D
sorry but it looks like i win ;D

JOhkonut February 25, 2011 at 4:06 am

@abdulhadi
The high score is stored on your own computer, so no one else’s scores will show up.

Mike Tyson March 10, 2011 at 3:45 pm

1980 lol, looks like I’m winning.. Although I seriously doubt that :P

lach mcpher May 6, 2011 at 12:32 am

weow 1650 mike tyson ur looking the good and munners u smell

Yebi August 31, 2011 at 8:44 pm

HI, pretty good game but how can I make it to move on diagonal? D:

Cazbot Commander September 5, 2011 at 8:00 pm

To make it move diagonal you have to make left,right,up, and down boolean fucntions.

Here is some pseudo code for an Idea:
var left:Boolean = false;
var right:Boolean = false;
var up:Boolean = false;
var down:Boolean = false;
var speed:Number = 5;

player.addEventListener(KeyboardEvent.KEY_DOWN, keyTrue);
player.addEventListener(KeyboardEvent.KEY_UP, keyFalse);
stage.addEventListener(Event.ENTER_FRAME, boolListen);

function keyTrue(event:KeyboardEvent)
{
if(charCode == 37) //or keyCode I forget which one works the best
{
left = true;
}
//do this for all charCodes 37 – 40 left-37 up-38 right-39 down-40
//Play around with else if’s and if’s to play around with the logic so you can understand it better
}

function keyFalse(event:KeyboardEvent)
{
if(charCode == 37)
{
left = false;
}
//again for all of them.
}

function boolListen(event:Event)
{
if(left == true)
{
player.x += speed
}
//for all charCodes.
// this one I believe should ALL be if’s, no else if’s or else only one at a time will work.
}

Traian December 27, 2011 at 11:42 pm

hehe i’m the best! did 2190! :D
Nice tutorial!
Gj!

iinsanity February 8, 2012 at 3:05 am

mine? 100000! oh yeah

Paul May 1, 2012 at 7:09 pm
  1. Life is good.

Cheers, Michael! Thanks for your tutorials!

Leave a Comment

Writing code? Write <pre> at the start and </pre> at the end to keep it looking neat.

Anti-Spam Protection by WP-SpamFree

{ 4 trackbacks }