Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-07-2011, 01:44 AM   #1
SaladBowler
SaladBowlers.com
 
Join Date: Jan 2011
Location: NorCal, USA
Posts: 25
Default [AS3] Formula for collision?

Still working on an online zombie game, ran into a possible problem of NPC zombies running through walls.

So i have a map with bounderies, that the local user will stop at wall fine because flash just tells it can't go through there. the problem is the zombie npcs are controlled through a cron tab PHP script, which gets the map Bounderies and randommizies its next location to move to. Now your up to speed...

The zombies will not go to locations that the boundaries are set, however they will go through them to reach there destination, so how can i make a formula that will pre-calculate that the zombie will hit the wall on its way to its destination, so the php script can know ahead of time that it should send the zombie else where?

Last edited by SaladBowler; 01-07-2011 at 01:54 AM. Reason: mistype
SaladBowler is offline   Reply With Quote
Old 01-07-2011, 01:58 AM   #2
92Garfield
Senior Member
 
Join Date: Jul 2010
Posts: 356
Default

ActionScript Code:
var futureCollide = false; for (var i= 0; i< 1000; i++) {     doZombieStep(copyOfActualZombie);     futureCollide  = checkCollision(copyOfActualZombie); } if (futureCollide ) {     //the zombie will run into a wall... }
92Garfield is offline   Reply With Quote
Old 01-07-2011, 02:04 AM   #3
SaladBowler
SaladBowlers.com
 
Join Date: Jan 2011
Location: NorCal, USA
Posts: 25
Default

Quote:
Originally Posted by 92Garfield View Post
ActionScript Code:
var futureCollide = false; for (var i= 0; i< 1000; i++) {     doZombieStep(copyOfActualZombie);     futureCollide  = checkCollision(copyOfActualZombie); } if (futureCollide ) {     //the zombie will run into a wall... }
Thanks! But I forgot to mention that this collision detection MUST be done in PHP.

Crontab:
Quote:
Map Bounderies(MySql) -> Check Collision(PHP) -> updateZombies newX & newY(Mysql);
Client:
Quote:
Zombie Position Updater Loop(Flash)-> get position(Mysql/PHP)

Last edited by SaladBowler; 01-07-2011 at 02:06 AM.
SaladBowler is offline   Reply With Quote
Old 01-07-2011, 01:04 PM   #4
92Garfield
Senior Member
 
Join Date: Jul 2010
Posts: 356
Default

well, it's just the principle, no realy code anyway.

Build that in PHP then

Let me have a try in PHP

ActionScript Code:
$futureCollide = false; for ($i= 0; $i< 1000; $i++) {      doZombieStep($copyOfActualZombie);      $futureCollide  = checkCollision($copyOfActualZombie); } if ($futureCollide ) {      //the zombie will run into a wall...      echo "OMG A WALL!!!11"; }
something like that right?

Last edited by 92Garfield; 01-07-2011 at 01:10 PM.
92Garfield is offline   Reply With Quote
Old 01-07-2011, 02:09 PM   #5
SaladBowler
SaladBowlers.com
 
Join Date: Jan 2011
Location: NorCal, USA
Posts: 25
Default

Right, I appreciate your help except your method was my first attempt..and of course it works but this game is already CPU/Network intesntive and i think it would be ineffeicent for flash to wait on php to finish a loop which CPU cycles could be saved if i get a math formula in here
SaladBowler is offline   Reply With Quote
Old 01-08-2011, 01:37 AM   #6
SaladBowler
SaladBowlers.com
 
Join Date: Jan 2011
Location: NorCal, USA
Posts: 25
Default

Well it seemed to difficult, so i just made the crontab, += X & Y values every refresh and if it hit the wall it would go in a diff direction
SaladBowler is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:10 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.