From 54b52af0d9baad19b08fb3a7091af16e1c7f478f Mon Sep 17 00:00:00 2001 From: grish-ka Date: Tue, 5 Nov 2024 20:33:53 +0000 Subject: [PATCH] Add player --- Player/__init__.py | 11 +++++++++++ main.py | 9 +++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 Player/__init__.py diff --git a/Player/__init__.py b/Player/__init__.py new file mode 100644 index 0000000..de09fdd --- /dev/null +++ b/Player/__init__.py @@ -0,0 +1,11 @@ +from tkinter import * + +class Player: + def __init__(self, canvas): + self.canvas: Canvas=canvas + self.mspeed:int + canvas.create_rectangle(20, 20, 39, 39, fill="blue", outline="blue") + + def move(self): + self.mspeed=1 + self.canvas.move() diff --git a/main.py b/main.py index 5310eb5..8094d46 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ import random from tkinter import * +import Player from CustomErrors import GridNotFound @@ -11,7 +12,8 @@ class Block: block_ids = { "clone:dirt": "brown", - "clone:grass_block": "green" + "clone:grass_block": "green", + "clone:air": "" } xy={ "0,0":[20,20], @@ -25,6 +27,8 @@ def draw_block(gridxy: str, block_id: str, canvas: Canvas): canvas.create_rectangle(xy[0], xy[1], 39, 39, fill=block, outline=block) + + def main(): tk = Tk() canvas = Canvas(tk, width=500, height=500) @@ -50,7 +54,8 @@ def draw_rows(size: int = 17, height: float = 20, width: float = 20): raise GridNotFound.GridNotFound("Grid Not Found") draw_cloumns(chunk_size) draw_rows(chunk_size) - Block.draw_block(gridxy="1,0", block_id="clone:dirt", canvas=canvas) + Block.draw_block(gridxy="1,0", block_id="clone:grass_block", canvas=canvas) + Player.Player(canvas) while True: