From 07374b4aa10fa71ecd8897d3d6f4bf29ed2215fb Mon Sep 17 00:00:00 2001 From: htom Date: Sat, 26 Jul 2025 14:49:49 +0200 Subject: [PATCH] drawing the player board --- constants.py | 4 ++-- main.py | 7 ++++--- player.py | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/constants.py b/constants.py index 2ee4d59..f0a2835 100644 --- a/constants.py +++ b/constants.py @@ -1,2 +1,2 @@ -SCREEN_WIDTH = 800 -SCREEN_HEIGHT = 600 +SCREEN_WIDTH = 1000 +SCREEN_HEIGHT = 800 diff --git a/main.py b/main.py index 4c71688..194e148 100644 --- a/main.py +++ b/main.py @@ -45,13 +45,14 @@ def main(): print("Quitting Battleships") return - pygame.Surface.fill(screen, (0,0,0)) - + pygame.Surface.fill(screen, (255,255,255)) + player.draw(screen) pygame.display.flip() #refresh screen - + r = input("add input") + print(r) dt = time.tick(60) / 1000 #converted to ms diff --git a/player.py b/player.py index 948e8e1..9058c68 100644 --- a/player.py +++ b/player.py @@ -1,3 +1,5 @@ +import pygame +from pygame import Rect class Player(): def __init__(self, board, ships = 5): self.board = board @@ -9,4 +11,18 @@ class Player(): def shoot(self, position): pass + + def update(self): + pass + + def draw(self, screen): + start_pos_x = 125 + start_pos_y = 30 + + for i in range(len(self.board)): + for j in range(len(self.board[0])): + pygame.draw.rect(screen, (0,0,0), Rect(start_pos_x, start_pos_y, 80, 80), 5) + start_pos_x += 75 + start_pos_y += 75 + start_pos_x = 125