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
Filter by
Sorted by
Tagged with
0 votes
0 answers
10 views

How can I make my pygame window designate in the center of my screen

I want to make my game window designate in the center of my screen and I don't have any idea on how to manage that. I searched to find a solution but I couldn't. I read that you can manage that with ...
Konstantinos Paliotzikas's user avatar
-2 votes
2 answers
37 views

How can I lock my mouse in the borders of my game window and unlock it when I click ESCAPE

I want to make my mouse invisible and staying into the screen. When I click ESCAPE I want to unlock my mouse, make it visible and pause my game. Then, when I click my mouse in the window, I want to ...
Konstantinos Paliotzikas's user avatar
1 vote
1 answer
78 views

Pygame Zero Collision Detection Not Working

I am a beginner trying to make a game that gives me a point whenever the ball is on the target (a white line) and I press my mouse. For some reason, the game gives me a point when I click the mouse ...
dgf fdg's user avatar
  • 11
-1 votes
1 answer
67 views

Cannot import name 'Actor' from 'pygame.sprite' [duplicate]

I have the following python / pygame code: import pygame import time pygame.init() WIDTH = 800 HEIGHT = 600 from pygame.sprite import Actor alien = Actor('alien') def draw(): alien.draw() ...
Miguel Moura's user avatar
  • 38.1k
0 votes
1 answer
34 views

The BLEND_RGB_MULT is changing my image to be fully transparent and the transparent parts are black

When I use the BLEND_RGB_MULT flag to blit an image of a flashlight beam it changes the beam transparent and the transparent parts black as shown here Image of Flashlight beam Im using pygame zero as ...
Scyther4545's user avatar
0 votes
1 answer
50 views

How to add multiple animations or images for 1 actor in pgzero?

I have an rpg game like character that can move up, down, left, right, which uses 4 different actors each with 4 different animations. I draw items from a list, and change the list item into the actor ...
Popup Red's user avatar
0 votes
0 answers
47 views

Pygame Zero Importing a script into another

I created a game in Pygzero from a Tutorial this code works fine i cut many of the lines import pgzrun import random from pgzero.builtins import Actor, animate, keyboard, clock RASTER_BREITE = 16 ...
SwissBelgi's user avatar
0 votes
0 answers
21 views

How to make an explosion in pgzrun python?

I'm trying to make an explosion in Python by pgzrun. Note that my files are in the right folders This is my code: from pgzrun import * from pgzhelper import * from random import * TITLE = "title&...
hoangnguyenth's user avatar
0 votes
2 answers
120 views

Is there a way to change volume of sounds in Pygame Zero?

I'm working on fully fleshing out a game I made following a tutorial, and have been trying to incorporate sound effects into the finished thing. However they are way too loud and I can't seem to find ...
Bee_Baguette's user avatar
0 votes
2 answers
60 views

How to color a single pixel in pygame zero

I can't and don't want to know how to use images in pygame zero. I thought of an alternative by making a spritesheet with the def function. I can't figure out how to color a pixel in a specific ...
31schral's user avatar
0 votes
0 answers
30 views

Trouble switching from intro screen to first level

I have basically created a "Maze" game in pygame (or at least tried to). The game has 3 levels with a game sprite and collectable stars that add to the "score" of the game. The ...
Nasrullah Hussain's user avatar
0 votes
0 answers
32 views

i cant make a cooldown on a CPS variable

Here is the code: def update(dt): global puan,cps clock.schedule(cps, 1.0) puan += cps here is the variable: cps = 0 I tried making it increase puan variable by 1 every second but it ...
clq's user avatar
  • 11
0 votes
1 answer
41 views

I cant increase clickpower variable on my game

So i tried to make an clickpower variable on my game. I tried making these: clickpower = 1 And the part where you buy an upgrade and increase your clickpower by 1. if upgbutton.collidepoint(pos): ...
clq's user avatar
  • 11
0 votes
1 answer
44 views

Get the name of Actor who collided with another actor

I am trying to make a simple game with a square going up and down in Pygame Zero, but I couldn't use any if statements. I am wondering what alternatives do I have for if player.y>downLimit or ...
Azbojrn's user avatar
0 votes
1 answer
422 views

Unable to find vcvarsall.bat (Unsolved for 2022 version, Python) [duplicate]

I've been trying to instsall pgzero library for python, but however it keeps giving me an error: "unable to find vcvarsall.bat " I have been searching over StackOverflow, it shows up how to ...
Aleksandra Milicevic's user avatar
1 vote
1 answer
210 views

How to fix my Pygame Zero incomplete background error

I am trying to complete a a python course (beginner) and I'm trying to make a game using pgzero. The problem I am encountering is that the background is not loading correctly i.e. the size of the ...
LekkerCoder's user avatar
0 votes
2 answers
1k views

Can't start PyGame Zero (pgzrun) from cmd

I can't start PyGame Zero window from cmd. According to book I bought my kid, I suppose to start it with pgzrun test.py Unfortunteally what I get is: 'pgzrun' is not recognized as an internal or ...
Tomek's user avatar
  • 711
0 votes
0 answers
74 views

Python Pygame Zero: Stuck on Not responding

so I was programming with Python, specifically Pygame. I came across a few problems, which I have fixed. But my latest problem, is that when I ran the game, the window is only black. when My code so ...
Azbojrn's user avatar
1 vote
1 answer
224 views

How can I implement on_mose_move method in pgzero?

So I'm trying to write a simple Arkanoid game, using only pgzero (!not pygame), and I want my paddle to move not using my keyboard, but using my mouse, so that the paddle moves left or right following ...
maksonios's user avatar
1 vote
1 answer
76 views

animation loop only cares about first item in list

In a simple pygame zero 2D game, I have a list of Actors that I'm looping through to ensure that they don't run off the side of the screen. However, going right, only the leftmost item in the list (...
beachCode's user avatar
  • 3,362
2 votes
2 answers
1k views

Resizing a sprite with Pygame Zero

I am making a space invaders game using pgzrun and I am trying to resize a sprite I have. I tried to research how to do it and I was not able to find a command. There is a command that does it in ...
Mr. Meerkat's user avatar
0 votes
0 answers
194 views

Pygame Zero only showing some of the background

I haven't found a question anywhere else which matches mine, but sorry in advance if I'm duplicating. I am doing a python course and I am making a game with pgzero. I have not completed it, but I have ...
Aahan's user avatar
  • 1
1 vote
1 answer
80 views

How do I make it so that it doesn't input more than once?

if keyboard.h and start == False: start = True print("hello?") dotty_move() if keyboard.h and start == True: start = False print("bye") ...
Whi_24's user avatar
  • 41
1 vote
1 answer
67 views

Making a Bullet move towards a Target without following the Target using Pgzhelper in Pygame Zero

Question: How can I make a bullet move towards a target without following the target using Pgzhelper in Pygame Zero? I wanted to share this with a lot of people that may have the same trouble using ...
AIzen Vermillion's user avatar
0 votes
1 answer
647 views

Thonny: No module named 'pgzrun'

I've been successfully using Thonny with Pygame and Pygame Zero for a while. Work upgraded the PCs to 4.0.0 (Python 3.10.4) and now I get the following error: import pgzrun ModuleNotFoundError: No ...
wibbleface's user avatar
1 vote
1 answer
47 views

What makes PyGame Zero an API? [closed]

I'm trying to understand what an API is. Consider the special case of PyGame Zero, which is an API. Wikipedia says that an api is a way for two or more computer programs to communicate with each ...
Nik's user avatar
  • 21
0 votes
1 answer
701 views

screen: Any "screen" is not defined in pygame zero

I'm coding a simple quiz game with pygame zero and pygame. But somehow the screen is not defined. I'm very new with coding so I mostly rely on stackoverflow. Didn't find anything that answers my ...
Legalybis's user avatar
0 votes
1 answer
294 views

Transparent rectangles in PyGame Zero

I'm using screen.draw.rect() to draw rectangles with PyGame Zero. They will be used as a collision map on a game. I can't work out how to make them transparent though. The only documentation I can ...
wibbleface's user avatar
0 votes
0 answers
125 views

Python hand recognition

for my last year in high school i need to make this project. It is the game "pong" but instead of buttons you use your hand to move the paddles. I tried writing the code but i am stuck, it ...
AWwwYeEAHh's user avatar
0 votes
2 answers
876 views

python ModuleNotFoundError: No module named 'pgzrun'

I have a problem with python programming, when I'm trying to write a game, it says: No module named 'pgzrun',but I had already install pyzero.On windows,it works perfectly,but on my macbook,it could ...
Jacob911's user avatar
0 votes
1 answer
940 views

How can I hide and show actors in python

So there's this game I'm making and I have the play button as an actor, how do I make it so that when I click it, it disappears? Using pgzero on windows. PS: I have everything down but the ...
janajayjana's user avatar
-1 votes
1 answer
301 views

Can you connect a controller to Pygame Zero?

I have programming as a subject in school, and this is our last project of the semester. For our last task we are going to use replit.com, which use PygameZero. Which from my understanding, is a ...
TogiTogi's user avatar
1 vote
0 answers
19 views

Stuck on how to make text appear as "assets" enter circle

Making a small game through pygame zero. trying to get text to appear on "assets" as they enter the circle. Have tried different methods with rect but end up with errors. This is apart of my ...
GATORSSSS's user avatar
1 vote
1 answer
520 views

Adding a text input field in PyGame Zero?

Is it possible to add a text input field into a Pygame Zero game? I can't see it in the docs but may have overlooked it.
PlantPot's user avatar
0 votes
1 answer
520 views

How do we tell if two sprites are colliding in Pygame Zero?

I recently started coding in Pygame Zero before starting Pygame. I was making a game and the I need to see if two of the sprites are colliding. How should I approach this? The two sprites: [1]: https:/...
Midyan Goel's user avatar
0 votes
1 answer
96 views

How to use variables in text function in pgzero

In my game, I want to make a score function. How to make it to display variables in the pgzero text funtion the code to display text is: screen.draw.text(score, (70, 30), color="orange") but ...
CodeWizard777's user avatar
0 votes
1 answer
429 views

Not able to display text in python with pgzero

I am making a simple game in pgzero, but the screen. function never seems to work correctly. when I try to display text at the start like so: screen.draw.text("Hello", (50, 30), color="...
CodeWizard777's user avatar
0 votes
1 answer
184 views

Pgzero errors that I cant figure out

I am writing a python (pgzero) project for a simple game with my teacher, but I wanted to improve it a bit. After adding something like a minimap, everything was fine, but after writing the next stage ...
Olek's user avatar
  • 1
-1 votes
2 answers
399 views

How to stop the sound in pgzrun (Pygame Zero) when my game ends?

the sound plays right now for eternity and I only want it to play once when the game ends. I've looked it up everywhere but I really cannot find any good and helpful solution to this problem. I use ...
I_code's user avatar
  • 1
0 votes
0 answers
27 views

Is there any way for me to be able to repeat this class from anywhere in the code?

I want to be able to reshuffle/re-randomize the numbers which is outputs. Is there any way to do that from anywhere in the code? Here's the class which I'm referencing: class Foe(Actor): #v ...
Whi_24's user avatar
  • 41
0 votes
1 answer
149 views

python sometimes runs normally, but sometimes doesn´t do anything at all

I am setting up python for the first time I have a beginners book that I am following This works fine from IDLE for count in range(10): if ((count % 2) == 0): print(count) print (&...
Ham's user avatar
  • 1
2 votes
1 answer
106 views

I wrote a line to display hello in pygamezero but instead its showing white blocks instead of texts

i executed the following code def draw(): screen.draw.text("hello", topleft=(10 , 10)) but the output I get is just 5 white blocks instead of hello enter image description here
Tathagat's user avatar
-2 votes
2 answers
68 views

How to add wrapping in pygame/pygame zero

If you can I would like the wrapping to be an add-on to the code I have already, as this code I know works seamlessly and smoothing going from one side to the other. Basically the code I have allows ...
Whi_24's user avatar
  • 41
1 vote
1 answer
492 views

How can I export Pgzero (pygame zero) to .exe?

I am just wondering how can I make an executable from pgzero game. I have tried for hours with no success. pyinstaller always had some errors during exporting, or opening .exe . Or exe file did ...
Dielna Reboot's user avatar
1 vote
1 answer
68 views

Fuel cans not showing up

I'm programming a game in Python 3.7 using the module Pygame zero. The name of the game is "Road rage". I'm trying to make fuel cans showing up on he road to collect them, but for some ...
Henryk's user avatar
  • 13
0 votes
1 answer
105 views

How to change the background of the game when touching edge

I'm making a rpg game in pygame and I don't know how to make the background change when touching edge and when I try, it won't work and it says a syntax error at line 31 import pygame WIDTH = 480 ...
green's user avatar
  • 1
0 votes
1 answer
65 views

How do I make my rocket go back to its position when hitting the border?

I am new to programming and started with pygame zero. I am making a little game where you shoot a rocket to an alien. But my rocket keeps stuck to the border when fired, I made a reload function but I ...
bongost's user avatar
1 vote
3 answers
227 views

Problem with the smoothness of the fly's movement

I'm learning programming and trying to write my own simple pgzero game. Attempts to make a smooth fly movement in def update (): to random coordinates. Tried animate, unfortunately failed, ended up ...
Slavo Heys's user avatar
1 vote
1 answer
93 views

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 ...
Whi_24's user avatar
  • 41
1 vote
1 answer
213 views

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 ...
PlantPot's user avatar