Skip to content
Advertisement

Tag: pygame

timer is not displaying text in pygame

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

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

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

Advertisement