Random obstacles
This commit is contained in:
parent
3b7984bba0
commit
d716eb1d79
@ -38,6 +38,7 @@ class Node:
|
|||||||
GREEN = (0, 255, 0)
|
GREEN = (0, 255, 0)
|
||||||
RED = (255, 0, 0)
|
RED = (255, 0, 0)
|
||||||
BLUE = (0, 0, 255)
|
BLUE = (0, 0, 255)
|
||||||
|
ORANGE = (255, 165, 0)
|
||||||
|
|
||||||
def __init__(self, row: int, col: int,
|
def __init__(self, row: int, col: int,
|
||||||
field_type: int = 0, reachable: bool = True):
|
field_type: int = 0, reachable: bool = True):
|
||||||
@ -76,3 +77,5 @@ class Node:
|
|||||||
return self.RED
|
return self.RED
|
||||||
elif self.field_type == 2:
|
elif self.field_type == 2:
|
||||||
return self.BLUE
|
return self.BLUE
|
||||||
|
elif self.field_type == 3:
|
||||||
|
return self.ORANGE
|
||||||
|
12
UI/window.py
12
UI/window.py
@ -1,4 +1,5 @@
|
|||||||
import pygame as pg
|
import pygame as pg
|
||||||
|
import random
|
||||||
from UI.grid import Grid, Node
|
from UI.grid import Grid, Node
|
||||||
|
|
||||||
|
|
||||||
@ -26,8 +27,19 @@ class Window():
|
|||||||
self.clock = pg.time.Clock()
|
self.clock = pg.time.Clock()
|
||||||
grid.change_field(0, 0, 1)
|
grid.change_field(0, 0, 1)
|
||||||
grid.change_field(19, 19, 2)
|
grid.change_field(19, 19, 2)
|
||||||
|
|
||||||
|
#random obsticle
|
||||||
|
for x in range(25):
|
||||||
|
grid.change_field(random.randint(1,18),random.randint(1,18),3)
|
||||||
|
|
||||||
|
|
||||||
path = [(i, i) for i in range(1, 20, 1)]
|
path = [(i, i) for i in range(1, 20, 1)]
|
||||||
self.grid.draw_map(self.screen)
|
self.grid.draw_map(self.screen)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for t in path:
|
for t in path:
|
||||||
x, y = t
|
x, y = t
|
||||||
self.grid.change_field(x-1, y-1, 0)
|
self.grid.change_field(x-1, y-1, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user