I'm starting out with python, I only know the basics and I want to create a top-down type of game to the one I have currently. I've tried some solutions on the internet and sadly, none of them has worked for me.
As I said, I can't find a working solution as of right now but I've tried a few, including this one
How can I make the player “look” to the mouse direction? (Pygame / 2D).
I'm also using pygame
, forgot to mention that. I also have pgzero
if you need to know.
This code works and it just places a new actor when you click on it, but I want to have a type of 'character' with a weapon that can move around and 'look' at the mouse.
import pgzrun
from random import randint
apple = Actor("apple")
score = 0
def draw():
screen.clear()
apple.draw()
def place_apple():
apple.x = randint(10, 800)
apple.y = randint(10, 600)
def on_mouse_down(pos):
global score
if apple.collidepoint(pos):
print("Good Shot!")
place_apple()
score = score + 1
print(score)
else:
print("You Missed!")
quit()
pgzrun.go()
I just need to know how to make the picture 'look' at the cursor and then what each bit does to I know hot to do it for next time.
The first time I tried with the link given above, It returned a positional argument and I can't figure it out. I may have messed something up when I put in the fixed code but I don't know, I was kind of tired.