Skip to content

Commit

Permalink
Add classic minesweeper bomb detection cheat functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Chubercik committed Mar 21, 2022
1 parent 2c99b62 commit 1923f77
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nuitka.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python -m nuitka --mingw64 --onefile --enable-plugin=numpy --include-data-file=../pysweeper/dlls/libmpg123-0.dll=libmpg123-0.dll --include-data-dir=../pysweeper/data=data --include-data-dir=../pysweeper/textures=textures --include-data-dir=../pysweeper/fonts=fonts --include-data-dir=../pysweeper/sounds=sounds --windows-icon-from-ico=../pysweeper/textures/bomb.png --windows-company-name=chubercik --windows-product-name=pysweeper --windows-file-version=0.2 --windows-product-version=0.2 --windows-file-description="a Minesweeper clone written in Python" --windows-disable-console main.py -o pysweeper.exe
python -m nuitka --clang --onefile --include-data-file=../pysweeper/dlls/libmpg123-0.dll=libmpg123-0.dll --include-data-dir=../pysweeper/data=data --include-data-dir=../pysweeper/textures=textures --include-data-dir=../pysweeper/fonts=fonts --include-data-dir=../pysweeper/sounds=sounds --windows-icon-from-ico=../pysweeper/textures/bomb.png --windows-company-name=chubercik --windows-product-name=pysweeper --windows-file-version=0.2 --windows-product-version=0.2 --windows-file-description="a Minesweeper clone written in Python" --windows-disable-console main.py -o pysweeper.exe
Binary file modified pysweeper.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions pysweeper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import platform
from sys import exit

from file_io import read_json, write_json
from sprites import load_file
from utilities import Board, Smiley, Timer, pygame, screen

if platform.system() == "Windows":
sys_name = "Windows"
import win32api
import win32gui
dc = win32gui.GetDC(0)
white = win32api.RGB(255, 255, 255)
elif platform.system() == "Linux":
sys_name = "Linux"
elif platform.system() == "Darwin":
sys_name = "Mac"


class Pysweeper:
def __init__(self, width: int, height: int, bombs: int) -> None:
Expand Down Expand Up @@ -59,6 +71,9 @@ def run(self) -> None:

clock = pygame.time.Clock()

if sys_name == "Windows":
temp = win32gui.GetPixel(dc, 0, 0)

while True:
screen.fill((170, 170, 170))

Expand All @@ -73,6 +88,14 @@ def run(self) -> None:
mouse_x = (mouse_pos[0] - self._board._left_offset) // 32
mouse_y = (mouse_pos[1] - self._board._top_offset) // 32

if sys_name == "Windows" and \
mouse_x < self._width and mouse_x >= 0 and \
mouse_y < self._height and mouse_y >= 0:
if self._board._board[mouse_y][mouse_x].is_bomb():
win32gui.SetPixel(dc, 0, 0, temp)
else:
win32gui.SetPixel(dc, 0, 0, white)

for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
Expand Down
3 changes: 0 additions & 3 deletions todo.txt

This file was deleted.

0 comments on commit 1923f77

Please sign in to comment.