Skip to content

Commit ca6bfa4

Browse files
author
sam
committed
Added first playing field part 2
1 parent d03fd06 commit ca6bfa4

4 files changed

Lines changed: 25 additions & 23 deletions

File tree

source/ev3dev2/simulator/Simulator.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,34 @@ def setup(self):
7373
for s in self.robot.get_sensors():
7474
self.robot_state.load_sensor(s)
7575

76-
# self.blue_lake = BlueLake(self.cfg)
77-
# self.green_lake = GreenLake(self.cfg)
78-
# self.red_lake = RedLake(self.cfg)
76+
self.blue_lake = BlueLake(self.cfg)
77+
self.green_lake = GreenLake(self.cfg)
78+
self.red_lake = RedLake(self.cfg)
7979

80-
self.rock1 = Rock(apply_scaling(175), apply_scaling(700), apply_scaling(150), apply_scaling(60), arcade.color.DARK_GRAY, 0)
81-
self.rock2 = Rock(apply_scaling(1000), apply_scaling(375), apply_scaling(300), apply_scaling(90), arcade.color.DARK_GRAY, 90)
80+
# self.rock1 = Rock(apply_scaling(175), apply_scaling(700), apply_scaling(150), apply_scaling(60), arcade.color.DARK_GRAY, 0)
81+
self.rock2 = Rock(apply_scaling(1000), apply_scaling(300), apply_scaling(300), apply_scaling(90), arcade.color.DARK_GRAY, 90)
8282

83-
# self.obstacle_elements.append(self.blue_lake.shape)
84-
# self.obstacle_elements.append(self.green_lake.shape)
85-
# self.obstacle_elements.append(self.red_lake.shape)
83+
self.obstacle_elements.append(self.blue_lake.shape)
84+
self.obstacle_elements.append(self.green_lake.shape)
85+
self.obstacle_elements.append(self.red_lake.shape)
8686

87-
self.obstacle_elements.append(self.rock1.shape)
87+
# self.obstacle_elements.append(self.rock1.shape)
8888
self.obstacle_elements.append(self.rock2.shape)
8989

9090
self.border = Border(self.cfg, arcade.color.BLACK_OLIVE)
9191

9292
for s in self.border.shapes:
9393
self.obstacle_elements.append(s)
9494

95-
# color_obstacles = [self.blue_lake, self.green_lake, self.red_lake, self.border]
96-
color_obstacles = [self.border]
97-
touch_obstacles = [self.rock1, self.rock2]
95+
color_obstacles = [self.blue_lake, self.green_lake, self.red_lake, self.border]
96+
touch_obstacles = [self.rock2]
97+
# touch_obstacles = [self.rock1, self.rock2]
9898

9999
self.robot.set_color_obstacles(color_obstacles)
100100
self.robot.set_touch_obstacles(touch_obstacles)
101101

102102
self.space = Space()
103-
self.space.add(self.rock1.poly)
103+
# self.space.add(self.rock1.poly)
104104
self.space.add(self.rock2.poly)
105105

106106

@@ -179,8 +179,8 @@ def main():
179179
required=False,
180180
type=check_scale)
181181
parser.add_argument("-x", "--robot_position_x",
182-
default=450,
183-
help="Starting position x-coordinate of the robot, default is 450",
182+
default=200,
183+
help="Starting position x-coordinate of the robot, default is 200",
184184
required=False,
185185
type=int)
186186
parser.add_argument("-y", "--robot_position_y",

source/ev3dev2/simulator/config/config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ obstacle_settings:
3939
lake_settings:
4040
border_width: 29
4141
inner_radius: 38
42-
lake_blue_x: 137
43-
lake_blue_y: 922
44-
lake_green_x: 1052
45-
lake_green_y: 567
46-
lake_red_x: 397
47-
lake_red_y: 232
42+
lake_blue_x: 500
43+
lake_blue_y: 170
44+
lake_green_x: 250
45+
lake_green_y: 600
46+
lake_red_x: 850
47+
lake_red_y: 500
4848

4949

5050
screen_settings:

source/ev3dev2/simulator/obstacle/Lake.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from arcade import Shape, PointList
33

44
from ev3dev2.simulator.obstacle.ColorObstacle import ColorObstacle
5-
from ev3dev2.simulator.util.Color import to_color_code, BLUE, GREEN, RED
5+
from ev3dev2.simulator.util.Color import to_color_code, BLUE, GREEN, RED, YELLOW
66
from ev3dev2.simulator.util.Util import get_circle_points, apply_scaling
77

88

@@ -86,7 +86,7 @@ def __init__(self, cfg):
8686
x = apply_scaling(lake_cfg['lake_green_x']) + edge_spacing + border_depth
8787
y = apply_scaling(lake_cfg['lake_green_y']) + edge_spacing + border_depth
8888

89-
super(GreenLake, self).__init__(x, y, radius, GREEN, border_width)
89+
super(GreenLake, self).__init__(x, y, radius, YELLOW, border_width)
9090

9191

9292
class RedLake(Lake):

source/ev3dev2/simulator/util/Color.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
BLUE = (58, 166, 221)
44
GREEN = (122, 182, 72)
5+
YELLOW = (252, 227, 3)
56
RED = (201, 45, 57)
67

78

89
def to_color_code(color: arcade.Color) -> int:
910
switcher = {
1011
BLUE: 2,
1112
GREEN: 3,
13+
YELLOW: 4,
1214
RED: 5
1315
}
1416

0 commit comments

Comments
 (0)