I’m a reasonably new consumer of pygame and i made a decision to start out out with a easy however ‘humorous’ recreation.
I’ve efficiently applied leaping mechanics, motion mechanics and a one directional capturing mechanic, nevertheless when making an attempt to place this capturing mechanic to work each methods i couldnt work out why it didnt work, i’ve tried just a few issues to repair it however i have no idea what’s flawed with it. It’ll solely shoot in the direction of the left aspect. Additionally, I did create all of the code myself with out tutorials and exterior enter so maybe there’s a higher system for my capturing mechanic.
Right here is the code:
#Importation & initialisation import pygame as py import sys import random py.init() CLOCK = py.time.Clock() #loop variable operating = True #Colors White = (255, 255, 255) Black = (0, 0, 0) Blue = (0, 70, 200) #variables #Fruit service provider FRUITmerchant_HEALTH = 10 XfruitM = 500 YfruitM = 500 SpeedFruitM = 5 RIGHTDASH = False LEFTDASH = False JumpingF = False #weapns for fruit WeaponFruit_right = False WeaponFruit_left = False APPLE = False YfruitApple = 530 XfruitApple = 495 Apple_reach = 20 Apple_VELOCITYX = Apple_reach #Veg service provider XvegM = 100 YvegM = 500 SpeedVegM = 5 JumpingV = False #Forces YGRAVITY = 0.7 JUMPHEIGHT = 21 Y_VELOCITY = JUMPHEIGHT Y_VELOCITYV = JUMPHEIGHT # FOR VEG Air_Resistance = 1 #Setup Display screen = py.show.set_mode((600, 600)) #Fruit Service provider features for motion def move_leftFruitM(): # a operate is sort of a mini program in your principal program so due to this fact you mjst declare a variable international international SpeedFruitM, WeaponFruit_right, WeaponFruit_left international XfruitM if py.key.get_pressed()(py.K_LEFT): #
Thanks!