mac-comp127 / kilt-graphics

Graphics and UI library for learning software development principles in Java
https://mac-comp127.github.io/kilt-graphics/
2 stars 17 forks source link

Graphic Group Coordinate Problem #5

Closed juliakispert closed 4 years ago

juliakispert commented 4 years ago

When calling getX() or getCenter() position of graphic group does not seem to be correct. Issue also is seen when calling setCenter() on a graphic group. This line: https://github.com/mac-comp127-f19/PixelJump/blob/master/src/PixelJump/Pixel.java#L77, moves the group off the screen.

pcantrell commented 4 years ago

There were two problems here:

  1. There was a bug where GraphicsGroup didn’t update its center properly. I just fixed that; pull 127-shared to get the fix.
  2. Your pixel group has all positioned all its individual components so that they are in the bottom middle of the screen even when the group itself is positioned at the upper left. This is the source of your platform bounce detection problems. To solve it, change these lines of code so that you do not use CANVAS_WIDTH or CANVAS_HEIGHT, but instead position all the group elements so that pixel’s upper left corner is at (0,0) in local group coordinates. Then move the whole group around the screen.