We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f94d3eb commit e5ac1fcCopy full SHA for e5ac1fc
examples/conway.py
@@ -10,9 +10,11 @@
10
arena2 = bytearray(7 * 7)
11
12
def show():
13
+ img = microbit.Image(5,5)
14
for y in range(5):
15
for x in range(5):
- microbit.display.image.set_pixel(x, y, arena1[8 + y * 7 + x])
16
+ img.set_pixel(x, y, arena1[8 + y * 7 + x]*9)
17
+ microbit.display.print(img)
18
19
# do 1 iteration of Conway's Game of Life
20
def conway_step():
examples/maze.py
@@ -5,7 +5,7 @@
5
6
import microbit
7
8
-d = microbit.display.image
+d = microbit.display
9
ac = microbit.accelerometer
# the maze data, as binary numbers (outside walls are added automatically)
@@ -34,10 +34,15 @@ def get_maze(x, y):
34
else:
35
return 1
36
37
-def draw(x, y):
+def draw(x, y, tick):
38
39
for j in range(5):
40
for i in range(5):
- d.set_pixel(i, j, get_maze(x + i - 2, y + j - 2))
41
+ img.set_pixel(i, j, get_maze(x + i - 2, y + j - 2)*5)
42
+
43
+ # draw the player, flashing
44
+ img.set_pixel(2, 2, (tick & 1)*4+5)
45
+ d.print(img)
46
47
def main():
48
x = 0
@@ -60,10 +65,8 @@ def main():
60
65
y = min(15, max(0, y))
61
66
62
67
# draw the maze
63
- draw(x, y)
68
+ draw(x, y, tick)
64
69
- # draw the player, flashing
- d.set_pixel(2, 2, tick & 1)
70
71
microbit.sleep(50)
72
examples/pomodoro.py
@@ -12,7 +12,7 @@
CLOCK_ADJUST = 4/60
-ALL_LEDS_ON = Image('1,1,1,1,1\n'*5)
+ALL_LEDS_ON = Image('99999\n'*5)
def index_to_xy(i):
examples/simple_slalom.py
@@ -4,8 +4,6 @@
4
import microbit as m
-m.display.set_display_mode(1)
-
p = m.display.print
min_x = -1024
@@ -98,7 +96,7 @@
98
96
use_wall_y = max(wall_y, 0)
99
97
for wall_x in range(5):
100
if wall_x != hole:
101
- s(wall_x, use_wall_y, 32)
+ s(wall_x, use_wall_y, 6)
102
103
if wall_reached_player and not handled_this_wall:
104
handled_this_wall = True
@@ -108,7 +106,7 @@
108
106
score += 1
109
107
110
if player_update:
111
- s(player_x, 4, 255) # turn on new pixel
+ s(player_x, 4, 9) # turn on new pixel
112
113
p(i)
114
examples/watch.py
@@ -78,8 +78,8 @@ def show_time(time):
78
79
80
def show_colon(visible):
81
- display.image.set_pixel(2, 1, visible)
82
- display.image.set_pixel(2, 3, visible)
+ display.set_pixel(2, 1, visible*9)
+ display.set_pixel(2, 3, visible*9)
83
84
85
def get_clock_time():
@@ -98,16 +98,16 @@ def plot_LED_column(column, number):
if number <= 5:
for i in range(4, -1, -1):
if i < 5 - number:
- display.image.set_pixel(column, i, 0)
+ display.set_pixel(column, i, 0)
- display.image.set_pixel(column, i, 1)
+ display.set_pixel(column, i, 9)
105
if number > 5:
if i < 5 - (number - 5):
while True:
0 commit comments