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

I need help understanding why objects are not drawing to canvas [closed]

So I’m getting back into coding and using Pygame plus a pygame coding book to learn. I’m about 185 lines in this lesson where I’m making a pong like game. All object to be drawn on the canvas have ...
1
vote
1answer
32 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
2answers
54 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
1answer
30 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
0answers
13 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
0answers
37 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
0answers
39 views

How to make player shooting?

this my code ...
0
votes
0answers
52 views

How do I make my player sprite move, while also facing the mouse?

...
-1
votes
1answer
38 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
0answers
30 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
1answer
38 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
1answer
140 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
0answers
35 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
0answers
40 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
1answer
80 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
1answer
42 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
0answers
44 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
1answer
35 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
1answer
24 views

How to blit a surface onto an already blitted surface in Pygame?

Consider the following code: ...
0
votes
1answer
58 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
1answer
91 views

Pygame 2D : rotation around center not working properly

here is the code I use to rotate an image around its center: ...
0
votes
1answer
55 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
1answer
169 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
1answer
78 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
1answer
66 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
1answer
90 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
1answer
90 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
1answer
408 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 ...
0
votes
0answers
36 views

Pygame unaccurate key press event handling

I have a problem with my game_over() function in Pygame. When the player loses, the game_over() function gets executed but since ...
0
votes
0answers
31 views

How I can get my pong ball collide on the paddle and bounce back?

Here is my code so far: ...
0
votes
0answers
26 views

pygame jump animation

So, I am trying to learn a little bit of Pygame and I really can’t get my little rectangle to jump. Using this code everything seems right to me. First the player should go up, then once ...
0
votes
1answer
73 views

Pygame some methods aren't working properly (collidepoint and get_rect)

I'm making a game menu in Pygame, consider the following block of code: ...
0
votes
1answer
100 views

Top-Down Tank Physics with Pygame

I am trying to make a top-down tank shooter game in Python and pygame, but I can't get the tank movement right. My objective is to make it move forward in the direction it is pointing in which would ...
0
votes
1answer
115 views

What is get_bounding_rect() method in Pygame?

I got used to get_rect() when detecting collisions in Pygame but I've just discovered that another method called ...
0
votes
0answers
23 views

Pytmx loads no tiles or textures, it seems

So, I've been trying to load a tmx file through pytmx But when it loads the file, it only loads a black image with the same resolution as the tmx file. ...
0
votes
0answers
93 views

How to remove a sprite from a group?

I am trying to make a chess game with Pygame, but am unable to remove the chess piece when it is captured. Stack Overflow already has a question on this here. But this code doesn't seem to work. When ...
0
votes
0answers
44 views

Pygame tile_size scalling to fullscreen/resizable window

I'm a newbie and I ran out of videos to watch on how to scale your tiles/sprites to fullscreen/resizable window on Python using Pygame. When I try to resize the window it looks like this: When I'm in ...
0
votes
1answer
38 views

"contains support" for Dreamcast/Atari/etc, but "not officially supported"?

I found this on the About page on the official Pygame website: Truly portable. Supports Linux (pygame comes with most main stream linux distributions), Windows (95, 98, ME, 2000, XP, Vista, 64-bit ...
-1
votes
1answer
49 views

How to stop player from slingshotting across my game window

In my pygame dungeon rpg when my player collides with a wall at the top or the bottom of its rect and I move the player in either x-direction, the player gets slingshotted off the screen. Using print ...
1
vote
1answer
121 views

How can i make a sprite appear middle of your cursor? Pygame

I made a sprite (hitmarker) to appear middle of your mouse when you click on a sprite (egg), but the hitmarker sprite appears at the right bottom of your mouse like this: however, I wanna make it ...
-1
votes
1answer
177 views

why doesn't spritecollide method work?

In my code, I wanted to use the spritecollides method but I got the following error message: Traceback (most recent call last): File "/Users/lanik2009/Documents/pygame testing.py", line 76, ...
0
votes
0answers
15 views

VS Code is no more suggesting Pygame methods for me

I've been using Pygame a lot. And I'm cuurently coding in VS Code. Last week, I have installed JAVA and started learning it's basics. However, from the moment I installed the JDK, VS Code have changed ...
1
vote
1answer
228 views

How to display the counter in pygame.time.set_timer?

in pygame, we use pygame.time.set_timer() to repeatedly create an event. This function takes 2 arguments : the event type and the delay time after which the event ...
0
votes
1answer
55 views

Full screen to windowed screen workaround causing segmentation fault in pygame

I'm having an issue that causes the window bar to appear above the screen when jumping between full-screen and windowed mode. Did some googling on the issue and it turns out it's actually a pygame bug,...
0
votes
1answer
39 views

Pygame bullet firerate not working sometimes

i have made this bullet class but i have a problem with the firerate. Sometimes i'm not able to shoot even when the little delay (700ms) between the two shots has ended. I guess it's due to the ...
0
votes
1answer
135 views

Image color being changed when pygame blitting to screen

I'm working on my first game, and I decided to add some trees that twinkle to the game. For some reason when the image is blitted to the screen using pygames blit ...
0
votes
0answers
106 views

How to make a z-depth buffer with pygame?

I am making a 3d renderer with python and so far am sorting the triangles which I want to replace with a z-depth buffer. The thing is, I don't know how to make a z-depth buffer in pygame. I still want ...
0
votes
0answers
27 views

How would you have a range of movement within a class in pygame?

I have blitted 4 zombies to the screen in pygame. First, the zombies will wander in a specific region (let us say a 10 x 10 area). And when the player enters any one of the zombie's areas, the zombie ...
0
votes
1answer
40 views

How do I click on specific text in an array of text?

I am trying to click on a specific word in an array but I can't think of how. This is what I have: ...
0
votes
0answers
40 views

Pygame Platform & Player collisions

I am trying to create a platform game where a player jumps between platforms horizontally (using a projectile curve). Currently, I have a class that blits platforms and a background, as well as the ...

1
2 3 4 5
9