mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-25 04:15:45 -08:00
First, pick either 'X' or 'O' from the screen then, play the normal one Player TicTacToe. Playing on Terminal is kinda boring so, I made it into an executable file.
24 lines
776 B
Python
24 lines
776 B
Python
import os
|
|
import game_config as gc
|
|
|
|
from pygame import image, transform
|
|
|
|
def GetName(val):
|
|
return str(val) + ".png"
|
|
|
|
class Image:
|
|
def __init__(self, val):
|
|
self.name = GetName(val) #names of image with .png
|
|
self.image_path = os.path.join(gc.ASSET_DIR, self.name) #path of image from the assets file
|
|
self.image = image.load(self.image_path) #loaded the image
|
|
self.image = transform.scale(self.image, (gc.IMAGE_SIZE - 2 * gc.MARGIN, gc.IMAGE_SIZE - 2 * gc.MARGIN)) #fixed image as per req.
|
|
# self.box = self.image.copy() # box
|
|
#self.box.fill((200, 200, 200))
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
for i in gc.ASSET_FILES:
|
|
temp = Image(i)
|
|
print(temp.name,temp.image_path,temp.image,temp)
|