so I’m trying to make a 3-sec timer but my code just waits 3 secs then continues to my game I’ve been trying to fix it for a week now but it doesn’t work Answer You must handle the events in the innen loop. See pygame.event.get(): For each frame of your game, you will need to make some sort of
Tag: pygame
Pygame advanced map editor
I want to make a level editor in pygame, and I have a simple code that does this. If I have dozens of objects to draw on the screen, should I check them one by one example: [0 = None, 1=dirt_img, 2=grass,3=tree,4=rock], actually I can’t think of any other way but this is there an easy way to do it
How can I make a button that goes to website in pygame?
I have a “Credits” menu in my pygame and I’d like to make some buttons that go to certain websites. What I mean is, when the button is clicked, it should open up, for example, GitHub (or whatever the link is). Is there a way I can achieve this? Answer Implement a Button class ans use the webbrowser module to
Creating a Asteroid type game, problem is when player waits to press play button many asteroids spawn instead of controlled amount
About 500 lines of code, so to make it easier to read I believe the bug comes from _update_asteroids(self) function. Simply put, when the user is in the paused game state and must press play, if the player decides to wait lets say a minute. A minutes worth of asteroids will spawn at the exact same time. I believe this
Python: game image changes to an undesired position after adjusting image’s moving speed
I’m making a simple python game and there are 3 py files: alien_invasion, settings, ship. I would like the image position to be at the middle bottom of screen every time the game starts. It works when code are like the following: ship.py: settings.py: Then I made changes to settings.py and ship.py to adjust the moving speed: ship.py: settings.py: Then
Python: how do I can use android.show_keyboard for my android app?
I wrote a small pygame app that fills random colors on the device’s screen: But there are no UI elements (like in kivy) (but I can draw them), so I want to show/hide the keyboard from code. But I can’t find docs about android.show_keyboard and android.hide_keyboard My attempts: When I call android.show_keyboard(), I get an error saying that 2 args
noisy bouncing in pygame
I’m cannibalising code from here to make a ball bounce around. Here is a stripped-down version of the code: Right now, the ball always bounces off the walls at a 45 degree angle. I want to introduce some noise into this so that bouncing is slightly more realistic. I tried to simply add random noise to the bouncing: Supposed to
Why won’t my Pygame sprite jump code work?
I am trying to make my Pygame sprite jump so I followed a tutorial and this is what it gave me. But it doesn’t work for some reason. What’s wrong with it Answer You need to set somewher isjump = True. Additionally the if isjump == False: needs an else case:
How do I assign the types for python-modules?
Here is an example with pygame (Types do not get inferred): Types do get inferred: Well, this library throws an error when importing single modules and using pygame.init(). Is there another way to use the first example and type the modules afterwards? Answer from pygame import * is the best thing to use in this situation. In your situation, init()
How to stop pygame buttons from overlapping in separate images?
I’m making a simple text based RPG game in pygame. I’m using a button class (not mine, but fairly simple to use and integrate) to add buttons with choices in them. However, it seems a button on the second slide, the ‘Sit and Wait’ choice, is overlapping with the ‘No’ button on the first slide. Since the No button closes