Updated Sketchy-Etch
Added option to clear drawing, added initial dialog with instructions, added ability to create circlessammachin-gprs
parent
1d02cdbc8d
commit
10aaf19204
|
@ -1,25 +1,40 @@
|
||||||
"""Accidentally created etcher sketch..."""
|
"""Accidentally created etcher sketch..."""
|
||||||
|
|
||||||
___name___ = "Sketchy Etch"
|
___name___ = "Sketchy-Etch"
|
||||||
___title___ = "Sketchy Etch"
|
___title___ = "Sketchy-Etch"
|
||||||
___license___ = "MIT"
|
___license___ = "MIT"
|
||||||
___dependencies___ = ["ugfx_helper"]
|
___dependencies___ = ["ugfx_helper", "dialogs"]
|
||||||
___categories___ = ["Games"]
|
___categories___ = ["Games"]
|
||||||
|
|
||||||
import ugfx, ugfx_helper, app
|
import ugfx, ugfx_helper, app, dialogs
|
||||||
from tilda import Buttons
|
from tilda import Buttons
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
j = 0
|
||||||
|
|
||||||
|
def reset():
|
||||||
|
global i
|
||||||
|
global j
|
||||||
|
i = int(ugfx.width() / 2)
|
||||||
|
j = int(ugfx.height() / 2)
|
||||||
|
ugfx.area(0, 0, ugfx.width(), ugfx.height(), ugfx.BLACK)
|
||||||
|
ugfx.area((i - 1) if i > 0 else 0, (j - 1) if j > 0 else 0, 3 if (i > 0 and i < (ugfx.width() - 1)) else 2, 3 if (j > 0 and j < (ugfx.height() - 1)) else 2, ugfx.GREY)
|
||||||
|
|
||||||
ugfx_helper.init()
|
ugfx_helper.init()
|
||||||
ugfx.clear()
|
ugfx.clear()
|
||||||
|
|
||||||
ugfx.area(0, 0, ugfx.width(), ugfx.height(), ugfx.BLACK)
|
dialogs.notice("Draw with joystick arrows\nHold joystick centre for circle\nA to clear\nB to exit", title="Sketchy-Etch")
|
||||||
|
|
||||||
|
|
||||||
i = int(ugfx.width() / 2)
|
ugfx.area(0, 0, ugfx.width(), ugfx.height(), ugfx.BLACK)
|
||||||
j = int(ugfx.height() / 2)
|
|
||||||
while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Buttons.BTN_B)) and (not Buttons.is_pressed(Buttons.BTN_Menu)):
|
|
||||||
|
circleSize = 3
|
||||||
|
reset()
|
||||||
|
while not Buttons.is_pressed(Buttons.BTN_B):
|
||||||
changed = False
|
changed = False
|
||||||
|
oldI = i
|
||||||
|
oldJ = j
|
||||||
|
|
||||||
if Buttons.is_pressed(Buttons.JOY_Right) and (i < (ugfx.width() - 1)):
|
if Buttons.is_pressed(Buttons.JOY_Right) and (i < (ugfx.width() - 1)):
|
||||||
i += 1
|
i += 1
|
||||||
|
@ -34,9 +49,20 @@ while (not Buttons.is_pressed(Buttons.BTN_A)) and (not Buttons.is_pressed(Button
|
||||||
elif Buttons.is_pressed(Buttons.JOY_Up) and (j > 0):
|
elif Buttons.is_pressed(Buttons.JOY_Up) and (j > 0):
|
||||||
j -= 1
|
j -= 1
|
||||||
changed = True
|
changed = True
|
||||||
|
|
||||||
|
if Buttons.is_pressed(Buttons.JOY_Center):
|
||||||
|
circleSize += 1
|
||||||
|
ugfx.fill_circle(i, j, circleSize, ugfx.WHITE)
|
||||||
|
changed = True
|
||||||
|
else:
|
||||||
|
circleSize = 3
|
||||||
|
|
||||||
|
if Buttons.is_pressed(Buttons.BTN_A):
|
||||||
|
reset()
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
ugfx.area((i - 1) if i > 0 else 0, (j - 1) if j > 0 else 0, 3 if (i > 0 and i < (ugfx.width() - 1)) else 2, 3 if (j > 0 and j < (ugfx.height() - 1)) else 2, ugfx.WHITE)
|
ugfx.area((oldI - 1) if oldI > 0 else 0, (oldJ - 1) if oldJ > 0 else 0, 3 if (oldI > 0 and oldI < (ugfx.width() - 1)) else 2, 3 if (oldJ > 0 and oldJ < (ugfx.height() - 1)) else 2, ugfx.WHITE)
|
||||||
|
ugfx.area((i - 1) if i > 0 else 0, (j - 1) if j > 0 else 0, 3 if (i > 0 and i < (ugfx.width() - 1)) else 2, 3 if (j > 0 and j < (ugfx.height() - 1)) else 2, ugfx.GREY)
|
||||||
|
|
||||||
sleep(0.05)
|
sleep(0.05)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue