Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [pygame]

A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.

0
votes
1answer
12 views

How to convert coordinates between world coordinates and screen coordinates

I am using a tilemap in which I have square tiles. Knowing that, the size of the screen and the player position(in world coordinates) how I convert between this systems? Is there any formula?
0
votes
1answer
15 views

PyGame - Top down shooter mechanics

I'm currently developing a game for some school work using the PyGame library for Python. I'm almost done with most of the game's core mechanics, but have gotten hung up on the shooting mechanics. My ...
0
votes
0answers
22 views

Generating a tile map in pygame

I have this code that, in my opinion it should work, but it don't. So far I figured out how to get the tile position and position in windows of the top left tile but I can't do the other tiles. I am ...
0
votes
1answer
37 views

Finding Closest of 8 Possible Angles to Theta Value

I'm working on creating a gesture recognition system, and I saw one simple implementation that isn't as accurate, but is really easy to implement. The idea is that you have a unit circle with the 8 ...
0
votes
0answers
30 views

Unity like RigidBody physics in PyGame

I am trying to make game but first I want to make simple simulator. The goal is to have a ball fall onto a surface and then roll off the edge. Here is my code: ...
0
votes
1answer
22 views

Scrolling Camera in Pygame is not working properly

I implemented a camera with edges in 2D side scrolling game using Pygame, it is working but sometimes it will scroll for more than it should have, and in case of using different moves that involved ...
0
votes
0answers
25 views

Cant load image into Pygame

I just started to get into python and pygame and i've been trying to load an image into a pygame window using Thonny, I saved the image and my code file into the same folder but an error message keeps ...
0
votes
0answers
20 views

Why doesn't my pygame window close on MacOS?

I am trying to create a window and then close the window. Everything runs smoothly until I click the red X. When I click it, the window doesn't close and all that happens is that the colourful red ...
0
votes
1answer
19 views

Pygame OpenGL init causes an X Error

...
0
votes
1answer
25 views

Drawing each sprite at different location

I can draw multiple sprites but they are all on top of each other at (0,0). How would I make each sprite appear after one another in a row? My Rect class and Draw function: ...
0
votes
1answer
23 views

How do I draw a rectangle in Pygame?

I am getting the error "AttributeError: 'Rect' object has no attribute 'draw'" with this code: ...
0
votes
1answer
39 views

Getting event types in Pygame

I want to have the type of an event from the event queue to decide certain actions (i.e. if it is a joystick event or a keyboard one), but the dir of events is an ...
1
vote
1answer
50 views

How to resize a surface in Pygame?

How can I resize a Surface object in Pygame? Is there a way to bind a surface object into a Rect object, so that resizing the ...
1
vote
1answer
49 views

How to get camera to follow car

i am making a top down racing game where the car progresses along the track, however i need the camera follow the car as it progresses through the track. I am unsure how to fix the error. I am new to ...
0
votes
2answers
82 views

Pygame platformer - Making sprite jump

I am currently trying to make a Mario-type platformer using pygame and the MVC design pattern. My progress as of right now is getting a character on screen and having it move left and right. My goal ...
0
votes
0answers
39 views

Generating Platform Scroller world using Chunk

I want to create a level for 2D sidescrolling platformer game. This level will have a series of platform, wall, etc. For an example, below is a Platform class, with a size of 32 x 32 ...
0
votes
0answers
96 views

How can I raycast a floor in a simple raycasting engine?

I've been following the infamous lodev raycasting tutorial for a little while now but I can't make heads or tails of how the raycasting for the floor/ceiling works. He seems to be drawing the floor ...
1
vote
1answer
86 views

How to Create a Perfect Dash (Quick Movement) in Pygame

I am trying to create 2d side scrolling platform similar to Megaman. Here is the progress so far: Red box is the spriteholder while blue box is the hitbox of the character. The sprite I use is random ...
0
votes
1answer
42 views

Terrain Rendering/Update Failure Python 3.x

I have begun to create a procedurally generated RPG using Python, and I am having trouble with rendering the terrain. What is happening: I generate some terrain from some files, or create/save new ...
1
vote
2answers
759 views

Adjusting collision hitbox size with Pygame

So I coded a 2d sidescrolling platform, everything is fine except this: As you can see, the sprite is standing at the platform when her feet is not in the platform anymore. I want to adjust the ...
-1
votes
1answer
52 views

Having trouble making more than 1 clickable object

I am a student trying to figure out how to make multiple clickable objects in pygame. I was able to make 1 working clickable object (dx,dy) work, but when I tried to make another clickable object (qx,...
0
votes
1answer
72 views

How do I port a game which uses print-output to pygame font rendering with the least amount of work?

I've been working on a text based RPG. It's pretty simple, I'm not very experienced with Python, or any other language for that matter. Edit: For context, I recently posted this question: Python 3: ...
1
vote
0answers
95 views

Pygame collision

I'm making a dungeon game, and I'm making the collision system. There is an object obstacle, which has got these properties: ...
4
votes
2answers
164 views

Simple 2D games - what is faster to render - images or drawing?

I am developing simple 2D environment in Pygame (Python 3.6), however I think this question is general. The environment is moving (player is rendered on the same position and everything else is ...
0
votes
0answers
70 views

Performance issue for simple pong game in pygame

I have made a simple pong game in pygame, where enemies and items fall down. However, even though it runs at 60fps, it stutters really often which leads to the game being annoying to play. I have ...
0
votes
2answers
187 views

How to move a sprite quickly whilst animating it?

At the moment I am creating a program in Python, and Pygame, similar to Fire emblem, so a game that has a tile based system in which the sprites use to move to and determine location. I have been able ...
0
votes
0answers
55 views

Rotating scenario in pygame

I want to create a top-down shooter and I am having performance problems with rotate or rotozoom in pygame. The effect I want is present in Daedalus (https://www.youtube.com/watch?v=ARclVI1e9k8&t=...
1
vote
1answer
147 views

How can I add 3D animation to my Pygame window?

I've developed a quiz game using Pygame but now I'm being asked to implement a 3D animation element (a game show host) to the game. I used Pygame as I was told it would be an easy enough language to ...
3
votes
1answer
106 views

Behavior after collision using masks overlap

I'm using masks to make collision detection in a game using pygame. The detection works well, but I have had problems with the behaviour after collision. In most games, the obstacles are vertical or ...
1
vote
2answers
348 views

How to create custom methods for sprite groups in pygame?

I want to use sprite groups in my game using pygame and the default draw isn't enough. I have tried some tutorials but I failed. So, being more specific: I want to create custom methods for sprite ...
1
vote
1answer
107 views

In pygame, is there no graphicsContext.translate() method?

I am new to pygame. I was searching on the internet and the pygame documentation for the functions which can translate, rotate, scale the entire graphics Context, but I couldn't find them. I know that ...
1
vote
1answer
122 views

Can somebody explain this behavior in pygame?

I have an image that I'm rotating and moving And when the rotation angle is negative the image moves as expected. But when the angle is positive it moves it's origing point to the left Can anybody ...
1
vote
1answer
320 views

pygame KEYUP KEYDOWN events only once per frame?

I've been playing around with pygame, and I ran into a bit of an odd issue with input on the pygame event queue. Consider the following test code: ...
1
vote
1answer
47 views

Why is the position of this image changing?

I have a python script to simulate a wrench moving, I have calculated it's origins position in x and y as a function of time, the problem is when I try to rotate the image, my code moves the image out ...
2
votes
1answer
171 views

How do I make mask work

I have been trying to make a game, but mask collision doesn't seem to work. Here is my code: ...
1
vote
1answer
58 views

Tile based game. Fixing surface issue for attack

So far I've loaded the images and can move the sprite around. When I hit the spacebar to cycle through the attack sprites within the attack_front list. The image ...
0
votes
1answer
128 views

How can I make tiny sprites larger?

I used a 16x16 sprite pack to make a 640x640 map in pygame: The problem is that everything is extremely tiny. How could I go about making the expected "JRPG" look, like this for instance: I have ...
0
votes
0answers
192 views

Using pygame on mac, strange errors

I am using pygame on a mac, and when the app runs, it draws a frame of the screen fine, and then crashes with the following error: ...
1
vote
2answers
261 views

Separate objects for hitbox and sprite?

I am making a technically top down game with a shifted perspective. It shows more of the characters side, not just above their head. I think most "top down" games have a similar art style. Due to ...
2
votes
1answer
123 views

Flexible Controller Support

I am developing a platformer in Pygame with the eventual hope of releasing it on Steam. I am currently trying to add input support for multiple controllers. To do this, I am using the Pygame ...
3
votes
1answer
51 views

Selective Collision Resolution While Rolling

I am working on a 2D action platformer in Pygame, though my question is a general one. The question concerns selective collision resolution. In short, I want certain collisions to be ignored while my ...
4
votes
1answer
161 views

Shooting function in pygame w/ 2 Players

I'm trying to program a shooting function in my game using pygame. Process: Player one will press 'Space' and shoot their type of projectile Player two would press 'E' and shoot their type of ...
0
votes
1answer
629 views

Pygame set_repeat() issue

I want a single key press to result in the sending of one event in my game loop. As a toy example, if the player presses and holds LEFT, I want the sprite to move 1 pixel left and then stop until the ...
2
votes
1answer
560 views

Handling Events & User Event Limits In Pygame

I am trying to make a vertical shoot em up using Python and Pygame. In order to handle timing, such as when certain enemies come out and other stage events, I've been using ...
4
votes
2answers
550 views

Collision Resolution of Axis-Aligned Bounding Boxes that Change Size

I am developing an action platformer in Python, with Pygame. That said, my question is a general one about collision resolution strategies. I use an axis-aligned bounding box for the purposes of ...
1
vote
1answer
41 views

Reflect Code Changes in a Current Run

I am developing a game in Python using Pygame. I am wondering whether there is a way to make changes to a currently running game by modifying the script (like Notch does in this clip). For example, ...
1
vote
1answer
217 views

Chaining Melee Attacks

I am working on an action platformer using Pygame. My player sprite has three melee attacks. Let's call them SLASH_1, SLASH_2, and SLASH_3. Each of these attacks has, let's say, 2 animation frames, ...
1
vote
1answer
1k views

Implementing Jump in pygame

I have come across a problem in my code for my game. Currently i am developing a 2D platformer game in pygame. I have gotten the character to move left and right, although i haven't been able to get ...
1
vote
1answer
63 views

Visual Glitch When Drawing Rects

I have the following code: ...