Questions tagged [pygame]
A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.
440
questions
0
votes
0
answers
30
views
How can i make multi-line dialog box?
I'm trying to make a dialog box with pygame, and initially everything was going well. I printed the letters sequentially on the screen and it works very well in a single line of text, but when I use <...
-1
votes
2
answers
69
views
1
vote
1
answer
39
views
Using collision with classes in pygame
I am trying to make some games using classes. But I got a problem when trying to make the ping pong game. I made 2 paddles and a ball but I just do not understand how should I make the collision ...
0
votes
0
answers
12
views
Is there any way to compile a python script to web like unity webgl [duplicate]
I've been working on a game in pygame for a while and decided it was too much of a hassle to compile it to all the operating systems. So, naturally, I turned to the web. While I am well aware that you ...
0
votes
1
answer
25
views
Why do I get this error: "error: video system not initialized"?
The error occurs when I call
keys_pressed = pygame.key.get_pressed()
Here is the full code:
...
0
votes
1
answer
32
views
In pygame I am trying to add the text as an integer and it keeps crashing, why?
I am trying to convert the string as an integer when I am using the font.render() function but it keeps saying different things like it has to be a unicode or ...
0
votes
0
answers
24
views
Need to see if you clicked a rectangle in a grid. (Pygame)
Basically, I created a grid with this:
...
0
votes
0
answers
31
views
Not being able to display pygame.freetype text
I'm trying to make a game where the player has to dodge asteroids coming, and I'd like to display the lives. I looked up some tutorials and decided to settle on pygame.freetype. When I run the code ...
0
votes
1
answer
69
views
How to properly set up a lives system for a side-scroller in pygame
I have a game where the player has to dodge asteroids coming towards it, and I would like to incorporate a life system. Unfortunately, when I tried this, it still killed my player immediately. I ...
0
votes
1
answer
104
views
1920x1080 Image don't fit to 1920x1080 screen
I'm making a game with pygame and I wanted to add a background for my game. I'm trying to add a 1920x1080 background to a 1920x1080 screen, but part of the background is not visible.
My code:
...
0
votes
1
answer
74
views
pygame only moving when moving mouse
Every time I press the left or right arrow keys it moves a little however when I wiggle the mouse around while pressing the keys the player flys across the screen for no reason. I'm following ...
1
vote
1
answer
40
views
Optimizing overlapping units vision calculations in RTS using PyGame
Currently I'm developing a RTS game using Python/PyGame and I got some problems with fps drops when there are many units on the screen.
Using Snakeviz profiling I found out that the function ...
0
votes
1
answer
103
views
Is there a way to make a game that uses Python/pygame that will work through a web browser?
Is there any framework or method that will allow to use browser to run a 2D game made in python with pygame graphical library?
0
votes
1
answer
44
views
Pygame Traffic signal logic
I am currently working on a traffic simulator with Pygame, however i am struggling with implementing the logic of the traffic signals.
Any help is welcome.
My traffic simulation is grid based. The ...
0
votes
1
answer
31
views
How to generate reliable labels for game state using Python and Pygame
I've been looking into making a small game where you would walk around and do puzzles (perhaps do some combat if I can get the basic framework going). So far, Googling for general game patterns used ...
1
vote
0
answers
127
views
Circle and circle collision (with physics), but when lots of circles pile up things go wrong [closed]
I'm trying to make an as realistic as possible ball physics simulator. Currently, I worked out all the collisions between balls, and it works really well when there are few balls. But once you create ...
0
votes
1
answer
210
views
Collision detection between moving objects (in pygame)
I am trying to work out how to detect and resolve collisions between moving sprites in pygame, I followed the logic of this video: https://www.youtube.com/watch?v=VpSWuywFlC8
The basic idea is that I ...
0
votes
1
answer
26
views
How can I make pygame use a specific input device as the mouse?
I am working on (not really a game, but it's using pygame so I hope my question is on topic here).
The program appears to be looking at /dev/input/event0, which is ...
0
votes
1
answer
64
views
How can I make a hitbox around my image?
I'm really new to PyGame and trying to program a game, and I can't figure out how to make a hitbox that when this image hits the edge, the game stops it from going past the edges
...
0
votes
1
answer
21
views
circles originating from player position not showing up on pygame window
I'm kinda new to python and pygame, anyone know why this won't show bullets coming out from my character?
...
0
votes
1
answer
70
views
How do I change only the angle of a certain PNG relative to the position of the mouse? (Python, Pygame)
Basically, I'm doing a game for a school project and I am not really sure how to make a player point towards the mouse pointer in a pygame tab. also if anyone has ideas of how i could point a bullet ...
0
votes
0
answers
95
views
What is a good method for 2D isometric lighting in Pygame?
I'm making my first isometric game in Python using Pygame. It's a 2D tile-based dungeon crawler, but I want to create a nice lighting system. I've made a random level generator that creates the rooms ...
0
votes
0
answers
22
views
frameskipping in Pygame?
I am struggling to find a solution on how to skip frames and keep the game at a constant pace, I had tried using
...
1
vote
1
answer
55
views
What is the easiest way to make pixelated maps with obstacles in pygame?
So I have been trying to create a game with a small map that moves with the player. If the player goes to a wall, the camera also stops. No scrolling. If you want to discover an area, you go to it. ...
1
vote
2
answers
373
views
How to make objects move continuously while a key is pressed in pygame?
So I made a new game in pygame and after hours of debugging, I got to a stage where all of my objects get blitted onto the screen. Well, that's great but now I want movement for a particular object. I ...
0
votes
1
answer
87
views
How can I move the object constantly downward in pygame?
I want the object to move continuously downward even while I'm pressing the upward key in keyboard. Eventually causing the object to drop completely after some moment.
...
2
votes
0
answers
25
views
Pygame RESIZABLE display flag not working as expected on display re-initialization
I'm working on a simple script to be used as a personal code skeleton for pygame projects (making this primarily for practice with Python, PyGame, and game design) but I'm running into an issue with ...
0
votes
1
answer
93
views
Pygame : having trouble with implementing movement with vectors
I've been struggling a lot to learn how to use vectors in programming. Now I've successfully made my own vector class but I still can't use vectors for movement.
This is my class :
...
0
votes
0
answers
57
views
How to make player shooting?
this my code
...
0
votes
0
answers
69
views
-1
votes
1
answer
89
views
Create list of objects with a for loop pygame/python
Hi everyone I am trying to make a Mahjong Solitaire game using pygame.
I want to create a list of objects (the tiles of the game) using a for loop, but I can't manage to set a different type (the ...
0
votes
0
answers
71
views
Problem trying to detect input focus pygame
I am currently creating my version of the classic "Snake" game from scratch. I have added code that creates a dialogue box using the Tkinter module, allowing the player to choose whether or ...
0
votes
1
answer
64
views
Internal representation of checkers board
I am creating a game of checkers using the but am struggling to find a good internal representation for the game. My initial thoughts were to store the game board in a 2d list, with 0=empty, 1=always ...
-2
votes
1
answer
294
views
How do I port a game made with Scratch, Pygame, or JavaScript to the Switch?
I've been making my own games in many different languages (mainly Scratch, Python 3 with Pygame, and JavaScript), but, so far, none of them have been ported to the Nintendo Switch. How can I do this?
0
votes
0
answers
38
views
Layer sprites according to their vertical position
I need advanced blitting options in my game. It's a 2D game that has trees' sprites along with the player's sprite.
I want that every tree sprite to be displayed either in front of or behind the ...
0
votes
0
answers
41
views
Implementing growth in Snake?
I'm new at this, so I thought I'd start simple. Snake. I started with pygame, just looking some things up, and I've now got movement, random fruit generation, and a score counter.
...
0
votes
1
answer
222
views
Pygame : problem with calculating an angle between two points
I've been struggling to calculate the angle alpha between an object and a certain point M so that I can move that object to M.
To calculate alpha, I'm using ...
0
votes
1
answer
139
views
Unable to restart level in Python Pygame
So, I am making Flappy Bird and when the player dies I have the spacebar assigned to reset the game.
However, it's not working and I truly have no idea why (after like 3 hours of going through ...
0
votes
0
answers
83
views
How to draw player from the bottom up [pygame]
so I have this basic game I made with pygame, in the game I have this player sprite:
which is 16x28, problem is: all other sprites in the game are 16x16, so I want the player's hitbox to be 16x16 as ...
0
votes
1
answer
63
views
Pygame having trouble with surface.blits method
I got used to blit every image into the screen on a seperate line in Pygame but now I want to start using the pygame.Surface.blits() method.
According to the ...
0
votes
1
answer
58
views
How to blit a surface onto an already blitted surface in Pygame?
Consider the following code:
...
0
votes
1
answer
157
views
Pygame logic to make a player stop at obstacles without overlapping them
what's the best logic to force the player to change its direction when he's just next to an obstacle (building, rock, tree..) ?
I know this is related to collision detection but maybe my logic isn't ...
1
vote
1
answer
149
views
Pygame 2D : rotation around center not working properly
here is the code I use to rotate an image around its center:
...
0
votes
1
answer
58
views
Recycling bullets versus spawning them on demand
Until now, I know 2 bullets' algorithms/configurations : (I mean 2 ways of logically creating a bullet class)
Make a bullet class and create only one instance from it that represents the bullet.
The ...
1
vote
1
answer
327
views
Can't check collision between a mask and a rect in pygame
I'm new to using masks in Pygame and I'm having trouble with them.
I have already learned how to check collisions between two masks but I'm wondering about an effective way to check collisions between ...
0
votes
1
answer
191
views
What is surface locking and unlocking in Pygame?
I've read a little about surface locking and unlocking in pygame in Beginning Game Development with Python and Pygame. However, I still don't understand it.
I've read that it can improve the game ...
1
vote
1
answer
87
views
Ensure that random enemies don't spawn just near the player
I need to find a method using which I can ensure that random enemies and objects don't spawn just near the player. In fact, if they do, the player will be more likely to collide with them and lose.
...
0
votes
1
answer
92
views
How to make a number show how much the player will lose
Bit new to python. I'm making a game where you click on a strawberry, then it reappears in a new location, and so on and so forth. But you see, every time the player misclicks, they lose Score equal ...
0
votes
1
answer
113
views
Turn-based grid movement - each click of the clock you want to move the player
I am working one the movement for a tactical turn-based pygame.
I'm stumped as to how to get a selected object to move one tile at a time up to it's max movement to the mouse's pos.
Right now this is ...
1
vote
2
answers
1k
views
How do you rotate a sprite in pygame?
I am making a game in Pygame and I want it so every time the sprite jumps it rotates mid-air and lands on its side. A lot like Geometry Dash jumping if you have ever played that. I have some code but ...