2d shift puzzle. About 130 lines. Simple example of a 2d game with mouse control using pygame.
Pygame.org account Comments
Coderess 2016-12-15 21:30:18
Hey this is an awesome game! Just out of intrest how long did this take for you to code?
Andréoti Castillo 2017-01-13 22:19:43
i can not move the tiles
paveway3 2017-01-23 14:26:57
I had this problem too. Determined that it was a problem converting the mouse position to a tile position. I changed lines 118 and 119 from:
c = mouse_pos / TILE_WIDTH
r = mouse_pos / TILE_HEIGHT
c = mouse_pos // TILE_WIDTH
r = mouse_pos // TILE_HEIGHT
The division operator was returning a float, so c and r would not evaluate correctly in the following if statement. I assume it was working correctly for the author, so it may be a difference in implementation. I notice that the screenshot is from Ubuntu, (no way of knowing what version of Python). I am running Python 3.4 on Windows.
paveway3 2017-01-23 14:55:28
I probably should have done some research before my initial post... The division operator ( / ) does floor division with integers in Python 2 and does 'true division' in Python 3. The floor division operator ( // ) was added in Python 3 and Python 2.2+. Therefore, I presume that the author wrote this with 2.x where c = mouse_pos / TILE_WIDTH would have returned an int and worked correctly.