We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [pygame]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

How to detect collision while the animation is running to move an object to the next coordinate?

I implemented SAT collision detection in Python with the GUI library pygame. It is working well, except when the objects are going too fast. I have velocity and acceleration variables. For each loop ...
0
votes
1answer
27 views

Positioning a Window to Fill the Screen

I'm using Pygame (just started), and I'm struggling to find how I set the position of the window to fill my entire monitor screen. I can move things around within the screen / surface. I can make the ...
0
votes
2answers
43 views

Find angle to a point

I'm trying to find the angle between a point and the left side of my camera's fov. In the picture below the camera (Red dot) is looking towards a polygon (Green) with the fov of the camera ...
0
votes
0answers
50 views

Editing this code to put in my own sprites and textures?

I have to make a game for class and have to have scrolling camera, fully textured background, and have the sprite be fluid. I need the rectangle to be turned into a sprite. This code I found on https:/...
0
votes
1answer
47 views

how to move object in a circle around point?

There are two controllable objects orbiting around a centre block. Unfortunately, I don't really know how to stick them so they can only move around the block (left/a sends them clockwise, right/a ...
0
votes
0answers
32 views

Pygame Mask Doesen't Detect Collisions

I'm trying to make my game's collisions with masks. I have 6 masks but only 2 works. My code is: ...
0
votes
1answer
34 views

Pygame Updating Display Without Being Told To

The following (abridged) bit of code is inside the main loop. What I expected to happen was the entity's position to update due to velocity, then update again if it's touching a static object before ...
-2
votes
1answer
77 views

How should I go about creating a multiplayer pac-man game in python? [closed]

For some context, I am making a Pac-Man game (using pygame) and I need a little guidance on how to structure the multiplayer side (using sockets). I have a few ideas (the first of which I have tried) ...
0
votes
0answers
16 views

How to reset Camera and Hero position at new level in pygame

I'm working on a 3rd level of my game. When the 3rd level begins the Camera and Hero position is getting same value which was left by the 2nd level at the end point. I'm not able to find a way around ...
0
votes
0answers
60 views

How to scroll background image from start in pygame

I'm making a game which has 3 levels. I have successfully created 2 levels and everything runs fine, but when I try to reach level 3, it loads the background image from the middle and it get stuck ...
0
votes
1answer
79 views

How to make player move into next level in pygame

When my player reaches at the end of the map, I want it to enter to next level. I've created first level and it all works fine. All I want to do is that when player finishes 1st level I want to load ...
-1
votes
1answer
25 views

Cube not square and being clipped horrendously, color doesn't apply

I'm trying to create my own object-oriented graphics library and use it to make a ping-pong game. I am following some tutorials online, and one uses old-style code with individual calls to ...
0
votes
1answer
106 views

PyBox2D car moves uncontrollably

I am trying to program TopDown Car using python and Box2D (similar to this tutorial: http://www.iforce2d.net/b2dtut/top-down-car ) The steering is so far limited to thres states of wheel rotation, ...
-1
votes
1answer
67 views

How to make player land on platforms more than one in pygame

I'm trying to make multiple platforms (blocks) on screen on which player can jump and land on it. When I just keep only one block, player jumps on it and land easily. But when I create other platform ...
0
votes
1answer
35 views

PyGame Inconsistent Framerate

This is the first game I have tried to make on PyGame, and I have followed the PyGame Primer tutorial (https://realpython.com/pygame-a-primer/) to do so. I'm practically done, but when I run the game, ...
1
vote
1answer
43 views

*Python* Class - self.x = self - What does it mean to set it to self?

I have this class for my game that is a scene manager. I followed a tutorial and I am confused on why the self.scene.manager is equal to self ...
0
votes
0answers
19 views

How can I make the image of the gun turn in its place? [duplicate]

how can I make the image of the gun (gun1.png) turn in its place pointed to the mouse, This is the code ...
1
vote
0answers
39 views

How do I organize this code to be able to have a menu system that can be nested?

I am a beginner programmer and I have been experimenting with pygame (uses python if that is not obvious) through tutorials and such. I am stuck because I have not been able to figure out how to make ...
0
votes
1answer
60 views

How do I add collision between two player controlled turtles

How do I add collision between two player controlled turtles. I asked the question before but misunderstood my own groundings on the plan. I cannot figure out how to make two player controlled turtles ...
1
vote
0answers
37 views

how do i convert my pygame games to executable [closed]

I have a lot of python games I made in pygame and want to compile them so I can distribute them on sites like itch.io and gamejolt.com, the thing is, when I try to my executable game it says "fatal ...
0
votes
1answer
264 views

How do I apply collision to a turtle

I cannot figure out how to apply collision to a turtle. I am in need of help for collision with pen lines and turtles. I want the two to hit and restart the game but I can't get collision on either. <...
0
votes
2answers
57 views

How can I set decimal values to a Pygame rect position?

I'm trying to make the gravity a bit slower, like ...
1
vote
2answers
80 views

Pygame - Maze collisions problem

I am a beginner in Python and Pygame and I have a problem with my game in pygame. I have Maze class and Player class but I can't do proper collisions. I reached the moment where I have no idea why my ...
0
votes
2answers
93 views

Pygame Collision Bug

I'm trying to add collisions to my first game, and it has a bug. My code is: ...
0
votes
1answer
138 views

How to get rid of the white border/background on my png image?

I am making a game using pyGame; it is basically a space invader game, with a tank. As we can see, this tank image I have has white borders / a white background, which I really want to get rid of. I ...
1
vote
1answer
121 views

How can I rotate my character so that he is facing the mouse?

I just want to preface this by saying I am very new to pygame. At the moment I have calculated the angle that I need to apply to my character so he can rotate but I am unsure how to actually make ...
0
votes
1answer
434 views

Pygame Error AttributeError: 'pygame.Surface' object has no attribute 'add_internal'

I'm making my first game of Pygame. I'm going to create groups for making collisions but when I add an object to the group, I get an error in sprite.py (Pygame's Files) ...
1
vote
0answers
59 views

Calculate velocity to hit the target on flat 2d surface

I am creating a game using Python and Pygame. I have used this function before (with JS with p5.js and Java with libwjgl, but for some reason it does not work with pygame (I am not sure if it matters ...
0
votes
1answer
233 views

“Video system not initialized” error

I always get the error message "video system not initialized" I don't get where I went wrong with the code below: ...
0
votes
1answer
57 views
-1
votes
1answer
389 views

Pygame for Android

Do somebody know how to make pygame games for android? many have done this but i still don't know how to do it. I googled it but there is no clean step by step tutorial. Can somebody answer this ...
0
votes
0answers
76 views

Render Pygame sprites with PyOpenGL

I am using Pygame for rendering my sprites, however that work is done on the CPU side. For performance reasons I would like to change to drawing those sprites using PyOpenGL. How can I take textures ...
0
votes
1answer
208 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? EDIT: ...
0
votes
1answer
160 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
1answer
49 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
89 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
46 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
2answers
314 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
41 views

Pygame OpenGL init causes an X Error

...
0
votes
1answer
38 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
292 views

How do I draw a rectangle in Pygame?

I am getting the error "AttributeError: 'Rect' object has no attribute 'draw'" with this code: ...
1
vote
1answer
72 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
991 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
178 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
308 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 ...
1
vote
1answer
203 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
49 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
2k 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
64 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
103 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: ...