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
1
vote
1answer
14 views

I want my shapes to stay at screen

I am working on a paint project and it's almost complete but I want it to behave like the ms paint , in which whenever we draw an object (rectangle ,line) it shows it on the screen while we are moving ...
-1
votes
0answers
27 views
-1
votes
0answers
12 views

Meu código está dando erro e não sei como resolver [duplicate]

for bullet in laser: index = 0 velx = math.cos(bullet[0])*10 vely = math.cos(bullet[0])*10 bullet[1]+=velx bullet[2]+= vely if bullet[1]<-64 or bullet[1]>600 or bullet[2]<64 or bullet[2]>...
-1
votes
0answers
17 views

Enemy A/MovementI in Pygame, idle and aggressive bosses

Working on my first project and I'm trying to get enemy movement sorted, the code below is my current implementation. The enemy using the distance between the player position (target.pos.x) and their ...
-2
votes
0answers
26 views

How to make my sprite shoot fireballs (bullets) in pygame?

This is my Sprite1.py program which I import to my main.py program. It contains all the classes I use in my main.py. I tried to create bullets based on a program I saw online but it doesn't work for ...
0
votes
0answers
36 views

How do I draw my particles when an enemy is killed?

I have enemies that move left and right. I was wonder how I could make my particles show up when the enemy is killed? Here is my particle class ...
1
vote
2answers
36 views

Rotating Cannon's Mouth Toward Player

I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. ...
0
votes
1answer
45 views

Implementing melee combat in pygame?

I've gone about 2 ways for implementing melee attacks however, bboth have major flaws, hoping someone has a simpler answer. Method 1: Creating a "projectile" that's using an image, then ...
0
votes
1answer
55 views

Problem With Enemy Bullets Attacking The Player Pygame

I am trying to make my enemy bullets attack the player but it only attack its x and y how could I make it curve instead of zigzagging VIDEO the bullets only attack the y axis and it wont curve or go ...
-1
votes
1answer
31 views

python sockets: receive data only when data is available?

I am writing an update to a game I have written in python, and I am currently adding server support. I can't show you the main code (for the client), as it is hundreds of lines long. However, what I ...
-3
votes
0answers
29 views

Best way to go about implementing melee attack in Pygame platformer? [duplicate]

I can't seem to find any tutorials on melee attacks in pygame only projectile attacks.
0
votes
1answer
30 views

EndScreen Not Loading My Best Score And Current Score How To Fix?

I am trying to make my endscreen save last score and current score but it just appears as 0 for both everytime I die event he I picked up the coins image so basically it isnt saving my coins I had and ...
0
votes
1answer
34 views

Pygame End Screen Problem How To Fix?

Video as you can see there I am trying to make my end screen restart my game but whats happening is that its not restarting my game its just loading the same thing when I die >> how could I make it so ...
0
votes
0answers
18 views

Enemies Bullet Shooting At Player Problem How To Fix?

I am trying to make my enemies shoot at my player rect where ever the position the player is and when it collides with the rect it should remove the -1 health ***my problem is that when the enemy ...
-1
votes
1answer
50 views

Tiled Map Editor Vs Text File? | Pygame [closed]

I've only recently got into coding and was looking around on how to create a 2D platformer, a lot of tutorials I've seen have used text files to create their maps. However, one I saw in particular ...
0
votes
0answers
20 views

Problem WIth Enemies Bullets PyGame

I am trying to make my enemy shoot my player but for some reason the bullets arent showing nor they are shooting at the player I don't even know why, I even draw the bullets on my window VIDEO ...
0
votes
0answers
18 views

Pygame Collision | Why do I slide up walls in my tile based game?

My player if in contact with a wall either left/right/top(head) they will be able to just continue in the Y direction if you press jump as if you were flying. This is for all walls and invisible walls ...
0
votes
0answers
24 views

(Pygame) Bouncing projectile gets stuck at window edge, rapidly bouncing back and forth

I've just started developing with Pygame and I figured that as my first project I would try to bounce some Rect objects around. I saw a sample of a bouncing ball here, and when I copied the code and ...
0
votes
0answers
19 views

Pygame Tiled Map Object layer collision

I'm using pygame to make a top down shooter I've placed my tiles and object layers using Tiled Map Editor. My player and mobs collide with their spawn locations (object layer) is anyone able to help? ...
0
votes
1answer
77 views

Pygame Scrolling Bug With Enemys

I have a problem with my enemy where when my player scrolls left the enemy scrolls with the player is there anyway to fix this even Video my full code is below its to long to fit here though what I ...
0
votes
1answer
29 views

how do you get pygame to register multiple key presses at the same time

every time i try to operate player one and two or try to use the pickup key it stops the players.plz help here is my code- ...
0
votes
1answer
32 views

Player won't move correctly due to gravity force pushing him into the ground

I am making a tilemap platformer with pygame ad I defined the X and Y movement for the player and also a Y force that represents the gravity force to make it jump correctly. However, when my player ...
0
votes
1answer
30 views

Why doesn't my Pygame game scroll properly?

When I am clicking the arrow keys, in order to scroll my ground and my lucky block, I cant just press the key and it keeps on going scroll. So I need to press the key every second to get a kinda ...
0
votes
1answer
56 views

How do I make my level scroll side-to-side as the player moves?

I am trying to figure out how can I make a side-scrolling view in Pygame. If I am moving right or left, I want the portion of the level shown on-screen to shift to follow the player character. Here ...
0
votes
1answer
44 views

Why does collision only work sometimes when there are multiple objects in the game?

when i was making a pygame in python for the first time i kinda have a problem where sometimes the player and the object would touch and the game would not close as intended i dint seem to find the ...
0
votes
1answer
61 views

How to add multiple floors to a map in a text-based game?

I decided to learn how to make games during this quarantine. I am reading Mission Python, a book that teaches how to make games using python and pygame. I'm halfway through it, but the game only has ...
1
vote
2answers
79 views

Pygame polygon click detection

Here is my problem : I am creating a game and I have a board made out of polygons (hexagons). I want to be able to click on the different tiles but I don't find a simple method. I understood how to ...
0
votes
0answers
32 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
73 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
27 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
151 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
37 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
51 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
56 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
32 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
93 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
61 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
40 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
55 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
76 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
121 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
73 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
41 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
133 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
55 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
1answer
920 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
131 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
150 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 ...

1
2 3 4 5
8