How to update text in PyGame?

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?

AttributeError when trying to use the pygame.Rect.scale_by() method

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

How to scale multiple images with a for loop?

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?

AttributeError: 'pygame.Surface' object has no attribute 'collidepoint'

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'

What is this error and how to fix it?…. this scale doesnt work

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