Compare commits
2 Commits
0b8d432697
...
62d7877903
| Author | SHA1 | Date | |
|---|---|---|---|
| 62d7877903 | |||
| a15dd6da40 |
9
main.py
9
main.py
@ -3,8 +3,7 @@ import numpy as np
|
|||||||
|
|
||||||
from board import render_board
|
from board import render_board
|
||||||
from position import pos
|
from position import pos
|
||||||
|
from renderPieces import ChessPiece
|
||||||
#print(pos)
|
|
||||||
|
|
||||||
pg.init()
|
pg.init()
|
||||||
size = 900
|
size = 900
|
||||||
@ -12,6 +11,10 @@ screen = pg.display.set_mode((size, size))
|
|||||||
clock = pg.time.Clock()
|
clock = pg.time.Clock()
|
||||||
running = True
|
running = True
|
||||||
|
|
||||||
|
all_pieces = pg.sprite.Group()
|
||||||
|
bRook = ChessPiece("pieces/b-rook.png",0 ,0)
|
||||||
|
all_pieces.add(bRook)
|
||||||
|
|
||||||
while running: #open window
|
while running: #open window
|
||||||
for event in pg.event.get():
|
for event in pg.event.get():
|
||||||
if event.type == pg.QUIT:
|
if event.type == pg.QUIT:
|
||||||
@ -19,6 +22,8 @@ while running: #open window
|
|||||||
|
|
||||||
render_board(screen, size)
|
render_board(screen, size)
|
||||||
|
|
||||||
|
all_pieces.draw(screen)
|
||||||
|
|
||||||
#flip display to put game on screen
|
#flip display to put game on screen
|
||||||
pg.display.flip()
|
pg.display.flip()
|
||||||
|
|
||||||
|
|||||||
15
renderPieces.py
Normal file
15
renderPieces.py
Normal 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)
|
||||||
Loading…
Reference in New Issue
Block a user