|
| 1 | +# Creating a new scenario |
| 2 | +1. Choose a scenario name. It will be referred to below as `<name>`. |
| 3 | + |
| 4 | +2. Copy `scenarioWriters/scenarioWriterBlank.py` to `scenarioWriters/scenarioWriter<name>.py` |
| 5 | + |
| 6 | +3. At Line 10 onward, add the following: |
| 7 | +``` |
| 8 | +# Initialises a new scenario object and sets the scenario name. |
| 9 | +scenario = Scenario('<name>') |
| 10 | +``` |
| 11 | + |
| 12 | +* Decide how big you want each square to be, in terms of pixels. If you already have a `BeeBot` image (or `Obstacle` images/`Goal` images), your squares should be the same size as this. Add the following code, but replace `n` with your number. |
| 13 | +``` |
| 14 | +# The size of an individual square. |
| 15 | +scenario.set_board_step(n) |
| 16 | +``` |
| 17 | + |
| 18 | +* Decide how many squares you want your map to be. If you already have a background image, this will dictate the height and width. Add the following code, but replace `x` and `y` with your width and height in terms of squares. |
| 19 | +``` |
| 20 | +# Sets the width of the map in terms of squares. |
| 21 | +scenario.set_logical_width(x) |
| 22 | +# Sets the height of the map in terms of squares. |
| 23 | +scenario.set_logical_height(y) |
| 24 | +``` |
| 25 | + |
| 26 | +* Decide where you want your `BeeBot` to start. Add the following code, replacing `x, y` with your starting co-ordinates. |
| 27 | +``` |
| 28 | +# Sets the bee bot starting square. |
| 29 | +scenario.set_beebot_start_position(x, y) |
| 30 | +``` |
| 31 | + |
| 32 | +* Set your `BeeBot` sprite, it needs to be the same size as your squares. Add the following code, but replace `<sprite>` with the file path of your image. |
| 33 | +``` |
| 34 | +# Set the BeeBot sprite. |
| 35 | +scenario.set_beebot_sprite('<sprite>') |
| 36 | +``` |
| 37 | + |
| 38 | +* You will need to tell the program which way you’re `BeeBot` sprite is facing, where 'UP' is `Heading.NORTH`. Add the following code, but replace <heading> with your heading. |
| 39 | +``` |
| 40 | +# Sets the BeeBots starting direction, where "UP" is Heading.NORTH. |
| 41 | +# (other options are Heading.EAST, Heading.SOUTH and Heading.WEST) |
| 42 | +scenario.set_beebot_heading(<heading>) |
| 43 | +``` |
| 44 | + |
| 45 | +* Set the background image. Add the following code, but replace <background> with the file path of your image. |
| 46 | +``` |
| 47 | +# Sets the image on the map. |
| 48 | +scenario.set_background('<background>') |
| 49 | +``` |
| 50 | + |
| 51 | +* If the image has no grid, one can be added by adding the following code and replacing `(R, G, B)` with your chosen RGB colour. |
| 52 | +``` |
| 53 | +scenario.set_border_colour((R, G, B)) |
| 54 | +``` |
| 55 | + |
| 56 | +* Obstacles, squares to avoid, need to be defined separately. To add an `Obstacle`, add the following code, but replace `x, y` with your `Obstacle` location. |
| 57 | + To add an `Obstacle` with an image, replace `x, y` with your `Obstacle` location and the file path of the image e.g. `(1, 2, './img/Default/obstacle1.jpg')` |
| 58 | +``` |
| 59 | +# This line adds an obstacle. |
| 60 | +scenario.add_obstacle(x, y) |
| 61 | +``` |
| 62 | + |
| 63 | +* Goals, squares to reach, need to be defined separately also. To add a `Goal`, add the following code, but replace `x, y` with your `Goal` location. |
| 64 | + To add a `Goal` with an image, replace `x, y` with your `Goal` location and the file path of the image e.g. `(1, 2, './img/Default/goal1.jpg')` |
| 65 | +``` |
| 66 | +# This line adds a goal. |
| 67 | +scenario.add_goal(x, y) |
| 68 | +``` |
| 69 | + |
| 70 | +* You can decide whether you want your goals to be completed in the order added, or in any order. Add one of the following blocks of code. |
| 71 | +``` |
| 72 | +# This method means the goals must be met in the order added. |
| 73 | +scenario.set_ordered_goals(True) |
| 74 | +``` |
| 75 | +or |
| 76 | +``` |
| 77 | +# This method means the goals can be met in any order. |
| 78 | +scenario.set_ordered_goals(False) |
| 79 | +``` |
| 80 | + |
| 81 | +* You'll need to set a sprite for when your BeeBot crashes. Add the following code, but replace `path` with the file path of the image. |
| 82 | +``` |
| 83 | +# Sets the sprite to be displayed when the robot crashes |
| 84 | +scenario.set_beebot_fail_sprite('path') |
| 85 | +``` |
| 86 | + |
| 87 | +4. Finally, run `python scenarioWriters/ScenarioWriter<name>.py` to generate your `.scitbot` file. |
0 commit comments