This site requires JavaScript, please enable it in your browser!
Greenfoot back
danpost
danpost wrote ...

2017/5/15

Speed of actor not uniform

danpost danpost

2017/5/15

#
In my Combo Support Demo scenario, I have an Orb object in the Level2 world that moves one pixel at a time to the right and two pixels at a time to the left. However, I believe I have it programmed to move 1.91 to the right and left (negating the horizontal velocity when needed). If anyone can tell my why I am getting this odd behavior, it would be much appreciated. BTW, the inspection panel on the orb shows 'vX' of 191 when moving right and of '-191' when moving left (which is what it should be). But the actual horizontal movement by step is not consistent with those values as stated above.
Super_Hippo Super_Hippo

2017/5/15

#
Somewhere between the end of the orb's act method and the start of the orb's next act method, the qX is rounded. Since vX is ±1.91 and qX is positive, ...000 → ...191 is rounded to ..100 (= one step) while ...000 → ...809 is rounded to ...800 (= two steps). I couldn't find out what happens between these act cycles, but maybe this helps. I spread some print commands... most of them are probably not needed anymore, but here we go: START = Start of orb's act method ENDE = End of orb's act method qX, qY, qX/QVAL = in the setQLocation method (QActor) Vertical, Horizontal = in moveHorizontally/moveVertically method (QActor) + qX, qY values moveVertical/moveHorizontal - MethodStart/End = in moveHorizontally/moveVertically method (GQActor) at the start/end of the method moving right: -- START:23100, 47000 moveVertical - MethodStart:23100, 47000 Vertical:23100, 47100 qX = 23100 qY = 47100 qX/QVAL = 231 qX = 23100 qY = 47000 qX/QVAL = 231 moveVertical - MethodEnd:23100, 47000 moveHorizontal - MethodStart:23100, 47000 Horizontal:23291, 47000 qX = 23291 qY = 47000 qX/QVAL = 232 moveHorizontal - MethodEnd:23291, 47000 ENDE:23291, 47000 ???? What happens here ???? START:23200, 47000 moveVertical - MethodStart:23200, 47000 Vertical:23200, 47100 qX = 23200 qY = 47100 qX/QVAL = 232 qX = 23200 qY = 47000 qX/QVAL = 232 moveVertical - MethodEnd:23200, 47000 moveHorizontal - MethodStart:23200, 47000 Horizontal:23391, 47000 qX = 23391 qY = 47000 qX/QVAL = 233 moveHorizontal - MethodEnd:23391, 47000 ENDE:23391, 47000 ???? What happens here ???? START:23300, 47000 moveVertical - MethodStart:23300, 47000 Vertical:23300, 47100 qX = 23300 qY = 47100 qX/QVAL = 233 qX = 23300 qY = 47000 qX/QVAL = 233 moveVertical - MethodEnd:23300, 47000 moveHorizontal - MethodStart:23300, 47000 Horizontal:23491, 47000 qX = 23491 qY = 47000 qX/QVAL = 234 moveHorizontal - MethodEnd:23491, 47000 ENDE:23491, 47000 -- moving left: -- START:27200, 47000 moveVertical - MethodStart:27200, 47000 Vertical:27200, 47100 qX = 27200 qY = 47100 qX/QVAL = 272 qX = 27200 qY = 47000 qX/QVAL = 272 moveVertical - MethodEnd:27200, 47000 moveHorizontal - MethodStart:27200, 47000 Horizontal:27009, 47000 qX = 27009 qY = 47000 qX/QVAL = 270 moveHorizontal - MethodEnd:27009, 47000 ENDE:27009, 47000 ???? What happens here ???? START:27000, 47000 moveVertical - MethodStart:27000, 47000 Vertical:27000, 47100 qX = 27000 qY = 47100 qX/QVAL = 270 qX = 27000 qY = 47000 qX/QVAL = 270 moveVertical - MethodEnd:27000, 47000 moveHorizontal - MethodStart:27000, 47000 Horizontal:26809, 47000 qX = 26809 qY = 47000 qX/QVAL = 268 moveHorizontal - MethodEnd:26809, 47000 ENDE:26809, 47000 ???? What happens here ???? START:26800, 47000 moveVertical - MethodStart:26800, 47000 Vertical:26800, 47100 qX = 26800 qY = 47100 qX/QVAL = 268 qX = 26800 qY = 47000 qX/QVAL = 268 moveVertical - MethodEnd:26800, 47000 moveHorizontal - MethodStart:26800, 47000 Horizontal:26609, 47000 qX = 26609 qY = 47000 qX/QVAL = 266 moveHorizontal - MethodEnd:26609, 47000 ENDE:26609, 47000 --
danpost danpost

2017/5/15

#
@Hippo, I figured it was probably being rounded. I just could not figure out why! I think I solved the mystery. Hopefully will upload fix shortly.
danpost danpost

2017/5/15

#
danpost[edit wrote...
I think I solved the mystery. Hopefully will upload fix shortly.
Orb issue is fixed, now and updated on site. The problem was that the Scroller class was treating the QActor objects as if they were normal Actor objects (not maintaining their more precise location coordinates). A slight modification to the 'scroll(int, int)' method in the Scroller class to move QActor objects as QActor objects was all that was needed.
You need to login to post a reply.