Sunday, March 15, 2026

python – How do I create a capturing software that works on each side?


I’m a reasonably new consumer of pygame and i made a decision to begin out with a easy however ‘humorous’ sport.
I’ve efficiently carried out leaping mechanics, motion mechanics and a one directional capturing mechanic, nonetheless when making an attempt to place this capturing mechanic to work each methods i couldnt determine why it didnt work, i’ve tried a couple of issues to repair it however i have no idea what’s incorrect with it. It’s going to solely shoot in 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 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 capabilities for motion
def move_leftFruitM():
     # a perform is sort of a mini program in your important 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!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles