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
12 views

Pygame - Explanation for code that stop crash

I have a piece of code and i don't know how it works: ...
0
votes
0answers
9 views

Is there a way to get relative center of a Rect object in pygame?

Now, suppose I always want to draw a circle at the center of a rect object, now, the problem is: For example, if I do ...
1
vote
1answer
36 views

Why is my program “not responding” when I run it?

I'm trying to learn to code with python and while using pygame, I came across this: every time I run the window it says "not responding". Specifically, it happens when I click to drag the window; the ...
0
votes
0answers
18 views

Improving the efficiency of a grid-based ecosystem simulation

I'm trying to create a grid-based ecosystem simulation game. The design I came up with is something like a 1000 x 1000 (or larger) grid, with each cell being a representation of an object containing ...
0
votes
0answers
36 views

How can I remove a sprite from the screen using pygame?

I am having trouble with removing sprites on my screen using pygame. I am killing my sprite with sword.kill which is removing it from an all_sprites group, so it should disappear right? Here is ...
0
votes
0answers
29 views

How do a make a smooth animation with images of different sizes in pygame?

I have an animation where my player swings his sword, with 5 images in pygame. The normal resting image is 14x22, and the rest are 13x23, 21x23, 18x23, and 18x23. I am having trouble with my character ...
0
votes
0answers
42 views

How to stop snake game stuttering?

I have the following code and it seems to work pretty well except that every once in a while the program stutters and the snake teleports forward a few spaces. I can't tell what this is related to. <...
0
votes
0answers
21 views

pygame multiple collisions between two objects

Ok, so I have been trying to figure out how to set this up and can't get it working properly. I'm trying to get the functionality similar to the moving logs in the game Frogger if you are familiar ...
0
votes
0answers
29 views

Collisons with rock and player(spaceship)

I'm trying to make when the rock hits the spaceship or player it should decrease the health from the health bar but when I run it, it doesn't work. The rock decreases the health randomly. How can I ...
0
votes
1answer
74 views

Collision detection / physics for simple game

I am currently working on a mini game for class (first time doing something like this) and I don't really know how to start with collision detection at all. The game I'm creating is a top down sumo ...
1
vote
1answer
35 views

Problem with diagonal collision response using PyGame

So I have been having this problem for the last few days and it has me really frustrated. What I am trying to do is resolve collisions with custom hitboxes in PyGame and it looks something like this: ...
0
votes
0answers
21 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
34 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
53 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
66 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
87 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
61 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
39 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
113 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
39 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
100 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
452 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
29 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
121 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
103 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
49 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
55 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
20 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
48 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
155 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
88 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
679 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
84 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
119 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
111 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
240 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
162 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
1k 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
69 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
1k 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
59 views

player movements aren't working python

...
-1
votes
1answer
659 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
1answer
349 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
239 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
51 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
121 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
50 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
552 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
55 views

Pygame OpenGL init causes an X Error

...
0
votes
1answer
49 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: ...

1
2 3 4 5
7