GUI changes

This commit is contained in:
Andrzej 2021-05-01 01:24:35 +02:00
parent 214d732397
commit 2db4051e5b
9 changed files with 28 additions and 22 deletions

View File

@ -17,13 +17,13 @@ step = IMAGE_SIZE + 3
class Field(object):
def __init__(self):
self.win = Tk()
self.width = 533
self.height = 533
self.width = 550
self.height = 550
self.image_size = 50
self.rows = 10
self.columns = 10
self.x_start = 3
self.y_start = 3
self.x_start = 5
self.y_start = 5
self.state_of_cell_array = [[0 for i in range(3)] for j in range(200)]
self.field_state_array = [[False for i in range(self.rows)] for j in range(self.columns)]
self.small_image_array = [[0 for i in range(self.rows)] for j in range(self.columns)]

View File

@ -32,9 +32,9 @@ def successor(state):
node_state_right.state.direction = "south"
node_state_right.action = "Right"
if state.coord[0] + 53 < FRAME_WIDTH:
if state.coord[0] + STEP < FRAME_WIDTH:
node_state_forward.state = State()
node_state_forward.state.coord = [state.coord[0] + 53, state.coord[1]]
node_state_forward.state.coord = [state.coord[0] + STEP, state.coord[1]]
node_state_forward.state.direction = state.direction
node_state_forward.action = "Up"
@ -50,9 +50,9 @@ def successor(state):
node_state_right.state.direction = "north"
node_state_right.action = "Right"
if state.coord[0] > 3:
if state.coord[0] > x_start:
node_state_forward.state = State()
node_state_forward.state.coord = [state.coord[0] - 53, state.coord[1]]
node_state_forward.state.coord = [state.coord[0] - STEP, state.coord[1]]
node_state_forward.state.direction = state.direction
node_state_forward.action = "Up"
@ -68,9 +68,9 @@ def successor(state):
node_state_right.state.direction = "east"
node_state_right.action = "Right"
if state.coord[1] > 3:
if state.coord[1] > x_start:
node_state_forward.state = State()
node_state_forward.state.coord = [state.coord[0], state.coord[1] - 53]
node_state_forward.state.coord = [state.coord[0], state.coord[1] - STEP]
node_state_forward.state.direction = state.direction
node_state_forward.action = "Up"
@ -86,9 +86,9 @@ def successor(state):
node_state_right.state.direction = "west"
node_state_right.action = "Right"
if state.coord[1] + 53 < FRAME_HEIGHT:
if state.coord[1] + STEP < FRAME_HEIGHT:
node_state_forward.state = State()
node_state_forward.state.coord = [state.coord[0], state.coord[1] + 53]
node_state_forward.state.coord = [state.coord[0], state.coord[1] + STEP]
node_state_forward.state.direction = state.direction
node_state_forward.action = "Up"

View File

@ -11,8 +11,8 @@ from resources.Globals import *
class Player(object):
def __init__(self):
self.x_start = 3
self.y_start = 3
self.x_start = 5
self.y_start = 5
self.current_x = self.x_start
self.current_y = self.y_start
self.step = IMAGE_SIZE + self.x_start

View File

@ -184,7 +184,6 @@ def MouseClickEvent(event):
end_position = []
# print("Pierwsza pozycja: {} {}".format(start_position[0], start_position[1]))
print(field.canvas_small_images)
for i in range(0, len(field.canvas_small_images)):
img_coords = field.small_field_canvas.coords(field.canvas_small_images[i])
@ -307,8 +306,8 @@ def AutoMove():
# Draws rectangles that indicate type of cells
def DrawRectangle():
x = player.x_start
y = player.y_start
x = 4
y = 4
color = None
@ -323,10 +322,10 @@ def DrawRectangle():
elif field.cell_expense[i] == 40:
color = "green4"
if color != "None":
field.small_field_canvas.create_rectangle(x, y, x + IMAGE_SIZE, y + IMAGE_SIZE, width=3, outline=color)
field.small_field_canvas.create_rectangle(x, y, x + IMAGE_SIZE + 2, y + IMAGE_SIZE + 2, width=2, outline=color)
x += player.step
if i > 0 and i % 10 == 0:
x = player.x_start
x = 4
y += player.step

View File

@ -1,7 +1,8 @@
WINDOW_X = 533 + 1200
FRAME_WIDTH = 555
FRAME_HEIGHT = 555
WINDOW_X = FRAME_WIDTH + 1200
WINDOW_Y = 950
FRAME_WIDTH = 533
FRAME_HEIGHT = 533
# Size of small image
IMAGE_SIZE = 50
@ -10,6 +11,7 @@ AMOUNT_OF_MINES = 10
DELAY_TIME = 0.5
STEP = IMAGE_SIZE + 5
standard_cell_cost = 10
@ -21,3 +23,8 @@ water_cell_cost = 30
amount_of_swamp_cells = 10
swamp_cell_cost = 40
x_start = 5
y_start = 5