Questions tagged [pygame]

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

-1
votes
1answer
36 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
25 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
votes
0answers
12 views

how can I make the gun (gun1.png) shoot towards the mouse's position (pygame 2D) [duplicate]

here´s the code: import pygame, sys import math clock = pygame.time.Clock() from pygame.locals import * pygame.init() # initiates pygame pygame.display.set_caption('Pygame Platformer') ...
1
vote
1answer
34 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
17 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
34 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
29 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
21 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
62 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
39 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
53 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
83 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
64 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 ...
0
votes
1answer
81 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
140 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
48 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
34 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
43 views
0
votes
1answer
130 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
61 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
82 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
108 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
46 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
61 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
42 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
1answer
153 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
30 views

Pygame OpenGL init causes an X Error

...
0
votes
1answer
31 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
98 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
56 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
497 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
114 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
208 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
162 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
43 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
57 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
91 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
176 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
170 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
2answers
233 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 ...
1
vote
1answer
221 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
186 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
572 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
189 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
126 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
420 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
48 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
269 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
60 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 ...