#game-development

1 messages Β· Page 36 of 1

limber veldt
#

Watching videos is not enough

#

Watching videos is where I discover a lot, but learning it is all hands on keyboard

drifting yew
#

not sure if I want to use pygame event for anything other than mouse and button input, seems too complicated

limber veldt
#

That's pretty much all I use it for, when I need a timer, I usually use a Timer() class or just accumulate dt in a variable

glass light
#

It's not complicated but it does make things harder to follow. Depends on your needs. Firing off events is a great way to reduce decoupling between objects

drifting yew
#

I need to have a turn-based system with time units, and once the value of a unit has counted down to 0 it's their turn

pine smelt
#

a timer's probably the better way to handle that

#

and just makes more sense in general

glass light
#

It means making stuff not depend on stuff

#

basically πŸ˜„

#

Real-life example is in my game (small plug: https://store.steampowered.com/app/3122220/Mr_Figs)

there are pressure plates.
Originally I had a pressure plate class and I'd inject the "spike" class of the spike it triggered into the constructor of the pressure plate

Now I do don't do any of that. Now, it takes a list of id's of sprites to toggle.

It's still coupled slightly but less so

untold sigil
#

The issue with blitting the enemy is that you're passing enemy_list directly into screen.blit(), but screen.blit() requires a specific Rect position, not a list. You should iterate over enemy_list to get each enemy's Rect and blit it individually. Try this inside your game loop-

for enemy_rect in enemy_list:
    screen.blit(enemy, enemy_rect)

This will maek sure that each enemy is blitted at its respective position.

dawn quiver
#

Hi

#

Which type of game are you talking about?

drifting yew
glass light
limber veldt
#

Most games on steam aren't released as python/pygame source code. I see this game isn't yet released but still, the question is, in what form will the release be?

glass light
#

Ah I see what you mean.
For windows it'll be frozen as an .exe and you'll just run that

I'm pretty sure pyinstaller can do the same for Linux too so I'm hoping to bundle a single executable file on Linux rather than a bunch of scripts.

To be honest I haven't looked into it fully but I'm not too keen on just having the source fully available once purchased

stuck cliff
#

hey guys, i am having some proplems with some microbit code, i have tried so many things to try and get this to work but nothing is working, this should be such a simple thing. if you guys can help at all please do, this is for a assesment where i am making space invaders on a micro bit but the most basic movent isnt working (dont mind the uncalled variables they will be used later) heres my code (from microbit import *
from random import *

screenreset = 2
flyerposition = 2
flyerhealth = 5
reset = 0
display.set_pixel(flyerposition, 4, 9) # set dot in middle
while True: # start game loop
screenreset = flyerposition # set screenreset to red dot last position
if button_a.is_pressed():
sleep(200) # debounce button
flyerposition -= 1 # set new position for dot 1 pixel left
if flyerposition < 0: # make sure it doesnt overshoot
flyerposition = 0
display.set_pixel(screenreset, 4, 0)
display.set_pixel(flyerposition, 4, 9)
if button_b.is_pressed():
sleep(200) # debounce button
flyerposition += 1 # set new position for dot 1 pixel right
if flyerposition > 4: # make sure it doesnt overshoot
flyerposition = 4
display.set_pixel(screenreset, 4, 0)
display.set_pixel(flyerposition, 4, 9))

smoky kindle
#

yoooo

stuck cliff
#

yoooo

fleet grove
#

!pypi ursina

frank fieldBOT
#

An easy to use game engine/framework for python.

Released on <t:1713733992:D>.

drifting yew
#

idk, does the game have a visible background? if you always set the screen to match where the flyer is it could look like no movement.

#

or maybe something about the button functions

#

maybe try printing something as test if a button is pressed to see if that works

drifting yew
#

I'm not exactly sure how I want to treat enemies that are on adjacent dungeon levels. Being able to follow you if you went to another floor while they were right next to you, most likely.

#

but also moving around and maybe even changing floors sometimes while not directly next to player

finite crow
limber veldt
#

I think it's a fine idea, looks ambitious

finite crow
#

!paste

frank fieldBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

pure flint
#

Hi everyone! I did my 3D engine with Pygame, made the movement but when I tried to do the camera rotation like in a first-person game, it did like in a third-person game and I can't figure out how to fix it.

I would be very happy if someone would help me as fast as possible.

My code: https://paste.pythondiscord.com/NCFA

finite crow
# pure flint Hi everyone! I did my 3D engine with Pygame, made the movement but when I tried ...

It seems like the camera is roating around the objects instead of the FPS perspective you want. Try this

    # Π‘Π΄Π²ΠΈΠ³ Ρ‚ΠΎΡ‡ΠΊΠΈ ΠΎΡ‚Π½ΠΎΡΠΈΡ‚Π΅Π»ΡŒΠ½ΠΎ ΠΏΠΎΠ·ΠΈΡ†ΠΈΠΈ ΠΊΠ°ΠΌΠ΅Ρ€Ρ‹ (Ρ†Π΅Π½Ρ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ² Π²ΠΎΠΊΡ€ΡƒΠ³ ΠΊΠ°ΠΌΠ΅Ρ€Ρ‹)
    x -= camera_position[0]
    y -= camera_position[1]
    z -= camera_position[2]

    # ΠŸΡ€ΠΈΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΏΠΎΠ²ΠΎΡ€ΠΎΡ‚ ΠΊΠ°ΠΌΠ΅Ρ€Ρ‹ (yaw ΠΈ pitch) ΠΊΠΎ всСм ΠΎΠ±ΡŠΠ΅ΠΊΡ‚Π°ΠΌ
    cos_yaw = math.cos(math.radians(yaw))
    sin_yaw = math.sin(math.radians(yaw))
    cos_pitch = math.cos(math.radians(pitch))
    sin_pitch = math.sin(math.radians(pitch))

    # Π’Ρ€Π°Ρ‰Π΅Π½ΠΈΠ΅ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ² Π²ΠΎΠΊΡ€ΡƒΠ³ оси X (pitch) - ΠΎΠ±Ρ€Π°Ρ‚ΠΈΡ‚Π΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° порядок!
    rotatedY = y * cos_pitch - z * sin_pitch 
    rotatedZ = y * sin_pitch + z * cos_pitch

    # Π’Ρ€Π°Ρ‰Π΅Π½ΠΈΠ΅ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚ΠΎΠ² Π²ΠΎΠΊΡ€ΡƒΠ³ оси Y (yaw)
    rotatedX = x * cos_yaw + rotatedZ * sin_yaw  # ИзмСнСно: + вмСсто -
    rotatedZ = -x * sin_yaw + rotatedZ * cos_yaw # ИзмСнСно: - вмСсто + ΠΈ порядок ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹Ρ…

    # ΠŸΡ€ΠΎΠ΅Ρ†ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ Ρ‚ΠΎΡ‡ΠΊΠΈ Π½Π° экран
    xscreen = int(rotatedX * (fov / (fov + rotatedZ + 1)) + centerX)
    yscreen = int(rotatedY * (fov / (fov + rotatedZ + 1)) + centerY)

    return (xscreen, yscreen)```
finite crow
pure flint
finite crow
#

!paste

frank fieldBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

finite crow
pure flint
#

so yeah, don't generate the code

spice tartan
#

honestly it looks funny

#

I'd like to see the answer too

finite crow
#

I'm not sure what you're doing, but I didnt get that exxpereince you're seeing in the video.

#

Maybe the issue is something else.

pure flint
pure flint
vagrant saddle
#

are you rotating the camera at 0,0,0 and then translate it to its pos ?

finite crow
# pure flint can you record a video of your expirience?

Try this, it seems to work better but its hard to test because of my juypter env i think. ```def create_point(x, y, z):
# Shift the point relative to the camera position
x -= camera_position[0]
y -= camera_position[1]
z -= camera_position[2]

# Apply inverse camera rotation (use negative angles)
cos_yaw = math.cos(math.radians(-yaw))
sin_yaw = math.sin(math.radians(-yaw)) 
cos_pitch = math.cos(math.radians(-pitch))
sin_pitch = math.sin(math.radians(-pitch))

# Rotate around Y-axis (yaw)
rotatedX = x * cos_yaw - z * sin_yaw
rotatedZ = x * sin_yaw + z * cos_yaw

# Rotate around X-axis (pitch)  
rotatedY = y * cos_pitch - rotatedZ * sin_pitch
rotatedZ = y * sin_pitch + rotatedZ * cos_pitch

# Project the 3D point to 2D screen space
if rotatedZ != 0:
    xscreen = int(rotatedX * (fov / (fov + rotatedZ)) + centerX)
    yscreen = int(rotatedY * (fov / (fov + rotatedZ)) + centerY)
else: 
    xscreen, yscreen = centerX, centerY # Handle division by zero

return (xscreen, yscreen)```
finite crow
spice tartan
pure flint
pure flint
spice tartan
#

it works sometimes for me

spice tartan
#

i think it just literally goes thru the floor i think

pure flint
spice tartan
#

maybe try anchor it.. like locking it in one fixed place.. idk what to say

spice tartan
#

the thing is that you're doing it raw

#

so uh idk

#

if ur using like unity or godot it should have options for it

slate sentinel
#

Hi all. I recently developed a 2D roguelike(very early stages but playable) using pygame in python along with custom music. Now I am not sure how to make it online so others can play and review on it. Can anyone guide me through the process or link me to a place I can study about it? Thank you.

#

I structured the code in pycharm IDE.

pine smelt
#

are you in thr pygame discord

#

the pygame-web channel and pmp-p will be a great help

drifting yew
#

I too am working on a roguelike (absolutely unplayable lol)

finite crow
# pine smelt are you in thr pygame discord

I wanted t o make a game that uses https://gitlab.com/2009scape The runscape sorce code, but I wanted to implement my AI idea in the mechanics.

https://github.com/plunder707/Aithera

GitHub

Aitheria: Code & Chronicles - A New Dawn in AI-Powered MMORPGs - GitHub - plunder707/Aithera: Aitheria: Code & Chronicles - A New Dawn in AI-Powered MMORPGs

finite crow
# fleet talon how to run this?

Sorry, it was a private repo. its still under construction, but I'd like to get the project rolling. I was starting to flesh out the files. But its a big job.

glass light
#

Didn't get loads done today however. Working on a new trailer and it's sucking precisely 100% of my free time

past sandal
limber veldt
#

I've just been refactoring again. I had all behavior of picking up and moving pieces in main, including that for both human and ai players, with conditions for switching between them. Have now moved all that behavior into a NewPlayer() class having generic player behaviors which I subclass for HumanPlayer() and AIPlayer() with each of those having specific piece handling behaviors. I think it makes more sense now, at least to me

#

So now in main, I just have a callback from each of the players (human and AI) to trigger the player change, then call the next player to play()

#

Main just does some bookkeeping, like adding the move to the move list, so got rid of a lot of code there, which was kinda the goal

#

Checks for game over and stuff

limber veldt
glass light
drifting yew
#

it's like old pokemon works, seems fine

glass light
#

Yeah that and bomberman were my gotos for inspiration on that front

glass light
limber veldt
tough star
#

can someone try my game and see what they think of it? And most importantly report any bugs

glass light
limber veldt
#

I'm wondering if it'd be worth the effort to create some sort of command system that oversees a command queue. Like I kind of already have that but not quite like a master queue, each player handles its own behavior and sets states of pieces by calling methods to trigger state changes. Like if piece is to move, player calls its get_moved() method with a square to move to, so get_moved() is basically a command but it's not queued

#

For normal play, human vs bot, totally unnecessary

thorn knoll
#

coded this game on TechSmart with the theme of "world improvement." the idea is that you play as a robot that collects acorns (it looks like a bird) and can swap out at any time with a robot that collects rain. the seed bot can plant acorns, which become small trees, and the water bot can use rainwater to grow said trees. this is a work in progress. what are your thoughts on my work so far?

hardy magnet
#

i really like the idea too

thorn knoll
#

thx

#

i just finished adding the storage system

#

the seed bot can now carry only up to 9 acorns at a time

hardy magnet
#

nice!

thorn knoll
#

:D

#

small trees = 1 pt. per second

#

big trees = 3 pts. per second

hardy magnet
#

yeah this is a pretty unique idea you could really build on this concept

thorn knoll
#

yeah

#

this was rly hard to make

hardy magnet
#

its definitely paying off

thorn knoll
#

@hardy magnet

#

thats the neat part

#

i actually DIDNT use OOP!

#

i made the entire thing without using OOP once

hardy magnet
#

nice

#

im a huge functional programming shill too

#

learning OOP is good though id look into it eventually

thorn knoll
#

yeah i am

#

i just started learning about it today

#

but i dont rly wanna risk breaking my code like i have 239020293 times already sooooooo yeah

hardy magnet
#

you could always start a new project for the sake of learning OOP if you want

thorn knoll
#

well ig yeah

#

when this is finished ill try reworking the code into oop as a separate project

#

oop is something like this right?

#

@hardy magnet

hardy magnet
#

Yeah, classes and stuff

thorn knoll
#

yep

thorn knoll
# thorn knoll
poll_question_text

guess if i used OOP in my program

victor_answer_votes

1

total_votes

1

victor_answer_id

1

victor_answer_text

yes, you used OOP

victor_answer_emoji_name

πŸ‘

floral quiver
#

Whats going on?

#

Please ping me in response

slate sentinel
slate sentinel
slate sentinel
drifting yew
smoky kindle
#

yoo

wraith wren
#

I recieve the same problem everytime, Can someone try figure out what's wrong with it? Is it the code that i did wrong or did i forget to insert something in the code?

pine smelt
#

can u send the code directly

#

i mean u dont enter the right password?

tranquil girder
wraith wren
#

Ok thank you for that.

slate sentinel
slate sentinel
floral quiver
#

Just finished my first ever game without a tutorial. the code is very shit but it has exactly 100 lines which is cool. Anyone got any ideas that I could try and add?

#

my recording software makes it look jittery the game actually runs fine πŸ˜…

limber veldt
bold hill
#

I need help making a main character class for painting that allows the user to pick a race and customize their character for a game I'm getting out the player out of the way so the world building can come in second sorry

floral quiver
floral quiver
bold hill
ruby hemlock
#

Hi, I have tried to look up for a way to organize folders in games, but whatever I tried to find nothing appears is there a general way devs do to organize folders or is it just something you figure yourself?

pine smelt
#

depends on the person but a way I've found pretty intuitive is having in the main directory

-assets folder
-audio folder
-data folder
-scripts folder
-main.py

#

in the main.py I have the main "game object" that has the update loop and I organise the scripts by having subfolder for a group of similar stuff

#

so I'd have for example a folder called particles, a folder called entities and sometimes subfolders within that (e.g. having a folders for players, and another for enemies, WITHIN the entities folder)

unkempt hornet
#

Hey y'all, I'm working on this simple RPG videogame where you battle others' animals, and this is what it looks like so far.
What do you think?

limber veldt
#

For my chess, I did...
-Assets folder < contains sounds folder, images (in multiple folders sorted by categories),
-code folder < has all scripts including players.py, pieces.py, groups.py, board.py, main.py...etc
-stockfish folder < contains stockfish.exe
-saved_data < all saved settings (from the Save Settings button)

pine smelt
#

u don't keep ur main.py in the root?

pine smelt
limber veldt
#

Not for this project, for some I have

pine smelt
#

I feel like the A's seem a bit squashed but still readable

limber veldt
#

I did try something a little different with this one. Instead of instancing screen and images in main like I normally do, I instance SCREEN, and a few other globals, and load images in game_setup.py then import them where necessary

#

I like that it gets all the image loading out my way in main

pine smelt
#

i usually do that in the initilisation of my game object

#

i have a function called cache_sprites that i run before the main loop

#

well that in itself calls the cache_sprites class method of every object i need to load the sprites of early

marble jewel
#

Isometria Devlog 50 - Mother, New Items, Better Weather, Better Saves, and More! https://youtu.be/5xCwcKujZXc

Wishlist and play the Isometria demo here: https://store.steampowered.com/app/2596940/Isometria

https://bigwhoopgames.itch.io/isometria-demo

In Today's devlog I show you the newest boss added to Isometria, Mother. I'll also preview some of the gear you can get from her as well as mention various improvements to the game like weather and saves....

β–Ά Play video
primal epoch
#

here are some cool ascii spaceships I made in python

coral horizon
pine plinth
#

I love it

pine smelt
#

thats amazng how long did that take

primal epoch
#

I like your pfp btw lol

limber veldt
spring ether
#

elo im a bit of a beginner at python + game development in general

here's some random stuff I coded for my text adventure game

twilit pike
spring ether
#

Mostly using it so I can easily reference the stat for the respective protagonist without having to make a long list of if else statements

cerulean nimbus
spring ether
#

renpy script file
The game engine has its own language but also uses python

pine smelt
#

also suggestion from a game point of view, after u put the key into the lock thing some sort of screen shake might be useful

#

tho it depends on where ur going with this

limber veldt
#

You're not supposed to be able to walk right up and drop the key through the wall, so the sentries prevent that

#

But that is a great idea, some visual feedback that a wall or gate has moved or opened

#

That lock is actuallty a little difficult to not lose a robot once the guard is in place, making saving the game very important

#

You need a robot that can find its way to and park right between the two fans and thrust both left and right at the same time, spinning the fans and opening the walls above the keyhole where a second robot can enter (by itself, no hiding inside it because of the sentry) with the key in its grabber and drop it when it reaches the keyhole

#

The puzzles in that level are meant to be hard af

#

It's the super secret sixth level

#

I spent weeks solving the purple lock the first time

#

And you also need to make sure you can get your robots back, other locks may need multiple bots

#

So many mechanics in that game, like every puzzle is a different set of them

pine smelt
#

how long have u spent on it so far

#

i cant imagine how long it would take to connect every puzzle together

limber veldt
#

Total time spent making the game? Oh man, a lot, hundreds of hours for sure

pine smelt
#

sounds about right lol

limber veldt
#

The first screen in the video, at like 2 seconds, is all items in the game, too

pine smelt
#

is that like a debug room or something

limber veldt
#

Not counting things from the toolbox (gates and devices like that)

#

Yeah

#

That whole level is a test

pine smelt
#

there are multiple levels?

limber veldt
#

Yeah, 5 regular and the super secret sixth plus the lab and about 8 tutorial levels, so about 14 total

still violet
#

Hello.

limber veldt
#

Hi

#

Walkthroughs of all the gates in one level, sensors in another, and so on

#

Robots, Circuits, Chip burning, all kinds of em

#

And the saves are level based, such that if you save in level 5 only that level is saved, for instance

#

Over 400 rooms total, nearly 500

#

And why it's my most ambitious project

limber veldt
#

After playing the game, one will definitely understand digital logic at some basic level at least

#

I have a playlist of me playing the 2000 remake (made in java) start to finish on my youtube, but I'll keep that secret for now : )

past halo
thorn knoll
hardy magnet
#

and a currency system to purchase the upgrades

thorn knoll
#

hmm maybe!

#

for now, any simple ideas? maybe i can add a speed boost to make it easier to catch falling acorns

#

"simple ideas" meaning things i can add to the objectives list

thorn knoll
#

Waiting for points to accumulate before spending it all on an upgrade is a bit annoying sometimes

hardy magnet
#

yeah

thorn knoll
hardy magnet
#

maybe an objective to stay alive for x seconds?

thorn knoll
#

wait hang on

#

theres no penalty for missing acorns

#

besides time

hardy magnet
#

you could also do it like
plant 3 trees
plant 7 trees
plant 15 ... ... to like 100 or something crazy

#

so its like continuous

thorn knoll
#

so maybe catching x acorns in a row?

hardy magnet
#

yeah that could be a good one too

thorn knoll
#

actually, the game resets after each objective

hardy magnet
#

oh i see

thorn knoll
#

i also added fires too

#

they deduct 0.1 points a second

#

and you do not gain any points

#

while a fire is active

#

you also cannot pass the objective if a fire is active

hardy magnet
#

mabye you could store the users stats in a text file so players can keep their scores and stuff

thorn knoll
#

the theme IS world improvement soo...

#

ohh wait i just had an idea

#

i can make the first 3 levels a tutorial

#

the first one is "plant three trees" and the second is "grow three trees" and the third is "extinguish three fires"

hardy magnet
#

oh yeah good idea

thorn knoll
#

maybe a bossfight?

#

against a fire guy who shoots fire, and you have to counter it by shooting water with the water bot

#

and if you manage to hit the boss x amount of times you win

#

maybe that can be the final level

#

i already found some techsmart sprites for the boss, as well as the arena

#

maybe we can give the seed bot a role too but idk how thats gonna work

thorn knoll
#

(Water and fire CANNOT spawn during level 1.)
(Acorns and fire CANNOT spawn during level 2.)

hardy magnet
#

ooh very cool

thorn knoll
#

still need to make one about extinguishing fires

#

will make around 3 fires spawn in and then only water can spawn after that

thorn knoll
#

added crystals to the game now

#

crystals set your Growth Points (GP) to 3

#

now, when an acorn is planted, it is automatically grown to a big tree in exchange for 1 GP.

#

if the player has 0 GP, then any acorns planted will become small trees.

bold hill
#

May I ask a question?

#

How can I make a crafting system?

pine smelt
#

depends on ur game

dawn quiver
#

Hello guys I’m just getting started with python /pygame

#

I need some help In creating a username passird screen

bold hill
pine smelt
#

do you have a screenshot of the game so far, im not sure how DND games look

pine smelt
dawn quiver
#

Now I am trying to figure out how I can type in the box and validate the input

#

But can’t

pine smelt
#

live typing is tricky, u sure u cant use tkinter for that part

dawn quiver
#

What is tkintr sry I’m new to this

limber veldt
#

tikinter is a user interface thing, it has textboxes, entryboxes, dropdown menus, things like this that you can build and use. I wonder about pygame_gui though, I haven't really checked that out so I don't really know what it can or cannot do

bold hill
lunar saddle
#

What is the best package for game development?

bold hill
#

Pygame

limber veldt
#

pygame-ce, almost the same thing but the Community Edition of pygame

floral quiver
#

Im wondering on how I could go about making a map in pygame, like using blocks and placing them around in a specific order

#

Ive seen methods where people use something like this:

",""x"

#

Like , being an empty space

#

and x being a sprite

#

but no idea how to do this so if anyone knows please tell me how

bold hill
#

How can I assign specific traits to what I want for in a game because I want to make it warm if you choose an Archer as a class you're able to shoot arrows but for warriors you would have to learn that trait

#
class mage:
    def __init__(self):
        
        health = 100
        
        mana = 50
        can_use_mage_progectiles = True
        
        defence_spells = []
        
        attack_spells = []
        
        heal_spells = []
        
        traits = {}
        
        buffs = {}
        
        debuffs = {}
        ```
        Is this okay for a game class
stable pasture
#

searching for people that wanna code a recoil compensator for all types of games... DM me if ur interested !!!

bold hill
manic totem
#

what does it mean by "all 4 fields"
TypeError: Invalid rect, all 4 fields must be numeric

pearl juniper
#

Make sure you're passing exactly four numeric values, such as integers or floats, in the correct order
For example: rect = (x, y, width, height)
Each of the four values (x, y, width, and height) is numeric (integer or float).
No fields are missing or None

shadow plover
#
            for index, zombie in enumerate(self.cur_zomb_wave):
                direction_x = self.player_pos[0] - zombie[0]
                direction_y = self.player_pos[1] - zombie[1]
                
                distance = (direction_x**2 + direction_y**2) ** 0.5

                if distance != 0:
                    direction_x /= distance
                    direction_y /= distance

                    self.cur_zomb_wave[index][0] += direction_x * zombie_speed
                    self.cur_zomb_wave[index][1] += direction_y * zombie_speed

                zombie_pos = [
                    zombie[0] - self.camera_offset[0],
                    zombie[1] - self.camera_offset[1]
                ]
                self.screen.blit(self.zom, zombie_pos)

Hey guys! I am new to pygame and I found this sample code to move an object towards a moving player, but when i try it, the objects just accumulate at one point after a few seconds and collectively move towards the player, i kinda want them to spread out and like encircle the player, if that makes sense? Thanks πŸ˜„

astral dust
#

I can share code if u need, but I am sure most part is unreadable.

vagrant saddle
#

sounds like selling cheating program for various fps

stable pasture
vagrant saddle
vagrant saddle
#

still R/E on a licensed cheat ( yeah even virus/cheats can be (c) work ) can be illegal in some countries

bold hill
#

Am I able to use a class for my game?

#
#===[imports]===#
import pygame 
import numpy
#===============#

#===[inits]===#
pygame.init()
#=============#

#===[window dimentions/ ect]===#
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 500

pygame.display.set_caption('eden')

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
#==============================#


#===[classes]===#
class races:
    pass

class classes:
    pass

class player(races,classes):

    
    comanions = []

    inventory = {}
    pass

#===[monster classes]===#
class monster:
    pass

class vault_monster(monster):
    pass
#===============#

running = True

while running:




    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
#

Here's my code I'm working on the classes first before I get into anything of the true game

bold hill
#

@pine smelt

spice vigil
bold hill
spice vigil
bold hill
#

What I mean is how can I make it intelligent to hunt the player

#

Sorry

bold hill
spice vigil
spice vigil
bold hill
#

I've never done anything I like this so I don't really know how to use it sorry

spice vigil
# bold hill I've never done anything I like this so I don't really know how to use it sorry

Making a platformer with Pygame is a fun way to learn both game development and software engineering. This tutorial covers a variety topics including tiles, physics, entities, particles, sparks, camera, parallax, enemies, AI, combat, level editing, level transitions, making executables, and more!

Project Reference Resources:
https://dafluffypot...

β–Ά Play video
#

It is may be overwhelming but it is very easy to understand

#

You will get the basic understanding in that video

limber veldt
#

I think the easiest way to track a player (or any object) is 1: get vector from chaser to chased, that is vec = chaser.position - chased.position. 2: Normalize that vector. 3: set it as chaser.direction. 4: update chaser position. chaser.position += chaser.direction * chaser.speed * dt

limber veldt
# limber veldt I think the easiest way to track a player (or any object) is 1: get vector from ...

A most basic demonstration ```py
import pygame
from pygame import Vector2

screen = pygame.display.set_mode((400, 400))

CLOCK = pygame.time.Clock()
FPS = 60

class Chaser(pygame.sprite.Sprite):
def init(self, pos, group):
super().init(group)
self.image = pygame.Surface((40, 40))
self.image.fill('red')
self.rect = self.image.get_frect(center = pos)
self.direction = Vector2()
self.speed = 200

def update(self, dt, target_pos):
    direction = Vector2(target_pos) - Vector2(self.rect.center)
    direction.normalize_ip()
    self.rect.center += direction * self.speed * dt

enemy_group = pygame.sprite.Group()
chaser = Chaser((200, 200), enemy_group)

while True:
dt = CLOCK.tick(FPS) * 0.001
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
raise SystemExit

screen.fill('black')

enemy_group.draw(screen)
enemy_group.update(dt, pygame.mouse.get_pos())

pygame.display.update()```
limber veldt
#

As with most of my quickie demos, pygame-ce required (for the get_frect() as opposed to regular pygame's get_rect() otherwise, we need to cast the chaser rect center ints to floats, do math on them, then assign them back to chaser rect center

#

Same thing but using get_rect() (this time with ZeroDivisionError checking before the vector.normalize_ip()) ```py
import pygame
from pygame import Vector2

screen = pygame.display.set_mode((400, 400))

CLOCK = pygame.time.Clock()
FPS = 60

class Chaser(pygame.sprite.Sprite):
def init(self, pos, group):
super().init(group)
self.image = pygame.Surface((40, 40))
self.image.fill('red')
self.rect = self.image.get_rect(center = pos)
self.pos = Vector2(self.rect.center)
self.direction = Vector2()
self.speed = 200

def update(self, dt, target_pos):
    self.direction = Vector2(target_pos) - Vector2(self.rect.center)
    if self.direction.length() > 0:
        self.direction.normalize_ip()
    self.pos += self.direction * self.speed * dt
    self.rect.center = round(self.pos.x), round(self.pos.y)

enemy_group = pygame.sprite.Group()
chaser = Chaser((200, 200), enemy_group)

while True:
dt = CLOCK.tick(FPS) * 0.001
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
raise SystemExit

screen.fill('black')

enemy_group.draw(screen)
enemy_group.update(dt, pygame.mouse.get_pos())

pygame.display.update()```
#

Notice how I use self.pos, a vector using floats for .x and .y attributes, as the position of the chaser instead of its rect.center. That's because get_rect() only supports ints and doing physics with ints is not precise enough, it loses the decimals on every update

glass light
limber veldt
#

Oh nice, gotta have some hidden areas, very cool

#

The music, the graphics, the movement, it's all good

glass light
#

Thanks, it was actually super easy to do

limber veldt
#

The mechanics look like they're working great too

glass light
#

Hah yeah it's getting there. a year or two left I think. It's been a slog πŸ˜„

limber veldt
#

That's what I'm lacking in my robot game but it'd have to be less 'actiony` kind of music, maybe I just leave that to the player to run their own music

glass light
#

Yeah, if you can catch a good opportunity, humble bundle do some good music/fx asset packs

limber veldt
#

I never think of using steam for assets, I should check it out the next time I need

floral quiver
#

For my second ever pygame project I wanted to make a clone of the classic fruit drop game where you catch falling fruit. I learnt about using random here and worked out how to use buttons and a game over screen I think it turned pretty neat!

#

I messed up the button placement during the recording somehow 🀣. If anyone is interested in seeing the code let me know I can dm it

#

Oh yeah, if anyone has an idea on what I could do next as a challenge/project please let me know! (im still a beginner about 2 weeks in so dont make it too difficult pls)

limber veldt
#

Looking good...next project...hmmm, I don't know, maybe something with rotations, like asteroids?

floral quiver
limber veldt
#

Sending bullets at angles is a good thing to know

floral quiver
#

yeah thats gonna be tough im gonna try and break it down into as many chunks as i can and try and complete each one, thats my method.

limber veldt
#

Pro-tip, if not already learning them, start learning to use vectors for movement

limber veldt
#

They can be scaled to work with deltatime, math on them is easy, many many advantages. They are pretty much the industry standard for moving things in 2d space, like screens, and even 3d games

floral quiver
limber veldt
#

Yeah, part of linear algebra

floral quiver
#

im gonna watch some vids on it now.

#

thanks for tips and feedback!

limber veldt
#

I learned a lot about them from a few youtubers, The Coding Train's Nature of Code series (not in python but the logic holds for any language, it's about the vectors, not the code), Freya Holmer, and a few others

#

And pygame has really useful Vector2 (and Vector3) classes and methods

floral quiver
limber veldt
#

Correct

#

They are in pygame.math.Vector2 but can also be accessed with just pygame.Vector2 which is why I usually just import them separately like so from pygame import Vector2 and can use it by that name anywhere

floral quiver
#

Vector 3 would be x,y,z so isnt that 3d?

limber veldt
#

Yep

floral quiver
#

so you can make 3d games in pygame?

#

i didnt know

limber veldt
#

I mean, not really but sometimes 3d vectors might be useful to some, I never use them

floral quiver
#

Im gonna mess around with vectors for a while and try and get some sort of accelaration decellartion thign working

limber veldt
#

Good luck, fun stuff

floral quiver
#

Happy pygame handles the complicated stuff

limber veldt
#

Take it slow at first, it's all part of the process

limber veldt
#

But many behaviors like seek(), arrive(), follow_path(), all that stuff, is using vectors

#

Where to spawn the bullet with a rotating cannon...vectors can figure that out in like three lines

limber veldt
#

Aiming at and hitting a moving target, particularly difficult stuff like that, also vectors

pine smelt
#

HOWEVER, people have made all sorts of pseudo-3d games

#

2.5D (literally any doom clone), isometric (bigwhoop's isometria) and sprite stacking (like fluffy's kart game) to name a few

limber veldt
#

Yeah, they can get things working in opengl contexts and stuff, but nothing I've seen yet is really mainstream

pine smelt
#

yeah

limber veldt
#

I've used Blender a few times to make and render images of 3d objects to be used as sprites in animations

#

And that's kinda cool, at least the sprites look 3d

#

Thought about doing it for chess pieces but blender sculpting (for the knight) was never my thing

#

All the other pieces are just fancy extruded circles

pine smelt
#

imo it wouldn't be worth the effort anyway, you'd only ever see one face of the pieces anyway

limber veldt
#

I'd probably tip them to an isometric angle but true, they wouldn't have rotation anyway

pine smelt
#

ye

limber veldt
#

Like this little ship that does a flyover during the intro to one of them, the path it follows and images all made in blender

#

The entire flight takes less than a second or so, but I had to have it

#

That original game was from like 1981 or so, if they could do it then, how hard could it be? I'm not sure how they did it but surely something similar

bold hill
crude dagger
limber veldt
# bold hill How can I difine a shape for the player?

I'm not sure I understand what you mean there but if you have a surface on which to draw your player, you could define points to use in pygame.draw.polygon() or any combination of the other pygame.draw.... methods and draw them on that surface

#

You could also pygame.image.load() an image

astral dust
#

Hello

#

I am making War Thunder like game on python, now I am working on penetration and modules damage simulation (very simple)

#

Anyone knows an article to read about this stuff

#

?

keen flame
#

Hi , is "Tkinter" library good for develop games?

If not please let me know which library is the best for making games in python

tidal drift
#

you may want to take a look at pygame-ce instead

floral quiver
keen flame
#

Ok , thank you so much

floral quiver
#

Could someone help me with vector movement in pygame I cant work it out

bold hill
#

Why mean is how can I define the player to be inside of the class itself sorry

floral quiver
astral dust
astral dust
keen flame
#

I think I will start learning pygame

Although I'm not sure where I can learn it or even where I should start with

#

Probably self learning

floral quiver
#

use youtube

keen flame
#

Only I know is

"Import pygame"

And that's all

keen flame
#

I mean about pygame

floral quiver
#

Sure

limber veldt
#

Clear Code, DaFluffyPotato, a few others have good quality videos

floral quiver
#

Tech with Tim too

floral quiver
floral quiver
# astral dust Well, then send code

Hello sorry about that. I dont have any atm I was hoping to have help actually writing it and making a player movement script with acceleration ect but I cant find a good tutorial

astral dust
#

I used tkinter here because I wanted to draw in overlay

keen flame
#

Wow that's cool , but I heard from people that tkinter is not good for games

astral dust
astral dust
prisma gust
#

Yo

#

Need some help

#

Im new to this server and to python

#

I dont understand python coding in the slightest

#

I wanna code a shooter game

#

On pygame

#

Or tkinter

dusky grove
#

Who needs developer?
I am fullstack, blockchain, game, bot developer.

floral quiver
verbal kestrel
floral quiver
#

^

ruby acorn
#

Hey

limber veldt
#

Playing around with seek() and arrive() methods, oh and also seeing what it takes to make a ghost behave like Mario's (facing away makes him chase you) https://paste.pythondiscord.com/CFTA

limber veldt
limber veldt
#

Thanks

floral quiver
limber veldt
#

Not terribly difficult, just get a vector from the mouse position to the ship's and normailize then assign it to the ship's .direction attribute (all inside the get_input() method)

#

See how I'm getting the keys to rotate that vector?

#

Instead, get the vector from the mouse to the ship

floral quiver
#

yeah I think so

limber veldt
#

It could be a little more (or even a lot more complicated if wanted that way), but surely something could be put together quickly

floral quiver
#

Your code is so clean how long have you been making games in pygame?

limber veldt
#

Like I'm damping the rotation with the rot_vel attribute, implementing that relative to the amount of difference between where the ship is facing and where that vector points might matter but I doubt it, it's very little damping anyway

limber veldt
floral quiver
#

I see now why your code is perfect haha

limber veldt
#

I dunno about that, there are others here that can do even better : )

floral quiver
#

everythign is in a functon

floral quiver
limber veldt
#

We're all somewhere along the path, keep practicing and anyone can be pretty good

#

Organizing code is a big part of keep it workable or at least making it easier to work with

floral quiver
#

I sure hope so just gotta keep motivated thats really what i struggle with

floral quiver
limber veldt
#

Coding Blender's API

#

Well, making an addon for it

#

Among other things

#

It used to have a Game Engine built in, it's since separated from main Blender branch but somewhere along the line, I went to using pygame

limber veldt
#

But I was pretty new at python when I started, some prior coding though, I've been ahobby coder for a looong time

#

For me, the motivation was really wanting or even needing to make that addon, no matter how long it takes

#

And of course, other ideas and projects happen since I learned allat

floral quiver
#

Fair enough

#

I think its a great hobby too so far

limber veldt
#

Nope, just practicing, always practicing and then practicing some more

#

It is fun, like I still get excited af when something really hard finally works

floral quiver
#

yeah its an amazing feeling even with small projects like my recent one where i made a main menu screen

limber veldt
#

Hell yeah

#

As for functions and methods, I feel like there's a sweetspot between making a long method with a few comments and just breaking out some of that code to other methods and the name of the method being the 'comment' or making it readable

#

Then you can kind of group things together in a logical way, probably takes a lot of practice though

midnight gust
#

Hi

#

I'm a newbie to python programming .

#

As a beginner , I need a guide to complete my journey

#

I'm a 10th grader in Banglore, India

floral quiver
gentle junco
nocturne lance
#

how do i make a gmae bot

bold hill
#

How can I call materials from a class for players specifically

warm mortar
#

Anyone interested in collaborating on a JS project?

vagrant saddle
warm mortar
gentle junco
#

https://paste.pythondiscord.com/BDTQ can anyone tell me how i can fix this? once the 'ai' attacks it doesnt stop and starts spamming them forever, seems very simple but i have no idea what to do

bold hill
#

How can I blit a class onto the screen sorry

#
class player(races,classes):
    #player_body = pygame.rect((150, 150, 50, 50))

    
    comanions = []

    inventory = {}
    pass
limber veldt
#

Make it a sprite, add it to a group, draw the group?

bold hill
#

I still need to work on figuring out how to draw sprites why I mean is drawing the character object itself onto the screen

limber veldt
#

That's what sprites and groups do, draw objects

#

Sprites have .image and .rect attributes. The .image attribute defines what to draw and the .rect defines where to draw it

bold hill
limber veldt
#

They don't always have to be in a group, you could just screen.blit(sprite.image, sprite.rect) in your main draw() method, too

#

You don't need a sprite sheet to make a sprite

bold hill
#

I managed to add a player movement in the class no I just need to call it to draw the player and game all the information from the class

#
class player(races,classes):
    player_body = pygame.rect((150, 150, 50, 50))

    
    comanions = []

    inventory = {}

    key = pygame.key.get_pressed()

    if key[pygame.K_a] == True:
        player_body.move_ip(-1 ,0)

    elif key[pygame.K_d] == True:
        player_body.move_ip(1 ,0)

    elif key[pygame.K_w] == True:
        player_body.move_ip(0 ,-1)

    elif key[pygame.K_s] == True:
        player_body.move_ip(0 ,1)


#===[monster classes]===#
class monster:
    pass

class vault_monster(monster):
    pass
#===============#

running = True

while running:

    pygame.draw.rect(screen, (0, 0, 255), player)
limber veldt
#

How is this class going to work? It has no __init__() method or nothing instancing it

bold hill
#

That's what I've been forgetting I've neglected to even put a basic initiate

bold hill
#
class player:
    def __init__( player_body):
        player_body = pygame.rect((150, 150, 50, 50))

    
    comanions = []

    inventory = {}

    key = pygame.key.get_pressed()

    if key[pygame.K_a] == True:
        player_body.move_ip(-1 ,0)

    elif key[pygame.K_d] == True:
        player_body.move_ip(1 ,0)

    elif key[pygame.K_w] == True:
        player_body.move_ip(0 ,-1)

    elif key[pygame.K_s] == True:
        player_body.move_ip(0 ,1)

updated player class

limber veldt
#

It has an update() method that is called from the group by player_group.update() at line 77, that's all it need to update it, and is drawn by player_group.draw() at line 74, that's all it needs

#

Since it has an update() method, we can read the keys inside the class itself with the get_input() method, assign the direction and update the position of the sprite

bold hill
#

I'm not going to get into inheritance yet I'm just trying to find a way of getting all of this to work without driving me crazy

limber veldt
#

You are already inheriting from races and classes, so why not make a sprite? Or were already

#

Totally up to you, sprites and groups make this a lot easier. You asked how to draw a player with a player class that won't really work the way it is

bold hill
#

Thank you I am sorry

limber veldt
#

Like how are you going to call these lines to read the keys?

#

If you want to use classes in pygame, I strongly recommend learning how to subclass pygame.sprite.Sprite and pygame.sprite.Group()

#

Sprite especially

#

It's really only two attributes in the sprite itself, the .image and .rect attributes, that's all you need to make anything a sprite

#

For me, that's much of the advantage of using pygame, the sprites and groups (along with all the other things, event loop, vector methods, so many)

limber veldt
warm mortar
vagrant bane
#

Im creating a dungeon based python game using basic python and I was wondering if anyone knows a good tutorial for top down map making. All the ones I have found on Youtube all import a lot of things and use external things like py.game and I am not allowed to use that on this project for Uni work.

restive pollen
#

Don't know much about game dev in particular, but in your shoes, I'd learn what I could from tutorials on text based game development in python and then use ChatGPT as an advisor to help structure your code (although that might be a no no for an assignment...). I'm guessing that getting the game loop and data structures right are going to be the most important parts of the game design, and those probably don't differ too much in structure with 3rd party packages. But again, not an expert

manic totem
bold hill
#

what did i do wrong? sorry

astral dust
#

forgot self. maybe ?

dawn quiver
#

No swearing

astral dust
dawn quiver
bold hill
#

This is outside of the player class I'm not going to work on spray sheets yet because I don't have any I just want to make sure that this works I might need the code for a Sprite sheets but comment that out later till I can find something that fits sorry

astral dust
astral dust
astral dust
bold hill
astral dust
#

Search in Internet "python OOP full course"

bold hill
astral dust
#

Save time

astral dust
vagrant saddle
astral dust
astral dust
vagrant saddle
vagrant saddle
#

yeah more like that, which on second run has no impact

#

because everything gets cached

astral dust
#

First impression and experience rule

vagrant saddle
#

experience says make attractives loading screens, wonderfull packaging and spend everything on marketing

#

if people can't wait for a free web game to load, they don't deserve the fun

astral dust
#

big part of web players are people with very slow internet

floral quiver
#

What is happening here

#
import pygame
import sys

pygame.init()

WIDTH = 1280
HEIGHT = 720
FPS = 60
clock = pygame.time.Clock()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
direction = pygame.math.Vector2()
player = pygame.rect.Rect(WIDTH / 2, HEIGHT / 2, 30, 30)

def movement():
    keys = pygame.key.get_pressed()

    if keys[pygame.K_w]:
        direction.y = -1
        print(direction)
    elif keys[pygame.K_s]:
        direction.y = 1
        print(direction)
    else:
        direction = 0


    if keys[pygame.K_a]:
        direction.x = 1
        print(direction)
    elif keys[pygame.K_d]:
        direction.x = -1
    else:
         direction = 0


def main():
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        movement()
        screen.fill("Black")
        
        clock.tick(60)
        pygame.draw.rect(screen, "Red", player)
        pygame.display.update()

if __name__ == "__main__":
    main()
#

Here is the whole script

#

Its supposed to print the vector values in the output

#

Please ping me when replying

#

@limber veldt Any ideas?

astral dust
#

including number of line

floral quiver
astral dust
#

do same with direction.y

floral quiver
#

But for some reason pressing do doesnt do anythign

#

but the others work

#

Sorry pressing "d" doesnt do anything

#

Oh I see its becuase i forgot to add print to it

#

all fixed thanks for help

warm mortar
#

Anyone interested in collaborating on a browser game? The structure of it has been completed and the base backend and frontend is already coded.

There is a GitHub and everything. I just could really use a hand

vestal iron
#

how to deal with offset problem. Image just starts going up and down constantly
like if condition met i move image up if not i revert back. But if i place my mouse at the bottom image it constantly offsets and return to original position

#

ping me if you got something

limber veldt
# floral quiver ```py import pygame import sys pygame.init() WIDTH = 1280 HEIGHT = 720 FPS = 6...

Nice start on using Vector2(). One thing I'd point out is that after setting direction, when all is done, it's a good idea to normalize the vector if its length() is greater than 0. If we think about it, we can realize why. When moving left, right up or down, we move 1 pixel at a time because that's the length of our vector, (1, 0) or (0, 1) for the x or y makes that length == 1. If moving right AND down or and up (or any combination of two directions) we get a vector of (1, 1) (both one for x and y of the vector) which makes the length() of our vector 1.4 or so, not 1, and faster than moving just one direction. vector.normalize_ip() will make that 1.4 length vector the length of 1, making all directions move at the same speed, even if at an angle

floral quiver
limber veldt
#

Good for you, making good progress and looking things up

floral quiver
limber veldt
#

Integrating motion over cartesian coordinates (screen pixels) might lead to some hits. But yeah, integrating acceleration, velicity and position is what's needed

limber veldt
#

So for that (acceleration), we usually don't affect the vector directions directly, like setting .direction.y or .x to some value. Instead, we affect acceleration and that gets added to our .direction vector. But there are many ways to accomplish this kind of integration nd me describing it here isn't one of them

#

I kind of faked it with increasing and decreasing .speed the scalar that I use to scale the normalized vector to our movement speed

#

Using two scalars on our position when adding our direction vector gives us that flexibility. position(a vector) += self.direction (a normalized vector) * self.speed (a scalar. .ie: a float) * deltatime (another scalar)

floral quiver
#

Would you use a class for handling movement becuase you self.direction?

limber veldt
#

I would keep movement of player inside a player class

#

All things affecting player should be in the player class but this is not a strict rule, you are totally allowed to affect player attributes from outside the class

floral quiver
#

Ive never actually used a class I think I know how to use them but at this stage i dont really see the point in using them

limber veldt
#

And that's fine too, but just know that classes will help keep your code clean. For now, at this stage of your adventure, you have discovered them, and kind of know what they are and sort of know how to use them at least a little bit, it's fine, in my opinion, if you would rather work on learning mechanics of motion and all that kind of stuff first

floral quiver
#

yeah

#

My code is messy atm but after I actually learn I plan on cleaning it up with functions, classes ect

limber veldt
#

Discovering what can be done is a big part of learning, but practicing what you have already discovered is probably more important

limber veldt
#

Yes

#

Again, something that will serve you better later than now

floral quiver
# limber veldt Yes

Oh okay I always thought it was only if you wanted your games to run at more fps

#

So it looks the same no matter the fps

#

fram independant or something

limber veldt
#

It's good in that if your game is ever ran on a faster or slower machine than the one you are currently running it on, delta time will keep the apparent speed of motion, the speed on the screens, consistent

#

Yeah, framerate independence

floral quiver
limber veldt
#

Yes

floral quiver
#

I'll look into adding it soon too but its very complicated right?

#

as in not complicated to add but how it works behind the scenes

limber veldt
#

It's mostly important for speeds dropping below that 60 fps, being higher than that and our framerate will be fine at 60

#

No, not at all

#

See the dt = something in my previous examples?

#

That's all I do for calculating it (in milliseconds)

#

Properly initializing and re-assigning it each frame isn't terribly difficult either but since pygame has a .time object and it's giving us that value with a simple call, I use it

vestal iron
#

I heared pygame .time doesnt give accurate time

#

like the more decimals you have the more accurate you are

limber veldt
#

Some say perf_counter (part of the python time module) is more accurate

floral quiver
#

Honestly for the small games im making right now your pc would have to be from ancient egypt to get below 60 fps

limber veldt
#

And same here

vestal iron
#

what games you making?

floral quiver
limber veldt
#

Some of my games might get a little heavy on slower machines but the vast majority, those without a hundred enemies on screen at a time and each of them searching for the player, keep a steady 240 fps most of the time

vestal iron
floral quiver
vestal iron
limber veldt
#

They are so valuable

limber veldt
#

To me at least

floral quiver
limber veldt
#

All little sign posts along the path I've mentioned before

astral dust
limber veldt
#

Interesting video

#

hey @vestal iron , I'm curious if you got your state machine working (I think it was you asking about them a few days ago)

vestal iron
limber veldt
#

Those (state machines) are awesome logic helpers. For me, I like that any attributes or special logic for one state is completely separate from any other state, therefor encapsulating logic to each state

vestal iron
#

you know one things is to know theory another thing is apply in practice

limber veldt
#

For sure, that application part is often much harder

vestal iron
#

like recently im pushing myself to make a mess of my code cuz its not ok refactor your state machine a month πŸ˜„ nothing gets dont so at least its for me i have to learn to make a mess

limber veldt
#

lol yeah, refactoring takes time

vestal iron
#

its not about the time it takes to refactor, my problem is that im perfectionist, and refactoring plus that is hazardeous combo

limber veldt
#

This is my basic state pattern. Sometimes I implement a .next_state attribute too and change the pattern slightly, but it works. I'd love to learn more ways to do it, like using an Enum instead of a dict for the states (among other improvements) https://paste.pythondiscord.com/C4VQ

#

And those states aren't doing anything either, only looking at the pattern there

#

Just counting time and switching to another state to count more time

#

In fact, there's a typo in it, but it's ok, it's not meant to be ran

#

Also shows why I consider delta time pretty important for things that move, it gets sent to and used by everything that animates motion on screen, or any kind of timing pattern

vestal iron
#

There is a website about patterns and there is state pattern example in OOP way. Im giving heads up that they love abstractions and overcomplicating things.

limber veldt
#

Wanna make a digital clock? That's the start of one

#

Oh that line 81 is unnecessary, remnant from a previous iteration of the code

#

Another quickie side project for my library of them

#

And it's already been refactored to lose the long lists and instead iterate the keys to instance all the Segment()'s

#

Like so ```py

    self.segments = []
    for key in directions.keys():
        self.segments.append(Segment(pos + offsets[key], directions[key], self.seg_group))```
#

Could even make that a comp but it's short enough already and easy to read

limber veldt
#

With a few more args and a little more logic, its size could be a parameter

#

Also would be handy to have an increment() and decrement() method

limber veldt
#

Could even use that in another class like NDigitDisplay() and make it that many digits with functionality to set values or increment/decrement current values

#

I've made digital clocks in Logisim before (with gates, converters, other stuff), so not a completely new idea

floral quiver
limber veldt
#

I dunno, some kind of counter, maybe a score keeper for a retro game

floral quiver
#

those numbers you made there seems realyl complicated to make lol

limber veldt
#

Turning off or on certain elements?

#

Yeah, much easier with code than with gates

floral quiver
limber veldt
#

Gates way

floral quiver
#

uh

#

is that for a circuit board

#

or smth?

limber veldt
#

Yeah, a logic circuit

floral quiver
#

So what exactly is a state machine

#

it prints or displays states on certain input like numbers?

limber veldt
#

I pattern of coding such that there are a finite number of states an object can be in at any one time with transitions to and from other states

#

The state machine I use for the Segment() there is a pretty simple one, it does nothing but change the image of the sprite during each state's initialization then just idles because the .init_state variable is immediate set to False

#

It doesn't even need to be a state machine, since it has zero functionality actually in the states being updated constantly, but I started with it because I wasn't sure where it was going

#

If it had some kind of timer running in the states, they'd make more sense but I've instanced it in another class that can do timing things if necessary

#

And update the Segment()'s

floral quiver
#

It sounds really complicated to me but im sure one day ill understand.

floral quiver
limber veldt
#

Not too bad, just remember that state machines have states that can run in any kind of sequence or by triggers

limber veldt
floral quiver
#

Thanks

limber veldt
#

I usually put that line right after the while True: starting the main loop, so it's updated at every loop

floral quiver
#

Read my mind 🀣 I was about to ask why it wasnt working

limber veldt
#

Anywhere in the main loop is fine, but just once somewhere there

limber veldt
#

Looking through old videos, this one from early 2023 or so. Testing how the small swarm moves, collision with the ship disabled but their mines can hit it, invincible is on...

#

That's me just spawning and ramming the enemy that splits into a small swarm about 8 at a time right in front of the ship

floral quiver
#

Videos wont even load

limber veldt
#

That's ok, it's only me reminiscing anyway

limber veldt
#

Pretty sure there's a .ttf font out there that can make it even easier

#

But that's cheating, lol

#

For an actual project, something much bigger and already taking time, I'd probably use a font

shut plume
#

how do i open the images which are inside the assets folder

pine plinth
#

project 1/assets/...

floral quiver
crimson lava
#

Is it possible to write a macOS screensaver using Pygame? On Windows, you can just use pyinstaller to compile it as an exe and change the extension to scr, but how can you make a screensaver using Pygame on Mac?

#

Does it HAVE to be written in Objective-C?

raven kernel
#

It's already not known to be customizable

vagrant saddle
mellow flint
#

average apple software flexibility

vagrant saddle
vagrant saddle
manic totem
#

so there this function inside the Enemy() class that can make enemies shoot and this function is the one responsible for spawing an enemies. so the question is how do i implement the function that can make the enemies shoot to 1/3 of enemies in range(10)

def create_enemies():
    X_position = [100, 200,300, 400, 500]
    Y_position = [-100, -200, -300, -400]
    exist = []
    random.shuffle([X_position, Y_position])
    for e in range(10):
        while True:
            x = random.choice(X_position)
            y = random.choice(Y_position)

            if [x,y] not in exist:
                exist.append([x,y])
                enemies = Enemy(x, y)
                enemies_grup.add(enemies)
                break
nocturne lance
#

if i wanted to make a full blow game in python how would i go about that?

frail copper
raven kernel
sweet inlet
#

Quick question. Im working on a game called Airborne : Python. It's a complex text based flight simulator. If I need help with the development, should I request for help here or in #1035199133436354600 ?

vital mountain
#

Is there some kind of JIT scripting language that can compile c++? I'm pretty sure I'm asking for something absurd, but a scripting language that can instantiate c++ templates for example.

vital mountain
#

You will also get fewer game dev resources if you do it on python, but I may be wrong

floral quiver
round obsidian
#

people's ideas of what games are seem terribly distorted by AAA-style gaming. you can make some pretty impressive stuff in just PyGame and vanilla Python

limber veldt
#

And, in the process, learn some basic (even advanced) game mechanics ideas, how to animate things among others, and carry much of that over to any language

sweet inlet
#

One of the biggest problems I currently have, being self-taught, is wasting time learning something and then realising that that knowledge will not help you later on.

round obsidian
vital mountain
sweet inlet
round obsidian
normal silo
# round obsidian people's ideas of what games are seem terribly distorted by AAA-style gaming. yo...

The fundamental misunderstanding is that not using Unreal or some other big fancy engine is what is preventing them from making such a game, it's not. It has nothing to do with programming even, the problem is assets, no single person can make all the required assets in a reasonable time frame. This is why "AAA" game devs focus on having a ton of assets / looks / music / sound, the main advantage that they have is lots of people to make these in parallel.

#

While engines like Unreal are providing a ton of "free" assets, your game will look terribly generic (which is also becoming a problem for many "AAA" devs that have switched to Unreal).

#

Using something like Pygame can actually make even more sense for a solo dev with a smaller scope game. There is less to learn with Pygame and better iteration speed than with something like Unreal, allowing for more time for assets and gameplay (not trying to compete on just assets/visuals/etc, but instead focusing on the part "AAA" seems to be lacking, gameplay).

gentle junco
#

hi i need urgent help with my game, is anyone willing to go through my code and help?

cosmic olive
gentle junco
cosmic olive
gentle junco
#

im making a very simple ai for a fighting game

#

and my 'ai' was bugging out and throwing infinite punches

#

but i think ive fixed it kind of now

#

was stuck on this for waaay too long

cosmic olive
#

It be like that from time to time lol

#

Have you ever tried using the dedicated help forum tho? Those usually help whenever I'm stuck

gentle junco
#

yes atleast 10 times id say haha

cosmic olive
#

lol

#

tough luck

floral quiver
#

Made a platformer map. 1 = block and 0 = air

#

Might add more blocks

#

and a player

#

ik it looks scuffed im working on it lol

raven kernel
#

great screenshot choices

limber veldt
#

Nice, looks like a good start to me

sweet inlet
#

Bugs are weird. Idk what's going on here but if anyone can explain I'd be grateful

#

It doesn't work without the text having an indent

#

Never mind. It goes back to normal after a add a space after the first backslash for the E.

sturdy arrow
junior osprey
#

@sweet inlet What app is that?

quasi hamlet
vital mountain
#

well yeah its just a tile grid dude : |

bold hill
#

Is there a way of making a field where a player won't be able to get outside of a box cuz I'm trying to make a submarine kind of game after I make a player class which I need some help trying to pack it onto the screen I tried that with a game earlier

dawn quiver
#

anyone need a programmer for the November pygame jam?

pine smelt
#

the team creation channel will open in a couple days if ur still looking for a team by then

limber veldt
#

I won't but maybe next time

proud elm
#

This one is interesting

sweet inlet
#

I use Termux as a CLI emulator for my android

pine smelt
#

it definitely won't be as big as my last jam game but experience is experience

bold hill
#

How can I make a partial system?

trim cave
#

partial system of?

bold hill
#

I need help making particle system for my game to run in the background since it's going to be a submarine-based game

bold hill
#
#===[imports]===#
import pygame
#===============#

class particals_system:


    def __init__(self,pos,particalX,particalY):
        
        self.particalX = particalX
        self.particalY = particalY

        self.pos = pos

        pos = particalX + particalY

        particles = []
print(pos)
dawn quiver
dawn quiver
#

!d pygame.math.Vector2

frank fieldBOT
#

pygame.math.Vector2```
 a 2\-Dimensional Vector Vector2() \-\> Vector2(0, 0\) Vector2(int) \-\> Vector2 Vector2(float) \-\> Vector2 Vector2(Vector2\) \-\> Vector2 Vector2(x, y) \-\> Vector2 Vector2((x, y)) \-\> Vector2
dawn quiver
#

If you want bubble particles Id give each particle a small force upward and a force that oscillates from left to right.

#

!d pygame.draw.circle

frank fieldBOT
#

pygame.draw.circle()```
 draw a circle circle(surface, color, center, radius) \-\> Rect circle(surface, color, center, radius, width\=0, draw\_top\_right\=None, draw\_top\_left\=None, draw\_bottom\_left\=None, draw\_bottom\_right\=None) \-\> Rect  Draws a circle on the given surface.
dawn quiver
#

!d random

dawn quiver
#

the big bubbles should in theory float to the top faster than the smaller ones

#

What could be cool looking is marching squares. So that the bubbles morph into each other.

bold hill
dawn quiver
bold hill
limber veldt
#

A particle system, to me, is a sprite group with sprites that have their own movement and it stays relatively consistent until the particle dies, either by leaving the screen or by living beyond its lifetime

limber veldt
#

The until it dies part is kind of important for particles because if they never die, they will start adding up (in memory)

#

Or any sprite(s) for that matter, when they leave the screen or you're done using them kill() them

#

Bullets, things like this

#

Bubbles

dawn quiver
# dawn quiver

Another thing that could be added is darker and lighter bubbles to get a sense of depth

dawn quiver
#

also these bubbles are very much in sync

trim cave
floral quiver
graceful yew
#

anyone familiar with this situation in pygame?
this will display the image on screen just fine:

class MonsterInfoSprite(Sprite):
    def __init__(self, rect: FRect, icon: Surface, groups: Sequence[Group]):
        super().__init__(*groups)
        self.image = icon
        self.rect = self.image.get_frect(topleft=rect.topleft)

but not this

class MonsterInfoSprite(Sprite):
    def __init__(self, rect: FRect, icon: Surface, groups: Sequence[Group]):
        super().__init__(*groups)
        self.image = Surface(rect.size)
        self.rect = self.image.get_frect(topleft=rect.topleft)
        self.icon = icon

    def update(self, _):
        self.image.fill(WHITE)
        self.image.blit(self.icon, self.rect.topleft)```
why?
pine smelt
#

wuts the error

graceful yew
#

nevermind, I found the bug - for blitting onto a surface I have to remember that the default position of (0, 0) is not the same as the window's (0,0), but always relative to the surface that calls blit()

#

kind of obvious in hindsight, but I got beaten hard by my own expectations

pine smelt
#

oh right it happens

pine smelt
mortal glacier
#

Here’s my lil roulette wheel if anyone wants to play it

#

If you have any ideas for it feel free to add them

limber veldt
limber veldt
mortal glacier
#

Bet

#

So like, if you wanna bet on color, you put β€œ2”

limber veldt
#

Sure

mortal glacier
#

Then it asks color and bet

mortal glacier
limber veldt
#

What do you mean? Entering the number should choose an option

#

Also, when entering color or bet or other values, maybe put the allowed values in the prompt...or use multiple while loops and inputs to get the choices instead of sending the player back to the start menu for not knowing the minumim bet is 100

mortal glacier
floral quiver
limber veldt
mortal glacier
#

Ok

#

Sorry for the misunderstanding

limber veldt
#

All good

dawn quiver
pine smelt
#

no its the most small brain solution ever

#

draw the white circles first, then inner circles after

#

i could optimise it but for my use case 600 particles per area at 60fps was good enuf

pine smelt
#

just modified the colours and particle velocities

dawn quiver
mortal glacier
#

!paste

frank fieldBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

candid blaze
#

Hey guys, I though some of you may find this interesting, I am building a turn based strategy game and we are doing it using our own in-house graphics engine, it’s entirely in python and we have been really working hard over the last few months on it. But since it’s entirely in python I was like hey these guys may enjoy it https://terra-tactica.com

mortal glacier
#

https://paste.pythondiscord.com/IJKQ
here’s my updated Roulette table. I know it’s got some bugs, but I’m too tired to fix them right now, so if you want to go ahead, if not, don’t. I don’t really care what you do, just please someone try it πŸ™‚

mortal glacier
candid blaze
candid blaze
mortal glacier
mortal glacier
#

And I don’t know how it would work out with child labor laws

candid blaze
foggy python
#

Released my first Python Steam game since 2019! πŸŽ‰
https://store.steampowered.com/app/2824730/Yawnoc/

EMBRACE CHAOSThe forest (filled with suspicious quantities of ammunition) has been invaded by cellular automata! Use various weapons, abilities, and upgrades to purge the machines in the forest before the machines take over. The enemy machines in Yawnoc are living on the rules of Conway's Game of Life and other cellular automata. Will you carel...

Price

$4.49

β–Ά Play video
mortal glacier
mortal glacier
foggy python
#

thanks!

candid blaze
mortal glacier
candid blaze
mortal glacier
#

Bet

#

Got it

tepid frost
#

guys is there some of you thaT could just help me, my game looked ok and it kinda worked like i could walk around and stuff. i was just finishing my first little biome and my yt tutorial said i should add some kind of bounderies to my camera to make it smoother. i did that and now its just grey and zoomed out

pine smelt
#

need code to help

sweet inlet
tepid frost
#

but can u help?

sweet inlet
candid blaze
rotund vigil
tepid frost
foggy python
rotund vigil
#

Thanks for the information

dawn quiver
#

Is there anyone who can teach Python? I am a beginner and can do small code operations.

pine plinth
#

!res

frank fieldBOT
#
Resources

The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.

hardy epoch
#

Can someone help me with linking mods to a mod installer I’m making

#

I can’t pull the mods from the website

candid blaze
tepid frost
#

yeah but that didn't help it was cause i was loading the wrong scene

#

i was loading player instead of world

stable crag
#

i'm trying to code an open/save function for a puzzle, however it does't work and i can't seem to find the mistake can anyone help me here? here's the link

austere flint
vagrant saddle
austere flint
vagrant saddle
graceful yew
austere flint
graceful yew
#

sometimes I feel like I should just follow the damn tutorial, because when I deviate from it, I can't just look up the solutions to the bugs I inevitably cause

frank fieldBOT
#

:incoming_envelope: :ok_hand: applied timeout to @north grove until <t:1731707799:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).

The <@&831776746206265384> have been alerted for review.

graceful yew
#

@foggy python hi, you mentioned you are using moderngl for your game yawnoc, does it replace the pygame framework?

limber veldt
#

Likely using an opengl context pygame window or display, along with the event loop and a few other pygame features and some shaders using moderngl

#

He has some tutorials/videos showing some of the process on his yt channel

graceful yew
#

thanks, I will check these out

limber veldt
#

Of course, I don't mean to speak for him but I offer my thoughts on the subject, maybe he can see the question some time and give us more information

#

I need to learn some of that, shaders for fx

#

Again showing that pygame is quite capable of making quality 2d games

foggy python
limber veldt
lusty pine
floral quiver
lusty pine
#

Thank you! Probably my best game so far

limber veldt
dawn quiver
lusty pine
#

My wife made it for me @dawn quiver

#

She's an artist

graceful yew
#

that's pretty cool

floral quiver
#

πŸ˜…

lusty pine
lusty pine
#

I really appreciate you all giving my game a try, I feel like none of the stuff I ever make lives up to what I wish it would

vagrant saddle
#

btw pygbag does not convert game to javascript, it runs it normally with cpython webassembly instead https://www.youtube.com/watch?v=oa2LllRZUlU

Speaker:: Christian Heimes

Track: PyCon: Programming & Software Engineering
Python 3.11 alpha comes with experimental support for Web Assembly and can be built to run in modern web browsers or Node.js out of the box. I’m going to show how we achieved the goal, which obstacles we faced, and what is missing to have fully working β€œPython for the w...

β–Ά Play video
lusty pine
muted sand
#

Hello! I'm a CS freshman in college and have recently gotten into game development with PyGame. Today I finished a class I've been working on called "AnimationController" which is meant to handle all the animation logic for an object or character in my game.

All the code is explained in the project, but here's a basic explanation: each class in the game has an attribute called "animation dictionary", which contains the name of each animation along with methods and attributes related to that animation. These include a method that will determine if animation conditions are met, a method that will run as long as the animation is playing, the animation priority, and the actual sprites of the animation. The AnimationController will use this information to correctly determine which animation and frame should be played.

I'm relatively new to Python and especially game development, so if you have any feedback or suggestions please let me know!

Below the class I have an example object to demonstrate how the AnimationController works. It has a basic loop and some basic PyGame setup to allow keyboard input and prints out to the console the animation, the animation count, and the current sprite (which right now is just a string; in a real object it would be images). Try it out and see how the output changes when you press "a" or "d" to run, and "e" to attack.

https://paste.pythondiscord.com/CRKQ

junior osprey
graceful yew
# muted sand Hello! I'm a CS freshman in college and have recently gotten into game developme...

delegating sprite animations to a dedicated class seems like an interesting idea, could be useful if you need to play a number of separate animations in specific order. I'm new to gamedev myself, and by following yt tutorials I learned to do animations by creating an update function for the sprite class and a draw function for the sprite-group class, which would have a reference to the sprite and thus be able to draw the surfaces referenced in the sprite

sweet inlet
#

Welcome, and I'd recommend Termux as your terminal emulator

velvet birch
muted sand
muted sand
muted sand
# muted sand Hello! I'm a CS freshman in college and have recently gotten into game developme...

Today I finished up another important class I've been working on: the InputController for the player. Code is explained as before, but here's a breakdown:

The player has an attribute called input_dictionary that stores an input along with attributes for the it. The InputController takes the player object and uses these values to determine when the method for the input should be called. Sometimes you'd want the method to be run as long as the input is held. Sometimes you only want it to run when the input starts. Sometimes you don't want to run the method until a certain condition is met. All of this is handled within the object and makes adding controls much simpler and quicker than writing all of that code within the player object itself.

Give it a read and tell me what you think. The only thing I might change is how the attributes are obtained, because right now it's kind of a mess lol, index within index within index. Logic is sound though. There's also an example below, so feel free to compile it and try it out. A and D make the player run when they're held, E makes the player attack and has a cooldown, and SPACE makes the player jump (although there are no visuals to accompany these; they are all printed to the console for the example)

https://paste.pythondiscord.com/QSPQ

muted sand
#

While it isn't what I originally intended, I did create a collision controller for my game. I originally tried to use masks - I don't believe I fully understand how they work or how to use them because it didn't go well, so instead I used some information about the object rects to make collision work.

Something I was able to get working is having the controller predict where your next position would be and handling your position accordingly, as opposed to putting you inside the object and then pushing you out. It takes the x or y velocity of the player and adds it to the player position (not setting the player position) and determines if that new position would put it inside the object. If it would, it instead set the player onto that side of the object, meaning the player will never actually clip in to it.

This method does have its limitations- but I'm happy with it for now and will update it as I learn more about PyGame capabilities.

Here's the code. Unlike previous projects it does use outside modules and assets, if you'd like those message me and I'll send them over. Otherwise you can watch the attached video to see it working.

https://paste.pythondiscord.com/U72Q

vocal basin
pine plinth
#

pygame

turbid needle
#

pygame and opengl
no one can create a good game by just pygame
u need gpu!

vagrant saddle
#

some good games don't even need graphics

#

u need an artist brain not a gpu+ai

sweet inlet
#

Not Python related but if you had to improve the following logo what would you do?

mellow flint
#

ngl

#

i read it as "dragon dish"

#

that K looks very similar to H

sweet inlet
#

I don't really know how to fix that, I'd have to change the font which is part of the logo and finding it wasnt even easy

#

Is it clearer without the Dragon or no? @mellow flint

mellow flint
#

yep

sweet inlet
#

I also have this one, quite minimalistic imo

sweet inlet
amber ether
#

so basically it's just kind of jittery so i came up with the idea of having a smoothing slider built into my GUI it goes from 0.0 to 1.0 the middle would be 0.50 for example and so i wanted 0 to be equal to the current XHorizontal and YVertical but then closer to 1.0 would be smoother, it's really important that it doesn't just slow it down as speed and precion of these coords is very important, could anyone enlighten me?

def move(self, x, y):
        XHorizontal = int((x - self.screenw) * self.scale)
        YVertical = int((y - self.screenh) * self.scale)

        smooth_x = XHorizontal * self.update_smoothing_factor
        smooth_y = YVertical * self.update_smoothing_factor

        ctypes.windll.user32.mouse_event(
            win32con.MOUSEEVENTF_MOVE, int(smooth_x), int(smooth_y)
        )
tender cobalt
pine smelt
#

and lerp the display position to the real by a some quantity depending on how far it is from where it should be and the distance between either end of the slider

muted sand
#

I finished another class I've been working on! The DrawController uses the player's position and an attribute called bound_dictionary to handle scrolling. It supports an object attribute called "offset multiplier" to determine how quickly or slowly the object scrolls relative to player movement. This is useful for background objects. Then, it uses that information along with the object sprite (determined by the AnimationController) to actually put the object on the screen, using the Draw() method.

https://paste.pythondiscord.com/SIBA

dawn quiver
gentle junco
#

hi im looking to make a menu for my game can anyone help?

muted sand
gentle junco
#

how do i get my main game program to only be shown when the start game button is pressed?

#

like how can i hide the game

limber veldt
#

In short, don't draw or update the main game during the time that you don't want to

#

How you implement that depends on how you're doing it now

gentle junco
limber veldt
#

Maybe make a variable in your main code, call it game_started = False and put your call to drawGameWindow() inside an if game_started: condition. Pressing the 'Start game' button would then need to be able to set game_started = True when you click it

gentle junco
#

ok ok thank you very much

limber veldt
#

Something like so can probably work ```py

somewhere in main, before starting the main loop

game_started = False

in main loop

while True:
# get and process events
# if game is not started, check for 'Start game' button press
# and if pressed, change game_started to True

if game_started:
    # draw and update game
    ...
else:
    # draw and update menu
    ...```
gentle junco
#

thank you

limber veldt
#

No problem. The same kind of logic can be used to run any part of a game but at some point, it gets too messy for me, which is when start defining states for a state machine, but that's another subject entirely

haughty bolt
#

has anyone got a good video on how to start making games with python

muted sand
# haughty bolt has anyone got a good video on how to start making games with python

This is the video that got me started, it's a great introduction imo https://youtu.be/6gLeplbqtqg?si=vVW-g-_O488MzN-G

Learn how to build a platformer game in Python. This game will have pixel-perfect collision, animated characters, and much much more!

✏️ Course created by @TechWithTim

πŸ’» Assets and Completed Code: https://github.com/techwithtim/Python-Platformer/tree/main/assets

⭐️ Timestamps ⭐️
⌨️ (0:00:00) Project Demo
⌨️ (0:01:32) Project Brief/Getting St...

β–Ά Play video
haughty bolt
#

thank you

manic totem
#

holy shit my game actually work

#

this is the first time ever

#

i just need to add sound effect and music to finish it

low ocean
#

Hi guys, currently trying to learn pygame and I created a floor for my game but it doesn't seem to work and I don't understand why

#

player_gravity += 1
player_rect.y += player_gravity
if player_rect.bottom > 300 : player_rect.bottom == 300
screen.blit(player_surface, player_rect

#

It doesn't give me any error message but the player just keeps falling despite adding the line of code that creates the floor

limber veldt
low ocean
limber veldt
#

Np

limber veldt
#

Using the == basically just turns this line if player_rect.bottom > 300 : player_rect.bottom == 300 into if player_rect.bottom > 300 : False or if player_rect.bottom > 300 : True which isn't really an error but doesn't do anything either

manic totem
#

lol

#

I remember making the same mistake as this guy before

#

Take me 1 hour to figure out that = and == is not the same

muted sand
bold hill
#

May I ask a question

#

How can I make interactable objects in pie game sorry

raven kernel
#

3.14 game?

raven kernel
#

you might want to look into the pygame.sprite API

vagrant saddle
#

and for moving objects what Axis said

raven kernel
#

you'll have to make te interactability yourself though

bold hill
#

How long does it take gifts sorry

bold hill
#

this is why im asking @vagrant saddle my apoliges

raven kernel
#

what are we seeing

bold hill
#

It's supposed to be the power core and maybe she'll generator for part of my game so that's why I was wondering so if the player if I have to add a text box with manual typing inputs I want to play an animation to turn on and turn off the core sorry

vagrant saddle
bold hill
#

Thank you I seen for buttons anime file for running the main game thank you

bold hill
#

Does any tile that I make for a part of the world supposed to be a bitmap? Sorry

limber veldt
#

Image, surface, bitmap, choose a name, they all mean basically the same thing within the context of displaying images on the screen

#

And can you drop the 'sorry` with every message, it makes me feel like you've already done something wrong

#

There is absolutely nothing wrong with asking questions here

graceful yew
#

a question on organizing code: is it "better" to have a sprite that also contains data not related to rendering or keep the sprite separated from the entity that it represents? this is for pygame, if it matters

limber veldt
#

I usually keep all behavior for a sprite within the sprite itself (actually a subclass of pygame.sprite.Sprite) and add it to a pygame.sprite.Group() to handle the rendering and updating, the group can draw/update all sprites within it inside my main draw() and update() methods

agile finch
#

hey guys, I have a problem related to object rendering. i copied the code from a tutorial, this one to be more specific https://www.youtube.com/watch?v=PsBYRAYVr5Q&list=PLn3eTxaOtL2PDnEVNwOgZFm5xYPr4dUoR&index=7&ab_channel=GetIntoGameDev
and now I am trying to load a bigger obj file (Vertex count: 2083581, Total faces: 694527, Total edges: 927913) but nothing appears in the pygame window
but from my console debuging i can see that the object was read and loaded. what do you think i should do?

bold hill
vagrant saddle
#

here's the tiles used

bold hill
#

Thank you

#

So I have to convert it to a bitmap.

limber veldt
#

It eventually reaches steady state in a mess though, since I have it wrapping around

#

175x200 grid size

bold hill
#

Do I need anything specific to use a bitmap?

limber veldt
dawn quiver