Compare commits

..

2 Commits

2 changed files with 22 additions and 2 deletions

View File

@ -3,8 +3,7 @@ import numpy as np
from board import render_board
from position import pos
#print(pos)
from renderPieces import ChessPiece
pg.init()
size = 900
@ -12,6 +11,10 @@ screen = pg.display.set_mode((size, size))
clock = pg.time.Clock()
running = True
all_pieces = pg.sprite.Group()
bRook = ChessPiece("pieces/b-rook.png",0 ,0)
all_pieces.add(bRook)
while running: #open window
for event in pg.event.get():
if event.type == pg.QUIT:
@ -19,6 +22,8 @@ while running: #open window
render_board(screen, size)
all_pieces.draw(screen)
#flip display to put game on screen
pg.display.flip()

15
renderPieces.py Normal file
View File

@ -0,0 +1,15 @@
import pygame
class ChessPiece(pygame.sprite.Sprite):
def __init__(self, image_path, x, y):
super().__init__()
self.image = pygame.image.load(image_path).convert_alpha()
# 3. Get the bounding box (Rect) of the image
self.rect = self.image.get_rect()
# 4. Set the initial position of the Rect
self.rect.topleft = (x, y)