|
| 1 | +"""This file writes a new scibot file.""" |
| 2 | + |
| 3 | +from src.Scenario import Scenario |
| 4 | +from src.BeeBot import Heading |
| 5 | + |
| 6 | + |
| 7 | +def main(): |
| 8 | + """Write a scibot file.""" |
| 9 | + # Initalises a new scenario object and sets the scenario name. |
| 10 | + scenario = Scenario("Default") |
| 11 | + |
| 12 | + # Tthe size of an individual square |
| 13 | + scenario.set_board_step(150) |
| 14 | + |
| 15 | + # Sets the width of the map in terms of squares |
| 16 | + scenario.set_logical_width(5) |
| 17 | + # Sets the height of the map in terms of squares |
| 18 | + scenario.set_logical_height(8) |
| 19 | + |
| 20 | + # Sets the bee bot starting square (x, y) |
| 21 | + scenario.set_beebot_start_position(3, 1) |
| 22 | + |
| 23 | + # Set the beebot sprite |
| 24 | + scenario.set_beebot_sprite("./img/Default/robot.jpg") |
| 25 | + # Sets the beebots starting direction, where "UP" is "Heading.NORTH", |
| 26 | + # other options are Heading.East etc |
| 27 | + scenario.set_beebot_heading(Heading.NORTH) |
| 28 | + |
| 29 | + # Sets the image on the map |
| 30 | + scenario.set_background("./img/Default/background.jpg") |
| 31 | + # If the image has no grid, one can be added by choosing a (R,G,B) tuple |
| 32 | + scenario.set_border_colour((0, 0, 0)) |
| 33 | + |
| 34 | + # This line addes an obstacle at square (2,1) |
| 35 | + # with sprite "./img/Default/obstacle1.jpg". |
| 36 | + # scenario.addObstacle(2,1) would add an obstacle at (2,1) with no sprite, |
| 37 | + # ie it will show whatever is on the background |
| 38 | + scenario.add_obstacle(2, 1, "./img/Default/obstacle1.jpg") |
| 39 | + # Add another obstacle |
| 40 | + scenario.add_obstacle(2, 3, "./img/Default/obstacle1.jpg") |
| 41 | + |
| 42 | + # Adds a goal square at (1,2) with sprite "./img/Default/goal1.jpg" |
| 43 | + scenario.add_goal(1, 2, "./img/Default/goal1.jpg") |
| 44 | + # add another goal |
| 45 | + scenario.add_goal(2, 0, "./img/Default/goal1.jpg") |
| 46 | + |
| 47 | + # This method means the goals must be met in the order added (Default) |
| 48 | + # scenario.set_ordered_goals(True) |
| 49 | + # This method means the goals can be met in any order |
| 50 | + scenario.set_ordered_goals(False) |
| 51 | + |
| 52 | + # Sets the sprite to be displayed when the robot crashes |
| 53 | + scenario.set_beebot_fail_sprite("./img/Default/robotx.jpg") |
| 54 | + |
| 55 | + # Copy the LICENSE from below into the Scenario |
| 56 | + scenario.set_license(LICENSE) |
| 57 | + |
| 58 | + # Writes the scibot file |
| 59 | + scenario.write_to_file() |
| 60 | + |
| 61 | +# Alter this to credit image sources |
| 62 | +LICENSE = """ |
| 63 | + GNU GENERAL PUBLIC LICENSE |
| 64 | + Version 2, June 1991 |
| 65 | +
|
| 66 | + Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/> |
| 67 | + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 68 | + Everyone is permitted to copy and distribute verbatim copies |
| 69 | + of this license document, but changing it is not allowed. |
| 70 | +
|
| 71 | + The full version of this license can be found here. |
| 72 | + https://github.com/gregcorbett/SciBot/blob/master/LICENSE |
| 73 | +
|
| 74 | + BeeBot image source. |
| 75 | + https://www.tes.co.uk/teaching-resource/bee-bot-sequence-powerpoint-6415227 |
| 76 | +""" |
| 77 | + |
| 78 | +if __name__ == "__main__": |
| 79 | + main() |
0 commit comments