I wanted to make a game, where player can move to any arrow and get a point for so. I can render the text, but cannot update it. I researched but no answer is there. My code was: import pygame, sys from pygame.locals import * import random import time pygame.init() FPS = 60 FramePerSec =… Read More How to update text in PyGame?
Just trying to draw a circle within a window as a player class, but having some trouble. Can’t get past this error, looked up other posts on the issue but to no avail. Understood that error stems from the need for x,y to be integers and tuple but don’t see how to solve. import pygame… Read More error, center argument must be a pair of numbers. newbie
Python script: import pygame left, top, width, height = 0, 0, 1, 1 my_rect = pygame.Rect(left, top, width, height) my_rect.scale_by(2) Result in terminal: pygame 2.2.0 (SDL 2.0.22, Python 3.8.8) Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: ‘pygame.rect.Rect’ object has no attribute ‘scale_by’ According to… Read More AttributeError when trying to use the pygame.Rect.scale_by() method
import pygame pygame.init() wn = pygame.display.set_mode((200,200)) x = 100 y = 100 class circle(): def __init__(self, x, y): self.x = x self.y = y def draw(self, x, y): pygame.draw.circle(wn, (255, 0, 0), (self.x, self.y), 5) circle.draw(x, y) What am I missing? I am new to all of this and I am really confused. The error… Read More How do I make this pygame class and .self work
I’m trying to make a game with pygame in which an object moves and i’m trying to get rid of its previous image by drawing a background colored object in its previous position, but for some reason it just wont work, and i’ve extracted the part of the code which fails import pygame, sys, math… Read More Python while loop bugs out
I’m trying to use a for-loop to iterate through a list of self classes. I want to give each one the same scale. def __init__(self): pygame.sprite.Sprite.__init__(self) self.image = pygame.image.load("Migue/m_normal.png") self.quieto = pygame.image.load("Migue/m_normal.png") self.andando = pygame.image.load("Migue/m_andando_normal.png") self.image = pygame.transform.scale(self.image, sizenorm) states = [self.quieto, self.andando] for i in states: i = pygame.transform.scale(i, sizenorm) This wont work, but… Read More How to scale multiple images with a for loop?
I am trying to make a logic in which i can subtract the geometrical shapes. Lets say i have to subtract a circle from a rectangle. The idea is to draw each point of the rectangle as a single individual point using win.set_at(). And then when we need to subtract the circle from the rectangle… Read More How to subtract geometry in pygame?
Making a button for a menu screen. I had to adapt from an example online so I could use a custom image to work as a button. Rather than using, play_button = pygame.Rect(50,100,200,50) Heres what I have so far, def main_menu(): while True: #menu background menu_background = pygame.image.load(‘game graphics/menu.png’) menu_background = pygame.transform.scale(menu_background, (screen_w,screen_h)).convert() screen.blit(menu_background,(0,0)) #menu… Read More AttributeError: 'pygame.Surface' object has no attribute 'collidepoint'
the error it shows TypeError: argument 3 must be pygame.Surface, not int please help me fix this . so the line is line 15 and line 21 that causes trouble… import pygame pygame.init() screen = pygame.display.set_mode((3840,2160)) running = True mouse = pygame.mouse.get_pos() pygame.display.set_caption("GermanBall") bg = pygame.image.load(r"C:\Users\tomarj\OneDrive – Tata Advanced Systems Limited\Desktop\War Crime\Tan.jpg") icon = pygame.image.load(r"C:\Users\tomarj\OneDrive… Read More What is this error and how to fix it?…. this scale doesnt work
First off, yes I’m a noob but I have ready meany tutorials on getting a character to jump which doesn’t seem too complicated but it’s not working. The character keeps incrementing up the screen. It seems the biggest challenge is using a usb controller but I don’t want to use a keyboard to controll the… Read More when character jumps it doesn't come back to the ground