math - column calc
paranoid_android
Member Posts: 22
I would like to identify which column my actor is in. I am dividing the screen into 4 (480/4 = 120), and I must include the camera offset.
in other apps I would use
int ( (self.postition.x - game.cameraX) / 120 )
How can I accomplish that here
@pa
in other apps I would use
int ( (self.postition.x - game.cameraX) / 120 )
How can I accomplish that here
@pa
Comments
That should give you 0,1,2,3 for the values. And 4 if you are at the right border.
in a scene that is 480 width, actor position 0-119 is the first column, 120-239 is the second column, 240-359 is third, 360-479 is fourth, and 480 is fifth.
If you want to include that 480 in the 4th column add the min function.
Column = min(3,floor(abs(self.position-game.cameraX)/120))
I would like to use a similar expression as above. Have a value range for each row.
The range would actually be a tolerance. (ie 10px)
row1 actor width = 117 (range 97-127)
row2 actor width = 85 (range 75-95 )
row3 actor width = 72 (range 62-82)
I could create a game variable for each row value. I know I at least have to have row1.
Ultimately I would like to do it with 1 game variable, and one prototype behavior.
Are the ranges supposed to overlap?
The ranges are not suppose to overlap. The reason I have ranges, is to allow for slight variation in the placement and sizing of the actors.
I wonder if thinking in percentages is a better way to solve this. In the end the behaviour has to set the prototype variable to 1,2,or3.