Pygame游戏帮助:轻松/加速

问题描述 投票:0回答:1

嗨,有人可以帮我做我的pygame游戏,这是我的第一个游戏,对此我真的很不好。本质上,我试图制作其中两个玩家都在冰环上(圈台)的相扑游戏之一,他们必须互相推开才能得分,我现在在冰物理学上遇到麻烦,我知道必须按住某种键时会产生某种类型的加速,释放时会产生摩擦,我现在试图这样做,但是当前当按下此键时它只会提高一次速度,而不是连续地提高速度,这意味着您必须发送垃圾邮件才能单击它快点。另外,如果我以后有任何疑问,如果您想为我的游戏提供帮助,我将不胜感激。

import pygame, sys, time
from pygame.locals import *
import random


#Colors
colorRed=pygame.Color(241,59,62)
colorPurple=pygame.Color(200,254,249)
colorBlue=pygame.Color(52, 207, 235)
colorGreen=pygame.Color(100,182,100)
colorWhite=pygame.Color(255,250,250)
colorBlack=pygame.Color(0,0,0)
colorOrange=pygame.Color(242,164,0)
colorBrown=pygame.Color(148,103,58)

#Dimensions
w=800
h=600
pygame.init()
fpsClock=pygame.time.Clock()
screen=pygame.display.set_mode((w,h))
pygame.display.set_caption ('SUMO')
centerX=w//2
centerY=h//2

#Stage
stageR=250
def stage (centerX,centerY):
    """stage (centerX,centerY) - creates a stage with given centerpoint"""
    pygame.draw.circle(screen, colorBlue, (centerX,centerY),stageR)

#Character 1
xR=int((stageR//10))
x1=int(centerX-(stageR*0.8))
y1=centerY
x1_dir=0
y1_dir=0
x1_right=False
def char1 (x1,y1):
    """char1 (x1,y1) - creates char1 at given coordinates"""
    pygame.draw.circle(screen, colorRed, (x1,y1),xR)
print (x1)
print (centerX)
if x1_right==True:
    x1_dir+2




while True:
    screen.fill(colorBlack)
    for event in pygame.event.get():
        #Game Exit
        if event.type== QUIT:
            pygame.quit()
            sys.exit()
        if event.type==KEYDOWN:
            if event.key==K_d:
                x1_dir+=1
                x1_right=True
            if event.key==K_a:
                x1_dir-=1
            if event.key==K_w:
                y1_dir-=1
            if event.key==K_s:
                y1_dir+=1
        if event.type==KEYUP:
            if event.key==K_d:
                x1_right=False






    stage (centerX,centerY)
    char1 (x1,y1)
    x1+=x1_dir
    y1+=y1_dir
    pygame.display.update()
    fpsClock.tick(60)

嗨,有人可以帮我做我的pygame游戏,这是我的第一个游戏,对此我真的很不好。本质上,我试图制作其中两个玩家都在冰冷的环上(圈台)并且...

python python-3.x pygame easing
1个回答
0
投票

KEYDOWN事件仅在按下键时发生一次(请参阅pygame.event)。用pygame.event获取每帧中琴键的当前状态。如果按下a

© www.soinside.com 2019 - 2024. All rights reserved.