Jump to content
  • 0

Source Code Help.


Noire

Question


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  103
  • Reputation:   1
  • Joined:  06/26/13
  • Last Seen:  

Can anyone explain how this code works/function? 

dir = map_calc_dir(src,bl->x,bl->y);
if( dir > 0 && dir < 4) x = -i;
else if( dir > 4 ) x = i;
else x = 0;
if( dir > 2 && dir < 6 ) y = -i;
else if( dir == 7 || dir < 2 ) y = i;
else y = 0;
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

dir = map_calc_dir(src,bl->x,bl->y);

it calculate the distance and save the value into te variable "dir"

if( dir > 0 && dir < 4) x = -i;
else if( dir > 4 ) x = i;
else x = 0; 

if the dir value is greater then 0 ...and less than 4 ..... the value of -1 will be assigned to variable x .....

if it's not greater than 4.. then the value of variable x is same as value of i.....

otherwise the value of variable x is 0 ...

if( dir > 2 && dir < 6 ) y = -i;
else if( dir == 7 || dir < 2 ) y = i;
else y = 0;

if the dir value greater than 2 and less than 6....variable y will be assigned with value of -1..

if dir value = 7 ...or less than 2 .... y value wil be assigned with the value of  variable i...

otherwise... y = 0.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  35
  • Topics Per Day:  0.01
  • Content Count:  103
  • Reputation:   1
  • Joined:  06/26/13
  • Last Seen:  

dir = map_calc_dir(src,bl->x,bl->y);

it calculate the distance and save the value into te variable "dir"

if( dir > 0 && dir < 4) x = -i;
else if( dir > 4 ) x = i;
else x = 0; 

if the dir value is greater then 0 ...and less than 4 ..... the value of -1 will be assigned to variable x .....

if it's not greater than 4.. then the value of variable x is same as value of i.....

otherwise the value of variable x is 0 ...

if( dir > 2 && dir < 6 ) y = -i;
else if( dir == 7 || dir < 2 ) y = i;
else y = 0;

if the dir value greater than 2 and less than 6....variable y will be assigned with value of -1..

if dir value = 7 ...or less than 2 .... y value wil be assigned with the value of  variable i...

otherwise... y = 0.

Took me a while to understand it. thanks Emistry.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...