Questions tagged [pgzero]

pgzero (Pygame Zero) is a Python library providing a zero-boilerplate game development framework. It is based on another third-party library named pygame.

pgzero (Pygame Zero) is a Python library providing a zero-boilerplate game development framework. It is based on the library pygame.

PyPi: https://pypi.org/project/pgzero
Source code: https://github.com/lordmauve/pgzero
Documentation: https://pygame-zero.readthedocs.io

104 questions
1
vote
1 answer

Im trying to create a space dodge game and I'm having a few issues

Basically I'm trying to have it so that when the ship touches the meteor it plays an explode animation. I'm using colour detection for this as when i used player.colliderect(name) it was really inaccurate and began the animation when it was far away…
Whi_24
  • 41
  • 4
1
vote
1 answer

PyGame Zero - Reloading image from a folder

I am wanting to 'reload' an image in PyGame Zero. This image will be updated outside of the game - so when the image is updated I'd like the new image (same file name) to be shown on the screen. How can I achieve this? WIDTH = 500 HEIGHT =…
PlantPot
  • 49
  • 6
1
vote
0 answers

Trying to get actor to wrap around screen (go from one side to the other at edge of screen) also trying to get animation to work:

import pgzrun import pygame WIDTH = 850 HEIGHT = 425 #sprites title = Actor('title.png') #calling sprites and saying their pos title.pos = 400, 212 cont = Actor('cont.png') cont.pos = 470, 300 player = Actor('ship.png') player.pos = 100,…
Whi_24
  • 41
  • 4
1
vote
1 answer

i am trying to make the actor "player" show on screen (along with the other actors) and add controls to it

import pgzero, pygame #music, sprites and background music.play("temp.mp3") x = 0 y = 0 WIDTH = 850 HEIGHT = 425 screen = pygame.display.set_mode((WIDTH, HEIGHT)) title = Actor('title.png') #calling sprites and saying their pos title.pos =…
Whi_24
  • 41
  • 4
1
vote
0 answers

How do I make my player collide with both the sides and bottom of my platform

I am trying to make a game which has many platforming levels. I want to know how to make collision detection for all of the angles. In my code, when I collide on the sides of my platform, it makes my player go on the platform but I want it to not…
1
vote
3 answers

Adding value to object adds value to all objects of the same type

I am working with pygame libary. I have Actor classes (for game objects) and ActorContext classes (for game object lists): class ActorContext: list = [] alpha_range = 255 time_diff = 0 alpha_diff = 0 def add(self, obj: Actor): …
Matej J
  • 615
  • 1
  • 9
  • 33
1
vote
0 answers

Pygame Zero: How can I add a Surface to Pygame Zero after having the Player go "Gameover"

I am currently working on a game for a school project. Basically: The Character gets hunted by a rect that is constantly moving towards him. Now whenever it Collides I want a big red box to show up with the Text "Gameover" in the middle of the…
Ignitris
  • 55
  • 5
1
vote
1 answer

Pygame Zero: Actor.top somehow not working

So I am currentl programming a game in Pygame Zero and I am facing a problem. I don't want the character/Actor to move outside the game window. The Window is defined by WIDTH and HEIGHT. "Tesbold" is the Actor. Somehow this works when tried on the…
Ignitris
  • 55
  • 5
1
vote
0 answers

Pygame and PGZero- STILL can't get it to work. Currently on Python 3.6.7 Windows 10, using Sublime Text

I STILL can't get Pygame and PGZero to work. I have read everything I can find about making sure the whl file has correct python version version and bit. I have read the articles about using import pgzrun at the beginning and pgzrun.go() at the end…
Raekwon
  • 11
  • 3
1
vote
1 answer

Pygame Zero Player Animation Code Is Not Working

I have been trying to code a small game with a character that moves around. For some reason, I can't use gifs. After that, I turned the gif into a bunch of pngs and with that, I tried to write some code to animate it: def animate(): global…
Cyber_Hawk
  • 13
  • 5
1
vote
0 answers

pyinstaller failure when creating pygamezero game

We are creatign our first python game with pygamezero and mu. we have modified the code to import and run pgz, copied the pgz directory to the mu directory. installed pyinstaller via pip and added the relevant path. running pyinstaller spacegame.py…
Adam Price
  • 11
  • 1
1
vote
1 answer

How do I put multiple actors in a list and have them move - python pygame

How can I move actors in a list in pygame, here's what I've tried: ` boxes = [] for i in range(10): h = random.randint(0,200) w = random.randint(0,200) boxes.append( Actor("red.png")) def draw(): red.draw() for i in…
1
vote
0 answers

pygame zero will not download and will error out

Whenever I try to download pygame zero, with the command pip install pgzero, it gives me this message. Collecting pgzero Using cached pgzero-1.2-py3-none-any.whl (69 kB) Collecting numpy Using cached numpy-1.19.4-cp39-cp39-win_amd64.whl (13.0…
1
vote
0 answers

what function do I use for it to print something if it detects a mouse hovering over an object or element?

what function do I use for it to print something if it detects a mouse hovering over an object or element? Is it box.collidepoint(pos)? Also, I am having some problems with importing playsound using from playsound import playsound. It just opens a…
1
vote
1 answer

How to show astronaut in python game

I'm making code for a Python game and I have the following WIDTH = 600 HEIGHT = 800 player_x = 600 player_y = 350 def draw(): screen.blit(images.backdrop, (0, 0)) screen.blit(images.mars, (50, 50)) screen.blit(images.astronaut,…
user13675340