Questions tagged [pygame]

Pygame is a set of Python modules designed for writing video games. Use this tag only if you are using the Pygame library and not if you have a question about programming a game in Python in general.

Pygame is a free Python library released under the Lesser General Public License (GNU LGPL) version 2.1 (according to its GitHub page), aimed at creating video games. It's built on top of , is highly portable and runs on nearly every platform and operating system.

References

Documentation

Games using Pygame

19430 questions
3
votes
1 answer

pygame.mouse.get_pos() doesn't work (Python IDLE 3)

I'm trying to make python detect the position of the mouse. My code: import pygames pygame.init() size = (700, 500) screen = pygame.display.set_mode(size) WHITE = (255,255,255) screen.fill(WHITE) pygame.mouse.set_pos([100,100]) #I didn't move my…
CU12
  • 54
  • 7
3
votes
1 answer

Python how to delay bullet shooting

Thank you in advance for your time. If I fire a bullet with space key, a stream of bullets are created. If I would set a delay with time.sleep() inside 'if keys[pygame.K_SPACE]:' it would also freeze the loop for the set amount of seconds. How could…
Rokas98765
  • 119
  • 1
  • 9
3
votes
3 answers

How to find points on a circumference

How do I find a user defined amount of points on a circumference of a circle. Then when it has been found, place it in a 2 dimensional array for later use. For a slightly better view of it: Thanks for all the help :)
3
votes
1 answer

pygame platformer - How can I make the bottom solid?

So I was making a pygame platformer and I got stuck on one thing. I coudn't find a way to make the bottom of my platforms solid. The player could land on the top of it but when it tries to go through the bottom it bounces back down. I tried this but…
sanjay
  • 33
  • 5
3
votes
1 answer

Pixel perfect collision detection for sprites with a transparent background

How can I use Pygame's sprite module to detect the collision of two sprites with transparent backgrounds, so that it will return True only if the actual sprites, not the transparent backgrounds collide?
Peter Ye
  • 457
  • 2
  • 6
  • 17
3
votes
2 answers

Pyttsx "run" but without "wait"

I'm using pyttsx in my game, but I have encountered a problem - method runAndWait() causes it to stop for a brief period of time to say the queued text. It is a problem, because it messes up my time counting. Is it possible to say a text but without…
3
votes
2 answers

Is it proper to use .pyc files?

I have a Python project (a game) I would like to sell eventually. Would it be considered, by Python standards, acceptable to use a .pyc file instead of a regular .py source file to distribute the game, for security reasons? Would this even be…
sirsnow
  • 33
  • 5
3
votes
2 answers

Why is the pygame rect not in the right place?

I have collisions but I'd like my code to work so that when the bird touches the blocks, it print('x'). It is doing that but not in the right place of the bird. Apologies for the long code but it is needed for it to run. import random import…
Crawley
  • 600
  • 2
  • 8
  • 15
3
votes
2 answers

Pygame - How can I allow my users to change their input keys? (Custom Keybinding)

I'm trying to make a game and want the user to change their input keys, e.g. they press the A key and that changes the MoveUp variable to the A key so that when they press A in the game they move upwards. Any help or advice would be greatly…
cdd
  • 109
  • 11
3
votes
1 answer

Pygame window not receiving keyboard events on Mac

I am running this very simple tutorial on Pygame: https://www.youtube.com/watch?v=xh4SV3kF-zk I can't get keyboard events to be recognised by the game window. I have read a number of similar questions about this, but the answers don't seem right for…
Davtho1983
  • 3,827
  • 8
  • 54
  • 105
3
votes
2 answers

Pygame sprite jumps around after being rotated and then moved

I am creating a basic tanks game and I am currently working on the gun of the tank. I have managed to make the gun rotate around an axis and it moves whenever you press the "a" and "d" keys but sometimes when the gun has been rotated and then is…
Harry West
  • 35
  • 5
3
votes
2 answers

Rect collision on a pygame display; pressing a second key, after collision, causes rect to jump

I'm having issues getting this collision to work 100%. If I only press one key at a time, the collision seems to work fine, but if I press a key and continue pressing, while colliding, then press another key, the collision seems to account for both…
Tophiero
  • 33
  • 4
3
votes
1 answer

Pygame RogueLike window not launching when running function

When i try to run this piece of code the pygame window created in the game_start function does not launch. When i remove the game_main_loop function it does. I cannot figure out what is wrong with the function, anybody have any…
3
votes
1 answer

how to rotate a bullet according to the player's rotation

I've finally figured out how to shoot bullets but now I want to rotate the origin of the bullets on the rotation of the players head. Now it's only shooting straight on the x line. The mobs are working fine. I only need to add in collision and the…
Ectrizz
  • 139
  • 2
  • 10
3
votes
1 answer

How do you move a circle in python?

I am trying to make a circle that moves but I don't know how to make it work. I am using pygame as the package. I think it'll work if you update the circle but I don't know how to do that. import os, sys, math, pygame, pygame.mixer from…
Lumeriaux Yt
  • 45
  • 1
  • 1
  • 2
1 2 3
99
100