-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanimacao_sprite.py
40 lines (25 loc) · 921 Bytes
/
animacao_sprite.py
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
import simplegui
#Dados da imagem do player
LARGURA_SPLAYER = 120
ALTURA_SPLAYER = 24
PEDACOSH_SPLAYER= 5
PEDACOSV_SPLAYER= 1
ALTURA_LARGURA_PLAYER = (LARGURA_SPLAYER/PEDACOSH_SPLAYER, ALTURA_SPLAYER/PEDACOSV_SPLAYER)
i = 0
#CENTRO_SPRITE_PLAYER = (((LARGURA_SPLAYER/PEDACOSH_SPLAYER+(i*48) )// 2),
# (ALTURA_SPLAYER/PEDACOSV_SPLAYER // 2))
def timer_handler():
global i
i += 1
def draw_handler(canvas):
global i
i = i % 5
canvas.draw_image(image, (((LARGURA_SPLAYER/PEDACOSH_SPLAYER+(i*48) )// 2),
(ALTURA_SPLAYER/PEDACOSV_SPLAYER // 2)),
ALTURA_LARGURA_PLAYER, (250, 250), (240, 240))
image = simplegui.load_image('http://i.imgur.com/vZvMeuH.png')
frame = simplegui.create_frame('Testing', 500, 500)
frame.set_draw_handler(draw_handler)
frame.start()
timer = simplegui.create_timer(100, timer_handler)
timer.start()