Be a Supporter!
Response to: Random movement on multiple tiles Posted May 12th, 2013 in Game Development

At 5/11/13 11:18 PM, kkots wrote: Why can't you just pick all tiles around the enemy and move to a random one every 5 seconds? What the hell is the freaking problem, dude!!!

Because that's what I'm having problem with? I'm not some badass coder like you are.


I have an arrangement of tiles that a player and an enemy are on.

public static var floor1:Array = new Array(7);
        floor1[0] = [0,1,1,1,1,1,0];
        floor1[1] = [1,1,1,1,1,1,1];
        floor1[2] = [1,1,1,0,1,1,1];
        floor1[3] = [1,1,0,0,0,1,1];
        floor1[4] = [1,1,1,0,1,1,1];
        floor1[5] = [1,1,1,1,1,1,1];
        floor1[6] = [0,1,1,1,1,1,0];
        public function Main()
        {

            var tilew:int = 60;
            var tileh:int = 60;

            for (var i:int=0; i<floor1.length; i++)
            {
                for (var u:int=0; u<floor1[i].length; u++)
                {
                    var cell:MovieClip = new Tile();
                    cell.gotoAndStop(floor1[i][u]);
                    cell.x = ((u-i)*tileh);
                    cell.y = ((u+i)*tilew/2);
                    addChild(cell);


                    cell.addEventListener(MouseEvent.ROLL_OVER, mouseover);
                    cell.addEventListener(MouseEvent.ROLL_OUT, mouseout);
                    cell.addEventListener(MouseEvent.CLICK, mouseclick);
                    cell.addEventListener(Event.ENTER_FRAME, beginfloor1);


                }
            }

            var player:Player = new Player();
        addChild(player);
        player.mouseEnabled = false;
        player.x = 5 * (tileh);
        player.y = 5 * (tilew/2);


        var enemy:Enemy = new Enemy();

        addChild(enemy);
        enemy.mouseEnabled = false;
        enemy.x = 9 * (tileh);
        enemy.y = 9 * (tileh/2);

My goal is to have the enemy move randomly on tiles in his range. What I did was create a square graphic called enemyVisionArea that checks which tile is hitting the enemy, which is basically surrounding tiles.

I have a timer function that tells the enemy to move every 5 seconds if the player isn't near him and if he's next to an available tile.

function timerenemy (event:TimerEvent){
                if (enemy.enemyVisionArea.hitTestObject(enemyMover) && !player.visionPoint.hitTestObject(enemyMover.tileMiddle))
                    {
                        enemy.x = (enemyMover.x)+55;
                        enemy.y = (enemyMover.y)+20;
                        trace("moved");

                    }
            }

enemyMover is a variable that I made equal to the tile objects.

function beginfloor1(event:Event)
            {
                enemyMover = event.currentTarget as Tile;

            }

It just stays where it is. I recently found out that the reason why it stays is because the enemyMover is checking one tile that the enemy is hitting instead of all available tiles the enemy is hitting. I'm not entirely sure on how to go about doing this. Any suggestions?

Response to: If offered immortality... Posted August 12th, 2010 in General

I couldn't do it. I'd get sick of the world.

Response to: To all you athiests Posted August 4th, 2010 in General

At 8/4/10 11:16 PM, zmatt007 wrote: OK HERE if people say 2 atoms clashed together and poof the universe is made! THEN HOW THE FUCK DID THE ATOMS APPEAR IN THE FIRST PLACE EXPLAIN THAT U SMART ASSES

It wasn't God hurrdurr. That is what the Atheists would say.

Response to: To all you athiests Posted August 4th, 2010 in General

Why did the atheist throw her watch out the window?
She wanted to see if it was designed intelligently enough to evolve into a bird.

Lol, ok that's the last one.

Response to: To all you athiests Posted August 4th, 2010 in General

How many atheists does it take to change a light bulb?
Two. One to actually change the bulb, and the other to videotape the job so fundamentalists won't claim that god did it.

I'm literally crying right now.

Response to: To all you athiests Posted August 4th, 2010 in General

Why did the atheist cross the road?
He thought there might be a street on the other side, but he wouldn't believe it until he tested his hypothesis.

HAHAHA

Response to: post batman related quotes Posted August 4th, 2010 in General

Dear Batman

I came in your mask

-Robin

Response to: Forum Posting Posted August 4th, 2010 in General

Couldn't get a job, and waiting for my fall semester to begin, so might as well be a fucking loser on newgrounds to communicate with other losers until I get my life back on track.

real talk
Response to: finding a job..holy shit Posted August 3rd, 2010 in General

At 8/3/10 09:53 PM, quagmire690 wrote: they wanted me to be a fucking door to door sales man...
no...

lol

Response to: finding a job..holy shit Posted August 3rd, 2010 in General

You live in Canada, so of course you found a job.

Response to: Top 10 Useless College Courses Posted August 3rd, 2010 in General

Art History? Are you fucking kidding me!? It's a form of history. This is a failed attempt at trolling. Saving the punch line for the first ranked. Bullshit, I fucking actually took that class.

Drake and Josh didn't suck Posted July 28th, 2010 in General

You know what, Drak and Josh wasn't so bad. They had Mindy Crenshaw, who I just realized is very good looking.

Drake and Josh didn't suck

Response to: What would u do I u controlled NG? Posted July 27th, 2010 in General

Everyone would have to post their dicks in this thread.

Response to: Masturbating in the shower? Posted July 27th, 2010 in General

Don't use a rag with soap on it. If the soap gets insdie when you cum, that shit'll hurt for days.

Response to: Commercials you just cant stand Posted July 24th, 2010 in General

It's a pillow, It's a pet, It's a pillow-pet
Not only is this commercial long, it portrays innocence, which will just be corrupted later on in life.

Response to: If you were a mod... Posted July 24th, 2010 in General

Probably Dick Rider. What am I implying about the mods exactly? hmm...

Response to: Need help finding anime show Posted July 24th, 2010 in General

Vandred?

Response to: If Chuck Norris and I have $5 each? Posted July 20th, 2010 in General

You both would have the same amount of money. However, if you had 5 bucks and the Old Spice Man had 5 bucks, the Old Spice man would clearly have more, seeing he can turn his 5 dollar bill into diamonds, making it worth over millions.

Response to: summer jobs Posted July 20th, 2010 in General

Fuck jobs, they're for the fucking lucky people.

Response to: Having a bad day? Posted July 20th, 2010 in General

At least he has a job.

Response to: Naacp:equal Rights Or Black Supreme Posted July 20th, 2010 in General

At 7/20/10 08:36 AM, StCyril wrote:
At 7/20/10 08:28 AM, Perversion wrote: Fox news.
Yeah very nice, why dont you go back and listen to one of those Liberal media stations blame G Bush for Mel Gibsons rant some more.

CNN Same Article.

Oh, if CNN has the same article, I'll accept this story. In the future, remember FOX sucks cocks.

Response to: Naacp:equal Rights Or Black Supreme Posted July 20th, 2010 in General

Fox news.

Response to: Is it right or wrong? Posted July 20th, 2010 in General

If there was a mouse in my house, I'd kill the little fucker.

Response to: Best Television Show Theme Song? Posted July 19th, 2010 in General

Uh, fucking Swat Kats

Response to: What do you wanna do, huh? Posted July 19th, 2010 in General

I must smell failure, because I must be in South Park, Colorado.

What do you wanna do, huh?

Response to: what person do you hate? Posted July 19th, 2010 in General

The Los Angeles Lakers
Maybe everyone from Spain

Response to: when war end??? Posted July 18th, 2010 in General

At 7/18/10 03:26 PM, zen64 wrote:
Yeah, he's using a translator. Omran is an Arabian name apparently. Huh. That explains a lot.

That doesn't make him funny anymore

Response to: when war end??? Posted July 18th, 2010 in General

At 7/18/10 02:53 PM, Ronald-McDonald-LoL wrote:
At 7/18/10 02:51 PM, Ptero wrote:
At 7/18/10 02:42 PM, Ronald-McDonald-LoL wrote: omran97 has done it again.
Another gem of quality BBS posting.
He is my new favorite poster.
I am going to link to these threads on my sig if he keeps posting at this level of genius.

I sent the fucker a congratulation PM. What an inspiration.