Category "pygame"

How to make MOUSEBUTTONDOWN to only detect the left clicks?

MOUSEBUTTONDOWN detects Left, Right and MouseWheel events. I want to make it to only detect the left clicks. Source Code: import pygame, sys, time from pygame.l

Invalid color argument in pygame when trying to gradient

I'm trying to change each value of RBG from one color to another target color. My window is 700 units in width and I'm trying to draw 350 rectangles, each 2 pix

Pygame installed on windows, getting "pygame.error: Failed loading libwebp-7.dll" when trying to call pygame.image.load()

I've got python 3.9.1 running on a windows 10 machine. I have pygame 2.0.1 installed on my machine via pip (python -m pip install https://github.com/pygame/pyga

Python 'Out of memory' when opening image

import pygame from pygame.locals import * \ image = pygame.image.load('.\\w.jpg') I'm trying to load an 59MB jpg file and it fails saying 'Out of memory' I'm

Why when import pygame, it prints the version and welcome message. How delete it?

Why is there a message when I import pygame, it prints the version and welcome message. The message reads "pygame 1.9.4 Hello from the pygame community. https

Pygame window jumps out and disappears immediately

im very new to python, and im currently at chapter 12 on Python Crash Course. it asks me to build an alien invasion game, and im stuck at this point where I wro

how to remove draw objects from pygame window?

I am creating a game using pygame and python. I have drawn a rectangle in the window which acts as a button. But i need to know how to remove the button once it

How to change cursor in pygame?

I have a button in my pygame program. Whenever my cursor is hovering over the button, I want the cursor to change to this: I already know how to get the positio

How to set the pivot point (center of rotation) for pygame.transform.rotate()?

I want to rotate a rectangle about a point other than the center. My code so far is: import pygame pygame.init() w = 640 h = 480 degree = 45 screen = pygame.d

Pygame Collision detection `colliderect()`

While going through the docs of pygame, there was a method of pygame called colliderect() that is used to test if two rect objects have overlapped. colliderect

framerate independent movement breaking at higher fps?

I am trying to understand framerate independence and wrote this test code: import pygame, sys, time pygame.init() screen = pygame.display.set_mode((1280,720)) c

pygame - How to display text with font & color?

Is there a way I can display text on a pygame window using python? I need to display a bunch of live information that updates and would rather not make an imag

How to block calls to print?

Is there a way to stop a function from calling print? I am using the pygame.joystick module for a game I am working on. I created a pygame.joystick.Joystick obj

Uninstalling pygame on linux

I have been trying to uninstall pygame, but i'm not sure how and i couldn't find any resources to help me. I had installed pygame with the command python3 -m pi

Pygame change level - level made of list

Hello i am new in pygame. And i have used this example: http://pygame.org/project/1061/ The example shows how to chack for collision, make a level from a list a