#game-development

1 messages · Page 29 of 1

manic totem
#

i try to figuring out how to make it move

#

and i still cant find the solution

#

as you can see i made a fuction on Bullets class to make it move but idk what i should do next

pine plinth
manic totem
#

im confused

#

wait

drifting yew
#

you need to know if your bullets should just fly straight or have different patterns

manic totem
#

so i accidently broke the sprites fuction because i add that move() fuction

drifting yew
#

whatever it is that function looks unfinished

manic totem
#

you mean that move() function

drifting yew
#

well I guess it works if they're just supposed to fly upwards

#

the function is not used anywhere of course

#

you need to link their movement to time somehow

cosmic olive
manic totem
#

i try that

#

didnt work

#

anyway

#

its doesnt matter anymore

#

because i change the move() function to update() and it work now

lavish marlin
#

so what should I do to fix it

pine smelt
#

any ideas how to set the background of a pygame.Wiindow transparent

#

ive searched the -ce docs cant find anything

raven kernel
#

ranges from 0 to 1

drifting yew
pine smelt
#

as in including stuff u blit on top

raven kernel
#

yes that's the only way

pine smelt
#

oh

raven kernel
#

otherwise you need to grab an image of what's behind your window

pine smelt
#

will that not be really slow to grab it pretty much every frame

raven kernel
#

actually i dont know many apps that do the kind of translucency you're talking about

pine smelt
#

ye I haven't really seen it before

pine smelt
#

if not just accept the background staying there

drifting yew
#

maybe you could do something with set or convert alpha

dawn bronze
#

Hey, y'all. I inherited a code base that uses PyGame to access gamepad input. I'd like a leaner solution, so I've been looking to pyglet, which seems to provide a similar API, but with fewer dependencies (and a smaller binary size). I don't want to directly access the USB driver, since I could not find any HID-ish cross-platform libraries. Any other library I should check out?

gray moon
#

hello, I have the basics in python and I want to make a little 2D platform game and why not market it on steam (I mean maybe), where is the limit of python for video games?

I want to do something simple but addictive with retro graphics

#

something like that

drifting yew
#

very possible

pine smelt
#

definitely ur just constrained by the time and effort u put in

#

look at dafluffypotato's vids and games for really polished results

gray moon
#

thank you guys, I'm going to see all that and above all start

drifting yew
#

though I would be lost if the game just doesn't work for some people

burnt harness
#

Did unity remove their run time fee ?

slow copper
#

No but they updated it

#

It wont affect small indie devs basically I think

grizzled dust
manic totem
#

can i load gif using pygame.image

pine smelt
#

they wont be animated

#

the closest u can get is extracting each frame and animating it urself

nocturne flume
#

Hello:
New member here. Not sure if I should post here, but I am wondering if anyone's used the esper (
https://github.com/benmoran56/esper
)
or any pyESC libraries and if so, how good are they when it comes to actually handling the entities and such in an efficient manner? By ESC I also mean entity component systems.

GitHub

An ECS (Entity Component System) for Python. Contribute to benmoran56/esper development by creating an account on GitHub.

#

I've only found a few and I'm trying to pick the most efficient one for a multiplayer project I'm doing. I did some shoddy benchmarking and so far I'm inclined towards esper, but curious if anyone's had any noteable experiences.

candid blaze
#

been making a 4x in python using pygame, if anyone is interested in helping with the overall project, lemme know 🙂

acoustic dagger
#

4x?

drifting yew
#
4X

4X (abbreviation of Explore, Expand, Exploit, Exterminate) is a subgenre of strategy-based computer and board games, and includes both turn-based and real-time strategy titles. The gameplay generally involves building an empire. Emphasis is placed upon economic and technological development, as well as a range of military and non-military routes...

lucid lion
#

what is new on

#

epic

uncut zenith
#

Can someone lend a hand with my attempt at context steering with pygame? The code nearly works, except the agent can get stuck when I start adding multiple obstacles, which is not desired or expected...

Here is the pastebin to my code: https://pastebin.com/0DYQnnAy

It creates an agent, and the left and right mouse buttons add obstacles and targets, respectively. There is a threshold distance for obstacles to affect the agent, but not targets.

Additionally, here is a link to a short paper on the steering method I'm trying to apply: http://www.gameaipro.com/GameAIPro2/GameAIPro2_Chapter18_Context_Steering_Behavior-Driven_Steering_at_the_Macro_Scale.pdf

limber veldt
#

I don't understand context steering though I have played with some of those steering behaviors

uncut zenith
#

I haven’t, but thank you for the share.

limber veldt
#

And thank you for the share as well, gives me terms and more info for steering behaviors to build upon

#

Also, if you can parse the logic in Java or JS, The Coding Train on youtube has a nice playlist (and his whiteboard explanations) for much of Reynolds' paper

devout summit
#

So you guys you Pygame?

uncut zenith
#

I do.

serene crystal
#

i can make hangman dm if u need any help

random oyster
#

my movement is kind of janky can anyone please tell me why? ```import pygame
pygame.init()

screen = pygame.display.set_mode([800,600])

class PLAYER():
def init(self):
self.surf = pygame.Surface((30,30))
self.rect = self.surf.get_rect()
self.surf.fill("red")
self.y = 300
self.x = 400

def update(self,keys_pressed):
    if keys_pressed[pygame.K_w]:
        self.y-=5
    if keys_pressed[pygame.K_s]:
        self.y+=5
    if keys_pressed[pygame.K_a]:
        self.x-=5
    if keys_pressed[pygame.K_d]:
        self.x+=5

player = PLAYER()

clock = pygame.time.Clock()

run = True
while run == True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
elif event.type == pygame.K_DOWN:
if event.key == pygame.K_ESCAPE:
run = False

    screen.fill("green")

    keys_pressed = pygame.key.get_pressed()
    player.update(keys_pressed)

    screen.blit(player.surf,(player.x,player.y))

    pygame.display.flip()
    clock.tick(30)```
pine smelt
#

what do u mean by janky?

#

BTW if u have a rect there's no point in storing and x and y value

#

u can use screen.blit(player.surf, player.rect)

#

and modify it in ur update method with

#

self.rect.x += 5
self.rect.y -= 5
etc

pine smelt
#

generally 60 gives "smooth" gameplay, ive seen 45-50 work as well but its less convential

#

if u want like REALLY smooth movement you would need smthn like

random oyster
random oyster
pine smelt
#
vec = pygame.math.Vector2
FRICTION = 0.9

class PLAYER():
    def __init__(self):
        self.surf = pygame.Surface((30,30))
        self.surf.fill("red")
        self.rect = self.surf.get_rect()

        self.vel = vec()
        self.acc = vec()

    def move(self, keys_pressed):
        self.acc = vec()

        if keys_pressed[pygame.K_w]:
            self.acc.y = -5
        if keys_pressed[pygame.K_s]:
            self.y = 5
        if keys_pressed[pygame.K_a]:
            self.x = -5
        if keys_pressed[pygame.K_d]:
            self.x = 5

        self.vel += self.acc
        self.vel *= FRICTION
        self.rect.topleft += self.vel

        #the above three lines are a faster way of doing
        # self.vel.x += self.acc.x
        # self.vel.x *= FRICTION
        # self.vel.y += self.acc.y
        # self.vel.y *= FRICTION
        #
        # self.rect.x += self.vel.x
        # self.rect.y += self.vel.y
    
    def update(self,keys_pressed):
        self.move(keys_pressed)
pine smelt
#

oh i see the problem

#

careful of ur identation

#
run = True
while run == True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
        elif event.type == pygame.K_DOWN:
            if event.key == pygame.K_ESCAPE:
                run = False

        screen.fill("green")

        keys_pressed = pygame.key.get_pressed()
        player.update(keys_pressed)

        screen.blit(player.surf,(player.x,player.y))

        pygame.display.flip()
        clock.tick(30)

is ur code

#
run = True
while run == True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
        elif event.type == pygame.K_DOWN:
            if event.key == pygame.K_ESCAPE:
                run = False

    screen.fill("green")

    keys_pressed = pygame.key.get_pressed()
    player.update(keys_pressed)

    screen.blit(player.surf,(player.x,player.y))

    pygame.display.flip()
    clock.tick(30)
random oyster
#

i see it

#

fuck thank you

pine smelt
#

ye

random oyster
#

i was so confused

pine smelt
#

no worries

#

prolly just tunnel visioned

random oyster
#

yeah

limber veldt
#

Would usually normalize player movement so it moves at a constant speed even at angles

pine smelt
#

oh good point

#

in the code I sent yesterday that would just be

#

self.vel += self.acc.normalize() * some_constant

#

I don't remember specifically but u might need to check if the magnitude of self.acc is greater than 0 aswell or it might give a zero division error

ember peak
#

Is a terminal-based Virtual Table Top something anyone would want and/or use?

#

Like I'll have fun programming it regardless, it's just one of those things you have to ask

cold storm
#

Hey all,
Thought I would drop by and remind them that UPBGE exists (fork of blender for game dev) and it has a robust py api.

New blender patches include multipass composition nodes system working (in game soon too!)

'Fast' Blue Noise (faster to converge on noisy renders)

Much Much more!
(soon Vulkan!)

#

UPBGE is free and open source

dawn quiver
#

nice

#

guys i know this is kinda nooby but is there any possible reason that im getting this error?

#

TypeError: argument 1 must be pygame.surface.Surface, not str

#

happens whenever i update the screen or at least im attempting to do that

#

is making another variable that loads a surface illegal?

pine smelt
#

r u sure u wanted to scale up Framer1

#

not Face

dawn quiver
#

oh god

#

ofcourse its a simple mistak

pine smelt
#

ye it happens

dawn quiver
#

sorry im new to pygame so i couldnt see such a basic

#

ugh

#

ive been working on this for hours

pine smelt
#

no no dont worry about it u just tunnel visioned

dawn quiver
#

thanks

#

no wonder it was complaining about a string , ill leave comments explaining this for future me in my code base

#

thanks for your help

limber veldt
#

You could assign those surfaces to variables and use those instead instead of loading the images every time you draw them

random jolt
#

I made snake!

verbal flare
#

noice

#

pygame?

candid blaze
dire grotto
#

Does anyone here know renpy?

pine smelt
#

the ddlc engine?

#

heard of its existence, no knowledge of it

proper peak
#

DDLC was later rewritten in Unity :p
(for letting people do file-editing tricks on platforms this is hard on, mainly)

pine smelt
#

o ok

dawn quiver
pine smelt
#

how?

#

surely it's less efficient to keep loading the same image over and o er again

#

rather than "caching" them once and reusing

limber veldt
#

Loading during draw is the worst time

dawn quiver
#

i am sorta doing a game

#

but not exactyl

#

its more of using pygame to load images and visuals and sounds since its much easier to do that then use a bunch of seperate libraries to achieve the same thi g

#

thing*

#

also i gotta ask

#

why does adding the .convert to the image load

#

screw up having 2 images at a time

#

this happens

#

INSTEAD

#

of this

#

eg the mouth is supposed to be animated ontop of the actual face

pine smelt
#

prolly need convert_alpha()

dawn quiver
#

THANKS DAMN tho i gotta admit they really shouldve added that in the docuementation nexts to convert

#

its basic stuff like this

#

that gets me sooo

#

this guys basically a virtual pet

#

so thats what i mean by not technically a game

#

but still within the audio , visuals and interactivity

limber veldt
#

All methods pygame.Surface are shown here, including .convert() and .convert_alpha()

candid hearth
#

Can I get some feedback on a rudimentary game I made using John Zelle's graphics.py module? https://github.com/cosmicmatter98/boundary-dash

Calling it a game is a big stretch, still thought about sharing and getting some feedback and ideas for enhancements and improvements on this.

Main purpose was to get to use the different functions of the module. Even though I haven't used the Image class, but I am planning to use it for the background and the player thing.

GitHub

A simple game where the player moves a rectangle (character) within a defined boundary. The player uses arrow keys to move the character, and the game ends if the character collides with the bounda...

pine smelt
#

i cant really install the module, but from the code alone

#

perhaps create some obstacles or walls

candid hearth
candid hearth
pine smelt
#

just thought it might an interesting thing to think about how u would detect collisions with multiple objects

#

not just the boundary

fringe berry
#

I have a bug in my raycasting demo that I have no idea how to fix. I'll demonstrate in the video.

You can see that when I stand away from the walls and move closer to them, the walls move up and down in an oscillating wave. The wave is more and less obvious from different vectors of movement but its always there.

If I turn off drawing the textures and go back to drawing solid rectangles, you can't see it anymore. I dont know if this is because it still happening on the solid color and I just cant see it as clearly or what

I know this is a python server but this demo is in Typescript with no other libraries rendering on canvas. You can look at it yourself if you want to https://github.com/divSelector/raycast/

Even just an explanation for why this happens from someone who knows game dev very well would be potentially useful

pine smelt
#

i mean one slight difference i can see is ur flooring the y values in ur texture one

#

is that meant to be like that

fringe berry
candid hearth
fringe berry
limber veldt
#

That's really cool, makes me wanna design some Doom levels and enemies

wintry bolt
#

can someone help me, ive been struggling to make this 2d game for hours lol, can someone fix the code for me

#

i js found this discord cuz i needed help

fringe berry
limber veldt
#

John Carmack was always one of my heroes. He used to do a blog, not sure if he still does, he'd gotten into amateur rocketry too and his blogs were pretty good, sometimes really deep

#

Carmack, one of the founders of ID and creators of Doom

#

The other founder was Adrian Carmack, seems quite a coincidence the two are not related

vocal grove
#

I'm literally watching High Score episode 6 on Netflix right now (cool documentary series) which is all about that and its really amazing what they did at the time with the hardware 🤯. I remember playing doom and wolfenstein 3d when I was younger and being blown away and also scared out of my mind lol, but at the time didn't think about how involved it was to pull that off

limber veldt
#

Like someone would have done it eventually but ID were the pioneers, everything that followed was in at least some small way based on what they started

#

I still have, in fact, a bunch of Doom levels and shit burned on DVDs and collecting dust in a closet somewhere

#

Though I don't even have an optical reader these days

grand spade
#

how do i detect when a key is currently pressed

#

Tkinter doesn't work cause it reports KeyPress and KeyRelease in the same frame when i first press the key

#

and trying to use keyboard.is_pressed('w') gives me and error

harsh otter
#

Does anyone know how to decrypt source codes inside dlls from game mods?

#

I need one from a mod called Custom Shaders Patch for a game called Assetto Corsa so that I can take a portion of it related to KN5 decryption (compressed format used to store FBX model, textures folder and a ini materials file for the game)

#

I think language is C and not Python

pine smelt
#

y would u ask the python discord then 🙏

fickle warren
#

hiiii'

#

can someone help me

warm crag
#

this gives me this 👆 (as shown in video) and it the blank screen stays their forever why??

fringe berry
#

I would check the values of things like game.start_game and game.died and make sure none of them are things that you dont expect. Find out where the execution is going with a debugger or using print() statements

#

i need to get a better screen recorder but yeah

pine smelt
#

oo looking good

#

is that raw pygame the fps is so good considering ur using textures

pine smelt
fickle warren
#

this error

pine smelt
#

i would assume u dont have the uh

#
def setup(bot): 
    bot.add_cog(Music(bot))```
#

at the bottom of ur file

fickle warren
#

uh

#

got a idea how to fix this

median plinth
fringe berry
#

its raycasting in typescript on 2d canvas context

#

there was a pretty bad frame drop when i tried to add floor and ceiling raycast, because you cant do it in the same raycast. But I think I also might have been doing it wrong and I want to try it again before i give up.

#

I love python and its definitely my preferred language for backend or command line tools, but... i feel like its so much easier to share a simple game you can deploy to the web.

#

So id just rather do it that way

median plinth
#

wow

pine smelt
#

do u have the package installed

#

do pip list

#

see if its there

#

i havent used discord_slash before so idk

grand spade
#

how do i detect when a key is currently pressed
Tkinter doesn't work cause it reports KeyPress and KeyRelease in the same frame when i first press the key
and trying to use keyboard.is_pressed('w') gives me an error
this is the error
https://paste.pythondiscord.com/AJIQ

fickle warren
#

dont worrry nvm

fringe berry
pine smelt
#

what acc is the game

#

doesnt sound like normal slots

manic totem
#

how do you make the enemy spawn from above at random x coordinate

limber veldt
#

You might want that on a timer or something so it happens automatically when running the game, but that's the basic idea

manic totem
#

Alr thanks

limber veldt
#

And it looks to me that your coordinates are backwards on your update() methods py def update(self): self.rect.y += 10 if self.rect.top < 0: self.kill() this is moving the rect down yet you're checking if it's above the screen?

#

You can print the len of your groups to see how many are in them, surely they never die like this

pine smelt
#

uhh

#

idk combo meter?

#

like if u get the right card multiple times there's some point multiplier

raven kernel
pine smelt
#

r u making that in ur jam

limber veldt
#

Slot machine is a fun idea, never thought about it before

grand spade
#

wait no i found it

#

fuck

grand spade
#

fixed it

grand spade
#

time is slow

floral frost
#

hello I am making a render engine for my VFX & 3D software project but the output of engine is total black.

pine smelt
#

code?

#

can't really help u without it

floral frost
floral frost
dawn quiver
#

I'm making a slot style game:
https://paste.pythondiscord.com/XIDQ

If you dont understand anything ping me!

I want to run some ideas for it by anyone.

So i was thinking about changing the King queen Jack combo to the 4 suits.

Then with King i was thinking about adding a chess thing where the king gives you points if it has another chess piece near it and maybe more depending on what piece.

pine smelt
#

should the red and green colours be [1, 0, 0] rather than [255, 0, 0]

#

oh u multiply it by 255

#

is it off screen qt all

#

maybe print the object locations

floral frost
dawn quiver
#

Anyone i can bounce an idea off of?

pine smelt
pine smelt
pine smelt
#

for example it doesnt accept dice instead of Dice

dawn quiver
#

What does .strip() strip

pine smelt
#

no its more the case of capitalisation or putting extra spaces at the end by default

#

removes whitespaces

#

like extra spaces or tabs

dawn quiver
#

Ahk

#

Have u ran my game?

pine smelt
#

ye

dawn quiver
#

Right so i was thimking of changing the king queen jack combo

#

To a 4 suite

#

So that i can add a chess combo

pine smelt
#

not entirely sure what that means

#

idk much card game lingo

dawn quiver
#

Do u get the jack queen king combo i have alr

#

?

pine smelt
#

the "royalty combo" right

dawn quiver
#

Yeah

pine smelt
#

right ye

dawn quiver
#

So instead i was thinking of changing it to 4 suits( in playing cards) spades hearts clubs and diamonds

pine smelt
#

sounds fine ye

dawn quiver
#

So i could add a new chess mechanic

#

Where the king loses you points unless its next to a chess piece

#

To “protect” it

#

Then it gives u more points depending on the piece value in chees

#

So queen gives more than a pawn

#

You following?

pine smelt
#

ye

#

just confused wut ur asking

dawn quiver
#

Im on that now

pine smelt
#

o ok

dawn quiver
#

Which do u think would be better:
1)Rarity system where your less likely to get queen than pawn but are cards obtainable normally.
2)normal obtain system for pawn and when pawn is in top row of grid (like in chess) it will permanently transform(promote) into a better piece(using a weighted random towards the bishop/knight)

#

Or if u have ur own proposition idm

pine smelt
#

i mean the second one makes more sense

dawn quiver
#

But does it sound good or crap?

#

Well ill add it today or tomorrow. I can show u the game after and see what u think then if u want

pine smelt
#

alr just send it here ill prolly see

fringe berry
vagrant saddle
fringe berry
#

Typescript.

Maybe I should look at other hobby raycaster games for inspiration

dawn quiver
#

!pastebin

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.

dawn quiver
dawn quiver
fringe berry
#

This game is turning into such headache. It was fun when it was just a graphics rendering demo but now that its becoming a game its just like fuuuuu

#

maybe i just need a break from it

dawn quiver
#

@pine smelt

pine smelt
pine smelt
fringe berry
#

yeah sometimes but in this case i feel like im either gonna do something with this project or i never will.

#

it's not that i dont want to work on it. Its that there is some pretty big problems to solve before I can get back to doing fun stuff.

dawn quiver
limpid hedge
#

hi

lucid gyro
pine smelt
#

i dont see it defined anywhere

#

or keyboard for that matter

lucid gyro
#

im using a code editor from my python class and without adding the variable of key nor keyboard i think that you mentioned it still runs fine

#

but i dont think it matters on which code editor you use

modern flint
#

And keyboard and other stuff is already predefined for you

lucid gyro
#

oh

lucid gyro
floral frost
#

can someone help me with this code I am making a render engine for my VFX and 3D program named HydrogenFX and need help for developing This is the code: https://paste.pythondiscord.com/BDHA

modern flint
lucid gyro
#

didnt answer my main question but still thanks i probably couldnt really explain my main question kind of well anyways

dense flame
#

could anyone help me? so ive been working on a project checkers with help of youtube but now i wanna make that game online so like i can play with a friend but i have no clue how sockets etc work

pine smelt
pine smelt
#

this prolly

dense flame
#

alright thanks man!

floral frost
dawn quiver
#

!pastebin

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.

fringe berry
#

python discord needs to pull the updates from upsteam pinnwand so that it will get my update 🙂

dawn quiver
#

How long lineswise are like proper games. Eg a 2d platformer???

proper peak
dawn quiver
#

Any tips for making neat cose

#

Cose

#

Code

dawn quiver
#

@proper peak

pine smelt
#

and empty lines to section off parts of ur code

#

also consistent identation

#

i edited urs

#

u can prolly do more

slow copper
# dawn quiver Any tips for making neat cose
  1. Either do-
from random import choice, randint

And use the methods choice and randint everywhere in your code
Or

import random

and use random.choice & random.randint in your code.
Instead of -

import random
from random import randint

And using random.choice and randint in your code. This makes your code more uniform. Although I would prefer the latter method as it explicitly mentions from where you're calling those methods from and increases readability.

  1. I'd personally split up the code into multiple files like constants.py, funcs.py (having all the game functions) and main.py which runs the code all together. You can split it in however way you want / feel comfortable or not do it at all.

  2. Use a specific casing style. Some of your functions are pascal + snake casing while others are in pascal..? Any casing is fine but stick to one casing throughout your code.
    In python people usually follow snake casing for vars and function/methods and pascal casing for classes.

  3. Use a formatter like black to fix up inconsistent spaces and makes your code more readable

  4. Unnecessary comments, almost 90% of them are unnecessary. And the places where you use comments to describe what a function does, replace that with docstrings instead.

  5. NEVER use try except without explicitly mentioning the exception type. This can suppress important errors for you to debug leading to unexpected results and makes your code less readable.

  6. Type hinting, this isn't nessescary I think? But it hugely helps with code readability.

dawn quiver
slow copper
#

You use android for coding? 💀

dawn quiver
slow copper
#

Reminds me of when I used to do the same

#

Wasn't a pleasant experience

dawn quiver
#

What app

slow copper
#

Pydroid I think

#

That was back when I first started to code like 4 or 5 years ago

#

Ever since I started coding on pc I never went back

dawn quiver
#

Yeah obviously i use pydroid as wl

slow copper
#

I kinda just gave an overview

dawn quiver
dawn quiver
#

@slow copper 🤣

#

Sorry

dawn quiver
#

I code at school on pc as well but i forgot how much harder pydroid makes it to read

slow copper
dawn quiver
dawn quiver
slow copper
slow copper
pine smelt
#

i dont really see many other ppl use lines of hashtags

#

but it helps me seperate it so

pine smelt
dawn quiver
pine smelt
#

especially with larger projects

slow copper
#

Yeah

dawn quiver
#

So you would already split my project into smaller chunks? Sort of where sh put the ###s

slow copper
#

Pretty much yeah actually lmao

pine smelt
#

example from my current project

#

i use both the hashtag lines and the importing thing

#

and clearly seperating sections of code

slow copper
pine smelt
#

do u just do that at the end of a project

dawn quiver
pine smelt
#

bro theres so many

#

imagine all of that code in every single file combined into 1

#

it would become a mess really quickly

#

hence y its advised to split ur code into multiple modules and importing them

dawn quiver
#

😭this seems like the part where im gonna hate

slow copper
slow copper
slow copper
inland spire
#

i finally made pygame can use IME now.....
with a bad way....

dawn quiver
#

This is my biggest project so far so im learning quite a lot as theres lots of problems ive not come across

inland spire
#

i use ctypes to call win api, and bound a text box to the pygame window....

slow copper
inland spire
slow copper
#

Cool stuff

inland spire
#

thank you.

dawn quiver
inland spire
#

does anyone knows how to do so?
or better, knows how do make the text box without a background?

dawn quiver
slow copper
#

I'm still learning pygame so can't help much

slow copper
#

It just formats it

#

And it has been pretty helpful ngl

#

Especially when I have a long nested one liner stuff

#

Like generators / comprehension

#

I'm going to go sleep now

#

So bye

#

👴🏿👋🏿

dawn quiver
#

Cya

cinder crater
#

i am making a game

dawn quiver
dawn quiver
# pine smelt

Btw do you have 1 file that just nicks stuff from all other files and puts it together. Like just functions in there

pine smelt
#

not really

#

i suppose that would make it extremely organised but nah

pine smelt
#

but it doesnt do anything, its just a visual prompt and for ur interpretor to know syntax wise what it should tell u i THINK

#

example

dawn quiver
#

Right

pine smelt
#
text: str = "obama"
number: int = 5123
fruits: list[str] = ["apple", "banana"]
dawn quiver
pine smelt
#

yuh

dawn quiver
#

Ahh thats what id do

pine smelt
#

this the top of my main.py

#

tho most of its

#

acc thats a bad example

#

cuz i only really import those for caching, a game dev thing

dawn quiver
#

Right

#

Bro ik theres no wrong way but im acc kinda scare to dk ut wrong

pine smelt
#

bruh no one cares as long as its readable

#

its not some law u'll get arrested for if u break the syntax slightly

dawn quiver
pine smelt
#

maybe u use repl?

pine smelt
#

not saying u should write ur code in a complete mess but it helps for structure and clarity

dawn quiver
#

Yep ill copy some across iab to different files

dawn quiver
#

Only good for 1 file im pretty sure

pine smelt
#

ohh

#

thats the interpretor that comes with python by standard

#

it wont have too many addons

#

u can still use multiple files tho

#

just create them in the same directory and import them in ur main file

dawn quiver
pine smelt
#

oh right ye

dawn quiver
pine smelt
#

nah all of them are free

dawn quiver
#

Ohr good

#

Whats like extra about urs then

pine smelt
#

uhh

#

integrated access to github

#

syntax highlighting

#

code suggestions

#

error highlighting

#

all files in the same window

#

multiple languages

#

those r the ones i use anyway

dawn quiver
pine smelt
#

ye

dawn quiver
#

So its just QOL and makes life easier

pine smelt
#

yup

dawn quiver
#

Right ill save vs code incase i use it

pine smelt
#

alr

candid blaze
#

Anyone looking to join ongoing projects? Been working on a Python based 4X strategy game for 2 months now. We have 5 active people on the team but would love some more help and minds! You can dm me if interested 🙂

Requirements

  • know Python to an extent
  • Have the ability to have fun and be creative.
  • be 18+
dawn quiver
#

Btw incase you didnt gather im way too inexperienced xd

candid blaze
dawn quiver
candid blaze
dawn quiver
#

Ok thx

candid blaze
#

Do you have Python experience?

dawn quiver
candid blaze
dawn quiver
candid blaze
dawn quiver
candid blaze
dawn quiver
#

Lemme know how the game goes

candid blaze
#

Gotcha for sure!

pine smelt
#

is it to do with the game content

candid blaze
pine smelt
#

oh okay fair enough

slow copper
# dawn quiver Whats num 7 anyone?

Just to add what sh said, you can even use it to hint whats the type of the parameters of a function/method, which is where its mostly used.

def add(a: int, b: int) -> int:
    return a + b

Over here we have type hinted a and b as int type.

If you pass in a string or any type other than int your code editor will raise a warning that it isn't of int type. Even though the code will run with whatever parameters you supply, type hinting is just used for convince.

The -> int you see is the return type of the function, as return a + b returns an integer. If we don't return anything from a function we use None instead, for example-

def add(a: int, b: int) -> None:
    print(a + b)
#

And type hints also allow you for code completion in editors

inland spire
slow copper
#

Damn

#

That's sad

#

I assume it just takes time to annotate the object and completely ignore it

inland spire
#

iirc, if you use list[int], it has to run to create a list[int] object when you run the progarm.

>>> class mylist:
...     def __getitem__(s,i):
...         print('runned')
...         return i
... 
...     
>>> mylist=mylist()
>>> def f(x:mylist[int]):
...     pass
... 
runned
inland spire
slow copper
#

I see

raven kernel
dawn quiver
slow copper
cinder crater
#

help me on pygame guys

woven spoke
#

honestly this isnt too pygame related but i cand find a more general text area but since i feel so dumb

#

im calling a function

#

it has an arguement

#

HOWEVER

#

for some damn reason

#

it doesnt work

#

it says im not parsing any data to it

#

def transition(Target_Emotion):

#

and calling it via the transition(Target_Emotion)

#

it feels so wierd but whener i ask it to return target_emotion it just gives me blanks

#

honestly if this is something scope dependant or something i might just

#

do what i did before and make it a file that stores data

modern flint
woven spoke
#

i might try that if i fail to get it working the file way

sudden sage
#

Hello, I'm currently working on a small 2d game with the Turtle library. I am attempting to update the window (a TurtleScreen object) from within a thread. I know that Turtle does not support threading, so I have used a global variable to attempt to cause an update. Here is the code for checking the update, which is within the main game loop of the program.
with lock:
if update == True and game_started == True:
money_counter(win_right=win_right, win_top=win_top,
money_count=money, money_cap=money_cap
)

Here is the code run by the threads.
def add_auto_money() -> None:
"""
Adds money per autoclicker.
"""

global money, update

if autoclicker_on_off == False:
ic()
while True:

for _ in range(autoclicker_counter):

time.sleep(15 - autoclicker_speed)
money += autoclicker_income

if money >= money_cap:
money = money_cap

if autoclicker_on_off == True:
ic()
while True:

if autoclicker_counter != 0:
update = False
time.sleep(15 - autoclicker_speed)
money += autoclicker_income

with lock:
if money >= money_cap:
money = money_cap
update = True

#

the variables money & update are the amount of currency the player has, and the global variable i have attempted to use to check for a screen update respectively

#

autoclicker_on_off variable is whether or not the player wants to have their currency update everytime the autoclicker adds to it (true for updating everytime currency is added to)

#

ic() is my debugger

#

autoclicker_income is how much to add to the money variable by

#

money_cap is the maximum money avaible to be stored

#

game_started variable is a boolean of whether i am running the "menu screen" or the "game screen"

#

money_counter function displays the money count to the screen

#

win_right and win_top variables are the right of the window and the top of the window respectively
lock is a threading.Lock object

zenith saddle
#

so now that my schools out and im out of my computer science class where do i go now i didnt learn anything about game development i just know basics on how to use python i would still use pycharm yes?

modern flint
#

pygame-ce
Is a python library for making games

zenith saddle
#

ok thankyou 🙂

modern flint
#

And yes you can still use pycharm

zenith saddle
#

cool

#

again thank you so much

dawn quiver
#

Yo what are classes ive seen so many ppl use them

modern flint
#

!class

frank fieldBOT
#
Classes

Classes are used to create objects that have specific behavior.

Every object in Python has a class, including lists, dictionaries and even numbers. Using a class to group code and data like this is the foundation of Object Oriented Programming. Classes allow you to expose a simple, consistent interface while hiding the more complicated details. This simplifies the rest of your program and makes it easier to separately maintain and debug each component.

Here is an example class:

class Foo:
    def __init__(self, somedata):
        self.my_attrib = somedata

    def show(self):
        print(self.my_attrib)

To use a class, you need to instantiate it. The following creates a new object named bar, with Foo as its class.

bar = Foo('data')
bar.show()

We can access any of Foo's methods via bar.my_method(), and access any of bars data via bar.my_attribute.

dawn quiver
#

What does this help with on peoples games??

limber veldt
#

Organizing code into their own classes is a lot easier to maintain

#

Especially things like pygame sprites. Imagine needing a few enemies moving around the screen, maybe chasing the player. To do this without classes means a bunch of variables and lists and code to handle each of those enemies. If they're all objects that handle their own behaviors, you just add more objects and update/draw them

dawn quiver
#

Ig i just dont really get how they work

modern flint
#

yeah classes are a whole topic, it takes time to learn

dawn quiver
modern flint
#

what do you mean only doing terminal?

pine smelt
#

he only does text based stuff

#

as opposed to graphical stuff like pygames

normal silo
#

Stay in the terminal for a while until you learn more Python, unless you are bored (and need visuals to get excited about coding / motivation).

dawn quiver
# pine smelt he only does text based stuff

Oh i wanted to make it 2 player but then was like nah ai will be easier. So im making a boss that has abilities and you have to kill it. Im gonna work on making it 2 player soon. If i do make it 2 player(on 1 device) will i need to change a lot to make it 2 player across 2 devices using networking?(which i havent even started learning)

dawn quiver
#

Is this basically saying from the class Person run the function say_hi .

#

Dkes that mean it wouldnt work if you just put say_hi()

craggy remnant
#

The function in that context is defined inside the class. Thus, python would throw an error as the function is a method (a function declared inside an object), not in the global scope.

dawn quiver
#

Would this be a good place to use a class?

Line 68
I've been trying to learn classes and would it be good to create a class for the moves on line 68 with their cooldowns instead of just inputting and outputting a ton of variables
https://paste.pythondiscord.com/DETQ

#

anyone answer. I need to know if im right or completely wrong

dawn quiver
#

@green mulch

#

@frozen panther

pine smelt
#

i would organise it like

pine smelt
#
class Boss:
  def __init__(self):
    self.hp = 100

  def attack1(self, player):
     player.hp -= 5

  def attack2(self, player):
     player.hp -= 8

  ...
#

smthn like that

#

oh have the player in its own class too

dawn quiver
#

Ima mess around in like an hour or 2 and test stuff out

pine smelt
#

👍

half siren
supple lantern
#

Hi! I am making a card game in pygame and I am struggling with the design of my game, I introduce restrictions and rules early on for no reason at all except to satisfy my autistic need of order in everything. I just need an advice with direction I am going (what to pay attention to, what rules to relax) with and the code design. So far I am just drawing surfaces and I implemented simple on click event for button type surfaces. I got 270 lines long script, if anyone's willing to look I'll share it. The main thing I am concerned with is --if I continue with my code design what kind of problems will I face, again, I introduced too many rules.

pine smelt
pine smelt
# half siren

do the characters only become black if u comment tint_screen?

supple lantern
pine smelt
#

i mean its unconventional

#

what did u mean by "rules"

supple lantern
# pine smelt what did u mean by "rules"

Surfaces have to be encapsulated by classes with Element inteface.
Surfaces have to be drawn at least once, through draw method.
Rendering has to be done through render method that is being passed the env (state)

I haven't touched on other concepts on pygame yet, I am learning pygame as I go. Right now I struggle with with positioning surfaces but it has to be done in a way that the size of the window does not matter

#

And right now I am thinking of how to attach event handlers to Surfaces for pygame and custom events without burdening subclasess. It has to have some order but flexible enoug. and events have to be handld similar to render method in Shisen class

half siren
pine smelt
#

i temporarily rewrote the transition_check and tint_screen methods to this, since i didnt know what "transition_sprites" were:

    # transition system
    def transition_check(self):
        sprites = [sprite for sprite in self.transition_sprites if sprite.rect.colliderect(self.player.hitbox)]
        if sprites or pygame.key.get_pressed()[pygame.K_SPACE]:
            # self.player.block()
            # self.transition_target = sprites[0].target
            self.tint_mode = 'tint'
        else:
            self.tint_mode = 'no tint'
            
    def tint_screen(self, dt):
        if self.tint_mode == 'tint':
            self.tint_progress += self.tint_speed * dt
        elif self.tint_mode == "no tint":
            self.tint_progress -= self.tint_speed * dt
            
        self.tint_surf.set_alpha(self.tint_progress)
        self.display_surface.blit(self.tint_surf, (0,0))
#

seemed fine to me player sprite wise, idk if its a problem with the player.block()

pine smelt
dawn quiver
#

If i wanna make my game 2 player can i just shove it all into a class and then each person can have their own score deck variable etc within the class and it saves copying out the code again. Or is there anyother way that might be better

slow copper
#

Allows you to reuse and structure various functionalities concisely

dawn quiver
dawn quiver
#

Can anyone recommend a game engine for python?

raven kernel
#

Though it's not really an engine, its a library

#

The only GUI engine I know for making games with python is using godot with the python plugin but its unmaintained afaik

slow copper
#

You can check that out

dawn quiver
#

Thank you

grizzled dust
inland spire
#

hi there.
my program works diffenently after using nuitka.....
left is the one after nuitka. and the right is the one before nuitka....

dawn quiver
#

Is it something to do with the print grid function not inside the class?

#

I can guide you round my code if you need to find atuff

sly vapor
# dawn quiver https://paste.pythondiscord.com/7TFQ Whys the `SlotGrid ` Variable the same for...

list.copy() is a shallow copy, that it, it is a new list, but the contents are references to the same objects, and since you have a list of mutable objects (other lists) - you can see the problem: changing those "inner lists" changes them for both players, because they're the same lists (literally, those are just different references to the same lists in memory).
if you want a new list, and for everything in it to also be copied - you want a "deep" copy which you can get with copy.deepcopy(list), or just.. write a function that makes the grid

#

!e

xs = [
  []
]
ys = xs.copy() # ys is a new list, but ys[0] is identical to xs[0]
ys[0].append(0)
print(xs)
frank fieldBOT
sly vapor
#

!e

from copy import deepcopy
xs = [
  []
]
ys = deepcopy(xs) # slow, but copies everything (recursively)
ys[0].append(0)
print(xs)
frank fieldBOT
sly vapor
#

!e

def f(): return [[]] # simple & fast
xs = f()
ys = f()
ys[0].append(0)
print(xs)
frank fieldBOT
dawn quiver
#

Ohr thanks

#

An alternative would be to input the list in itself and not as a variable

#

Why doesnt it affect the deck list as well

sly vapor
#

because strings are immutable. it doesnt matter if its a shallow or deep copy in that case, you cant change the strings.

xs = ["x"]
ys = xs.copy() # new list, the string is the same one, but, we cant change it anyways, so no bamboozle like with appending in the above examples can happen
dawn quiver
#

Right

#

It gives me an error and says deepcopy is not defined

sly vapor
#

its not a good idea anyways - more like a band-aid fix. just make a function that returns a new grid each time

dawn quiver
#

Ohhhh

modern flint
#

But yeah a function makes more sense

dawn quiver
#

Could i not just input py [[],[] etc

sly vapor
#

well, you could copy-paste that expression each time you need it, but why not give it a name? and since you want to re-evaluate it each time, make that a function

dawn quiver
#

Can someone have a look and lmk what they think

#

@pine smelt

pine smelt
#

lookin good

#

one small thing is prolly just readability but its definitelly better than the last code i saw

#

like example

#

for this:

Player1 = Player([Ace],50,[
    ['□','□','□',],
    ['□','□','□',],
    ['□','□','□',] ], input("Player 1, what is your name?"))  
#

i would write it as

#
Player1 = Player(
    [Ace],
    50,
    [
      ['□','□','□',],
      ['□','□','□',],
      ['□','□','□',] 
    ], 
    input("Player 1, what is your name?")
) ```
#

idk how others would do it but thats what seems the most clear to me

#

also for function names,

#

keep the same naming convention like pascal case and stuff the other guy talked about last time

#

not having different ones like CardChoice(self) and Print_Slots(self)

dawn quiver
#

Oh ye i forgot to change print slots

#

Is it fine if for future projects i want to use snake case and pascals mixed if ygm

dawn quiver
#

Yes

pine smelt
#

entirely fine as long as u stick with it

#

theres tons

#

my favourite sounding name is prolly kebab case or screaming snake case

dawn quiver
#

But most_common_is_snake?

pine smelt
#

ye

pine smelt
#

note, kebab case wont work in python

#

very unfortunate

dawn quiver
#

Hypens not supported?

pine smelt
#

well think about what a hyphen does in python

dawn quiver
#

Ahh subtract

pine smelt
#

ye

dawn quiver
#

Very sad

#

Im pretty sure this is ambitious but imma try get my game to be 2 player over 2 devices

#

Is it networking i need to learn?

pine smelt
#

yeah

#

search up socket programming in python

cedar merlin
#

i need help downloading python modules. I am trying to download pygame, and some data stuff like tensorflow and when i try to download them they never work. I tried homebrew, I downloaded python through the website and the terminal. whille trying to download pygame It said pip needs to update and gave me a command for it and when i copy and pasted the command it still wont update

inland spire
dawn quiver
#

any moderngl book recommendations?

manic totem
#

the vcs say "randint" is not defined

pine smelt
#

u prolly didn't import it

#

at the top of ur code put

#

from random import randint

manic totem
#

oh shit youre right

#

just got notif from bot for using that word

#

my bad og

manic totem
#

i run to new problem

#

how do you make the enemy spawn more than one

pine smelt
#

for loop i suppose

#
for i in range(number):
  enemy = Enemy(randint(0, width), 0) # random x position and at the top of the screen
  enemies_grup.add(enemy)```
tribal shell
#

print('Choose your class')
print('Assasin,Archer,Herbalist,Cleric,Wizard,')
character = input(" ")
if character != 'Assasin' + 'Archer' + 'Herbalist' + 'Cleric' + 'Wizard':
print('wrong')

if character == 'Assasin' + 'Archer' + 'Herbalist' + 'Cleric' + 'Wizard':
print('mmmm I see, you have chosen '+ character)
print('A fine choice,I hope...... that you do not come to regret this ')
import turtle

it keeps printin wrong after character selection

modern flint
# tribal shell print('Choose your class') print('Assasin,Archer,Herbalist,Cleric,Wizard,') char...

Using + means your strings get added together, so you end up with 'AssasinArcherHerbalist' etc.
Your input is never equal to that, so your if statement always evaluates to True and will always print 'wrong'

You probably want something like:

if character not in ['Assasin', 'Archer', 'Herbalist]:
    print('wrong') 

This is called a list, it allows you to store multiple values
And the in keyword checks if a value is somewhere in that list or not

tribal shell
#

tysm

broken prairie
#

Would discussion of a ttrpg character manager go here as well? Trying to put together a Cyber:RED one as an exercise/something to chew on to produce serotonin

pine smelt
#

not entirely familiar with those terms

#

what's a ttrpg and cyberred?

broken prairie
#

tabletop roleplaying game, and cyberpunk: red

limber veldt
craggy remnant
#

Fellow ttrpger spotted.

#

Good luck with the char sheet, there's some examples out there, mostly web apps.

shell nexus
#

Hello. I made a pygame. Who wants to play it? or is this the wrong channel?

vagrant saddle
shell nexus
#

can i paste the URL here?

vagrant saddle
#

not sure how you can start a game from reddit, i think you would have to host it somewhere before

shell nexus
#

its a pygame not a web game

vagrant saddle
#

these are pygame games

shell nexus
#

oh okay

shell nexus
#

how do you play pygames in a web browser?

vagrant saddle
bold hill
#

I can use some help is it possible to add keys together like holding down shift and then moving a wsd my apologies

limber veldt
#

You can use that to see if modifier keys are being held, like shift, ctrl, alt, whatever else is there

bold hill
#

What can I use to make sure that part of code doesn't break when I hold it down because I'm using the basics for right now my apologies

#

@limber veldt

limber veldt
#

You're asking how to not break code, I can't answer that

bold hill
#

I'm sorry

#

@limber veldt would this work for a maze with a colider

#maze#

Import random 

#===[generateion]===#
Maze_wall =Pygame.Rect(random.randint(0,79), random.randinit(0,79),random.randinit(0,50),random.randinit(0,50)

Draw.pygame( (255,0,255),maze_wall)
#===================#
#

My apologies

cold storm
#

checkout blender geometry nodes for generating maps

#

the game engine upbge you can use py to access the evaluated blender object

#
depsgraph = context.evaluated_depsgraph_get()
ob = KX_object.blenderObject
eval_ob = ob.evaluated_get(depsgraph)
#

geometry nodes can encode attributes we can accelerate retrieval using bvhtree or kdtree

#

(kdtree for points / edge centers / face centers - bvhtree for raycasting)

limber veldt
#

I used BGE quite a lot before the fork, like when it was still part of Blender

broken prairie
craggy remnant
dawn quiver
#

How do I resume the debugger?

leaden bane
#

idk but that button looks like it

dawn quiver
#

Now it seems to not pause where the breakpoint is which means the code breaks before the breakpoint, thoughts on how to fix?

bitter field
#

How do I get started?

pine smelt
#

get started with what?

pine smelt
#

i dont really know how javascript works

quartz junco
#

@me if you can help

pine smelt
#

wait no

#

nvm lemme see

#

ok one thing im noticing

#

when the player is "in space"

#

u teleport them to the bottom of the screen?

#

ye and whne u do that

#

when u call update_positions()

#

it just sets in_space to false again

#

cuz they're still on screen

quartz junco
#

Yeah if they jump from the top of the screen up on the next screen they should be at the bottom right

#

Not bottom right, bottom, right

pine smelt
#

in update_positions

#

once they're in space ideally they should stay in space

quartz junco
#

If you fall down from space then it would make since to go back to the first background and level

pine smelt
#

but u put the player at the bottom of the screen

#

they immediately fall back down

#

maybe give them an upwards velocity when u enter space

wicked heath
#

So I know how to toggle fullscreen in pygame but the window bar at the top doesn't show

#

neither does the task bar

#

how would I accomplish this

pine smelt
#
info_object = pygame.display.Info()
display_surf = pygame.display.set_mode((infoObject.current_w, infoObject.current_h))
wicked heath
#

That's what I have right now

#

and it covers the whole screen

#

I'm making a settings menu and wanted to make a windowed mode

pine smelt
#

uhh

#

what about

#
width, height = pygame.display.get_desktop_sizes()[0]
display_surf = pygame.display.set_mode((width, height))
raven kernel
#

i thought pygame.FULLSCREEN would have achieved what you're looking for

bold hill
#

Need some help with a making a collision system for walls to keep the player from going through the wall my apologies

pine smelt
#

uh assuming the walls are rects, and the player has its own rect

#
if player.rect.colliderect(wall.rect):
    if player.rect.right > wall.rect.left:
        player.rect.right = wall.rect.left
    if player.rect.left < wall.rect.right:
        player.rect.left = wall.rect.right

    if player.rect.top > wall.rect.botom:
        player.rect.top = wall.rect.bottom
    if player.rect.bottom < wall.rect.top:
        player.rect.bottom = wall.rect.top
#

this isnt perfect but its a start

wicked heath
#

I'm probaly just not gonna bother with it

#

I have more important aspects to work on

hidden wolf
#

Hi. Trying to figure out how to make a "simple" draw program. If anyone knows which modules I can use to get started with would be much obliged

  1. Draw stroke, but store them so I can move them around (animation purposes) - I'd like to be able to be able to click in the middle of a line for example and move it so it forms a bend in the line (like a triangle) like moving vertexes around
  2. create different layers
  3. be able to combine all layers and export as PNG or GIF

optional - add color

#

if this is the wrong channel let me know and I will delete

slow copper
hidden wolf
#

Sorry, pretty new to programming. any recs for a GUI module to start with?

raven kernel
# hidden wolf Hi. Trying to figure out how to make a "simple" draw program. If anyone knows wh...

Not gonna lie you might be looking for something lower down the line of abstraction to help you with this, this is the kind of thing I'd make with pygame (not because pygame is the most ideal for guis, but because it can be used to more easily access lower level concepts like "brush strokes" by saving them an separate surfaces for example, and defining your own BrushStroke class etc.)
Might be achievable with pyside6 though, but whatever you choose will be complicated and ton of research to make everything you listed with no prior programming experience

hidden wolf
raven kernel
#

cool, but i feel obligated to advice you not to do this as your first project if you plan on seeking help with it - the instructions to be given on help will be complicated and frustrating for the helper if you cant keep up with the basic concepts

#

maybe build a small tic tac toe game at least with pygame then go ahead

hidden wolf
#

I can try that. ty

manic totem
#

@pine smelt sorry for the ping but why its now just stuck up there

pine smelt
#

uh

#

can u send the code i dont rly remember

manic totem
#

i try to fix it but i just make it worse and the code is not working

dim yew
#

can someone help me please

stuck spade
#

when exporting with pyinstaller it becomes necessary to install libraries in whichever device you will use it in, is there a way to make it so you dont have to install libs?

stuck spade
# manic totem i try to fix it but i just make it worse and the code is not working

trashcan_grup = pygame.sprite.Group() bullet_grup = pygame.sprite.Group() enemies_grup = pygame.sprite.Group() trashcan = Trashcan(int(width / 2), height - 100, 3) trashcan_grup.add(trashcan)

You are also not using super().__init__(group) in group classes

And instead of the class being used for .update() method you are using the group ITSELF (Dont use the group itself, get in a for loop like for enemy in enemy_group: enemy.update() )

#

since its multiple sprites

#

and not a single

#

Forgot the bracket btw

#

Does this even work?

#

As enemies is inside another function which isnt a global var

hidden wolf
#

anyone can help me with a pygames issue?

I put buttons on a surface which itself is on the "main screen" When I go to click the button it doesn't work as intended (should print "Clicked" to the console)

Now I know the issue is that the button.rect is giving the value of it's position RELATIVE to the surface I placed it on (the surface is on the right side of the screen)

When I click in the spot that printing (button.rect) gives It triggers the button

#

my current code, any help would be appreciated
the collision attempt is in the draw function of the Button class

limber veldt
#

Seems you'd have to do the math to translate the position of the mouse when pressed, maybe subtract the button's self.screen.topleft.x from mouse.x and self.screen.topleft.y from mouse.y, not sure just reading the code

hidden wolf
#

the mouse position when trying to click the button is like 650, 20
the button thinks it is located at 60, 20 since it's only 60 pixels from the side of the surface I put it on

#

I just tested and it does work if I put it only the main_screen at it's true location, was just hoping not to hard code it

modern flint
#

Is there a framework or a library for simple text based games with some ASCII graphics? It also doesn't need to be anything more than turn based (the game is paused while the user is thinking of the input), so real time processing is unnecessary
I'm thinking pygame is just a huge overkill for something like this

hidden wolf
#

why do you need a framework? if it's going to run in a console, can't you just make the world in a 2d array and use the basic python functions for making characters, dialog etc?

modern flint
#

I guess so, I was just thinking maybe there's a library that will make it easier to handle ASCII art, I've never worked with it before
I'll just write it myself, should be a good challenge

limber veldt
hidden wolf
limber veldt
#

Yes, understood

#

And that should be just doing the math like I mentioned before

#

Using the mouse event like above, you could test the math, I haven't needed to click relative positions on surfaces enough to just know off the top of my head but if you add the above to your event loop, you should be able to wrok it out pretty easily

hidden wolf
#

gotcha

limber veldt
#

If you subtract the topleft.x of options_list x surface from the mouse position, it should give you the relative position on that surface

#

Then do the same for y

#

Or any of the left virtual attributes, there are a few ways to get the x of a rect, topleft.x, left, bottomleft.x among them

hidden wolf
limber veldt
#

I played with it a little, clicks are printed relative to the topleft of the blue surface https://paste.pythondiscord.com/YU7Q similar math can move those numbers relative to other objects as well

#

Like this finds the test_button ```py

        elif event.type == pygame.MOUSEBUTTONDOWN:
            if event.button == 1:
                pos = pygame.mouse.get_pos()
                relative_pos = pos[0] - option_list_location[0], pos[1] - option_list_location[1]
                if relative_pos[0] > test_button.rect.left and relative_pos[0] < test_button.rect.right:
                    if relative_pos[1] > test_button.rect.top and relative_pos[1] < test_button.rect.bottom:
                        print('clicked test_button')```
#

Long lines suck but it's ok for now

#

Your option_list surface doesn't have a rect, I realized after I talked about finding the topleft of it, but you already have that location in your option_list_location so really don't need the topleft of its non-existent rect, lol

hidden wolf
# limber veldt Long lines suck but it's ok for now

oh wow, thank you so much !!

I couldn't figure out what to do and was going to do more googling tomorrow because when I was printing the rect I was getting 0,0 as the location of topleft. Forgot I calculate the location already 🤦‍♂️

#

Really appreciate you working out this for me

limber veldt
#

No problem, I changed your code a little but I think you got it pretty good, keep at it

hidden wolf
#

appreciated 🙂

now I'm trying to get the layer_manager to work, all the new layers added keep the same list of points drawn on, but I'll try to figure it out tomorrow lol, it's too late to think anymore

shell nexus
limber veldt
#

I don't know about registering there but I'm pretty sure it's unnecessary. If you want to install and use pygame, I suggest installing pygame-ce, the Community Edition (and updated, unlike old pygame that is no longer really even active)

shell nexus
#

i want to upload my game on the website and im pretty sure that takes a registration

limber veldt
#

Oh I'm not sure in that case, maybe someone here will know the right answer though

modern flint
#

Do you want to upload your game to that specific website or to any website? Usually people upload their games to itch, as far as I know

limber veldt
#

Matiiss isn't active but they'd probably know

manic totem
#

And for your question

#

Idk

#

Idk what am i doing most of the time

limber veldt
#

Same, but I keep practicing anyway

stuck spade
#

Keep practicing

stuck spade
#

when exporting with pyinstaller it becomes necessary to install required libraries in whichever device you will use it in, is there a way to make it so you dont have to install libs?

limber veldt
#

Sorry, but I haven't used it (nobody cares about my codes so I don't put a lot of effort into sharing them)

stuck spade
#

ah its okay but its not like that

pine smelt
stuck spade
#

wellimean whats the point if they have to install everything anyway

slow copper
#

but id reccomend using nuitka over pyinstaller tho

stuck spade
slow copper
stuck spade
#

using pyinstaller enraged me

#

;-

#

i use Linux so I'm tryna use Wine to compile it to .exe format

#

and then when i launch it

slow copper
#

but nuitka exes are much larger than pyinstaller tho

stuck spade
#

i get "missing module" errors

#

not 1 but a lot more many

proper peak
# stuck spade i get "missing module" errors

are you sure that's due to wine and not an issue with your pyinstaller setup? check that a normal linux build works, and also make sure to use a venv (in my experience pyinstaller has all sorts of weird problems when used without a venv)

stuck spade
#

isn't wine itself a veng

#

venv

#

not python one

#

but it is standing to the definition of virtual environment

proper peak
#

not in that sense; I mean that for some reason pyinstaller works better in a venv compared to an empty global environment

stuck spade
#

oooh

#

I'm using global

#

but there's just 1 problem

#

I'm already far in the project even in GitHub, if i switch to venv will that change anything or ruin anything?

proper peak
#

also you might need to be using an old enough python version, since wine emulates... well, it can be changed, but isn't it like Windows-7-equivalent by default?

stuck spade
#

my wine is windows 10

#

it's box64 running in it

#

and the python is the latest 3.12.4

proper peak
stuck spade
#

private repo

proper peak
#

that makes things massively easier; you can stop messing with wine and instead use github actions to build on a windows system

stuck spade
#

wait howww

proper peak
stuck spade
#

not the executable or its build files

#

so does that count

proper peak
#

everything necessary for the build needs to be on github, so that the action can use it

#

the results of the build will be posted as an artifact (see the end of the workflow i posted), where they can be downloaded from

bold hill
#

I'm working on something specific and I don't want to use just pressed for key I'm still I have making another key my apologies

#
from time import sleep 

Player_speed=1
#===[abilities]===#
Def Dash ():
     Player_speed += 2
     sleep(5)
     Player_speed-=2
Print(player_speed)

#===============#
bold hill
#

My apologies

bold hill
#

@limber veldt

limber veldt
bold hill
#

I'm sorry I'm my code okay my apologies I'm sorry

limber veldt
#

All good

bold hill
#

Would that work?

limber veldt
#

Would what work, time.sleep? That has no place in a game but for very specific uses...maybe, but probably not

fringe berry
#

most game devs: "I can't use free assets because they never have everything i need and it doesnt match"

#

me

stuck spade
#

which engine

fringe berry
#

defold.

#

it's a pretty good engine if your main priority is ease of deployment to different platforms. But it doesnt have as many features as larger engines.

#

But if you dont need them, its kind of refreshing

#

oh another good thing about defold is they have almost no terms of the license

#

the only terms is that you cant commercialize the editor, which is source available. but you can do anything else

stuck spade
#

oh nice

green ether
raven kernel
#

golang scripting? that's cool

fringe berry
#

Nah it's lua. That engine uses a file type .go for a game object. It's pretty annoying because vs code always thinks it's go.

hidden wolf
#

I'm trying to use while pygame.mouse.get_pressed()[2]:
but it turns into an infinite loop, even when the right click is up. How to fix this?

limber veldt
#

Using another while loop that is to span more than one game loop can be tricky, a nested while blocks the outer one, so the event loop doesn't happen or whatever else needs to be constantly updating in the main loop

hidden wolf
#

I'm trying to make a drag selection box, so I am trying to detect the highest and lowest corner the user drags their mouse over. if statements keep resetting though

limber veldt
#

Hmm, maybe get the mouse position at button down and get it again at button up?

hidden wolf
#

that would work, but how to draw the box dynamically while mouse is moving?

#

I want user to be able to see wht they are over

#

oh maybe the MOUSEMOTION event - store initial click in variable, then capture current position and draw the box to that position?

limber veldt
#

Use some kind of flag when the button is pressed that your draw loop can use, when that flag is True, print your saved mousebuttondown location and your current mouse position and go from there?

#

When that flag is False, don't print the values

#

After you get something printing, draw a rect using those values instead of printing them

bold hill
limber veldt
#

I commented the ternaries and left the regular if/else statements, but the ternaries do the same thing

hidden wolf
limber veldt
#

No problem, just a matter of breaking it into pieces that draw.rect() can use

limber veldt
#

I suppose if you wanted to do something with that rect, you might save it in the draw() function or method, just stuff it into a variable

manic totem
#
def create_enemy():
    for e in range(10):
        enemies = Enemy(randint(10, width - 10),randint(-1000, height - 1500))
        enemies_grup.add(enemies)

create_enemy()

how do you make so it wont spawn too close and overlap to each other

limber veldt
manic totem
#

list?

limber veldt
#

This way they're not entirely random, they can only spawn at positions in the list

manic totem
#

how do i make this list

limber veldt
#

my_list = [[200, 0], [400, 0], [600, 0], [800, 0]] If we choose from that list, they can only spawn at those locations for x an y, or similar. If you need to learn lists, I suggest a tutorial on them

#

Either way, randomly choosing will have some overlapping others. Setting up a list of positions to iterate and spawn one at a time isn't too difficult though you lose the randomness

#

Maybe make a few lists of positions and spawn waves in different shapes as the game progresses

#

Pre-determined waves instead of random waves

manic totem
#

so i need to make a list of coordinate of spawn position and then apply it to the function

#

sound confusing to me

limber veldt
#

Totally up to you, just an idea

manic totem
#

also how do you make the enemy spawn one at the time

limber veldt
#

Just iterate a list of positions and spawn one enemy for each position

#

Not a range of enemies like you are now

manic totem
#

iterate?

limber veldt
#

Your create_enemy() creates 10 enemies by iterating a range(10), so it creates 10 enemies, that is iterating a list

manic totem
#

so instead using range i have to call my list

#

so something like this?

def create_enemy():
    for e in my_list:
        enemies = Enemy(randint(10, width - 10),randint(-1000, height - 1500))
        enemies_grup.add(enemies)
limber veldt
#

Do something like this py def create_enemy(): positions = [[200, 0], [300, 0], [400, 0], [500, 0], [600, 0]] for position in positions: enemy = Enemy(position[0], position[1]) enemies_grup.add(enemy) maybe not exactly that but similar

manic totem
#

oh

limber veldt
#

So use the list instead of random

manic totem
#

alr

limber veldt
#

I mean, it's something you could do, an idea, maybe right for your intentions, maybe not, but maybe worth a try for you

manic totem
#

man coding is hard. like, i find out how to solve a problem but idk how to turn it into code

limber veldt
#

Keep practicing what you learn, try not to move on too much until you know each thing

manic totem
#

try not to move on too much?

limber veldt
#

Right, like if you're just starting, learning something really complicated is even harder

limber veldt
#

Always want your names to make sense

manic totem
#

btw can i call a list with this randint thing

limber veldt
#

No, but you can get a random.choice(your_list) to get any one of them randomly

manic totem
#

oh, thanks

limber veldt
#
def create_enemies():
    positions = [[200, 0], [300, 0], [400, 0], [500, 0], [600, 0]]
    for position in positions:
        x, y = random.choice(positions)
        enemy = Enemy(x, y)
        enemies_grup.add(enemy)``` to be clear, I hope you get the idea, keep practicing
manic totem
#

i cant use the choice function

#

what happened

limber veldt
#

Why not?

#

Have you import random at the top of your code?

manic totem
#

AttributeError: 'builtin_function_or_method' object has no attribute 'choice'

limber veldt
#

Then maybe you have assigned something else to choice = something?

manic totem
#

huh?

limber veldt
#

Would have to see your code to know why

manic totem
#

alr

limber veldt
#

You can skip the random. part, since you imported * from random

#

Just use choice()

manic totem
#

oh ok

limber veldt
#
  • imports are too vague, generally shouldn't use them
#

Cause now you have this call to choice() with no reference to it in the code, it just became available because of the * import

manic totem
#

i see

#

TypeError: invalid rect assignment

#

what does this mean

limber veldt
#

A pygame.rect wants a tuple of (x, y, width, height), so something isn't right with your values

manic totem
#

tuple?

#

what am i doing wrong here

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

        enemies = Enemy(x, y)
        enemies_grup.add(enemies)

create_enemies()
limber veldt
# manic totem tuple?

It's like a list but not a list, just some values separated by commas in inside () instead of []

manic totem
#

oh wait

limber veldt
#

You have lists inside your list, right? The [100, 0] is a list inside your x_positions list

manic totem
#

fuck i forgot to change the range

limber veldt
#

So you are getting that list with random.choice() when you only want one value, the x_position

manic totem
#

yes

limber veldt
#

So make your list more like x_positions = [200, 300, 400, 500, 600] or whatever single values, not lists

#

Since you only want one value from the list

#

And of course, do the same for the y_positions

#

Choose each one separately and send them to the enemy

manic totem
#

like this?

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

        enemies = Enemy(x, y)
        enemies_grup.add(enemies)
#

oh i forgot to erase that square thing

limber veldt
#

You don't need all the [100] [] in those

limber veldt
#

You're still making lists inside a list

manic totem
#

so what should i do with that range()