#game-development

1 messages · Page 41 of 1

normal silo
#

As for what GPUs are doing in games: https://www.youtube.com/watch?v=C8YtdC8mxTU

Go to http://brilliant.org/BranchEducation/ for a 30-day free trial and expand your knowledge. The first 200 people will get 20% off their annual premium membership.

Have you ever wondered how video game graphics have become incredibly realistic? How can GPUs and graphics cards render such incredibly detailed scenes? Well, in this video we'r...

▶ Play video
#

Interested in working with Micron to make cutting-edge memory chips? Work at Micron: https://bit.ly/micron-careers
Learn more about Micron's Graphic Memory! Explore Here: https://bit.ly/micron-graphic-memory
Curious about AI memory and HBM3E? Take a look: https://bit.ly/micron-hbm3e

Graphics Cards can run some of the most incredible video...

▶ Play video
#

Historically GPUs also were specific purpose hardware just for rendering, but over time became more general purpose (with the introduction of things like the CUDA core (general purpose cores)). After having become more general purpose other fields such as physical simulation and machine learning started making heavy use of them.

#

GPUs are continuing to become better at general purpose parallel compute (and starting to make CPUs somewhat obsolete other than for low latency tasks (GPUs are high latency) or tasks that can't be parallelized at all).

dawn quiver
#

Wow, I'm impressed let me go watch the video

exotic parcel
#

Hi

muted sand
#

Hey

granite ruin
#

Hi devs, is it good to use pygame to make mini games in Python?

raven kernel
#

its good for productivity for the sake of being productive i guess, but you'll pretty much only get good at that and python

dawn quiver
#

is anyone here

gloomy ledge
#

perhaps

vernal hearth
#

Hi this logo is my game

vernal hearth
robust egret
#

did you make it?

vernal hearth
#

Make in ChatGBT

robust egret
#

I feard so

magic jolt
#

Alright so just a quick question here so I can research it further. I want to make a simple 2d game, likely top down or frozen first person perspective (View of the room from the doorway without ability to move for instance) I've got a decent handle on how I want to code all the backend stuff but could use some suggestions on what programs to put it into to make a UI and visuals

#

Like I can build the entire game and play it in just the print out terminal in VS code but I'm wanting to have an actual UI instead of a Text based game played in a terminal

balmy pilot
#

pyGame is pretty popular here.

magic jolt
#

Can you import art assets with that or is it stuck as the grey minesweeper-esque terminal?

balmy pilot
#

pygame lets you do almost anything you might want, at least in 2D

magic jolt
#

Looks good, running into an issue with the import atm though, might be because I installed it in a different location than the automatic installer?

balmy pilot
#

Yeah, personally what I do is make a virtual env for each project, and install things locally inside that

#

I use uv to do that but there are many possible approaches

magic jolt
balmy pilot
#

I haven't thought about it super hard, but 3.11 might be a good choice; new enough that you get nice features, not the latest though so every library doesn't need to be up to date?

#

Lemme see what their build/CI runs on

#

Oh wow I guess 3.9 still? That surprises me.

#

The last merge to main on pygame was 7 months ago? Yikes

#

I hate to suggest using Python 3.9 at this point because it's end-of-life.. 3.11 should work but it's surprisingly non-obvious from the pygame github page.

magic jolt
balmy pilot
#

It usually is; they probably just need to update their GitHub build config and it'll just turn out to be working

#

I'm just surprised it's not currently automatically tested on 3.10 or newer

magic jolt
#

So 3.11.12 should be fine?

balmy pilot
#

Yeah

#

But if you do run into trouble, 3.9 seems like the safe (though ancient) choice.

#

(October 2020 wow)

limber veldt
#

I use pygame-ce 2.5.3 (SDL 2.30.12, Python 3.12.2) daily

balmy pilot
#

Maybe I should open a pygame PR to update their CI build matrix then

magic jolt
limber veldt
#

Instructions for installing it can be found there

#

It's pygame but has a few extra features not found in the original pygame, and is steadily updated

magic jolt
#

Gotcha 👍

limber veldt
#

Many of the newer tutorials by some are using pygame-ce, it's totally backward compatible so even old pygame projects still work with ce

balmy pilot
limber veldt
#

Yeah, there was a shake up of ownership or something with the original pygame, so much of that same team forked it to work on their own version, ce

magic jolt
#

Gotcha, that makes alot more sense. alright that seems to have installed alright so far using pip, now to see if it imports properly 👍

limber veldt
#

Good luck!

magic jolt
#

Alright ran into a small error because I deleted python to reinstall everything and VS code had a heart attack about it (infinite terminal reactivation loading) but fixed it and now it looks like the import is working correctly 👍

limber veldt
#

Nice, have fun

magic jolt
#

Now just to figure out how pygame actually works and learn a whole new branch of python coding to figure it out

limber veldt
#

Yeah, there's a lot you can do, the docs is a great place to start, maybe familiarize yourself with some of the modules and methods

#

Tutorials too, like to get up and running just making a screen and things like that

rocky blaze
#

Just finished 28 levels of my pygame lol

#

Took 5 months

#

Super level intensive game with a bunch of conditional statements, nesting, and numpy arrays

shy dock
#

nice

magic jolt
#

For the pygame screen.fill command, what set of color numbers does it use?

#

is it 3 digit hex or?

limber veldt
#

You can use hex like 0xabfe81

#

I usually just use one of the pygame color constants

#

Or can do rgb like (200, 155, 128)

#

Or can do 'black' (one of the constants)

#

All the named colors

magic jolt
#

Oh so I could just do

screen.fill([black])
#instead of
screen.fill([0,0,0])
#or is it
screen.fill(black)
limber veldt
#

in quotes for the constants, like 'black'

magic jolt
#

keep the brackets?

limber veldt
#

A list should work, though the function wants a tuple

#

Like screen.fill('black')

#

Or screen.fill((0, 0, 0))

#

Same thing, both are black

rocky blaze
#

Just screen.fill(black)

#

No ‘

limber veldt
#

It's convenient for pygame to have a bunch of them defined as constants

#

I see a lot of code defining themselves when pygame has already done so many of them

magic jolt
#

alright so I'm confused, does it or does it not need the ' ?

rocky blaze
#

No it does not

limber veldt
#

Filled with 'steelblue4'

#

A string

magic jolt
#

... okayyyy I'm just going to assume its not needed but coded to recognize it either way until I can get home to test it

limber veldt
#

So just pass the string

rocky blaze
#

And you could then input the variable to the different objects to determine the color and the alpha

limber veldt
#

The point is, there is no need to define your own black = (0, 0, 0) variable, pygame already has that in the string 'black'

magic jolt
#

no reason besides 'I want to' anyway

limber veldt
#

Yeah, custom colors and having complete control of what color means what is totally valid

rocky blaze
#

Mb for the late response, I had to look back at my codes to give you a more definite answer @magic jolt

limber veldt
#

I do some for my games when I want to define global colors

magic jolt
#

So question since you brought up alpha Blackberry is

screen.fill(blue, a = 25)

Valid?

limber veldt
#

Alpha?

magic jolt
#

well maybe I should change it to blue instead of black

#

but yes

limber veldt
#

For that, I'd define my colors myself, with 4 element tuples, like black with alpha of 25 (0, 0, 0, 25)

magic jolt
#

Ah okay I didnt know you could just do another value either. the pygame documentation lists it as
"Color(r, g, b, a=255) -> Color"

limber veldt
#

I think all of the pygame colors have alpha set to 255

runic saddle
#

yes

rocky blaze
#

255 is max

runic saddle
#

you can see that from the colordict

rocky blaze
#

You could set it to 192

limber veldt
#

Yeah

rocky blaze
#

128

runic saddle
#
    "aliceblue": (240, 248, 255, 255),
    "antiquewhite": (250, 235, 215, 255),```
etc
rocky blaze
#

92

#

And so on

limber veldt
#

Right on

magic jolt
#

Got it, also thats an amazing idea pik4, I can just label them a color as "Shadow" or something for all my shadows

runic saddle
#

that is how pygame does theirs already, yea

limber veldt
#

Yeah, make your own dict is a good idea

magic jolt
#

👍

rocky blaze
#

Only when the game is paused or in menu, do I have decrease the alpha

magic jolt
#

The game I'm planning on making is going to be "Greenscale" (I dont know if thats the correct term) but I'm trying to mimic those retro terminals/fallout 4's pipboy

#

so I'll probably be messing with alpha alot

rocky blaze
#

Poly3DCollection

runic saddle
limber veldt
#

pygame has some decent blendmodes too, for combining colors

magic jolt
#

So question, if I just wanted the button to be transparent with text. How do you acomplish that with the color pallete or is there a seperate command? (I'll probably want a graphic to take the place of the button color and just throw text on top of it)

limber veldt
#

Either import an image with alpha transparency or define a surface with the pygame.SRCALPHA, 32 flag and draw your button on it

magic jolt
#

if I wanted to get that old school random terminal flicker, should I do an import random paired with a delay and loop command or is there an easier way to accomplish that in pygames commands?

limber veldt
#

See this white circle that's supposed to be a ghost? I drew that on just a regular pygame Surface

#

I drew this one on a surface with alpha transparency

#

Using the pygame.SRCALPHA, 32 flags

magic jolt
#

👍

#

Also, the pygame.display.flip() command is listed as required but doesnt seem to say what it actually does in the notes I'm flipping through. Do I need to know anything about that or can I just call it required and not worry about it?

limber veldt
#

It just updates the screen, I don't worry much about it

#

update() varies in that it can take arguments for a specific rect of the screen to update, flip() updates the entire screen

#

I just do flip()

#

Most of the time

#

Or an empty update() (with no args)

#

I haven't had any projects to try out updating only part of the screen

rocky blaze
limber veldt
#

Games don't wait

rocky blaze
#

You could use pygame.time.wait(5000) when it’s game over and you want to wait 5 seconds to transition back to the menu setting

limber veldt
#

pygame has timers and userevents and ways to manage 'waiting' for things, I use my own Timer class most of the time, time.wait() blocks the entire game, no events, can't close the window, nothing during that time

rocky blaze
#

There a a few ways to use the timer in pygame

limber veldt
#

Do you know how to use delta time in your games?

rocky blaze
#

Every 10 seconds, first 10 seconds, and wait 10 seconds are what I generally use

limber veldt
#

Delta time is a timer

rocky blaze
#

It’s a good way to just speedrun the game for me

limber veldt
#

Okay, but I'll just reiterate, most games don't wait or sleep or anything of the sort, they are always running their main loop, checking events and handling them

pine plinth
#

there is no point in checking the events a million times a second

#

if the game is don't with it's stuff for a frame, it goes to sleep until there is a need to handle the next frame/quantum of logic

#

otherwise game would consume a whole CPU core without doing much stuff

rocky blaze
#

The game doesn’t sleep of course, the screen.fill(black) usage is just to ensure the previous objects in that level are not visible throughout that short timeframe. And you’ll see that black screen for 5 seconds before moving on.

vestal iron
#

Any advice how to structure my code for game development? I suck ass at that. For things like Entities and Object i know how to seperate task and all, but i suck at passing elements of world to Entities and Objects or something like making a state machine that can change state from a state, at first i used someone else code and states had backreference to statemachines and somone sayed its bad. I want to make my own structure/framework but i dont know how to start

#

Maybe im just gonna go simple and make Enum class with all the states and handle them in main file

limber veldt
vestal iron
#

Looks similar to my, so you dont have any kind of interfaces or context managers? Like letting statemachine handle things or having like RenderManager? For now im going simple since that what i know but ive seen people having they own class to render stuff and they just do like renderer.render('tree10', pos, etc, etc)

limber veldt
#

For a simple project like this, no, I don't use or need a state machine

vestal iron
#

In general do you have like base work framework you follow?

limber veldt
#

It only has one state, shoot at cursor

#

pygame.groups render all sprites inside, the group is doing the rendering there

#

Having a render handler is like my draw() method

#

Just draw the groups

#

And the groups draw their sprites

limber veldt
#

Like we don't see each bullet being drawn in the code, only the group, that's the benefit of pygame.groups

#

and sprites, for that matter

#

Because only pygame.sprites can be added to pygame.groups

atomic jungle
#

Hello all, not really on the subject of game development. Currently working on (just started) an automation project for an RTS game, if there's anyone with experience on this could they DM me please. Just some questions about planning and packages, thanks in advance. (If this request needs re-directed to another thread, please inform me as I know you will lol)

rocky blaze
vestal iron
#

its not what i meant, i didint meant the actuall functions, i rather meant a specific inteface that deals with that

limber veldt
#

I rarely manually blit anything, always use groups

#

That's what they're for

rocky blaze
#

I’ve only ever used this twice w/ time = pygame.time.get_ticks, where different text will appear for the first 2, 4, 6 seconds. But that’s just in the beginning of the level, similar to the text generated in Smash Hit.

pine smelt
#

i quite literally pass in the Game instnace to every object

#

the game instance has the state loader in it

#

so i can access anything state specific within any entity

vestal iron
#

that is ok, i know many ways to do things im just very picky, got to fix that habit of mine

rocky blaze
#

For me, generally you use pass so all previous objects that are moving in a certain level remain stationary on the next.

#

Or if I don’t even want to see the objects, I just do object.clear()

digital moth
#

hello can someone help to do a jump button working when i try it doesn't work pls

limber veldt
#

I recently did a slightly different way, too. Giving an abstract class a class variable like level = None then, when level changes, set that variable to the new level and anything subclassed from it will have self.level attribute that references the level

#

So instead of passing the level to all objects that need a reference to it, it's stored in the class variable

rocky blaze
digital moth
rocky blaze
#

I dabbled in that a bit

digital moth
digital moth
keen flower
#

how i can implement ninja dead but very simply manner preferably no additional spritesheet animation. i am just trying to learn game dev with simple start

frank fieldBOT
balmy pilot
#

You really don't want to share your API keys

white sonnet
#

Or apk

west prairie
balmy pilot
#

I mean, like, get it from an environment variable so we can't just steal it

radiant rapids
#

You realize someone can just grab that API key and do whatever they want with it?

bright plover
#

🚨 You posted your token in your message. This means that your token has been compromised. Please change your token immediately 🚨

west prairie
#

or hide the api key behind a backend (overkill for this, but maybe when you're making something large it'll come in handy)

radiant rapids
digital moth
#

why when i try to do a jump sytem in my game it doesn't work pls ?

radiant rapids
#

@white sonnet That is, you should delete the key from OpenRouter. Someone could have already copied it down while your message was up.

white sonnet
#

I deleted

radiant rapids
#

Good

#

You should typically load API keys from environment variables, using for example dotenv

west prairie
balmy pilot
white sonnet
#

(Reposting the message with the .py file without my API key)
A Little text-based adventure game I made in PyDroid3 using the requests library & ChatGPT API, Basically it's a endless text-adventure game which you start another random adventure when you finish your adventure or when you closes the game & open it again, The game uses the ChatGPT API on OpenRouter for Creating new Stories & Adventures for you, So have fun, I will give the py file here (It required having the "requests" lib installed via pip3)

west prairie
#

yippee

white sonnet
#

So, if you want to try it, you need to install the requests library

radiant rapids
#

In your profile settings

#

Just to be super clear

white sonnet
#

Oh oki

#

I deleted my og api key

#

& created a new one for testing

radiant rapids
#

I tried similar things manually with ChatGPT quite a long time ago, and the result was kinda so-so. Maybe you can improve the structure and consistency of the result by scripting it like that.

radiant rapids
#

It'd probably work better with the newer models available nowadays as well.

balmy pilot
#

I wonder how different the results would be if you made each of these requests be part of the same "chat" with the LLM.

white sonnet
#

But it has a saving system if you type "salvar"

radiant rapids
balmy pilot
#

He's not posting the history back to the API each time though?

white sonnet
balmy pilot
#

Where am I missing that? Let me read it again.

radiant rapids
#

preguntar_ao_chatgpt passes historia for each call

balmy pilot
#

Oh I see mensagem is the full history not a single value

radiant rapids
balmy pilot
#

Yeah, got it

radiant rapids
#

But it keeps appending the latest prompt and reply

balmy pilot
#

I guess this has a 'hard' context size limit vs. a longer chat progressively forgetting things

#

but up until that point it should work the same

radiant rapids
#

That's how it works with chatgpt as well

#

Or at least it did back in the day when I tried it

balmy pilot
#

Oh does it just cut you off? I thought it degraded more gracefully these days.

radiant rapids
#

The sessions would become more incoherent as it grew longer

fervent lance
#

The bot can still ignore/forget details though, even if you remind it on every message

radiant rapids
#

Well, this was quite a while ago

#

I'm not sure in what way it degrades

#

Or if that algorithm has changed

radiant rapids
white sonnet
radiant rapids
#

Maybe you could try to compress the log, by having the model summarize it or something

#

While keeping the most important instructions at the forefront

white sonnet
radiant rapids
#

Like the game rules

white sonnet
#

Yeah, good suggestion

digital moth
digital moth
balmy pilot
#

Is it correct that there are only two directions? Isn't up/down a different axis?

balmy pilot
#

Also shouldn't those be self.y += min(...)? Right now it just directly sets y, and presumably makes the character teleport?

balmy pilot
#

I guess I am not understanding your min() logic

digital moth
balmy pilot
#

OK so the play area is 240 pixels high and wide?

balmy pilot
#

I don't see anything obviously wrong in what you've shown then; what are the symptoms?

balmy pilot
#

Like, does the character move at all?

digital moth
balmy pilot
#

OK then my guess is that you should look at where you're using the direction value

balmy pilot
#

What is direction used for in your code?

digital moth
balmy pilot
#

OK so it's just facing left vs. right, not used during movement etc?

#

and if you put a debug print statement in your if KEY_UP branch, it's happening?

digital moth
digital moth
balmy pilot
#

print("This is happening") and you see that message

digital moth
balmy pilot
#

Yeah

digital moth
balmy pilot
#

OK, so it's getting called. What might be going on that setting self.y (which doesn't need to be +=, what you had before seems fine) isn't taking effect sometimes?

#

It doesn't seem like the problem is in THIS code

rocky blaze
#

It means that if your direction is originally going right, it’ll go the opposite direction after a condition

#

But it’s completely different what you’re doing because you’re just setting up the keys

rocky blaze
balmy pilot
#

Are you sure you're always calling the necessary function to render updates to the screen?

rocky blaze
#

Right = np.array([1, 0])

balmy pilot
#

Does python accept those spaces after def draw? I didn't expect that to be valid.

balmy pilot
#

What you have looks fine to me, though it's pretty brute-force in that it redraws everything per-tick, but it should at least work. No idea, sorry.

#

Never used pyxel myself, maybe there's something someone else can see.

digital moth
#

can't solve it

balmy pilot
#

What happens if you try to also modify self.y in one of the things that IS working?

#

e.g. KEY_LEFT

digital moth
balmy pilot
#

Interesting. So something is different about y, vs. x.

rocky blaze
#

What you could also do toggle between keys and mouse

#

I used mouse more often than none to control self

digital moth
digital moth
limber veldt
#

Try a velocity based movement, where your keypresses affect velocity and velocity is added to player position each frame

limber veldt
#

In quite short pseudo code py def update(self): self.vel.x = 0 self.vel.y = 0 if key_right: self.vel.x = 1 elif key_left: self.vel.x = -1 if key_up: self.vel.y = -1 elif key_down: self.vel.y = 1 self.x += self.vel.x self.y += self.vel.y

limber veldt
#

So you can control self.vel.y with your jump key and multiply it by something close to but not quite 1.0 to simulate gravity

#

That is not exact code, I can't walk you through it but maybe you can look up some velocity based player movement in a tutorial, that's why I said pseude code, not for actual use

rocky blaze
#

I do pygame.mos.get_pos()

limber veldt
#

I've never used pyxel

rocky blaze
#

To use mouse for control

digital moth
#

bruh

#

does someone use pyxel or used to use it ?

#

thx for trying to help me @balmy pilot @rocky blaze @limber veldt

balmy pilot
#

Yeah, sorry that I couldn't spot the problem. I guess keep adding debug output; show the result of your 'y' calculation and make sure it matches what you expect?

rocky blaze
digital moth
white sonnet
#

well, now the player needs a OpenRouter API Key to play the game (for avoid overcharging my API Key on Open Router)

white sonnet
scarlet reef
scarlet reef
raven kernel
restive zephyr
# scarlet reef

What are you doing this with ? It's not Pygame (I'm a beginner)

scarlet reef
restive zephyr
rocky blaze
#

The point in doing pygame is to get better in Python in general

hollow horizon
ashen compass
#

how do you prevent people from possibly stealing/copying your game/code?

vagrant saddle
#

for code use nuitka or mypyc, game you can't prevent : just slow down ( and loose time/money doing that instead of making a better product people will gladly buy)

pine smelt
#

are nuitka and mypyc just compilers?

carmine escarp
#

i am looking dev

round obsidian
frank fieldBOT
#

9. Do not offer or ask for paid work of any kind.

raven kernel
slow copper
#

sweat

cinder hound
#

Hello, I'm a game devleoper, and I'm looking for new project to earn money

slow copper
#

i love money

long hare
#

Anyone making Pygame games on android ..?

vagrant saddle
long hare
silver thorn
#

Ik this ain't the server for kolin but I need help making a app thats in kotlin its for mcpe

balmy pilot
cloud silo
#

Hi. I need help to create a script in Python. Some of the code is already there, but I can't understand one logic. This script concerns one browser game, where the same actions are repeated.

balmy pilot
#

Can you show the code that you haven't understood yet?

tired reef
#

How can I change the name of panda 3DS window?

balmy pilot
# tired reef How can I change the name of panda 3DS window?

A super old answer I see online says:

from pandac.PandaModules import WindowProperties

props = WindowProperties()
props.setTitle('My Window')
base.win.requestProperties(props)
``` be warned, some of that may have changed. I've been meaning to try P3D but haven't yet.
tired reef
quick stirrup
#

hello people

#
class Controller:
    def __init__(self, speed, transform, keys: tuple[str, str, str, str]):
        self.speed = speed
        self.transform = transform
        self.name = "controller"
        self.keys = keys

    def execute(self):
        if keyboard.is_pressed(self.keys[0]):
            self.transform.y += self.speed
        elif keyboard.is_pressed(self.keys[1]):
            self.transform.y -= self.speed
        if keyboard.is_pressed(self.keys[2]):
            self.transform.x -= self.speed
        elif keyboard.is_pressed(self.keys[3]):
            self.transform.x += self.speed
        self.transform.x = max(0, min(self.transform.x, winWidth - self.transform.size))
        self.transform.y = max(0, min(self.transform.y, winHeight - self.transform.size))
        ```
#

created this beast

whole garnet
#

I think keys should be a dict instead of a tuple

maiden canyon
#

Bro this section for pygame?

limber veldt
#

Not specifically but often

dawn quiver
#

can some one help me convert a file from .py to .exe??? i am only asking becasuse i cant use any admin on my laptop which makes it so that i cant use pip at all 😦 so if anybody could convert it for me that would be rly helpful

hearty tapir
dawn quiver
#

i alr tried and it didnt work but thank you

hearty tapir
#

Maybe you can reinstall python but just for this user account you're on then find a way to work and use that version? What you do at installation time might be able to smooth this and you might be able to change which version the py command uses.

crude drift
lone halo
#

Right, so. I dont wanna use Pygame, can i use any other thing

foggy python
modern flint
weak lake
foggy python
#

ModernGL, Pygame, GLFW, PyOpenXR, and PyOpenAL.

weak lake
devout gorge
foggy python
grave inlet
#

text-rpg combat system w.i.p

modern flint
river skiff
#

im not sure if this is the right channel for this but i just started learning python and i made a pink pantheress quiz game if anyone would like to try it out or check out the code and give feedback that would be really awesome

frank fieldBOT
cerulean nimbus
wooden night
#

Does anyone does pygame?

vagrant saddle
limber veldt
#

Yeah, pygame-ce rocks

wooden night
somber vine
wooden nacelle
#

hi guys i want to make a good/fun game to play can someoen maybe help me making it im not verrry good at python codeing and want to learn about it!?

cerulean nimbus
opaque quest
#

I just made a basic python tic tac Toe bot

It's not impressive and the code is a mess but I'm just starting out

river skiff
river skiff
wooden night
cerulean nimbus
wooden night
#

Ok thx

#

Do u know about pyinstaller to make your game from .py to .exe?

cerulean nimbus
wooden night
#

I have troble to convert it after creating my game in pygame(vs studio)

cerulean nimbus
#

what is the trouble

wooden night
#

It giving errors of saying not having pip installed but I do I have it intalled and when ever I try to use pyinstaller it always results in package not made

cerulean nimbus
#

show me the error ?

wooden night
#

I don't have my computer so I'll show it latter today

cerulean nimbus
#

oki

#

just ping me when

wooden night
#

Sure

wooden night
#

@cerulean nimbus I don’t have my comp yet.. but his is the error Traceback (most recent call last):
File "racing_game.py", line 244, in <module>
File "racing_game.py", line 217, in main_menu
File "classdef.py", line 90, in file_read_write
FileNotFoundError: [Errno 2] No such file or directory: 'highscore.txt'

#

its when i open the files.exe

#

do u want the code too

cerulean nimbus
#

ooooh

#

its because when you make your exe

#

the file doesnt get transfered with it

#

so make it so that first check if it exists and if not to make the file before you try to write to it

opaque quest
wooden night
#

i even made it so it creates a new folder with every thing but still not… here check the code

#

It works just fine if it’s runs from vs studio directly

cerulean nimbus
wooden night
#

.exe

#

heres the code

frank fieldBOT
wooden night
#

for classdef

#

this is where the files are found

#

i just took a break for the pygame,pyimstaller and took a break now

cerulean nimbus
wooden night
#

ya but when i compiled it, i made sure to make a temp folder for every addons

#

in the exe file

cerulean nimbus
#

lets say your folderstructure is like this

-> src -> ....
-> bin -> exe
highscore.txt
main.py
```when running the exe the folder where the exe is is your new directory
wooden night
#

wait

#

its

cerulean nimbus
#

!code

frank fieldBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

cerulean nimbus
#

but instead of py i used e

wooden night
#

!code

wooden night
#

the directry is:

#

pics folder

#

musicfolder

#

highscore.txt

#

python 3.313

cerulean nimbus
#

ooh my bad thought it was a txt that wasnt getting exported

wooden night
#

And also the exe file works fine if its in the folder with highscore.txt

cerulean nimbus
#

make sure when running your pyinstaller to say what folder to check for .py files or manually put them in

wooden night
wooden night
cerulean nimbus
wooden night
#

ya but i add the txt file to the temp folder with pics and music

cerulean nimbus
#

cause your probably doing

with open("./highscore.txt", r): ...
```without checking if it exists
wooden night
#

so i add a error check in the function , if filenotfound error?

cerulean nimbus
#

yes and if not found just create a new one

wooden night
#

Oh ok, that actually helped a lot thx

river skiff
opaque quest
grand delta
#

hello. i need help with my AIFOOTBALL GAME. can someone help me :((((

#

i have competition tomorrow. i need emergency help

dawn quiver
#

Dude

#

I honestly don't know about game dev things much

#

But you can take help from deepseek and ChatGPT

#

You can frame the basic architecture from ChatGPT then after further refinement use deepseek to add more details

limber veldt
modern flint
# limber veldt Warning, mind your volume! Siren and pew pew sounds, my latest retro remake

Cool! I used to love asteroids! Your version has power ups too, nice
I have to say though, the sound effect that gets faster and faster towards the end of the level is kind of strange and unpleasant, it sounds almost like someone is starting to say a word and then abruptly stops? I don't know how to describe it
Sorry if you weren't looking for feedback, just looks like a great remake except for this one detail

limber veldt
#

It departs slightly from the original in a couple of ways, it has a shield and the particle effects

#

The original game had the duts

#

So I put them in

modern flint
#

Oooh I see
I think I played the original without sound so I don't remember it lol

limber veldt
#

I think a few other games had them too

#

Centipede?

#

Space invaders

#

I think mine are too loud

#

And maybe too fast, the tempo starts slower

#

Nope, Centipede just had the constant annoying machine beeping

modern flint
#

The particle effects are really nice though, I feel like they fit the sound of asteroids exploding very well

limber veldt
#

Space invaders was similar, slightly different tone

#

Space invaders got so fast toward the end of a level that it almost becomes one sound

#

Refering to game play vids over here

modern flint
limber veldt
#

They only had 8 bit synthetic sounds, I suppose they tried a lot

modern flint
#

Yeah that makes sense

limber veldt
#

I set their volume quite low, still there but not so annoying

fading nebula
#

Hello there, i'm making a python game by myself and need some help as it's getting quite a mess since it's my first project and as it's getting bigger and bigger...

prime kernel
#

Keep the work up bro

shut tulip
# dawn quiver What's wrong with it 😭

Everything. What's the benefit of doing things like that? You got a roughly working game that you didn't make. You didn't learn anything, you won't play it much. You will not earn any money with that neither. Not talking about energy consuption, data centers usage etc...

dawn quiver
#

If he would do that perfectly then it could be the best game created in a short span of time

#

And then he could think to add better new ideas in that game rather than focusing on coding part

#

(BTW I AM NOT ARGUING, JUST SHOWING UP MY THOUGHTS )

shut tulip
shut tulip
dawn quiver
#

Else u will fail

shut tulip
#

That's a shitty assignement indeed

patent bluff
#

Hey everyone ik this isnt really a game but i cant think of wehre else to put it, but for a school project ive been coding this orbit simulator in python, and I want to do this tracker like in spaceflight simulator or other simulators that shows the trajectory, but ive only been able to get trails working and whenever i try implement a projectile tracker or wahtever you can call it it just flickers like crazy and doesnt fill the whole circle anyway Im bad at explaining so maybe someone can run the code and you can see for yourself. ive attached it here if anyone could give some help thatd be awesome

frank fieldBOT
ashen compass
#

I made a bit of progress on a game in tkinter and than someone recommended me to build a game in pyside6 but I've never used pyside6 before and when i tried converting it I ran into a lot of problems basically what I'm asking is if it's worth it to convert to pyside6 or stick with tkinter?

modern flint
ashen compass
#

the best way i can describe it is it's like pokemon chess, there are two 5 by 5 boards each with 5 elements and you click on them and than click on a blank square to move them and each element has a ranged attack to attack enemy elements and each element has buffs or debuss against enemy elements

#

I'll show a video

#

the only game library I know is pygame and that library seems to be made to make 2d platformers or something like that

modern flint
ashen compass
#

Not with tkinter but converting my code to pyside6

#

I’m newer to pyside6 and where I am right now I can’t move an element and the colors won’t show up

modern flint
#

Ah, I have no experience with pyside6
Maybe post your code and say what your specific problems are and someone will help, also you may want to ask in #user-interfaces
People there are more likely to have experience with pyside6 I'm guessing

ashen compass
#

Ok thanks for helping

grave inlet
#

made a silly little grid map with player movements

#

can detect walls and outer edge of the grid map

frank fieldBOT
woven pier
#

How recommended is making a web game with python?

thin gulch
#

fine unless you're trying to do realtime simulation on backend, then questionable

woven pier
#

you mean online games

#

?

vagrant saddle
#

anyone can run, guaranteed virus free

shut tulip
vagrant saddle
fading nebula
#

Anyone know a lib to easely make good looking ui and box for the terminal ?

#

as I'm doing them manualy for each one with differents shapes with "║" and it's really long..

fading nebula
#

thanks

quaint rain
#

help me please

#

how can i get pygame screens to work on github? i have pygame installed on my github repository?

vagrant saddle
quaint rain
#

a CI?

vagrant saddle
quaint rain
#

i click on the download pygbag file and it doesnt download?

vagrant saddle
#

paste the yml code in your code editor, or right click smthing like "save as" in the browser

quaint rain
#

there is no code?

#

name: pygbag_build
on: [workflow_dispatch]

jobs:
build-pygbag:
name: Build for Emscripten pygbag runtime
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Checkout
  run: |
        python -m pip install pygbag
        python -m pygbag --build $GITHUB_WORKSPACE/main.py
- name : "Upload to GitHub pages branch gh-pages"
  uses: JamesIves/github-pages-deploy-action@4.1.7
  with:
    branch: gh-pages
    folder: build/web

this is what shows up

vagrant saddle
vagrant saddle
quaint rain
vagrant saddle
#

not actually but you can find more help on pygame-ce discord i'll ping you there

robust egret
#

there is better ways of doing the nasty if's

woven ruin
#

Broo

left cradle
#

Is there a programmer / someone here that I can help with Python integration?

vagrant saddle
grave inlet
robust egret
grave inlet
#

oh neat

grave inlet
robust egret
robust egret
# grave inlet would love to learn how to reduce my if staircases

in this case, you could take the high and width of the map and validate if the player is going to go out of bound by checking if the position is bigger than the height/witdh and for the walls, just include the statement in the parent if using and example: elif direction == 'right' and grid_map[y_axis][x_axis+1] != 'o':

#

this is a minimal solution

#

would love to see the result of your code after those tips

spring zealot
sly surge
#

I'm looking for ganedevs to connect with

silver spear
ionic flame
#

pygame.draw.rect(screen, (21, 32, 82), (0, 237, 600, 25))
pygame.draw.rect(screen, (21, 32, 82), (237, 0, 25, 600))

How would I make this at a 45* angle?

dawn quiver
#

Please does anyone use pyglet

limber veldt
#

Then of course, draw the surface instead of a rectangle

ionic flame
silver spear
# prisma pumice

My chat is off so you can ask me if you want me to request dms

#

And for the text there sure 👍

raven kernel
#

their "members" are not precious people of the guild, they are just passerbys discussing the topic of interest

limber veldt
#

"I don't even know what that is"

loud bramble
rocky estuary
#

does someone use pygame to write games? can someone help me using it.

#

please

little heart
lost zenith
#

Hi everyone, I'm exploring different domains in python. I have a good knowledge of python , django , numpy and pandas. What would be the best way to start developing games using python??

vagrant saddle
#

well 2D pygame-ce , 3D Panda3D are good start. Fallback to godot if you are lost

cerulean nimbus
vagrant saddle
#

no idea and imho anyway all script engines in godot should run inside a wasm sandbox

regal scroll
#

if anyone has any experience with Ursina engine, i have 2 entities with shapes and colliders but they arnt well, colliding...

tired reef
#

In panda3D how do I make it so I can use awsd to control the cameras direction

regal scroll
stuck sedge
#

Hello can someone help with code? the card stack doesn't work. What I should to do? Can someone edit this or tell me? I will be grateful ^^

frank fieldBOT
boreal lynx
slow briar
#

yo does anyone know why i have this error occuring

#

something to do with lists, and geeks or stack weren't any help

#

yea nevermind

#

lets hope no one is ever this dumb

modern flint
# slow briar

You're trying to use [1] as a dictionary key. Dictionary keys must be hashable and [1] isn't because it's a list
You could change it to (1) (a tuple instead of a list) or something else hashable

slow briar
#

tried using lua syntax

boreal lynx
#

😦

dawn quiver
hearty ether
#

@stuck sedge I fix your python code check your massage

formal phoenix
#

is it 2d or 3d?

dawn quiver
formal phoenix
dawn quiver
frank fieldBOT
pine smelt
#

i'd avoid using sys.exit() in this situation just use a flag

#

flag = True
while flag:
    printx("Do you want to play 'Guess The Number' Game?")
    agreement = input("(Yes or no?): ").lower()

    if agreement == 'yes':
        start_game()
    elif agreement == 'no':
        printx('bye')
        flag = False
    else:
        printx("Please Type (Yes or no). ")
#

also worth making ur indentations and whitespacing more consistent just for readability

cerulean nimbus
#

Cause sometimes you still want it to finish the loop

halcyon beacon
#

Looking for a guy who knows programming, more specifically Python, in DM please, urgently

devout idol
#

anyone have any experience with pygame or similar 3d game tools

devout idol
#

Coding for beginners by Mike McGrath is a great book

pine smelt
tired reef
formal phoenix
#

whats the best way of making a 3d maze game?

slow copper
formal phoenix
#

but 3d is harder for me

slow copper
lucid grotto
#

how can i use images from a sprite sheet on pygame?

like, all this time im having to cut my sprite sheet for all images, and add one by one on pygame, and use image.load. How can i utilize sprite sheet and select the image i want to use, or even do an animation?

shut tulip
#

You can load a big image an then take subsurfaces

limber veldt
#

I find it easier to edit images in an image editor than to cut them up in code

#

I use subsurface for things but not cropping images

#

I think set_clip() and get_clip() can be used too, I haven't used them much though

cerulean nimbus
#

but it would be able to be used for editing images

#

also @limber veldt (sorry for the ping) but how is your game coming along where you go from room to room ?

honest drift
limber veldt
#

Just too much pain in the ass to serialize objects

limber veldt
#

Working on this one lately. I've done this game before but this one is a remake. Here I'm showing how the editor works. Run editor, edit and save the file, load game, play newly edited map

limber veldt
#

Thanks, made it really easy to create maps so the game has both the original game maps and those of the tournament edition, 32 more maps for a total of 64

#

I need a way for the ball to know if it gets stuck in a repeating pattern though

#

In the original game, any time the ball repeats the same pattern for more than ten or so times, it will automatically change its direction vector

#

Oh I know what I could do...put a timer on the deltas between paddle hits, if that timer gets too high, the ball is probably stuck in a pattern

#

It gets stuck a lot in the original game but always finds a new direction

#

Watching the gameplay vids for references, I saw it many times

#

That's also why the NPCs are important, they help deflect the ball and add some level of randomness to it

limber veldt
#

Or maybe even better, a hit counter that increments for each block hit and resets when it hits the paddle, when the counter gets too high, find a new direction

limber veldt
#

Yeah, that's the way to do it

#

If it hits a gold block, increment counter

#

Otherwise, reset it

#

Gold blocks are indestructible, the only blocks that can cause the ball to get stuck in a pattern

cerulean nimbus
spring zealot
frank fieldBOT
spring zealot
#

testing loading textures and level dat files

#

only works with file path setup and i cant post a rar but it works all together

#

-3111111111111111111115-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-3444444444444444444445-
-6777777777777777777778-


this is the dat file loaded

#

texture data and the dat in the collider file has just collider data witch i havent added in the code yet

proper garden
#

have you guys tried to use mapbox as game map? 🙂

#

i got an idea that im gonna try out, if it works, it should be pretty sweet

wooden night
#

can anyone help me with the A* path finding?

chrome hull
#

Super cool to see gamepad support for Python
https://www.youtube.com/watch?v=4fXLB5_F2rg

We added support for gamepads in Python via the mopad library. It's a new tool that could be used for a lot of things, but in this video we show the main use-case that we had in mind: to make data annotation fun!

00:00 Yes! Gamepads!
01:01 First demo
03:21 Annotation
04:58 How to build with it
06:48 Bigger systems

Repo: https://github.com/...

▶ Play video
vapid orchid
#

I'm trying to make a text-based game and I need to show a variable name along with the number that correlates with it (Ex.: ("variable 1:", variable_1), "Variable 2:" variable_2) but when I do this it give me an error indicating that it expected at least 1 argument but got six. How do I fix this?
Full code:
import time
import sys

def slow_type(text, speed=0.1):
for char in text:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(speed)
print() # Add a newline at the end

slow_type("A wild Lucario appeared!\n""Go, Venasaur!")
Lucario_Health = 207
Bulbasaur_Health = 236
solar_pp = 16
whip_pp = 16
sleep_pp = 24
while Lucario_Health > 0:
Choice = input("What do you do?\n""Fight - Run - Bag - Stats")
if Choice == "stats":
print("Lucario health:", Lucario_Health)
print("Venasaur health:", Bulbasaur_Health)
if Choice == "fight":
Fight = input("Solar Beam; PP:", solar_pp, "Power Whip; PP:", whip_pp, "Sleep Powder; PP:", sleep_pp)

wooden night
#

For ex. print(f"health: {health_var}")

formal phoenix
#

and you can rework it

vapid orchid
#

Problem solved, thank you though!

formal phoenix
#

its not perfect but its working

vapid orchid
spring zealot
#

F string my beloved

#

Constructing file path so easy with holy f string

pine smelt
#

think its literally just called pathfinding

limber veldt
#

Also the excellent articles on the subject over at redblobgames

wooden night
#

But I want to understand the code

#

So if am working on pathfinding i could use my own

#

But is there any other easier pathfinding algorithems?

pine smelt
#

other than a direct vector from A to B id say its the easiest

#

theres dijkstra too but thats basically the same algorithm

limber veldt
#

I wouldn't say I know it but have played with it a few times, a* is fun once you start understanding it

#

Currently working on powerups for Arkanoid. It turns out that they do randomly spawn from broken blocks but there can be only one on screen at a time. Also, there is no lifetime of powerup effects, they're permanent until you get another powerup

#

With one exception that I've noticed so far...the slow powerup, which slows the ball speed, runs out as soon as the ball hits the top border of the play area

modern flint
limber veldt
#

Yeah, same here but some articles I read mentioned some of these details

#

I'd love to find a disassembly of the original rom, written in z80 assembly I think

cerulean nimbus
limber veldt
#

They were both block breakers but not at all the same game or even look alike

grave inlet
frank fieldBOT
robust egret
#

I assumed you would search it up and find out

#

if you are comfortable with using third party libraries, checkout rich or/and textual pretty awesome libraries for cli based UI's

#

dope script though

grave inlet
formal phoenix
#

i like my 3d maze game progress so far. for a beginner its pretty good

wooden night
#

I did try to make one pathfinding, if touching wall then move right ot left

hearty marten
wooden night
#

But it got stuck on the corners bouncing there

wooden night
hearty marten
#

I don't know the name

#

Wiat a moment

wooden night
#

I thing one is called Voxel

#

Maybe

hearty marten
#

Panda3D

#

It seems

wooden night
#

?

hearty marten
#

Idk

wooden night
hearty marten
#

I only heared about it

wooden night
#

Let me check this out

#

It has crossplatform

hearty marten
#

Yes

#

Literally is the first time i enter in the web

#

Just i will drop a procedural generation system if anyone wants it (works like the img)

frank fieldBOT
cerulean nimbus
#

i made one with perlin noise and neighbour weights

#

like a combo

slow copper
#

It's a game engine for python

#

It's built on panda3d iirc

limber veldt
#

New paddle explode sequence, maaaybe slightly overdone with the flash but the I like the pieces

#

A lot of time for something that appears on screen for a quarter second

#

Or so

#

And the animation, I think it needs another shrapnel frame at the end and maybe tone down the flash

limber veldt
#

Yeah

grim abyss
#

cool! can you do characters/enemy sprites too ?

limber veldt
#

If I have a good design, I suck at designing

limber veldt
#

That paddle has a few animations

grim abyss
limber veldt
#

To and from extended and laser, and a spawning animation, along with the explode, six total yeah

grim abyss
#

what program did you use to illustrate the paddle sprite sheet ?

limber veldt
#

Gimp

grim abyss
#

lol of course 😄

limber veldt
#

Yeah, it works, it's a little quirky but I'm getting used to it

grim abyss
#

do you have a github ?

limber veldt
#

No, I should make one to share these things

grim abyss
#

yeah you should.

are you using git though with your projects?

limber veldt
#

Nah

#

They're small enough, easy to manage

grim abyss
#

you're not using anything? so you have no code history 🤷‍♂️

limber veldt
#

The history of some of this code isn't worth saving, lol

grim abyss
limber veldt
#

Well thanks, maybe some day

grim abyss
#

you're pretty experienced with pygame-ce ?

limber veldt
#

I think so, yeah

#

Been doing it on and off for eight years or so

grim abyss
#

i should try my hand at a simple lil Castlevania clone

#

need art though 😦

limber veldt
#

Yeah you should, have you made games before, can do sprites and stuff?

grim abyss
#

i've made basic stuff. tetris clones and such. nothing I would show off lol

limber veldt
#

Well, you already have a headstart on a lil castlevania

grim abyss
#

honestly I've never tried to create a sprite.
illustration isn't my strong suite

limber veldt
#

I get that, I struggle with it too

grim abyss
#

I've thought about using AI to create the sprites/art but it's
such a pain getting the AI to go in the direction I want it to

limber veldt
#

I write all my code with a little google help now and then

grim abyss
#

yeah I write 90% of my code

limber veldt
#

I can't say it's always well written but whatever, it works

grim abyss
#

i know that's right lol

hearty marten
spring zealot
#

How do I share a zip or rar here?

hearty marten
spring zealot
#

nvm

frank fieldBOT
formal phoenix
formal phoenix
wooden night
spring zealot
wooden night
#

Like unity or unreal engine?

spring zealot
#

I think so tho

tired reef
#

How can I make an engine without any bugs/exploits?

wooden night
#

Also try to push the engine to its limit

formal phoenix
wooden night
#

Ya sure

wooden night
tired reef
#

So let me know a 3D software how can I make it so that it doesn't have any glitches you know with collisions etc because I want to train in a night the real world and if I want to have that also help me with tasks I need to have it so it can move in a 3D space to grab parts that might be on the other side of the room or to pick something up from the mailbox

tired reef
wooden night
#

I mean, I think the best way is only play testing many times with diff people

formal phoenix
wooden night
formal phoenix
vital hamlet
#

Anybody make full retro game projects using Tkinter before?

wooden night
wooden night
wooden night
loud lynx
#

Hi, I am using pygame to write my game and need to draw text onto the screen.

I created a custom Text class as such:

class Text():
    def __init__(self, center_coords: IntFloatTuple, text: str, rotation: int, size: int) -> None:
        self.center: IntFloatTuple = center_coords
        self.text: str = text
        self.rotation: int = rotation
        self.size = size
    
    def draw(self, screen: pygame.Surface, color: str) -> None:
        text_font = pygame.font.SysFont("0xprotonerdfontmono", self.size)
        text = text_font.render(self.text, True, color)
        text = pygame.transform.rotate(text, self.rotation)
        text_rect = text.get_rect(center = self.center)
        screen.blit(text, text_rect)```

Is there a way with this or another set up to draw text over multiple lines? When I blit the text, \n is interpreted as unknown character and is drawn as a box
formal phoenix
# loud lynx Hi, I am using pygame to write my game and need to draw text onto the screen. I...

well in Pygame, the render method doesn’t support \n for multiline text—it treats it as an unknown character (like a box). To handle multiline text, you need to split your text string by \n and render each line individually. Here’s a quick update to your Text class to support this:

class Text():
def init(self, center_coords, text, rotation, size):
self.center = center_coords
self.text = text
self.rotation = rotation
self.size = size

def draw(self, screen, color):
    text_font = pygame.font.SysFont("0xprotonerdfontmono", self.size)
    lines = self.text.split('\n')
    line_height = text_font.get_height()
    total_height = line_height * len(lines)
    start_y = self.center[1] - total_height // 2 + line_height // 2

    for i, line in enumerate(lines):
        rendered_line = text_font.render(line, True, color)
        rendered_line = pygame.transform.rotate(rendered_line, self.rotation)
        text_rect = rendered_line.get_rect(center=(self.center[0], start_y + i * line_height))
        screen.blit(rendered_line, text_rect)
loud lynx
shut tulip
#

I think pygame-ce has this functionality implemented

#

(It's a more maintenained fork of pygame that you use exactly the same)

loud lynx
shut tulip
#

why would you need sin and cos to do that ?

loud lynx
#

Very rough formatting, but I hope its unserstandable

shut tulip
#

also if you want something a little more robust


    def render(
        self,
        font: str,
        text_or_loc: str | TextFormatter,
        color: Color,
        background_color: Color = None,
        justify: Anchor = LEFT,
        can_be_loc: bool = True,
        wrap: bool = False,
        max_width: int = None
    ) -> Surface:
        thefont = self._get_font(font)
        if can_be_loc:
            thetext = self._texts.get(text_or_loc)
        else:
            thetext = str(text_or_loc)

        if wrap:
            thetext = self.__wrap_text(thetext, font, max_width)

        if "\n" in thetext:
            lines = thetext.split('\n')
            line_size = self.get_linesize(font)
            bg_width = max(self.size(font, line)[0] for line in lines)
            bg_height = len(lines)*line_size
            background = Surface((bg_width, bg_height), SRCALPHA)
            background.fill((0, 0, 0, 0) if background_color is None else background_color)
            line_y = 0
            for line in lines:
                render = thefont.render(line, self._antialias, color, background_color)
                background.blit(render, ((bg_width - render.get_width())*justify[0], line_y))
                line_y += line_size
            return background

        return thefont.render(thetext, self._antialias, color, background_color)
#

This is my rendering function, which is a a method a class storing the fonts and managing languages as well, so lot of sugar but the important thing starts at the if
The main important thing is the background_color, the antialias, and the justify (here it is a tuple but only the first value is intersting: 0 for left, 1 for right, 0.5 for center, and another float for something weird

loud lynx
shut tulip
#

basically:

thefont is a pygame font. I store them so that I don't recreate a new instance every time I need it.
thetext is the string to be shown. text_or_loc and can_be_loc are used to represent the input, that is useful for language translations if you want to make your game in more than 2 languages
wrap is used to add automatically \n inside the text if it is too long to fit.

then, if there are some \n inside the text:
split line by line
get the height of a line for this font
get the maximum width of one of the line
get the height of the full rendered block
make an empty surface, color it
for each line:
make the text surface by rendering the line with the font
blit the rendered ine to the right coordinates

loud lynx
#

Aaa thats what textformatter is 😄

#

What is the point of can_be_loc?

shut tulip
#

locs are strings as well, like "LOC_MENU_BUTTON", for a button it can be loc, for like a textual entry it cannot

#

Imagine typing LOC_CHARACTER1_DESCRIPTION inside a textual entry asking for your name or password and having it display "John is a ...."
Of course your should add a validation behind to not allow it, but it shouldn't be shown on screen anyway

#

TextFormatter is just a list of strings with an optional separator. Some of the strings can be real strings, others can be localizations

#

like TextFormatter("LOC_SCORE", "273", sep=": ") will be converted in "Score: 273", which is useful to concatenate piece of strings that are locs and that are not

loud lynx
shut tulip
#

not it's mine

loud lynx
#

Its something you made? Sounds interesting

shut tulip
#

everything that is not a font or surface is basically mine in this piece of code

loud lynx
shut tulip
#

to set the alpha to 0

#

by default the background is transparent

loud lynx
#

Thats a very beautiful function

#

I might steal some ideas for myself 😄

formal phoenix
shut tulip
loud lynx
formal phoenix
spring zealot
#

Tkinter for games

spring zealot
#

There's always gonna be some bugs just remove the obvious ones and any you encounter

#

Play testing with other people helps too

vital hamlet
# spring zealot Bro what

.. it is usable for stuff like snake or things that are super small scope retro inspired games.

May give it a try. I like the idea of being creative with frameworks.

spring zealot
vital hamlet
# spring zealot Can you give me an example code or smth I'd lowkey want to do that for my own re...

https://youtu.be/bfRwxS5d0SI?si=TyyFitRi8YAkws9R dont have the script written yet but this is what i saw it from. gave me inspiration to try for something else top down because i like grid patterns and dont always like how some frameworks impliment it by default

python snake game code tutorial example explained

We're using Tkinter, because I have not taught PyGame at this point in time, in case you're wondering

#python #snake #game

music credits 🎼 :

Up In My Jam (All Of A Sudden) by - Kubbi https://soundcloud.com/kubbi
Creative Commons ...

▶ Play video
#

I don't actually know much about how Tkinter handles rendering on the backend so I actually wanna dive into it and see what it's capable of cause even just this is a lot

spring zealot
#

I didn't even realise you could display graphics past a photo on tkinter ngl

vital hamlet
#

Oh yes.. you can do A LOT. I'm just figuring that out and that's why I'm about to go crazy 🤣🤣🤣 (remember me if this starts a trend)

spring zealot
#

Me too bro

#

I've been making an obj veiwer this is big win

formal phoenix
#

You need a snake game? I can give one i made

loud lynx
#

I would really like to have this feature in my game, but I really hate that this glitching is happening. Does anyone know a solution to circumvent this?

The mouse cursor is at the bottom edge of the card when this happens.

#
    def adjust_position_based_on_mouse_pos(self) -> None:
        """
        Function that determines card's position when hovered.
        """
        if self.mobile: # self.mobile is shut off during certain phases and events
            relative_mouse_pos: IntFloatTuple = self.get_mouse_pos_relative_to_mask()
            center: IntFloatTuple= self.rect.center
            sin_rotation: float = math.sin(math.radians(self.rotation))
            cos_rotation: float = math.cos(math.radians(self.rotation))

            approximate_original_location, approximate_float_position =\
                    self.get_approximate_movements(100)
            # if self.rect is not hovered, it returns an IndexError
            try:

                # if card is hovered and not yet at float position
                if (self.mask.get_at(relative_mouse_pos) and 
                    not approximate_float_position.collidepoint(self.rect.center)):
                    
                    #card is moved up every frame
                    self.rotate_and_move(self.rotation, 
                                         (center[0] - 8 * sin_rotation,
                                          center[1] - 8 * cos_rotation))

                # if card.rect is hovered but not card.mask and card not at original position 
                elif (not self.mask.get_at(relative_mouse_pos) and 
                      not approximate_original_location.collidepoint(self.rect.center)):
                    
                    # card is moved down every frame
                    self.rotate_and_move(self.rotation, 
                                         (center[0] + 8 * sin_rotation,
                                          center[1] + 8 * cos_rotation))```
#
except IndexError:
                # if card is not yet at origin
                if not approximate_original_location.collidepoint(self.rect.center):
                    
                    # card is moved down every frame
                    self.rotate_and_move(self.rotation, 
                                         (center[0] + 8 * sin_rotation,
                                          center[1] + 8 * cos_rotation))

this is the culprit function. I cant think of anything better

#

self.get_approximate_movements returns two pygame.Rects that are later used in the conditionals. If the rects collide with the card mask, the cards stop moving. So with this function, if the mouse is between those two rects, the card starts glitching out.

formal phoenix
#

can someone give me a game ide and i will try to make it (2d)

rich gulch
#

how can u even make games w python?

#

what engine should ii use?

icy valve
#

oh yea its magic

rich gulch
#

unity?

#

NO I MEANT

#

what engine should i use

icy valve
#

well you dont even need an engine

rich gulch
#

vscode is enough?

icy valve
#

when you are creating a game on python

#

ive created at least 1 whit out any engine 100% python

rich gulch
#

oh

icy valve
#

and the other game ive created is in 2D like pacman but about flying soccer and used just the library pygame to pop out a window whit the game

rich gulch
#

oooh

#

so like vscode is enough?

icy valve
#

now im working in something that is not a game but kinda a 3d game just using the library ursina

#

i havent work whit VScode but any knoledge in programing is good

rich gulch
#

okay okay

icy valve
#

just knoledgue in python is enough

rich gulch
#

but like

icy valve
#

as dont need much of other languages

rich gulch
#

nvm i found the answer to my question

icy valve
#

i max use a little of bash and c++ just for a smal things for complex scripts

rich gulch
#

wait so the pygame library

icy valve
#

yes?

rich gulch
#

how do u use it

#

in ur script

icy valve
#

many ways

#

not only in one script

rich gulch
#

ah

icy valve
#

ive used on more of 20 for difrent things

#

ok you can use it as a more nice terminal whit symbols created by yourself

#

or you can use it to representate maps in a old style 8 bit

rich gulch
#

import pygame?

icy valve
#

or to make games to train a neural network

#

yyes import pygame

#

but first install it

rich gulch
#

but yea it doesnt work

#

in vscode

icy valve
#

exactlly

#

how big is teh game you want to create?

rich gulch
#

idk i am a begginer

icy valve
#

what style? what kind of platform?

rich gulch
#

i just wanna have a basic idea

#

until i feel ready

#

to code a game

icy valve
#

well you first need the idea of what do you want to do before to start searching how to do it

rich gulch
#

ohh so it matters ?

icy valve
#

yes

rich gulch
#

lets say a 2d platformer

#

like mario or games like that

icy valve
#

what about a pacman?

#

something like mario and simple to start

rich gulch
#

yes

#

mario sounds harder than pacman i think i wanna try it lol

icy valve
#

ok i have a pacman game already

#

give me a moment

rich gulch
#

ohhh alrr bet

icy valve
#

oh i found some code even simplier to start

#

you will love it as its more compact and easy to use

rich gulch
#

yooo i found how to import it

icy valve
frank fieldBOT
# icy valve

Please react with ✅ to upload your file(s) to our paste bin, which is more accessible for some users.

rich gulch
#

pip install pygame in terminal

#

to start downloading

icy valve
#

yes

#

pip install pygame time random

#

those 3 basic libraries

rich gulch
#

wow this looks so exciting

rich gulch
icy valve
#

to calculate the ticks

rich gulch
icy valve
#

basically how fast every frame works on the game

rich gulch
#

dw ik what ticks are

icy valve
#

the minimum time unit

rich gulch
#

thats interesting

#

yea ik

#

random is for what ?

#

creating a random seed?

icy valve
#

to generate random numbers

rich gulch
#

yea ik

#

but like how is it used in pacman

icy valve
#

random seed is to not always start whit the same random seed

#

o well for this you only have to add the ghosts, convert the snake in pacman and add walls

#

you can "draw" the walls whit code like the snake body or the point that snake has to eat

rich gulch
#

HOW

#

wait

#

lemme run that cod

#

code

icy valve
#

you can start creating a yello scuare as pacman

rich gulch
icy valve
#

magic

rich gulch
#

ikr

icy valve
#

not engine needed

rich gulch
#

i need to make it htat it cant turn when a wall is next to it

#

and how do i make the ghosts chase me

icy valve
#

is simple, just modify the wall void

icy valve
#

1 is creating like "gravity" so they follow you like water drops

#

2 is creating a path finding to you

#

so they do like 5 lines of code

rich gulch
#

water drops?

icy valve
#

like if im not whit pacman then i run in front to it, if im hitin a wall i turn right, if im still fighting a wall turn right again and tahsts it

#

basically imagine like a magnet

#

but slower so the gosts feel atracted to the magnet which is you

#

also i have another game but in 3D

frank fieldBOT
rich gulch
#

i get it

icy valve
#

so whit this you have a first person shooter

rich gulch
#

but like they ll always end up turning right?

#

HWAT?

icy valve
#

same size of the snake one

rich gulch
#

wait lemme ry

icy valve
rich gulch
#

i couldnt run it

#

i need the libraries downloaded

icy valve
#

yes

#

let me give you the comand

#

pip install ursina

#

and thats it

loud lynx
inland breach
#

hey im really new to python and i wanna write a recoil script does anybody know how to and can help me please?

icy valve
#

remember me what is a recoil code

inland breach
#

im playing rust and i wanna write a script so my recoil is like nothing

icy valve
#

oh that kind of recoil

#

becasue there is other kind of recoil code but is more for haking "banks" and real stuff in real life

#

ok to make a recoil code you need a library that can help you to convert clicks on movement of the mouse

inland breach
#

well that could be usefull but i dont wanna go to jail XD

icy valve
#

well is also usefull to make a inspection on a building to see were are bulneravilities

rich gulch
#

WHAT THE FUCK

icy valve
#

is like a corporation pays a criminal to try to steal something and then he describes how he didit and then get more pay than the thing he stole in the first place

rich gulch
#

HOW DID U MAKE THAT

#

IN 100 LINE

icy valve
#

im the magic femboy

#

ive done more in less lines

rich gulch
#

NAHHHHHH CRAZZZZZZZZZZZY

#

I STILL HAS A LOT TO LEARN

icy valve
#

there are to proofs

#

you can do it

rich gulch
#

i mean it doenst looktoo complicated

icy valve
#

i dont remember when i started maybe 1 or 2 years ago

lost kindle
#

@rich gulch, @icy valve, I've deleted your off-topic messages. Consider this an informal warning to stay on-topic.

formal phoenix
cerulean nimbus
#

its just to whatever people prefer 🤷‍♂️

waxen bronze
#

Yo guys i just have a question rq, me and my friend are creating a mini game ( 2D ) using pygame and we've basically just reached 200 lines of code in it, we didnt realise it but we were writing it in procedural style, should we change it to more of a OOP code or should we just stick up to the procedural coding?

shut tulip
#

200 lines aren't that much, if you feel you are still going well, no reason to change

#

If it gets too complex to manage like this, then refactoring the code to make some classes is a good solution

waxen bronze
#

hmmmmmm ok ty

waxen bronze
#

Anyways guys, what should i change about this code? really looking for some tips

formal phoenix