I use the latest version of PyQt4, and python3.
The game I want to make its most common name is "sliding puzzle".
I know the easy part (start, reset, close, and the stopwatch time), but I have some issues with slides motion.
I created 15 QPushButtons inside a QGridLayout (shown in the attached image, here: Game Design:
), and I want to know how to move the clicked button based on these thoughts:
for each mouse click
- determine where the empty cell is, inside the GridLayout
- determine the surrounding non-empty cells
- if the click is on one of the surroundings
- switch the empty cell with the clicked one
- if not
- do nothing
I have these problems:
I don't know how to determine the clicked object (widget) inside a specific GridLayout cell
If I'm able to solve the 1st problem, I don't know how to switch the empty cell with a non-empty one
I don't know how to randomise the arrangement of the buttons
I also don't know how to check if the puzzle is solved (how to check the arrangement based on index of the buttons and their text values)
Any ideas?
If you have a better concept, I'll be happy to implement it inside the app.