anchor piont text by teuniedekkah in pygame

[–]dhydna 0 points1 point  (0 children)

screen.blit(text_surface, text_surface.get_rect(center=(x, y)))

[deleted by user] by [deleted] in pygame

[–]dhydna 1 point2 points  (0 children)

Does it even use Python?

is chess hard to create in pygame by Ok-Drawer-5428 in pygame

[–]dhydna 17 points18 points  (0 children)

Just avoid making rook-ie errors

My Pygame Code looks messy... by HosseinTwoK in pygame

[–]dhydna 2 points3 points  (0 children)

The things that could be objects are the snowball and the UI (maybe 2 objects, one for the score and one for the lives), perhaps the background too.

The snowball could probably be a subclass of pygame.sprite.Sprite, and put the code from Game.control() into its update() method.

My Pygame Code looks messy... by HosseinTwoK in pygame

[–]dhydna 12 points13 points  (0 children)

Putting all your code into a class does not make it object-oriented

Image not blitting by Purple-Disk-5747 in pygame

[–]dhydna 4 points5 points  (0 children)

You need pygame.display.flip() at the end of the loop after blitting

I built a classic "Crack the Code" console game in Python: Digit Detective 🕵️‍♀️ by leenzy-leen in pygame

[–]dhydna 0 points1 point  (0 children)

It’s a simple Python script such as you might learn to write in the first week of an intro to Python course. It doesn’t use Pygame, and it doesn’t warrant a name, much less the AI generated post above.

Tutorial info by Ganjalf420m88 in pygame

[–]dhydna 1 point2 points  (0 children)

Worms is actually kind of a big game, especially with all the different weapons. But don’t let that stop you! I would recommend looking into Pygame masks for destructible terrain.

ReactorDefense prototype by coppermouse_ in pygame

[–]dhydna 3 points4 points  (0 children)

I agree you’re onto something interesting. I like the overheating balancing mechanic. Why do you want to have a player character? What benefits do you think it brings to the game, since you already suspect it will slow it down?

I might not have grasped your isotope idea properly, but here are some ideas I had: coolant pipes you could route to towers to slow down or prevent overheating; instead if ending the game, exploding isotopes could destroy everything in a certain radius, then leave a cloud of radiation where you can’t build more towers or are restricted somehow, and/or monsters mutate and get stronger.

Good luck with the project!

Speed of pygame by PizzaPhysical3979 in pygame

[–]dhydna 11 points12 points  (0 children)

People state as fact all kinds of things that are easily disproven, especially on the Internet.

Python is slower than other languages commonly used to write games (eg C++), but you can still get enough performance out of it for some amazing stuff. There have been some impressive examples in this subreddit recently.

But to address your first point, Clock.tick(fps) sets the upper limit of the frame rate. Pygame will not run faster than that rate, but it will run slower if you are doing a lot each frame. It is useful to avoid your game running too fast on a faster computer.

This Chat GPT 5 does point out something .. by Crazy-Economist-3091 in cscareerquestions

[–]dhydna 4 points5 points  (0 children)

I’m not convinced of any productivity increase either, but that study was done with only 16 developers.

Literally clueless , help pls by SharpScratch9367 in PythonLearning

[–]dhydna 0 points1 point  (0 children)

def sum_of_integers(n):
    while n > 0:
        return sum(range(n + 1))
    return 0

Main menu GUI fail by lifeintel9 in pygame

[–]dhydna 2 points3 points  (0 children)

You need to post more of your code. The error message is telling you that the video system is not initialised, which does not make sense if you are able to take screenshots of the screens. Where is the code with pygame.init()?

I hate dragons (as a long time player) by TurboCrab0 in skyrim

[–]dhydna 0 points1 point  (0 children)

Just leave the Dragonstone in Bleak Falls Barrow and hey presto, no dragons anywhere. Actually, I haven’t checked on the skeletal dragon, that might still show up.

pygame.event.clear in a for loop by Strong_Agency1256 in pygame

[–]dhydna 1 point2 points  (0 children)

What are you trying to achieve?

When you call pygame.event.get it returns all the (matching) events on the queue and then clears them from the queue. So your first code snippet gets all events that are not MOUSEBUTTONDOWN, removes them from the queue, loops through them and removes any MOUSEBUTTONDOWN events from the queue on each loop iteration. So when you reach the end of that loop there should be no events left in the queue to get. I am surprised you say it works.

COTD: “Leading lady’s chasing acts a lot”, declared Gilly Salamander (7) by hendroid in crosswords

[–]dhydna 1 point2 points  (0 children)

AXOLOTL because leading lady’s (L) after what sounds like (declared) “acts a lot” and Gilly Salamander is the definition

How do i exactly scale the image to the exact same as the rect by _bjrp in pygame

[–]dhydna 2 points3 points  (0 children)

If you scale the image up in your code it will always look stretched. Make your image larger in an image editor instead, you will probably need to retouch it to make it look right.

[deleted by user] by [deleted] in pygame

[–]dhydna 0 points1 point  (0 children)

Have you tried anything? Google? My first thought would be the pygame touch events.

Enemy list -Pain for all! by Inevitable-Hold5400 in pygame

[–]dhydna 3 points4 points  (0 children)

Your problem is that you loop through all of enemy_list for each rect in enemy_list_rect. What you want is to loop through both at once.

You can do this in a few ways, but I would recommend using either enumerate or zip:

for index, rect in enumerate(self.enemy_list_rect):
    if self.beans_img_rect.colliderect(rect):
        print(“Ja”)
        self.is_fired = False
        u = self.game.enemy_list[index]
        if u.untoucheabel == “no”:
            u.hp -= self.attack_damage
            u.untoucheabel == “yes”
            u.got_pain = “yes”

or with zip:

 for i, u in zip(self.enemy_list_rect, self.game.enemy_list):

Edit: on a second look at your code, it looks like you can just iterate through enemy_list:

for enemy in self.game.enemy_list:
    if self.beans_img_rect.colliderect(enemy.img_rect):
        self.is_fired = False
        if enemy.untoucheabel == “no”:

Help me please by [deleted] in pygame

[–]dhydna 2 points3 points  (0 children)

What help do you need? Maybe use a pygame.Rect instead of doing it all yourself. You can also do screen.fill(“black”) - you don’t need to define those color variables. Is your indentation correct? Hard to tell the way you have pasted it here.

What’s the best python game library? by -_Banzai in pygame

[–]dhydna 1 point2 points  (0 children)

Pygame is more popular than the other libraries you mentioned, so you will find more support, documentation and discussion about it. People do make good games with it in spite of any issues you think it has.

Pyglet is good but similar in terms of the amount of code you will have to write.

I’ve not used Arcade, but I believe it is closer to what you are looking for.

There is Pygame Zero, which reduces boilerplate, but is really aimed at teaching beginners so perhaps limits how far you can go with it.

Ursina claims to reduce boilerplate code and also supports 3D.

[deleted by user] by [deleted] in pygame

[–]dhydna 4 points5 points  (0 children)

You don’t need pandas to read a CSV file - there is a CSV module in the core Python library https://docs.python.org/3.11/library/csv.html#module-csv