I've decided that I'm going to make a top down shooter game, but I can't figure out how to do omni directional shooting. Every website and video is based on pygame, not zero and this is my code so far:
#Imports
import pgzrun
import random
#Pygame Zero window size
WIDTH = 400
HEIGHT = 400
#Actors
floor = Actor("floor")
sadboy = Actor("sadboy")
#Variables
sadboy.x = WIDTH//2
sadboy.y = HEIGHT//2
#Lists
sadtears = []
def update():
#Movement
if keyboard.a:
sadboy.x -= 2
if keyboard.d:
sadboy.x += 2
if keyboard.w:
sadboy.y -= 2
if keyboard.s:
sadboy.y += 2
#Drawing floor and character
def draw():
screen.clear()
screen.blit("floor", (0, 0))
sadboy.draw()
for sadtear in sadtears:
sadtear.draw()
def on_key_down(key):
if key == keys.UP:
sadtears.append(Actor('sadtear'))
sadtears[-1].x = sadboy.x
sadtears[-1].y = sadboy.y
sadtear.y -= 5
if key == keys.DOWN:
sadtears.append(Actor('sadtear'))
sadtears[-1].x = sadboy.x
sadtears[-1].y = sadboy.y
sadtear.y += 5
if key == keys.LEFT:
sadtears.append(Actor('sadtear'))
sadtears[-1].x = sadboy.x
sadtears[-1].y = sadboy.y
sadtear.x -= 5
if key == keys.RIGHT:
sadtears.append(Actor('sadtear'))
sadtears[-1].x = sadboy.x
sadtears[-1].y = sadboy.y
sadtear.x += 5
pgzrun.go()
If anyone could help me, please do because I have been struggling on this for a while. Thanks a lot!