Show pygmy figures

I am using Python 2.7.6 with pygame and i am still new to programming and pygame.Is there a way i can make it where if i have numbers, it will go to 0 to 1 to 2 to 3 to 4 to 5 instead of just 0 to 5? Like the health system in earthbound, it doesn’t just drop, it ticks down one number at a time. i tried using time.sleep() in a for loop but it just paused my entire game for a second.

for i in range(7):
    dodged += 1

i tired it without the time.sleep() but it was too fast to even see.

for i in range(7):
    dodged += 1

Anybody know how to do this?

You should use pygame.time.set_timer
for periodic events in your game (in this case the number increasing. Run this code before your event loop:

increase_event = pygame.USEREVENT + 1
pygame.time.set_timer(increase_event, number_change_time_in_milliseconds)

And run this code in your loop:

if event.type == increase_event
    dodged += 1
Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Show pygmy figures

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录