View Single Post
  #4   (View Single Post)  
Old 17th April 2012
xmorg xmorg is offline
Real Name: Tim Cooper
Fdisk Soldier
 
Join Date: Sep 2010
Location: San Diego
Posts: 56
Default

So basically, a lot of if/else logic, accounting for every direction?

like so:
Code:
if(gc->mousecx < gr->rcSprite->x && gc->mousecy < gr->rcSprite->y)
	    {}
	  else if(gc->mousecx > gr->rcSprite->x && gc->mousecy > gr->rcSprite->y)
	    {}
	  else if(gc->mousecx < gr->rcSprite->x && gc->mousecy > gr->rcSprite->y)
	    {}
	  else if(gc->mousecx > gr->rcSprite->x && gc->mousecy < gr->rcSprite->y)
	    {}
	  if(gc->mousecx > gr->rcSprite->x) 
	    {player->screen_x = 1; pdirection = EAST; player->moving = 1;}
	  else if(gc->mousecx < gr->rcSprite->x) 
	    {player->screen_x = -1; pdirection = WEST; player->moving = 1;}
	  else if( gr->rcSprite->x == gc->mousecx ) 
	    {player->screen_x = 0; player->moving=0; gamestate = GAME_HERO_SELECTED;}
	  else if(gc->mousecy > gr->rcSprite->y) 
	    {player->screen_y = 1; pdirection = SOUTH; player->moving = 1;}
	  else if(gc->mousecy < gr->rcSprite->y) 
	    {player->screen_y = -1; pdirection = NORTH; player->moving = 1;}
	  else if( gr->rcSprite->y == gc->mousecy ) 
	    {player->screen_y = 0; player->moving=0; gamestate = GAME_HERO_SELECTED;} //dont move
Reply With Quote