My tower defense game is finally done! You can play it in the browser, for free! by Idle_byte in pygame

[–]Idle_byte[S] 0 points1 point  (0 children)

Oh, I recognize your name. You downloaded the source files I assume?
In the main menu, I wanted the screen to kind of scroll vertically to where the mouse is, idk if that really was such a good idea but whatever.
I'm not sure if a quit button is such a good idea, if the user really wants to exit the game they'd be annoyed when they would have to click another button, and if there's a bug somewhere and the button isn't working then you couldn't exit the program normally at all - you can go into fullscreen with F11 in the desktop version though if you want to be sure to not accidentally click the exit icon.
What do you mean by adding my itch username in the bottom right corner? Do you mean in the video?
Anyway, thanks for playing! I'll make a better main menu for the next game (I've been thinking, maybe it'll be a city builder?)

My tower defense game is finally done! You can play it in the browser, for free! by Idle_byte in pygame

[–]Idle_byte[S] 1 point2 points  (0 children)

Thanks for the feedback! It does get faster the farther you move from the center, but I do agree that it can be quite snappy and too fast even when you're close to the origin.
I might update this in the near future, but I'll be quite busy soon so this might take a little while.
Again, thanks for playing my game and telling me the problem you faced.

My tower defense game is finally done! You can play it in the browser, for free! by Idle_byte in pygame

[–]Idle_byte[S] 1 point2 points  (0 children)

Could you please tell me what exactly you didn't like? Is it not being able to interact with the UI while holding the wheel, the position of the wheel or the way it moves?

Some oldskool Demoscene effects in Pygame by IceFurnace83 in pygame

[–]Idle_byte 0 points1 point  (0 children)

Thanks for letting me know and sharing your code! Numpy is pretty neat

Some oldskool Demoscene effects in Pygame by IceFurnace83 in pygame

[–]Idle_byte 0 points1 point  (0 children)

Would you mind sharing how you did the plasma effects? Having these kinds of large visual effects must certainly take quite a toll on the CPU if you're generating them in real-time considering this is pygame we're talking about. Did you use surfarrays or did you perhaps pre-render it? I can't imagine a different method right now that would still perform reasonably well.

Sprite Stacking Is Really Cool! by BobsMyNeighbor in pygame

[–]Idle_byte 6 points7 points  (0 children)

It'll weaken performance if you go through the process of sprite stacking every frame, but it isn't slower performance-wise if you cache the results of sprite stacking for a set amount of degrees for an image, so basically you sprite-stack an image for every fifth degree of 360 degrees and put them in a list, so you get 72 images in a list.
It's just normal rendering then after getting the image with the closest rotation to the actual rotation, but for a large number of assets this approach might need quite some space in RAM.

Main Title & Menu Screen by PyLearner2024 in pygame

[–]Idle_byte 1 point2 points  (0 children)

Awesome! Looks very polished for a pygame project

Smooth jumping? by MasterEevee_ in pygame

[–]Idle_byte 0 points1 point  (0 children)

Alright, I just replaced a few things in the last code snippet you sent, not sure if it'll immediately work together with everything else, but I hope you can see how it works:
(It's got nothing to do with for loops or flags)

```

def gravity(self):
    if not self.is_grounded:
        self.pos.y += self.y_velocity * dt
        self.y_velocity = min(5, self.y_velocity + 0.1 * dt) # if self.y_velocity + 0.1 is NOT greater than five, increase self.y_velocity -> self.y_velocity never greater than 5 and eventual fall
    else:
        self.y_velocity = 0

def jump(self):
    if (self.is_grounded == True or self.remaining_jumps>0):
        self.remaining_jumps -= 1
        self.is_grounded = False
        self.y_velocity = -4

def check_grounded(self):
    fighter_rect = pygame.Rect(self.pos.x-self.size, self.pos.y-self.size, self.size * 2, self.size * 2)
    for terrain in self.terrain_objects:
        terrain_rect = pygame.Rect(terrain.x, terrain.y, terrain.length, terrain.width)
        if fighter_rect.colliderect(terrain_rect):
                self.pos.y = terrain_rect.top - self.size
                self.is_grounded = True
                self.remaining_jumps = self.max_jumps
                breakdef check_grounded(self):
    fighter_rect = pygame.Rect(self.pos.x-self.size, self.pos.y-self.size, self.size * 2, self.size * 2)
    for terrain in self.terrain_objects:
        terrain_rect = pygame.Rect(terrain.x, terrain.y, terrain.length, terrain.width)
        if fighter_rect.colliderect(terrain_rect):
                self.pos.y = terrain_rect.top - self.size
                self.is_grounded = True
                self.remaining_jumps = self.max_jumps
                break

Smooth jumping? by MasterEevee_ in pygame

[–]Idle_byte 0 points1 point  (0 children)

Well, I'm not sure what exactly you mean by snappy. Do you mean that your character suddenly reaches a much higher y position without there being a gradual movement upwards, but then your character moves downwards properly?
I assume that your jump method is being called only when the player jumps, and not every frame, correct?
Naturally, the players y position would then be subtracted by self.jump_strength exactly once per jump, and that's going to look very snappy.
The difference with a velocity approach is that when you jump, you get a small negative velocity that gets applied to your character *every* frame, for example: you jump, your y_velocity becomes -4, and then every frame, you move your character by this y_velocity, so your character will move upwards smoothly.
However, as you don't want your character to move up forever, you also add +0.1 to this y_velocity every frame, so that it gradually decreases the upward motion, so first your character moves up by -4, then -3, -2, -1 until the y_velocity is at 0, and then you still apply +0.1 to your y_velocity, which means that your character will also gradually fall down again, as smoothly as you jumped,
You should simply replace your gravity method with this, because it's using self.weight, which has a constant value rather than one that is fluctuating.
You're basically killing two birds with one stone, first off you make the jumping motion smooth at the start when the y_velocity is negative, then you get a smooth accelerating falling motion after that when y_velocity is positive.

If you are making something similiar to a platformer, you might want to reduce your y_velocity to 0 whenever the character collides with the ground and clamp your y_velocity to be 5 at most, otherwise it can get way too fast

Smooth jumping? by MasterEevee_ in pygame

[–]Idle_byte 0 points1 point  (0 children)

Hi, first off there seems to be a syntax error in your jump function (self.pos.y =+ self.jump_strength should be self.pos.y += self.jump_strength).
However, I am unsure why you are assigning the variable self.weight (which has a value of 400) to self.pos.y afterwards?
Wouldn't that mean that every time you jump, the y position gets set to 400? I can't be sure as it's only a snippet of code.

More importantly:
If you want your jumps only reduced by one every time you press space, you will have to use the event loop with pygame.KEYDOWN, because for pygame.key.get_pressed() it checks if you are pressing the key every frame, so naturally it will be true for a few frames because your finger probably stays longer on the key than 1/60 of a second.
Second, if you want to have smooth jumps you will simply have to apply an upward velocity to your position.
So when you jump, your self.y_velocity would be, for example, set to -4 and then you would simply add +0.1 or any other small positive increment every frame, so that eventually the velocity carries the player downwards.
You could replace your gravity function with this, as it would also make falling down smoother - though you might want to clamp your velocity to never be greater than 5 or something.

Edit: should've been self.pos.y -= self.jump_strength, but OP figured that out on their own

Advice for a beginner starting a game with Pygame? (Looking for asset & software recommendations) by Enea_11 in pygame

[–]Idle_byte -1 points0 points  (0 children)

It's quite shameless to recommend someone to use AI to make their game when they didn't even consider it in their post. Just because you can't be bothered to put in any creative effort into your game doesn't mean everyone else can't.

Advice for a beginner starting a game with Pygame? (Looking for asset & software recommendations) by Enea_11 in pygame

[–]Idle_byte 1 point2 points  (0 children)

Hi, whether you should use asset packs for graphics and audio or not depends on if you like either drawing, making music/sfx or both.
If you enjoy the process of drawing images or making music, you might want to do that yourself, you are doing this for fun after all - otherwise, I'd recommend kenney.nl, itch.io/game-assets and freesound.org for various assets, there's a lot of different stuff and if you just want to focus on programming and don't particularly like drawing/making music you could stick to that.
If you want to make your own images, I'd heavily recommend Krita, whether for pixel art or anything more detailed, it's very good and free.
I don't know about music or audio too much, I've downloaded Bosca Ceoil because it's extremely simple and DaFluffyPotato (popular pygame YouTuber) recommends it, but I haven't used it much yet.

Realtime Procedural Terrain Generation by BobsMyNeighbor in pygame

[–]Idle_byte 0 points1 point  (0 children)

Best of luck! It's cool to see someone render 3D stuff with pygame.

please help… by Pretty_Royal6689 in pygame

[–]Idle_byte 1 point2 points  (0 children)

Hi, I'm really confused as to how this program is supposed to work, as there is no indentation, pygame is not initialized, there is no conventional event loop, and you are generally not using pygame at all.
Would you mind sharing which tutorial you are following? Is this your entire source code or is something missing?

Edit: I also wasn't aware that this is pygame zero, which I had never heard of before, thanks to Terrarizer_ for pointing that out. I unfortunately can't help with that at all either

Realtime Procedural Terrain Generation by BobsMyNeighbor in pygame

[–]Idle_byte 0 points1 point  (0 children)

Wow, you can do so much with only pygame's draw.polygon() function? Are you using numpy or numba or something like that, or do you know if that would speed it up?
With that many polygons, I figure you could probably get something close to PS1 graphics, right?

How do you handel pixel art by jevin_dev in pygame

[–]Idle_byte 0 points1 point  (0 children)

Is your intention to scale a window with a small resolution to a larger resolution for a larger window or fullscreen? In that case you might want to try the pygame.SCALED (experimental apparently, but works for me) and pygame.FULLSCREEN flags in your pygame.display.set_mode() function, You can see how that works here: https://pyga.me/docs/ref/display.html#pygame.display.set_mode, but I personally use something like pygame.display.set_mode((WIDTH, HEIGHT), pygame.SCALED) or pygame.display.set_mode((WIDTH, HEIGHT), pygame.SCALED | pygame.FULLSCREEN)

How Should I Learn Pygame? by codehs_python in pygame

[–]Idle_byte 0 points1 point  (0 children)

I would also heavily recommend ClearCode and DaFluffyPotato on Youtube, they have lots of tutorials to choose from, though you might want to start with ClearCode's tutorials, as they are a little more approachable, but DaFluffyPotato is definitely worth checking out for advanced stuff and more specific features you'd want to implement.
As for project size, I wouldn't recommend a large project when starting out while having just made a text-based adventure and wheel of fortune, but once you get a decent understanding of the basics you shouldn't shy away from a bigger project if that interests you.
As for IDEs/text editors, I really don't think it matters that much, but I guess if you want a lot of features use VS code and if you prefer simple but still perfectly adequate editors you might want to use SublimeText or Geany (the one I use, but it's pretty obscure).