Math logic

comport9

  • Posts: 51
I want to set my actors position using the following formula:

round(self.X / 64) * 64

I want to do this when the mouse is released BTW. How would I go about doing this?

comport9

  • Posts: 51
I think I figured it out. Problem though: rounding doesn't seem to work properly. Seems "rounding" is actually more like "ceiling". :(

Oh, and the Event effects all objects, rather than just the single instance.

comport9

  • Posts: 51
<SOLVED>

Ok, what I was trying to do was move game pieces (like Checkers) and have them drop into place when the player released the mouse. I figured out what I was doing wrong, and how to solve the problem. I'm just putting it here in case it helps others...

To get the math to work in the proper order (with parentheses) I had to use multiple "palettes" rather than a single. Otherwise the / 64 * 64 cancelled each other out obviously.

The reason the rounding didn't seem to be working was because I was getting the X/Y position of the MOUSE, not the game piece I was moving. Once I changed that, it worked perfectly.

BTW, when I had it on X of MOUSE, ALL game pieces would move, not just the dragged one. I don't know why this is. However, after the change, the appropriate behavior applied itself. :)

Hope I didn't waste too many peoples time reading this...