Shift Puzzle - 1.0
2d shift puzzle. About 130 lines. Simple example of a 2d game with mouse control using pygame.
Lars P
(larsp90)
Changes
Links
Releases
Shift Puzzle 1.0 — 17 Sep, 2016
Pygame.org account Comments
-
Coderess 2016-12-15 21:30
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
i can not move the tiles
paveway3 2017-01-23 14:26
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[0] / TILE_WIDTH
r = mouse_pos[1] / TILE_HEIGHT
to:
c = mouse_pos[0] // TILE_WIDTH
r = mouse_pos[1] // 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
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[0] / TILE_WIDTH would have returned an int and worked correctly.
-
John Mamani 2018-11-03 23:12
problema con los mosaicos que no se mueven: lo resolvi cambiando en el boton del evento del mouse que controla los azulejos. Linea 118 c = mouse_pos[0] / TILE_WIDTH r = mouse_pos[1] / TILE_HEIGHT cambios: from math import ceil c = ceil(mouse_pos[0] / TILE_WIDTH) - 1 r = ceil(mouse_pos[1] / TILE_HEIGHT) - 1