Skip to content
Advertisement

Tag: pygame

My Score adds to much every single time rectangle collides with other rectangle

So I’m trying to make it so that if my rectangle collides with an another rectangle/Point, it will move the Point y position away from the rectangle and will add one to my score. The problem that I’m getting is that my score will add two instead of one evey single time my rectangle collides with my point https://gyazo.com/d9e4167f749f2a672fe7f713ce5bab2e. I

How can I play song repeatedly using pygame.mixer.music.play()?

I have tried to repeat a song(mp3) using pygame module. The code is as follows from the site https://www.studytonight.com/tkinter/music-player-application-using-tkinter When calling this function, it comes out only one time, of course it’s natural. To repeat this sound file I added loop like this, but it plays just one time. How can I repeat many times over and over this? Should

Pygame How to check for second press of a key

Hi guys i’m making a game in python using pygame. I have a piece of code that shoots lasers from a ship in a space themed game. Here is the code: Well this piece of code shoots two lasers from the ship, like this. But i don’t want that. I want to make if player presses space once shoot the

I want this cube in pygame to move when I update it

My cube in which I am updating to move 5 pixels every frame, will not move. I have checked my code and I cannot find the issue, send pizza. I wish to make the cube move right 5 pixels every frame. separate file separat file Answer You have to create the instance of the Game class before the application loop:

Move Character with Vector

I am teaching myself pygame and am looking at making my character able to rotate and then move in the direction they are facing. I can do the rotation but cannot get the character to move in the direction the image is then facing. The code is on Trinket HERE Answer Rotate the player around its center (see How do

PyGame: issue with MOUSEBUTTONDOWN events

I’m trying to build a game of Chess in PyGame. My code is something like this: What I’m trying to do is this: The first MOUSEDOWNEVENT will select a piece that the user clicks on. If the user didn’t click on the piece, it will simply return None. The second MOUSEDOWNEVENT will actually move the selected piece to the new

Pygame sprite not moving while jumping [duplicate]

This question already has an answer here: How to make a character jump in Pygame? (1 answer) Closed last year. I’m confused why my sprite is not moving while jumping. I’ve checked several times and changed my code over and over with no luck. My code is below and contains 3 pages, first contain the main loop, second contain the

How can I rotate this object back and forth forever?

I have a bone arrow image that rotates. If it reaches a certain timer I want it to stop rotating on one side and start rotating the other. If the other side reaches its timer it should goes back and forth, back and forth, like this short gameplay video. I don’t know why it stops when its timer2 turn at

Advertisement