-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmova_o.py
More file actions
50 lines (35 loc) · 1020 Bytes
/
mova_o.py
File metadata and controls
50 lines (35 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# CodeSkulptor runs Python programs in your browser.
# Click the upper left button to run this simple demo.
# CodeSkulptor is tested to run in recent versions of
# Chrome, Firefox, and Safari.
# https://py3.codeskulptor.org/
# esse programa move o "o" quando você clica nos botões.
import simplegui
message = "o"
# [x, y]
posicao = [50,112]
# Handler for mouse click
def cima():
global posicao
posicao[1] -= 5
def baixo():
global posicao
posicao[1] += 5
def esquerda():
global posicao
posicao[0] -= 5
def direita():
global posicao
posicao[0] += 5
# Handler to draw on canvas
def draw(canvas):
canvas.draw_text(message, posicao, 48, "Red")
# Create a frame and assign callbacks to event handlers
frame = simplegui.create_frame("Home", 300, 200)
frame.add_button("cima", cima)
frame.add_button("baixo", baixo)
frame.add_button("esquerda", esquerda)
frame.add_button("direita", direita)
frame.set_draw_handler(draw)
# Start the frame animation
frame.start()