27.2 C
New York
Thursday, July 31, 2025

python – How do I create a taking pictures instrument that works on each side?


I’m a reasonably new person of pygame and i made a decision to begin out with a easy however ‘humorous’ recreation.
I’ve efficiently carried out leaping mechanics, motion mechanics and a one directional taking pictures mechanic, nonetheless when attempting to place this taking pictures 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 improper with it. It can solely shoot in 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 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 features for motion
def move_leftFruitM():
     # a operate is sort of a mini program in your major program so subsequently you mjst declare a variable world
    world SpeedFruitM, WeaponFruit_right, WeaponFruit_left
    world XfruitM  
    if py.key.get_pressed()[py.K_LEFT]: #

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles