Hi can someone help me with my pygame game, it's my first game and im really bad at this. Essentially im trying to make one of those sumo games where 2 players are on an icey ring (circle stage) and they have to push each other off to score points, im having trouble with the ice physics right now i understand that there has to be some type of acceleration when the key is held down and friction when it is released and im trying to do that right now but currently when the key is pressed it only increases the speed once, not continually which means u have to spam click it to go faster.
Also if you would like to help me with my game if i have any questions later i would greatly appreciate it uh i have discord if you would like to add thanks : vincent#3996
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)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…