|
|
@@ -78,30 +78,30 @@ Draw a Karel at 135X and 35y, facing west with a red background:
|
|
|
karel_west = draw_karel(canvas, centre_x=135, centre_y=35, orientation="west", background="red")
|
|
|
```
|
|
|
### Changing colour
|
|
|
-To change the colour of any created Karel, use recolour_karel(karel, colour, background).
|
|
|
+To change the colour of any asset, use recolour_asset(karel, colour, background).
|
|
|
For example changing a red/blue Karel to a green/yellow Karel:
|
|
|
```
|
|
|
my_karel = draw_karel(canvas, colour="red", background="blue")
|
|
|
-my_karel = recolour_karel(my_karel, colour="green", background="yellow)
|
|
|
+my_karel = recolour_asset(my_karel, colour="green", background="yellow)
|
|
|
```
|
|
|
|
|
|
-### Changing position
|
|
|
-To change the position of a Karel on the canvas, use move_karel(karel, x, y).
|
|
|
+### Changing position relative to current position
|
|
|
+To change the position of an asset on the canvas relative to its current position, use relative_move_asset(karel, x, y).
|
|
|
Where x is the amout of pixels shifted horizontally, and y is the amount of pixels shifted vertically.
|
|
|
To move a Karel up 10 pixes:
|
|
|
```
|
|
|
my_karel = draw_karel(canvas, colour="red", background="blue")
|
|
|
-my_karel = move_karel(my_karel, y=-10)
|
|
|
+my_karel = relative_move_asset(my_karel, y=-10)
|
|
|
```
|
|
|
|
|
|
To move a Karel down 10 and left 10 pixels:
|
|
|
```
|
|
|
my_karel = draw_karel(canvas, colour="red", background="blue")
|
|
|
-my_karel = move_karel(my_karel, 10, -10)
|
|
|
+my_karel = relative_move_asset(my_karel, 10, -10)
|
|
|
```
|
|
|
|
|
|
-### Rotating Karel
|
|
|
-To turn karel, use rotate_karel(karel, orientation).
|
|
|
+### Rotating
|
|
|
+To turn an asset, use rotate_asset(asset, orientation).
|
|
|
Orientation options:
|
|
|
* "right"
|
|
|
* "left"
|
|
|
@@ -116,19 +116,19 @@ Orientation options:
|
|
|
To turn a Karel to the right:
|
|
|
```
|
|
|
my_karel = draw_karel(canvas, colour="red", background="blue")
|
|
|
-my_karel = rotate_karel(my_karel, "right")
|
|
|
+my_karel = rotate_asset(my_karel, "right")
|
|
|
```
|
|
|
To turn a Akrel toward the south:
|
|
|
```
|
|
|
my_karel = draw_karel(canvas, colour="red", background="blue")
|
|
|
-my_karel = rotate_karel(my_karel, "south")
|
|
|
+my_karel = rotate_asset(my_karel, "south")
|
|
|
```
|
|
|
|
|
|
-### Erasing a Karel
|
|
|
-To remove a Karel from the canvas, use erase_karel(karel):
|
|
|
+### Erasing an asset
|
|
|
+To remove a Karel from the canvas, use erase_asset(asset):
|
|
|
```
|
|
|
my_karel = draw_karel(canvas, colour="red", background="blue")
|
|
|
-my_karel = erase_karel(my_karel)
|
|
|
+my_karel = erase_asset(my_karel)
|
|
|
```
|
|
|
|
|
|
### Generating a random hex colour
|
|
|
@@ -173,19 +173,20 @@ def main():
|
|
|
sleep(5)
|
|
|
|
|
|
# Change the colour of one Karel to random colours
|
|
|
- karel_east = recolour_karel(karel_east, "random", "random")
|
|
|
+ karel_east = recolour_asset(karel_east, "random", "random")
|
|
|
|
|
|
# Move one Karel
|
|
|
- karel_east_mirrored = move_karel(karel_east_mirrored, 10, 10)
|
|
|
+ karel_east_mirrored = move_asset(karel_east_mirrored, 10, 10)
|
|
|
|
|
|
# Wait five seconds
|
|
|
sleep(5)
|
|
|
|
|
|
# Erase four Karels
|
|
|
- erase_karel(karel_east)
|
|
|
- erase_karel(karel_east_mirrored)
|
|
|
- erase_karel(karel_west)
|
|
|
- erase_karel(karel_west_mirrored)
|
|
|
+ erase_asset(karel_east)
|
|
|
+ erase_asset(karel_east_mirrored)
|
|
|
+ erase_asset(karel_west)
|
|
|
+ erase_asset(karel_west_mirrored)
|
|
|
+
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
main()
|