demo-04-20/tron.py

47 lines
1.1 KiB
Python
Raw Normal View History

2020-04-28 10:51:27 +02:00
from draw import *
2020-04-26 17:19:23 +02:00
from math import floor
def main():
C_BLACK = (0, 0, 0)
xspd = 1
yspd = 0
scrw = 0
scrh = 0
while get_pixel(scrw, 0):
scrw += 1
while get_pixel(0, scrh):
scrh += 1
x = floor(scrw / 2)
y = floor(scrh / 2)
2020-04-26 17:19:23 +02:00
clear_screen()
play = True
while play:
try:
while play:
x += xspd
y += yspd
if x == scrw:
x = 0
if y == scrh:
y = 0
if x == -1:
x = scrw - 1
if y == -1:
y = scrh - 1
if not get_pixel(x, y)[0]:
play = False
set_pixel(x, y, C_BLACK)
for i in range(100): show_screen()
except KeyboardInterrupt:
xspd, yspd = yspd, -xspd
2020-04-28 10:51:27 +02:00
loop = True
while loop:
try:
fancy_text(0, 0, "GAME OVER, press AC/ON to continue.")
while 1:
show_screen()
except:
loop = False