player class

This commit is contained in:
2025-07-26 14:13:55 +02:00
parent e577c389e3
commit b56ccb610a
4 changed files with 23 additions and 1 deletions

5
board.py Normal file
View File

@@ -0,0 +1,5 @@
class Board():
def __init__(self, board):
self.board = board

1
draw.py Normal file
View File

@@ -0,0 +1 @@
class

View File

@@ -1,6 +1,7 @@
import pygame import pygame
import sys import sys
from constants import * from constants import *
from player import *
def main(): def main():
print("Starting BattleShip!") print("Starting BattleShip!")
@@ -24,10 +25,13 @@ def main():
good_inp, player_board = check_valid_input(inp) good_inp, player_board = check_valid_input(inp)
enemy_board = player_board.copy() enemy_board = player_board.copy()
player = Player(player_board)
enemy = Player(enemy_board)
for i in range(10): for i in range(10):
for j in range(10): for j in range(10):
print(f"{board[i][j]} ", end="") print(f"{player.board[i][j]} ", end="")
print() print()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))

12
player.py Normal file
View File

@@ -0,0 +1,12 @@
class Player():
def __init__(self, board, ships = 5):
self.board = board
self.ships = ships #alive ships
self.shot_positions = [] #just add the shot positions here individually
def get_hit(self, position):
pass
def shoot(self, position):
pass