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
0
votes
1 answer

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 an error comes up like this: AttributeError: 'int' object…
CodeWizard777
  • 71
  • 1
  • 10
0
votes
1 answer

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="orange") it comes out saying screen is not defined yet when I…
CodeWizard777
  • 71
  • 1
  • 10
0
votes
1 answer

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 of the code, it stopped working completely. For…
Olek
  • 1
0
votes
0 answers

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 constructor v def __init__(self, image): …
Whi_24
  • 41
  • 4
0
votes
1 answer

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 ("is even") else: print(count) …
Ham
  • 1
0
votes
1 answer

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 HEIGHT = 365 player =…
green
  • 1
  • 1
0
votes
1 answer

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 want it to go automatically ( when it hits the…
bongost
  • 1
  • 1
0
votes
1 answer

AttributeError: 'list' object has no attribute 'x' in Python

I'm working on a basic game with python, but the system gives an error impostors.x = new_x_pos AttributeError: 'list' object has no attribute 'x' Below is my code, can anyone tell me what I'm doing wrong? I've checked very carefully but still can't…
0
votes
0 answers

Pygamezero code, My code works when I don't have any code after this, why is this?:

backg.pos = 242, 105 WIDTH = int(backg.width + 200) HEIGHT = int(backg.height + 50) def draw(): screen.clear() backg.draw() print("hi") I have a picture called dining that I am trying to use as a background in a game which works just fine…
0
votes
1 answer

How to make omni directional bullets in Pygame Zero

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…
user16451666
0
votes
1 answer

pygame surface is cutting off in the middle despite being the same size as the screen

screen = pygame.display.set_mode((WIDTH,HEIGHT)) canvas = pygame.Surface((WIDTH,HEIGHT)) def makefunnytiles(saice): global WIDTH global HEIGHT global screen global roomdata global tiledefinitions print("Baking Tiles") …
Rush Fox
  • 1
  • 1
0
votes
2 answers

I made a very simple Pygame Zero game, but my Actor image and the screen.clear() is not working. Can you help me fix this?

This is the full code for the very bad game example. import pgzrun from random import randint from pgzero.builtins import Actor, animate, keyboard apple = Actor('apple') def draw(): screen.clear() apple.draw() def place_apple(): …
0
votes
0 answers

How to make ship shoot?

import pygame WIDTH = 1000 HEIGHT = 500 bg=Actor("bgbgbg") ship = Actor('ship_f') ship_en=Actor('ship_enemy') blaster1=Actor('blaster') a=random.randint(2,4) def draw(): screen.clear() bg.draw() ship.draw() ship_en.draw() …
SlazZzor
  • 3
  • 4
0
votes
0 answers

How to make one object move after another?

import random WIDTH = 500 HEIGHT = 500 bg = Actor('bg_space') platform = Actor('platforma') ball = Actor('ball') a=random.randint(-2,2) b=random.randint(3,4) platform1=Actor("platforma1") def draw(): screen.clear() bg.draw() …
SlazZzor
  • 3
  • 4
0
votes
1 answer

Why is my Pygame Zero program 'not responding' when I try to rotate Actor?

I've just started trying to teach myself Pygame Zero, because we are doing an assignment on it in class next term and I want to be prepared. I tried to make a simple program where your spaceship constantly accelerates forwards and you can use the…