Skip to content

Commit

Permalink
Add player
Browse files Browse the repository at this point in the history
  • Loading branch information
grish-ka committed Nov 5, 2024
1 parent 2898b1b commit 54b52af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Player/__init__.py
Original file line number Diff line number Diff line change
@@ -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()
9 changes: 7 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import random
from tkinter import *

import Player
from CustomErrors import GridNotFound


class Block:

block_ids = {
"clone:dirt": "brown",
"clone:grass_block": "green"
"clone:grass_block": "green",
"clone:air": ""
}
xy={
"0,0":[20,20],
Expand All @@ -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)
Expand All @@ -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:
Expand Down

0 comments on commit 54b52af

Please sign in to comment.