Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
st7789_mpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
st7789_mpy
Commits
5f6bbbd6
Commit
5f6bbbd6
authored
Dec 14, 2021
by
russhughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor toasters.py demo tweak
parent
36fd428c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
examples/RP2/Waveshare-lcd-2/toasters/toasters.py
examples/RP2/Waveshare-lcd-2/toasters/toasters.py
+3
-3
examples/esp32_st7789/toasters/toasters.py
examples/esp32_st7789/toasters/toasters.py
+3
-3
No files found.
examples/RP2/Waveshare-lcd-2/toasters/toasters.py
View file @
5f6bbbd6
...
@@ -52,7 +52,7 @@ def random_start(tft, sprites, bitmaps):
...
@@ -52,7 +52,7 @@ def random_start(tft, sprites, bitmaps):
'''return new location along the top or right of the screen that does not overlap any sprites'''
'''return new location along the top or right of the screen that does not overlap any sprites'''
while
True
:
while
True
:
if
random
.
getrandbits
(
2
)
>
1
:
if
random
.
getrandbits
(
2
)
>
1
:
row
=
0
row
=
1
col
=
random
.
randint
(
bitmaps
.
WIDTH
,
tft
.
width
()
-
bitmaps
.
WIDTH
)
col
=
random
.
randint
(
bitmaps
.
WIDTH
,
tft
.
width
()
-
bitmaps
.
WIDTH
)
else
:
else
:
col
=
tft
.
width
()
-
bitmaps
.
WIDTH
col
=
tft
.
width
()
-
bitmaps
.
WIDTH
...
@@ -77,7 +77,7 @@ def main():
...
@@ -77,7 +77,7 @@ def main():
self
.
location
=
random_start
(
tft
,
sprites
,
bitmaps
)
self
.
location
=
random_start
(
tft
,
sprites
,
bitmaps
)
self
.
last
=
self
.
location
self
.
last
=
self
.
location
self
.
step
=
random
.
randint
(
0
,
self
.
steps
)
self
.
step
=
random
.
randint
(
0
,
self
.
steps
)
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
1
,
0
,
0
)
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
2
,
0
,
0
)
self
.
prev_direction
=
self
.
direction
self
.
prev_direction
=
self
.
direction
self
.
iceberg
=
0
self
.
iceberg
=
0
...
@@ -115,7 +115,7 @@ def main():
...
@@ -115,7 +115,7 @@ def main():
# if new location touches edge of screen, erase then set new start location
# if new location touches edge of screen, erase then set new start location
if
new_location
.
col
<=
0
or
new_location
.
row
>
tft
.
height
()
-
self
.
location
.
height
:
if
new_location
.
col
<=
0
or
new_location
.
row
>
tft
.
height
()
-
self
.
location
.
height
:
self
.
erase
()
self
.
erase
()
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
1
,
0
,
0
)
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
2
,
0
,
0
)
self
.
location
=
random_start
(
tft
,
sprites
,
self
.
bitmaps
)
self
.
location
=
random_start
(
tft
,
sprites
,
self
.
bitmaps
)
# Track post collision direction change
# Track post collision direction change
...
...
examples/esp32_st7789/toasters/toasters.py
View file @
5f6bbbd6
...
@@ -52,7 +52,7 @@ def random_start(tft, sprites, bitmaps):
...
@@ -52,7 +52,7 @@ def random_start(tft, sprites, bitmaps):
'''return new location along the top or right of the screen that does not overlap any sprites'''
'''return new location along the top or right of the screen that does not overlap any sprites'''
while
True
:
while
True
:
if
random
.
getrandbits
(
2
)
>
1
:
if
random
.
getrandbits
(
2
)
>
1
:
row
=
0
row
=
1
col
=
random
.
randint
(
bitmaps
.
WIDTH
,
tft
.
width
()
-
bitmaps
.
WIDTH
)
col
=
random
.
randint
(
bitmaps
.
WIDTH
,
tft
.
width
()
-
bitmaps
.
WIDTH
)
else
:
else
:
col
=
tft
.
width
()
-
bitmaps
.
WIDTH
col
=
tft
.
width
()
-
bitmaps
.
WIDTH
...
@@ -77,7 +77,7 @@ def main():
...
@@ -77,7 +77,7 @@ def main():
self
.
location
=
random_start
(
tft
,
sprites
,
bitmaps
)
self
.
location
=
random_start
(
tft
,
sprites
,
bitmaps
)
self
.
last
=
self
.
location
self
.
last
=
self
.
location
self
.
step
=
random
.
randint
(
0
,
self
.
steps
)
self
.
step
=
random
.
randint
(
0
,
self
.
steps
)
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
1
,
0
,
0
)
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
2
,
0
,
0
)
self
.
prev_direction
=
self
.
direction
self
.
prev_direction
=
self
.
direction
self
.
iceberg
=
0
self
.
iceberg
=
0
...
@@ -115,7 +115,7 @@ def main():
...
@@ -115,7 +115,7 @@ def main():
# if new location touches edge of screen, erase then set new start location
# if new location touches edge of screen, erase then set new start location
if
new_location
.
col
<=
0
or
new_location
.
row
>
tft
.
height
()
-
self
.
location
.
height
:
if
new_location
.
col
<=
0
or
new_location
.
row
>
tft
.
height
()
-
self
.
location
.
height
:
self
.
erase
()
self
.
erase
()
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
1
,
0
,
0
)
self
.
direction
=
rect
(
-
random
.
randint
(
2
,
5
),
2
,
0
,
0
)
self
.
location
=
random_start
(
tft
,
sprites
,
self
.
bitmaps
)
self
.
location
=
random_start
(
tft
,
sprites
,
self
.
bitmaps
)
# Track post collision direction change
# Track post collision direction change
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment