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 carried out leaping mechanics, motion mechanics and a one directional taking pictures mechanic, nevertheless when attempting to place this taking pictures mechanic to work each methods i couldnt determine why it didnt work, i’ve tried just a few issues to repair it however i have no idea what’s incorrect with it. It is going to solely shoot in the direction of the left facet. Additionally, I did create all of the code myself with out tutorials and exterior enter so maybe there’s a higher system for my taking pictures 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 = py.show.set_mode((600, 600)) #Fruit Service provider capabilities for motion def move_leftFruitM(): # a operate is sort of a mini program in your predominant 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!