Noire Posted August 27, 2013 Group: Members Topic Count: 35 Topics Per Day: 0.01 Content Count: 103 Reputation: 1 Joined: 06/26/13 Last Seen: April 14 Share Posted August 27, 2013 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; Quote Link to comment Share on other sites More sharing options...
Emistry Posted August 27, 2013 Group: Forum Moderator Topic Count: 93 Topics Per Day: 0.02 Content Count: 10018 Reputation: 2372 Joined: 10/28/11 Last Seen: 9 hours ago Share Posted August 27, 2013 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. Quote Link to comment Share on other sites More sharing options...
Noire Posted August 28, 2013 Group: Members Topic Count: 35 Topics Per Day: 0.01 Content Count: 103 Reputation: 1 Joined: 06/26/13 Last Seen: April 14 Author Share Posted August 28, 2013 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. Quote Link to comment Share on other sites More sharing options...
Question
Noire
dir = map_calc_dir(src,bl->x,bl->y);
Link to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.