admin管理员组文章数量:1291144
I've only just recently began coding in pygame, and I am currently making a platformer game. I am trying to implement a cooldown for a dash, and can't get it to work. This is the code I have done for the keybinds (the dash part is in bold).
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_RIGHT:
moving_right = True
if event.key == K_LEFT:
moving_left = True
if event.key == K_UP:
if air_timer < 6:
player_y_momentum = -5
** if event.key == K_z:
if player_dash == False:
# if not player_rect+50.collideRect(tile_rects):
if player_flip == False:
moving_right == True
player_rect.x += 50
if player_flip == True:
moving_left == True
player_rect.x -= 50
player_y_momentum = 0
player_dash == True**
if event.type == KEYUP:
if event.key == K_RIGHT:
moving_right = False
if event.key == K_LEFT:
moving_left = False
I tried this block of code, thinking it was an easy fix, but i started the game and it didn't work, I could spam the dash as much as I wanted
if player_dash == True:
pygame.time.wait(10000)
player_dash == False
本文标签: Trying to make a cooldown for a dash in pygameStack Overflow
版权声明:本文标题:Trying to make a cooldown for a dash in pygame - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741525090a2383419.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论