29.2 C
New York
Monday, July 21, 2025

python – How do I create a taking pictures instrument 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 taking pictures mechanic, nevertheless when making an attempt to place this taking pictures mechanic to work each methods i couldnt work out why it didnt work, i’ve tried a number of issues to repair it however i have no idea what’s incorrect with it. It’s 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
working = 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 perform is sort of a mini program in your essential program so due to this fact you mjst declare a variable world
    world SpeedFruitM, WeaponFruit_right, WeaponFruit_left
    world XfruitM  
    if py.key.get_pressed()[py.K_LEFT]: #

Thanks!

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles