#game-development

1 messages · Page 9 of 1

woven canopy
#

Wait did you just open up that course and that battleship game is what they gave you?

placid wing
#

no

#

i was a bit through the course and that was a project

#

it started from nothing and gave me worded steps which i had to turn into code

woven canopy
#

aah

placid wing
#

.

woven canopy
#

guessing it's in the loops section?

placid wing
#

nap

#

in the lists and cunctions

#

functions*

#

loops is next

woven canopy
#

~ Upon further inspection of the Code Academy tutorial in question, the code was fine, seems to be the suite locking up in the browser causing the error ~

muted wadi
fallow finch
#

you're using huge images to resize them to 32x32, then you make a board and you blit the tiles

#

what do you need

muted wadi
#

i scaled the coin image to 16x16 and printed them so it looks like on pic, now i want to make a coin going up and down from one top border to bottom and vice versa

dawn quiver
fallow finch
#

or you want to make it move in the board

muted wadi
fallow finch
muted wadi
fallow finch
#

if its just about moving up and down you can use a global animation index

#

or you can make a list of surfaces for the animation (i recommend to do this with a rotating coin, going up and down isnt a good animation for a coin)

muted wadi
#

rotating animation is easier?

fallow finch
#

by rotating i don't mean rotating the surface

#

you see how mario coins look like ?

#

that's how a coin should be animated

#

but its not really related to your issue

#

i generaly make a global animation index (starts at 0 and is incremented at each iteration of the main loop), and i use it for all animations so everything is synchronized

#

like, if i have some animation in 20 frames i do animation_index % 20 to know the right frame to display

#

you can use this to make the coin move

muted wadi
#

without the particles at bottom

fallow finch
#

this is an animation you can't do with just moving the surface, the coin "rotates"

#

it's better to make an image with all the frames and import it as a list of 16x16 surfaces

#

also if its a grid making the coin move will not look good, its better to just have rotating coin like mario coins

#

like this one

muted wadi
#

ok, ty for help ill try to do that ❤️

dawn quiver
bleak rose
#

can someone please explain why this isnt working, what I mean is that once the spacebar is pressed self.status = attacking, but when I release the spacebar it is never reset to flying

if keyboard_input[pygame.K_SPACE] and not self.coolingdown:
    self.coolingdown = True 
    self.status = ('attacking')
    #print ('Attacking')
    self.create_attack()
    self.attack_time = pygame.time.get_ticks()

for event in pygame.event.get():
    if event.type == pygame.KEYUP and event.key == pygame.K_SPACE:
      self.status = ('flying')
bleak rose
#

I have resolved this issue

#

I have another question, i have a list with 5 variables and i would like to set all of them to the same value

#

i dont want to change the variables name but what rather their value, I may be doing this incorrectly

sleek wolf
#

yo can anyone help me with a pygame problem

midnight galleon
#

can anyone explain the cordinate system for pyglet

fallow finch
midnight galleon
open cairn
#

hey I am trying to pick over ursina or pygame

#

anyone want to help me pick

dawn quiver
#

What type of game

open cairn
#

I am wanting to make 2d games but in the future I want to make a fps game. I know you'll probably say ursina. but there are more tutorials for pygame but does that really matter?

fallow finch
#

ursina is for 3d only

#

pygame isnt made for 3d

open cairn
#

i think

fallow finch
#

you can use opengl with pygame window but its super bare bones, don't try to make a full fps in opengl

#

ursina is made with panda3d itself made for 3d

dawn quiver
#

Python i not good for 3d

fallow finch
#

i don't recommend ursina for 2d

open cairn
#

should I use both

fallow finch
#

panda3d isnt made in pure python of course, and using raw opengl is still completely possible too

dawn quiver
#

Yea but it's gonna have low frames

fallow finch
#

no ?

#

you can't beat super modern engines but its completely possible

dawn quiver
#

Depends tbh on how complex

fallow finch
#

yea, but with a few shaders you can do really cool looking stuff in opengl

#

never really used ursina so idk its power

vital skiff
#

anyone want to chat and code

dawn quiver
#

First steps of my own lang

pure vessel
#

cannot access local variable 'HOUR' where it is not associated with a value

i have this error code and cant find a way to fix it (yes ive looked on the internet and cant find anything)


class Planet:
    AU = 149.6e6 * 1000 #Astronomical Unit
    G = 6.67428e-11
    SCALE = 250 / AU #1 AU = 100p
    TIMESTEP = 3600*HOUR #represents 1 day```*gap*
```for event in pygame.event.get(): #every button press or click
            if event.type == pygame.QUIT: #the x on the top right of the screen
                run = False

            elif event.type == pygame.KEYDOWN:
                if event.key == pygame.K_PERIOD:
                    HOUR = HOUR + 1
                if event.key == pygame.K_COMMA:
                    if HOUR >= 0:
                        HOUR = HOUR - 1```
dawn quiver
#

@pure vessel pass the hour var into the class

pure vessel
#

i swear if thats all i had to do

pure vessel
dawn quiver
#

@pure vessel show your proper code please

pure vessel
#

ok

frank fieldBOT
#

Hey @pure vessel!

You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.

pure vessel
#

BRUUUUU

#

txt cause its too big

#

sad

#

do i use that

dawn quiver
#

What error is the line on

#

You never even declare hour in the main func

#

@pure vessel

pure vessel
#

ah wait i’ll try it in a bit

pure vessel
#

im changing the HOUR inside of the def main when i want to change it in the class Planet

dawn quiver
#

@pure vessel def your hour in the init

class lol:
    def init(self, blah):
        self.hour = 24 

test = lol()

lol.hour+=1 
pure vessel
#

like that?

dawn quiver
#

Yes

pure vessel
#

then make every HOUR a Planet.HOUR

#

like that

dawn quiver
#

would be earth.HOUR

pure vessel
#

but i wanna do it over all

dawn quiver
#

Or what ever you declare it too

#

Make a global var then

pure vessel
#

i saw that but dont get it

dawn quiver
#

top of script do

global HOUR 
HOUR = 10
#

Everytime you def a function add

GLOBAL HOUR

#
def lol():
    global HOUR 
pure vessel
#

ok

dawn quiver
#

Yes

#

But you are changing the var in the class now

pure vessel
#

?

dawn quiver
#

You start the global at the top of your script

pure vessel
#

like the top of the code

dawn quiver
#

Not in any func or class

pure vessel
#

ok

#

done

#

still dosent

dawn quiver
#

show code now

pure vessel
#

what should this be

dawn quiver
#

Still wrong

#

it's not Planet.hour anymore

#

It's just HOUR

pure vessel
#

yea thought so

#

awsome

#

back to the start

dawn quiver
#

Did you global it in the main func

pure vessel
#

no

dawn quiver
#

I'll do a example 1 sec

pure vessel
#

thanks

#

want to learn this

next estuary
#

Not exactly game development, but python based discord ping system for Minecraft. It launches the self-hosted MC server as a subprocess and captures stdout, running different actions based on the printed string

dawn quiver
#
global hour 
hour = 10
class lol:
    def __init__(self):
        global hour 
        hour+=1 

def main():
    global hour 
    hour+=1
pure vessel
#

oh

#

all three

dawn quiver
#

When ever you def a new func you put the global in there

#

Meaning you give access to that function to now share the var

pure vessel
#

wait

dawn quiver
#

That was just example

pure vessel
#

i already have a function called that

#

Ah

#

ok

pure vessel
#

ok

dawn quiver
pure vessel
dawn quiver
#

Haha good

pure vessel
#

so

#

HOUR is not defined

#

wait

dawn quiver
#

Did you define it under the hour

pure vessel
#

did i mess up

#

wait what

pure vessel
dawn quiver
pure vessel
#

hm

dawn quiver
#

You define it after you make the global

#

So that would be the starting number

pure vessel
#

so i call this inorder to add or subtract HOUR?

#

dident change the code just asking

#

like this

#

then just call that after key down

dawn quiver
#

For everything

pure vessel
#

ah

#

thats not good

dawn quiver
#

Declare hour = 24 at very top of script

#

Not in the class

pure vessel
#

so just delete
the class

#

the code so far

dawn quiver
#

@pure vessel i don't see any errors ? Any errors for you

pure vessel
#

no

#

just

#

still dosent work

#

not changing the speed of time

#

im trying to change the HOUR inside of the Planet class

dawn quiver
#

You do all that in the init part

#

And make them all self.value

#
self.AU = blah 
self.G = blah 
pure vessel
#

this init?

#

or

dawn quiver
#

Yes

pure vessel
#

ok

dawn quiver
#

Put global hour in the init aswell

pure vessel
#

ok

pure vessel
dawn quiver
pure vessel
#

oh

dawn quiver
#

you defined earth to the class planet

pure vessel
#

what

dawn quiver
#

i will send example

pure vessel
#

wait

#

this first

dawn quiver
#
class planet:
    def __init__(self):
        self.AU = 100 
        self.EU =120 

test = planet()
print(test.AU)
pure vessel
#

What?

dawn quiver
#

what ??

pure vessel
#

my mind

#

it broke

#

wait

#

idk

dawn quiver
#

I bind the class planet onto test. So now anything that is self.value becomes test.value

pure vessel
#

allowing?

dawn quiver
#

wym ??

pure vessel
#

nvm

#

so

dawn quiver
#

Why are you even sending the planet au if you already declared it in the class

#

The first parts your declaring in the class is the x and y

pure vessel
#

idk

#

but it works

#

lol

#

oh wiat

#

i see

#

well

dawn quiver
#

Did you get chat gpt to write the script

#

Lol

#

There is no way you got that far without understanding classes

pure vessel
#

its cause im multiplying the AU to get distance it should start in

pure vessel
pure vessel
#

this is how i learn

#

its weird but works

#

some times

dawn quiver
#

You need to learn classes

#

They are really good

#

I use them alot

pure vessel
#

ik to a point

#

still very beginner things but o well

fallow finch
#

here's a template of pygame app using oop, you'll need to make more classes and initialize the objects in the main constructor before using them in the main loop for example

import pygame
import sys

class Template:

    def __init__(self):
        pygame.init()
        self.clock = pygame.time.Clock()
        self.screen = pygame.display.set_mode((800, 600))

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

            pygame.display.update()
            self.clock.tick(60)

if __name__ == '__main__':
    template = Template()
    template.run()
heavy tundra
#

anyone here know pygame

fallow finch
#

just tell your problem

tranquil girder
#

yes

heavy tundra
#

Pygame wont respond

#

the window gets whited out

dawn quiver
#

That's alot of help

#

Show code

dawn quiver
hardy escarp
#

Is there a mix of pygame.time.Clock().tick and asyncio.sleep?

hardy escarp
fallow finch
#

ah the tick method

#

why do you need this exactly ? what are you trying to do

hardy escarp
#

have a steady fps and print x every 5 seconds and y every 1 second (an example)

fallow finch
#

you can use timers in pygame

#

functions running every x ms

hardy escarp
fallow finch
#

milliseconds

#

you know what timers are ?

hardy escarp
fallow finch
#

it's basically running something every x amount of time

#

you can also not use them

#

and do your own thing

hardy escarp
#

can you do multiple at the same time?

fallow finch
#

yes

hardy escarp
hardy escarp
#

i did

pallid patio
#

this hasn't worked -- in particular the image tiles once and then doesn't again, once you scroll past that it stops tiling

would there just be a decent way of checking if the image is scrolled past the display screen so then I would run the tiling function every time it's needed? I think that would help with the performance quite a lot, I can't seem to find a good way to do this unfortunately

#

I guess a solution would be to simply check the layer's coordinates and see if the value's greater than the screen itself

vagrant haven
#

Hey is there any way by which we can earn money using pygame 🤔

tranquil girder
#

You can make a game and sell it

dawn quiver
#

hi pygame users, have a look at my doubt posted in help channel. Also its my first time developing a game using pygame so can anyone of you kindly become my mentor for this???

dawn quiver
pallid patio
#

I tried this but unfortunately it seems to just push the image to the end of the screen

#

I also run into this issue where the player character stops blitting properly

#

I'll try tinkering with it a little more and I appreciate the code here. I dunno why i can't seem to get this concept figured out

#

nvm I think I figured out, just drawing the background twice seems to have done it

tranquil girder
#

Try linking it so we don't have to go search for it

dawn quiver
#

its not about the help post anymore but for mentoring. Its my first time developing a game, so I need someone to become my mentor guiding me

pallid patio
#

for those who might be able to help:

    def loop(*obj:object):
        while running:
            screen.tick()


            # create keyboard instance and catch key presses
            kb = control_dsg() 

            for event in pg.event.get():
                if event.type == pg.QUIT: sys.exit()

                kb.move(event, p1, kb.set_move_AD())

            kb.borderEx(screen, p1)
            kb.jumpEx(p1)         

            p1.animChara()
            p1.delayEx(20)
            p1.BulletEx(1000)
            

            bg.draw_moving_scene(p1, screen) # <--- the culprit
    ...
    bg    = scene(screen, 0, 'assets//images//background//dune.png','assets//images//background//middle1.png','assets//images//background//front1.png')

pallid patio
#

# This is a pretty hasty and thrown together function, but what I'm thinking of doing to clean it up wouldn't aid the performance much
    def draw_moving_scene(self, player:fighter, screen:screen):

        if player.is_past_border():
            self.back.x1 -= self.back.drawspeed
            self.middle.x1 -= self.middle.drawspeed
            self.front.x1 -= self.front.drawspeed


        if player.is_before_border():
            self.back.x1 += self.back.drawspeed
            self.middle.x1 += self.middle.drawspeed
            self.front.x1 += self.front.drawspeed

        if abs(self.back.x1) >= self.back.WIDTH:
            self.back.x1 += self.back.WIDTH

        if abs(self.middle.x1) >= self.middle.WIDTH:
            self.middle.x1 += self.middle.WIDTH

        if abs(self.front.x1) >= self.front.WIDTH:
            self.front.x1 += self.front.WIDTH



        self.back.draw(screen, coord=(self.back.x1, self.back.rect.y))
        self.back.draw(screen, coord=(self.back.x1 + screen.WIDTH, self.back.rect.y))
        self.middle.draw(screen, coord=(self.middle.x1, self.middle.rect.y))
        self.middle.draw(screen, coord=(self.middle.x1 + screen.WIDTH, self.middle.rect.y))
        player.draw(screen, False, (player.rect.x, player.rect.y))
        self.front.draw(screen, coord=(self.front.x1, self.front.rect.y))
        self.front.draw(screen, coord=(self.front.x1 + screen.WIDTH, self.front.rect.y))
#

without the function in place, I get around 200+ fps without any qualms. With the current implementation, just drawing the back, front and player leaves me with about 60 fps, and drawing middle drops it down to 40

fallow finch
#

you have to make your own things and sell them (tutorials, games)

pallid patio
dawn quiver
#

It's unlikely to get sustainable income from it, but you'll get some cash

#

Of course, it all depends on the quality of your game and marketing

#

This might help you

vagrant haven
dawn quiver
#

Sure, that's a sound idea

fallow glade
#

In Python arcade, how to set a track to play only on one of right or left speaker channel?

dawn quiver
#

hi i am developing a game in which the characters are sprites. My code works currently. Do I need to import sprites class?

#

is it required?

#

or does it helps some functions that help in animating sprites?

#

please enlighten me

fallow glade
#

I think whether it will be beneificial or not depends on how your code works

#

But usually it's common to utilise them, and they can help in speed, consistency, and convenience

dawn quiver
#

okay

#

thank you

fallow finch
#

arcade is based on pyglet and looks like pyglet doesnt have this feature

#

you can maybe use a different library for sounds if you need a feature like this

dawn quiver
#

some of my images are not loading

fallow glade
#

But I can try to use the 3D sound feature for this

fallow finch
#

i don't really see a reason to have that much advanced sound features in arcade

fallow glade
#

Pyglet has 3D Spatial sound support

fallow finch
#

yes it's a 3d game engine too

#

arcade is based on pyglet but for 2d

fallow glade
#

But anyway I need the 2d part only

fallow finch
#

you can maybe try to use some other library, bass is a pretty lightweight one, fmod was still fire 10 years ago but i can't find any binding for python, fmod() being a python function lol

dawn quiver
manic totem
#

hey guys how do i make my character able to move in all direction

#

i already figure out how to make it go up and down

#

but when i want to make it also able to go right and left something when wrong

fallow finch
#

we don't even know the library used...

manic totem
#

oh ok

#

my bad

#

so you able to help me if i send my code right

#

here, i cant send the code because of discord

woven canopy
#

Well, just at a glance...

#

you're just using 1 or -1 for the direction without any differentiation between moving in the X axis or Y axis

#

nor do you have any code to handle moving in the X direction at all

#

direction should probably be a tuple including an X and Y direction. EG, up {0,1} right {1,0} , down {0,-1}, left {-1,0}

#

(and perhaps some code to handle when 2 keys are pressed, like up and right {1,1} down right {1,-1} etc...

#

By extension, in the 3rd image. ```py
def move(self, direction, max_height):
if direction[1] > 0:
#handle moving up
elif direction[1] < 0:
#handle down
if direction[0] > 0:
#handle right
elif direction[0] < 0:
#handle left

#

might help

manic totem
#

thanks

woven canopy
#

np lemme know if that helps out. Btw, are you going for a platformer or like zelda top down movement?

manic totem
#

i want to make vertical shoot em up game

woven canopy
#

In either case, you might also consider the pygame.key.get_pressed
As with KEYDOWN and KEYUP you can run into weird behavior. EG right now if I'm holding "Up" and hit right to move that way, then release "Up" movement will stop in all directions

#

with get_pressed, if I've got Up, Down, and Right all pressed at once, you can add together all of the directions, Up and Down will cancel out, but I'll still be able to go right with them pressed.

#

Also you cna transition from moving up to down (or right to left) more easily

manic totem
#

cool

#

this also make my code shorter

woven canopy
#

Also with get_pressed it'd be easier to recognize and handle diagonal movement.

manic totem
#

@woven canopy how do i make it stop while using get_pressed

woven canopy
#

Well it's been a hot minute since I messed with it but

#

Probably have something that looks liek this in your main game loop so it fires every frame.

direction = [0,0] #resets movement at the start of every frame
keys_pressed = pygame.keys.get_pressed() #checks for all keys that are currently pressed
if keys_pressed[K_UP] or keys_pressed[K_W]:
  direction += [0,1]
if keys_pressed[K_DOWN] or keys_pressed[K_S]:
  direction += [0,-1]
if keys_pressed[K_RIGHT] or keys_pressed[K_D]:
  direction += [1,0]
if keys_pressed[K_LEFT] or keys_pressed[K_A]:
  direction += [-1,0]

Basically, you set direction to 0 at the beginning of the frame, and then check which keys the player has held down and update direction before it's handed off to the actual movement code

#

Thus if no movement key is held, it'll default the character to stationary

manic totem
#

my character still keep moving even tho i i have let go the key movement

woven canopy
#

Can you post the section of code that reads your keys now, and the section that actually does the movement itself please?

#

(sry, am working so intermittent)

manic totem
#

oh hey so have other to do so how about i send it on dm

woven canopy
#

works for me

pallid patio
#

Any way I can make this less laggy? I am calling .draw() twice to make the image scroll properly

        self.back.draw(screen, coord=(self.back.x1, self.back.rect.y))
        self.back.draw(screen, coord=(self.back.x1 + screen.WIDTH, self.back.rect.y))
        self.middle.draw(screen, coord=(self.middle.x1, self.middle.rect.y))
        self.middle.draw(screen, coord=(self.middle.x1 + screen.WIDTH, self.middle.rect.y))
        player.draw(screen, False, (player.rect.x, player.rect.y))
        self.front.draw(screen, coord=(self.front.x1, self.front.rect.y))
        self.front.draw(screen, coord=(self.front.x1 + screen.WIDTH, self.front.rect.y))
dawn quiver
lime raven
#

i was wondering why my wip tile-based sandbox was lagging so badly until i realized i was doing something really stupid - i was loading the block sprite to render for every block every frame

#

made the straightforward optimization of loading all the images before the loop and just getting them from there at the render loop

#

although im not sure i actually need that .copy()

fallow finch
#

always load the images you need first, and you should also avoid using pygame.transform functions in a loop or during runtime too

fallow glade
#

Testing arcade's texture caching```py
import arcade

s = arcade.load_texture(r"assets\images\lion_run01.png", width=145, height=69)
t = arcade.load_texture(r"assets\images\lion_run01.png")

print((s.width, s.height), (t.width, t.height))
print(s.image == t.image, s is t)Outputpy
(145, 69) (145, 69)
True False```So doing it this way makes the images not cache to the same key even though they are identical

fallow finch
fallow glade
hollow shuttle
#

hey can i change the origin point of a text in pygame?

fallow finch
#

you want to rotate a text surface ?

hollow shuttle
#

no

#

basically

#

to adjust its position

fallow finch
#

you're making a surface with the text right ?

hollow shuttle
#

yeah

fallow finch
#

you have to center it when blitting the surface

hollow shuttle
#

basically i want the (0,0) coords of the text be the center of the surface

#

not the top left corner

fallow finch
#

what

#

the text IS the surface

hollow shuttle
#

yeah

fallow finch
#

then you blit it where you want

hollow shuttle
#

ik

#

no i mean like

#

one sec

#

basically the origin point is the top left corner of the surface

#

well i want it to be at the center

fallow finch
#

but 0, 0 of what

#

the surface is just the text

#

this is the surface

hollow shuttle
#

yeah i know

fallow finch
#

then you blit it at the center, you can use get_size() to get the width/height

hollow shuttle
#

its origin point is the top left corner

#

OHHH

#

wait i got it

#

thanks

fallow finch
#

and then you blit it at (destination width - surface width) / 2, (destination height - surface height) / 2

#

you can also use pygame.freetype to directly blit text instead of making a surface

#

but using the surface it's easy to center it

hollow shuttle
#

@fallow finch just a question what does the get_size() return

#

does it get returned as a list or tuple or?

fallow finch
#

width and height

#

a tuple

#

you can use get_width() and get_height() too

hollow shuttle
#

ok thanks

fallow glade
#

arcade.AnimatedTimeBasedSprite does not support collisions?

#

I assume no as then it would have to calculate hitbox and store the contours for each and every frame which will be memory expensive

#

So what is a solution here, a faux sprite which will have the animation as a separate attribute?

trim jay
#

This might be noob question but how i can make polygon i draw to sprite and give it rect

#

i have sprites in my gae with pixel perfect collission but wanna do meelee attack and drawing it with code and stuff

#

i have sprite groups handling collission detection its small project just doing for fun and learning purposes

fallow finch
trim jay
#

nvm solved it already

#

doing bulelthell rpg in school project for fun

#

its ice to code without game engines like unity, godot, unreal engine ect. learns something

#

nice*

fallow glade
#

Like 2 other people in the world use arcade I guess, and no one here

next sun
fallow glade
next sun
fallow glade
#

Arcade

next sun
#

Yea arcade has bulit in physics engine for collisions

fallow glade
#

I am not making a platformer or a side scroller

#

I am making an isometric, 8 directions

#

And this does not use the animaitontimebasedsprite class either, doing manual frame updates

#

Rudimentary level

next sun
next sun
fallow glade
fallow glade
#

Your have lesser idea about this than me

#

arcade is the engine, it contains the pyglet physics engine

#

*pymunk

next sun
fallow glade
#

That is unrelated to my question though

#

My question is not about movement, but edge detection for amimated objects for use in collisions

next sun
#

So can you answer in a yes/no are you using a physics engine?

fallow glade
#

You are literally googling and pasting wrong or not very useful answers for me

#

I dk why if you haven't even used this library

dawn quiver
bleak rose
#

hey all, I am going through Clear Code tutorial and I am not sure why he is saying at this point in the video that adding a update status method to the enemy update would cause it to then be performed on all visible sprites. Thank you for any help.
https://youtu.be/QU1pPzEGrqw?t=16726

A Zelda-style RPG in Python that includes a lot of elements you need for a sophisticated game like graphics and animations, fake depth; upgrade mechanics, a level map and quite a bit more.

Thanks for AI camp for sponsoring this video. You can find the link to their summer camp here: https://ai-camp.org/partner/clearcode

If you want to suppor...

▶ Play video
night fiber
#

i got a question
since i wanna make a game once i get a better computer and i would like to have some music is there any good, free and trust worthy music making software?

night fiber
#

yea i guess

fallow finch
#

the only free music sofware i use for games aside Audacity of course is OpenMPT

#

the thing to make tracked music, very useful for games

#

i really don't know a real good music app that is free

night fiber
#

alright thanks that really helps

fallow finch
#

you know what tracked music is ?

night fiber
#

no not exactly

fallow finch
#

it can be used for games but aside games it's kinda useless

night fiber
#

ohh kinda like bossfight music and stuff?

fallow finch
#

looks like good free music apps really don't exist lol, never thought of this

fallow finch
night fiber
#

ahh got it

fallow finch
#

its not really used anymore nowadays

#

that's funny to see how there's good free video editing sofware but for music i really can't find anything free that is known

night fiber
#

yea i kinda figured that i would have to buy some software

#

thanks for your help

fallow finch
brisk yew
#

sure you can, it also has generators and stuff
probably not the most sophisticated tool for creating music, but you can still try sth

dawn quiver
versed aurora
#

im not really sure if this is glitched or not but i tried making a pendulum sim

primal cipher
#

is it worth implement a split in blackjack where the hand will split until it can no longer split? Or is is fine to just do one split since the prob. of getting multiple splits in a row is pretty low. I can't seem to get the recursive splits quite right.

manic totem
#

hey can someone help me how to make my character move diagonally. I've try using key_get_pressed but with some reason it doesn't work

#
    def run_game_loop(self):
        game_over = False
        player_character = PlayerCharacter("game assest/pemain.png", 270, 500, 45, 45)
        direction = [0, 0]

        while not game_over:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    game_over = True

                if pygame.key.get_pressed()[pygame.K_w]:
                    direction = [0, 1]
                if pygame.key.get_pressed()[pygame.K_s]:
                    direction = [0, -1]
                if pygame.key.get_pressed()[pygame.K_d]:
                    direction = [1, 0]
                if pygame.key.get_pressed()[pygame.K_a]:
                    direction = [-1, 0]```
fallow glade
#

Probably change the 2nd and 4th if to elif

manic totem
#

Huh

#

Thanks

fallow glade
#

Welklam

pallid patio
#

I'm moving the background for my game but how would I go about moving the sprites in relation to that? is there any other way of doing this besides manually pushing aside the objects as the screen slides?

#

relevant code (ish?)

    def draw_moving_scene(self, screen, *players):


        self.back.draw(screen, coord=(self.back.x1, self.back.rect.y))
        self.back.draw(screen, coord=(self.back.x1 + screen.WIDTH, self.back.rect.y))

        for p in players:
            if type(p) == player:
                if p.is_past_border():
                    self.back.x1 -= self.back.drawspeed


                if p.is_before_border():
                    self.back.x1 += self.back.drawspeed

            if abs(self.back.x1) >= self.back.WIDTH:
                self.back.x1 += self.back.WIDTH

            p.draw(screen, False, (p.rect.x, p.rect.y))
snow crane
#

Can anyone help with the next?
I need to draw let's say a cube in 2d (net of a cube!) for further game developing using pygame.
It should look like something like this:

fallow finch
#

the next ?

snow crane
#

haha sorry
i need to draw net of a cube like in the picture i sent
furthermore, i need to make tic-tac-toe boards on each of 6 squares

fallow finch
#

you can use images or drawing functions from pygame

#

i think its better to use images rather than just rects

fallow finch
snow crane
#

no
i just know how to draw it by drawing each line separately to draw that net

fallow finch
#

just use an image its easier

#

its not apple II basic heh

snow crane
#

okay i found something and i think it could be correct but i can't adapt an image to the code
also i tried to draw one square and load it 6 times but same problem


import pygame

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)

# Initialize Pygame
pygame.init()

# Set the dimensions of the screen
size = (400, 400)
screen = pygame.display.set_mode(size)

# Load the images for each face of the cube
front = pygame.image.load("cube_model.png").convert()
back = pygame.image.load("cube_model.png").convert()
left = pygame.image.load("cube_model.png").convert()
right = pygame.image.load("cube_model.png").convert()
top = pygame.image.load("cube_model.png").convert()
bottom = pygame.image.load("cube_model.png").convert()

# Create a list of Rect objects for each face of the cube
faces = [
    pygame.Rect(100, 100, 100, 100),
    pygame.Rect(200, 100, 100, 100),
    pygame.Rect(0, 100, 100, 100),
    pygame.Rect(300, 100, 100, 100),
    pygame.Rect(100, 0, 100, 100),
    pygame.Rect(100, 200, 100, 100),
]

# Draw each face of the cube on the screen
screen.blit(front, faces[0])
screen.blit(back, faces[1])
screen.blit(left, faces[2])
screen.blit(right, faces[3])
screen.blit(top, faces[4])
screen.blit(bottom, faces[5])

# Update the screen
pygame.display.flip()

# Wait for the user to close the window
done = False
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True

# Quit Pygame
pygame.quit()

probably i just don't know how to edit an image that i'm trying to load

fallow finch
#

first, dont load the same image several times, of course you can blit the same images more than once

#

then, blitting should be done at any iteration of the main loop, for example 60 times per second

#

and so pygame.display.flip() will be the end of your main loop

#

what do you mean by editing the image, you want to do what now

fallow finch
#

your image is a black square ?

snow crane
#

yes when i tried the option with loading it 6 times to make the net

pallid patio
#

hey there! I'm getting a really weird bug and was wondering if I'm just doing something wrong

#

so, I have code that lets me scroll a background image indefinitely (that, I don't plan on using afterall, because it is a bit too costly), and whenever it glides, I make in sort that every entity aside from the player (so, all npcs) are pushed alongside it (as it would be in most games, moving the background moves everything on it logically). But I am having a strange problem when there is more than one entity to move, in particular, they just don't all move

#

The code

    def draw_moving_scene(self, screen, p:player, *ents:entity):

        self.back.draw(screen, coord=(self.back.x1, self.back.rect.y))
        self.back.draw(screen, coord=(self.back.x1 + screen.WIDTH, self.back.rect.y))

        for e in ents:
            if p.is_past_border():
                self.back.x1    -= self.back.drawspeed
                e.rect.x        -= self.back.drawspeed

            if p.is_before_border():
                self.back.x1    += self.back.drawspeed
                e.rect.x        += self.back.drawspeed

        
            if abs(self.back.x1) >= self.back.WIDTH:
                self.back.x1 += self.back.WIDTH

            e.draw(screen, False, (e.rect.x, e.rect.y))
        
        p.draw(screen, False, (e.rect.x, e.rect.y))
#

e.rect.x -= self.back.drawspeed is what should push the entities out of the day when needed

#

it's a bit easier to see with a video

#

okay so I found the problem but I can't seem to figure out something to fix it. Basically I need to get rid of the list for the moving function

#

because this works when there are 2 entities to move:

    def draw_moving_scene(self, screen, p:player, *ents:entity):

        self.back.draw(screen, coord=(self.back.x1, self.back.rect.y))
        self.back.draw(screen, coord=(self.back.x1 + screen.WIDTH, self.back.rect.y))

        
        if p.is_past_border():
            self.back.x1      -= self.back.drawspeed
            ents[0].dx        -= self.back.drawspeed
            ents[1].dx        -= self.back.drawspeed

        if p.is_before_border():
            self.back.x1     += self.back.drawspeed
            ents[0].dx       += self.back.drawspeed
            ents[1].dx       += self.back.drawspeed

    
        if abs(self.back.x1) >= self.back.WIDTH:
            self.back.x1 += self.back.WIDTH

        ents[0].draw(screen, False, (ents[0].rect.x, ents[0].rect.y))
        ents[1].draw(screen, False, (ents[1].rect.x, ents[1].rect.y))

        p.draw(screen, False, (p.rect.x, p.rect.y))
pallid patio
#

remediated code:


    def draw_moving_scene(self, screen:screen, p:player, *ents:entity):
        """draw all elements of a scene and perform all necessary calculations to move objects in the scene approriately

        Args:
            screen (screen): The screen to blit to
            p (player): the player object
        """
        p.update_borders()

        self.back.draw(screen, coord=(self.back.x1, self.back.rect.y))
        self.back.draw(screen, coord=(self.back.x1 + screen.WIDTH, self.back.rect.y))

        p.borderMoveLayer(self.back.drawspeed, self.back)

        if ents:
            p.borderMoveEnt(self.back.drawspeed, *ents)

        for e in ents:
            e.draw(screen, False, (e.rect.x, e.rect.y))

        p.draw(screen, False, (p.rect.x, p.rect.y))
# Player Class
    def update_borders(self) -> None:

        self.past_border = self.rect.x > self.border and self.action == 1 
        self.befr_border = self.rect.x < self.border and (self.action == 1 and self.charaFlip == 1) 

    def borderMoveEnt(self, speed:float, *ent:entity) -> None:

        for e in ent:
            if self.past_border:
                e.rect.x -= speed
            
            if self.befr_border:
                e.rect.x += speed

    def borderMoveLayer(self, speed:float, *layers) -> None:
        for layer in layers:
            if self.past_border:
                layer.x1 -= speed

            if self.befr_border:
                layer.x1 += speed

            if abs(layer.x1) >= layer.WIDTH:
                layer.x1 += layer.WIDTH
quiet cedar
dawn quiver
raw falcon
#

the programs are an actual feature of the game?

dawn quiver
#

Yep! The theme for the game jam I'm participating in is "Fool the player". The type annotations are misleading, so you have to select the values based on your knowledge too. Or you can guess and have fun :)
If the program executes without any errors, you get gold, otherwise you get fool's goold(pyrite) (the other theme is 'Gold')

#

Tomorrow I'll be working on the combat, but I've finished everything else

patent mantle
#

Hey, I'm trying to make a window close once I click escape, I'm newish to python and would like some help if possible.
Here is the code I have right now >
import pygame

while True:
pygame.display.init()
pygame.display.set_mode(size=(1000, 1000))
pygame.display.flip()
If you can direct me to any websites or anything that will give me some sort of material of how to figure this out that’d be great.

patent mantle
#

so that will begin the instance or initialize the prgram?

#

oh, I thought it looked something like that, sorry. I did it last night and forgot to save, I had close to exactly that

#

yeah, its just hard to remember

#

im taking cs in school but it's not the best... teaching method you could say.

#

thats what ive been doing all day, ill do the same with that.

#

lmao alright

#

true

#

I've been on the fence for most of this stuff "python" mostly because of the things you can do with it; game development, app development, you could make an OS if you wanted.

#

thats the main reason I don't know some things yet, haven't researched. Thought if I choose one thing, I would switch to another. The reason I'm making a minecraft clone as my first project.

#

so, just start with little things, progress the way you want to but in small doses so you can understand/ comprehend what you're trying to learn as well as be able to use what you've learned with any project/ mastering it.

#

good idea tbh

#

but, other than that. Now I have to go define my verticies and make a cube in a 3d display. for the game ofc.

tawdry wharf
#

Not to be rude, @dawn quiver , but it is unnessasary to set the window mode and initialize every frame.

Maybe try the following instead?

import pygame

pygame.display.init()
pygame.display.set_mode((800,600))

running = True
while running:
    pygame.display.flip()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_ESCAPE:
                running = False

pygame.display.quit()
fallow finch
#

anyone can make a better one ? 🙃

manic pewter
#

Can someone explain me how to control the opacity of color in pygame?

fallow finch
#

you mean alpha transparency maybe

manic pewter
#

Yea

#

Idk how to do it

fallow finch
#

s.set_alpha(something from 0 to 255) to change alpha transparency of a surface

#

s is the surface

manic pewter
#

Can you show me a exemple pls?

fallow finch
#

the set_alpha method changes alpha transparence of surfaces

manic pewter
#

Ok thx

upbeat mulch
#

do you guys make games on Ren'Py too??

#

or is it just pygame

versed aurora
#

from scratch, as per usual

leaden jacinth
#

I want to learm

versed aurora
#

ansi codes mainly

#

the ansi is not necessary at all, it just makes it actually understandable

versed aurora
#

it has a background which is the same color as the actual game

raw falcon
versed aurora
#

textual?

pallid patio
quiet cedar
#

I just started learning data types. Lol. I got a long way to go

manic totem
#

so i hear when using get_pressed you dont need to use .KEYUP but with some reason my character still keep moving even tho i dont press any key input. can someone help me

    def run_game_loop(self):
        game_over = False
        player_character = PlayerCharacter("game assest/pemain.png", 270, 500, 45, 45)
        direction = [0, 0]

        while not game_over:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    game_over = True

                if pygame.key.get_pressed()[pygame.K_w]:
                    direction = [0, 1]
                elif pygame.key.get_pressed()[pygame.K_s]:
                    direction = [0, -1]
                if pygame.key.get_pressed()[pygame.K_d]:
                    direction = [1, 0]
                elif pygame.key.get_pressed()[pygame.K_a]:
                    direction = [-1, 0]

                if pygame.key.get_pressed()[pygame.K_w]:
                    direction[1] = 1
                elif pygame.key.get_pressed()[pygame.K_s]:
                    direction[1] = -1
                if pygame.key.get_pressed()[pygame.K_d]:
                    direction[0] = 1
                elif pygame.key.get_pressed()[pygame.K_a]:
                    direction[0] = -1
versed aurora
fallow glade
#

Otherwise the last mod sticks until next direction change

#

Remove the first four if elif block too

#

It's entirely useless when the lower one exists

#

Alternately, you can modify the if elif chains topy if pygame.key.get_pressed()[pygame.K_w]: direction[1] = 1 elif pygame.key.get_pressed()[pygame.K_s]: direction[1] = -1 else: direction[1] = 0

#

^ The lower chain, the upper chain can be deleted

manic totem
#

hmm thanks

#

so i just need to move the direction = [0, 0] inside the while loop

#

lets go it work

fallow glade
# manic totem so i just need to move the direction = [0, 0] inside the while loop

That, or this```py
def run_game_loop(self):
game_over = False
player_character = PlayerCharacter("game assest/pemain.png", 270, 500, 45, 45)
direction = [0, 0]

    while not game_over:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                game_over = True

            if pygame.key.get_pressed()[pygame.K_w]:
                direction[1] = 1
            elif pygame.key.get_pressed()[pygame.K_s]:
                direction[1] = -1
            else:
                direction[1] = 0

            if pygame.key.get_pressed()[pygame.K_d]:
                direction[0] = 1
            elif pygame.key.get_pressed()[pygame.K_a]:
                direction[0] = -1
            else:
                direction[0] = 0```
manic totem
#

ok i will remember this too

raw pasture
#

Guys

#

Guys

#

I need a

#

Floating grass platform

fallow finch
exotic echo
#

can u help me

#

@fallow finch

fallow finch
exotic echo
#

what do u mean

fallow finch
#

who are you

#

why are you pinging me

exotic echo
#

i need help

fallow finch
#

instead of just telling your problem here

exotic echo
#

please

fallow finch
#

well, you just pinged me

#

i cant help

exotic echo
fallow finch
#

it's a server everyone can help, just don't ask to ask and dont ping for help 😉

exotic echo
fallow finch
#

well

#

when are you going to tell your problem

exotic echo
fallow finch
#

15 useless messages lol

exotic echo
#

to open the game

fallow finch
#

what tool are you using for this ?

exotic echo
#

python

fallow finch
#

no, i mean to make the .exe

exotic echo
#

i dont know i just know i need to turn it into .exe

fallow finch
#

you need a library like cx_freeze to do this

exotic echo
#

i started doing pythong 3 days ago myself

#

im also using a macintosh i dont know if that matters

fallow finch
#

.exe on macintosh ?

exotic echo
fallow finch
#

nice

exotic echo
#

how do i make the launcher

#

i made the game

fallow finch
#

cx_freeze makes completely safe exe files, but bytecode is present so it's kinda open source and there's a lot of files, so it's long to install

exotic echo
#

so what do i do

#

using mac

fallow finch
#

pyinstaller can make one file exes with all the code but it's not very good

#

and nuitka is probably the best choice

exotic echo
#

can u help me can i friend u on discord?

lapis marsh
#

hi guys, i got a question but i wondering where should i really ask ? its about a simple question. really simple

exotic echo
#

plz

fallow finch
#

nuitka, pyinstaller and cx_freeze are all python libs

#

you can make exes with python script or cmd using them

exotic echo
#

whats best and easiest to do with mac

fallow finch
#

not related to mac, they're just python libs

#

you can use them with commands

#

and they'll create your files

exotic echo
#

can i call u and share my screen?

#

thats why i ned ur discord

fallow finch
#

why

exotic echo
#

plz

#

its easier

fallow finch
#

you don't need this

#

no it's just about typing a command

#

you have to install the modules first

#

which one do you want to use

exotic echo
#

i guess easiest one i dont know what is the best option

#

pyinstaller?

fallow finch
#

pyinstaller is the easiest one but it's also the worst one

exotic echo
#

why worst

lapis marsh
#

def getstr(string):
while True:
if string.isalpha() and len(string) > 1:
return string
else:
string = input("Try again: ")

fallow finch
#

pyinstaller exes can be detected as malware, you have to tell it's not to play

exotic echo
#

what should i use then

fallow finch
#

nuitka or cx_freeze

lapis marsh
exotic echo
lapis marsh
#

but i don't know how, could someone help me ?

fallow finch
#

cx_freeze is easy and 100% safe but source code is present as bytecode, and so there's a lot of small files, not the best to install and it's easy to get the code

#

and nuitka can bundle the code in the exe file but it's harder to use

exotic echo
#

so nuitka is good with exe file but hard to use but cx is bad with exe but easy to use?

tawdry wharf
fallow finch
#

the python interpreter is the first part, it can be detected as malware

exotic echo
#

so do i use cx or nuitka

exotic echo
#

so i use cx?

fallow finch
#

adding a digital signature to the exe can maybe fix the issue with pyinstaller, signed exes arent detected as malware generaly

exotic echo
#

i think its good option?

fallow finch
exotic echo
#

it needs to be smaller than 1gb

fallow finch
#

you'll get a folder full of .pyc files and other python related stuff

exotic echo
#

will it work?

fallow finch
#

not 1GB but can be large

#

like, easily 60-70MB if you're using different libraries

#

like numpy, pillow...

exotic echo
#

what

#

i just need the launcher

#

i made the game

fallow finch
#

when you make a exe distribution you bundle the python interpreter and the python modules

#

so the players can play without installing python and the modules

exotic echo
#

yew

#

yes

#

yes

#

how

fallow finch
#

python is not compiled, pygame will not be converted as machine code

#

you have to bundle it to make a exe with a game made with it

exotic echo
#

so what do i use tell me what do i download

#

which software to help

#

making the launcher

fallow finch
#

they are python modules

#

and it's not a launcher it's just making a .exe file that acts as if you run the main python file

exotic echo
#

yes

fallow finch
#

pip install cx_freeze to install cx_freeze, then you make a setup file, you run it and you get the exe

exotic echo
#

where do i write that on the terminal

#

?

fallow finch
#

where ? alienunconcerned

#

you write it on the terminal, how do you want more info

exotic echo
#

terminal

exotic echo
fallow finch
#

no, pip install cx_freeze will just install the module

#

then you have to use it

exotic echo
#

so do i download cx_freeze

fallow finch
#

you can easily find setup file examples on the net

fallow finch
#

it's a python module

#

like pygame or any lib

exotic echo
#

can u make them simpler plz i started coding 3 days agoo

#

plz

fallow finch
#

open terminal

exotic echo
#

o

#

k

fallow finch
#

type pip install cx_freeze

#

i mean, you never installed a lib ?

#

how do you made a game so

#

with tkinter ?

exotic echo
#

no

#

i used ren'py

fallow finch
#

so you already installed a lib

exotic echo
#

yeah

#

i think?

fallow finch
#

it's the same for any lib

#

pip install name of the lib

exotic echo
#

i do that?

#

what do u mean

#

i put that in search?

#

plz dont give up on me

#

dont leave me

fallow finch
#

its a command

#

commands are written on the terminal

exotic echo
#

for terminal?

fallow finch
#

not in google

#

where else do you want to write a command

exotic echo
#

ok

#

i thought i was supposed to put pip install autopip install cx_freeze

fallow finch
#

looks like ren'py has its own packaging stuff btw

exotic echo
#

so what do i do

#

i put the pip install autopip install cx_freeze in the terminal

#

now?

#

plz dont leave

fallow finch
#

you can easily find example setup files on the net

exotic echo
#

can u send me

fallow finch
#

official doc

exotic echo
#

i put this?

#

import sys
from cx_Freeze import setup, Executable

Dependencies are automatically detected, but it might need fine tuning.

build_exe_options = {
"excludes": ["tkinter", "unittest"],
"zip_include_packages": ["encodings", "PySide6"],
}

base="Win32GUI" should be used only for Windows GUI app

base = "Win32GUI" if sys.platform == "win32" else None

setup(
name="guifoo",
version="0.1",
description="My GUI application!",
options={"build_exe": build_exe_options},
executables=[Executable("guifoo.py", base=base)],
)

fallow finch
#

you have to tell what third party libs you're using (like renpy)

exotic echo
#

in terminal?

fallow finch
exotic echo
#

is it a pyhton file?

fallow finch
#

then you run the python file

exotic echo
#

so i put it in terminal

fallow finch
#

no, you create a new python file with the code

#

.py file

#

then you open terminal, go to the folder and use this command

exotic echo
#

cant u just add me on discord pleaseeeee then i can call u share my screen and u can tell me what to do pleaseeee i dotn understand

#

plz

#

pzl

fallow finch
#

no this is unneeded

#

i'm also just telling you what the doc is saying

exotic echo
#

yeah i dont understant that though

fallow finch
#

you know how to create a python file ?

exotic echo
#

no

fallow finch
#

so how you made a game in python

exotic echo
#

i started doing python 3 days ago by mself

fallow finch
#

without python file

exotic echo
#

mabye i did?

#

whats a python file

#

anyways

fallow finch
#

.py file, containing python source code

#

if you don't have a python file you can't use python

fallow finch
exotic echo
#

so i have a python file

#

i dont

fallow finch
#

you don't need to make exe at this point

#

really

exotic echo
#

i just made the game

#

i just need a launcher

fallow finch
#

how you made a finished game that fast

#

without knowing what a file is

exotic echo
#

the code isnt long

fallow finch
#

are you sure you have to make exe now ?

exotic echo
#

119

fallow finch
#

make exe only to distribute a finished game

exotic echo
#

sentances

fallow finch
#

otherwise just distribute the python file

#

it's easier for running it on all platforms

exotic echo
fallow finch
#

you don't have to make an executable / "launcher" as you call it

exotic echo
#

i dont?

fallow finch
#

make this only when you want to distribute a finished game

exotic echo
#

i thought i did

#

yeah

#

what do i do to make it distributeable

fallow finch
#

are you sure you have to distribute it now ?

exotic echo
#

why not

fallow finch
#

if that's just for showing it to friends just send the py file

exotic echo
#

then they will have to download everything tho

#

the sofwear

#

the ren'py

fallow finch
#

okay make the exe

exotic echo
#

how

fallow finch
#

everything is on the doc, you don't need me

#

if you know what a file and a command is, you don't need anything else

exotic echo
#

do u think i can solo it

fallow finch
#

if you can create a .py file and run a command on a terminal, yes

exotic echo
#

ok ty

#

i hope i can do it

fallow finch
#

also renpy has its own distribution thing

#

that is really similar to cx_freeze

#

DDLC is made in renpy and the lib folder is just like cx_freeze with also some linux/windows relative stuff

tawdry wharf
#

Is using, for example, (0,0,0) as a key to a dictionary faster than using '0,0,0' and parsing it?

fallow finch
#

because of json ?

tawdry wharf
#

I had a system I had used at one point, before knowing you could use a tuple as a key to a dictionary, where I used keys to store coordinate values.

fallow finch
tawdry wharf
#

fair. I was just wondering which was faster to use, performance-wise.

fallow finch
#

idk if using a tuple as key is slower than using a string

#

but if you have to parse the string, i don't see how it can be better performance-wise

tawdry wharf
#

fair

versed aurora
fallow finch
#

so i was just checking if it was cx freeze or not

versed aurora
#

ah ok

stable talon
#

how do i turn pygame games into exe

vagrant saddle
fallow finch
#

pyinstaller is easy to use but its bad

#

cx freeze is easy to use but bytecode files are present (so source code is kinda visible and there's a lot of files)

#

and nuitka can bundle all the code in the exe but its harder to use

chrome ruin
#
  File "c:\Users\Rocket v 2\Desktop\codecool\roguelike\roguelike-game-python-Ruda05\main.py", line 1, in <module>
    import menu as menu
  File "c:\Users\Rocket v 2\Desktop\codecool\roguelike\roguelike-game-python-Ruda05\menu.py", line 2, in <module>
    from ui import *
  File "c:\Users\Rocket v 2\Desktop\codecool\roguelike\roguelike-game-python-Ruda05\ui.py", line 3, in <module>
    from movement import player_sprite, enemy_sprite1, enemy_sprite2
  File "c:\Users\Rocket v 2\Desktop\codecool\roguelike\roguelike-game-python-Ruda05\movement.py", line 2, in <module>
    from main import *
  File "c:\Users\Rocket v 2\Desktop\codecool\roguelike\roguelike-game-python-Ruda05\main.py", line 18, in <module>
    menu.window_start()
AttributeError: partially initialized module 'menu' has no attribute 'window_start' (most likely due to a circular import)```
#

Hey guys... got some bugs and dont know how to fix it... can anyone help me?

wise cipher
#

@chrome ruin check the imports in those files. Like it says, there is probably a circular import

#

i.e foo imports bar, but bar imports foo

#

so neither can get anywhere

chrome ruin
#

I have solved this problem already. Thank you for your response anyway. I feel like I shall have more problems with my code XD

upbeat tide
#

Look how good i am at coding guys

#

;)

silk sandal
hushed vine
fallow finch
paper ginkgo
upbeat tide
dawn quiver
# vagrant saddle afaik people use pyinstaller for that, but you may want to try pygame wasm on we...

Hey, I might need this by 31st for a game jam submission on itch.io. I've made it work before, but not with a dynamic aspect ratio. What are your thoughts on this? Is it doable with pygbag

How I initialize the display:

        self.shared.screen = pygame.display.set_mode(
            self.shared.SCRECT.size, pygame.NOFRAME
        )

How SCRECT is defined:

    user32 = ctypes.windll.user32
    SCREEN_WIDTH, SCREEN_HEIGHT = user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)
    SCRECT = pygame.Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)
#

If not I can probably just set a fixed size for the display when I'm building the game with pygbag, but just curious if this is possible

fallow finch
#

you're using windows stuff, how can this work on web

dawn quiver
dawn quiver
fallow finch
#

what's the value of sys.platform on pygbag

#

is it related to the browser or what

dawn quiver
#

Something Emscripten. And yes, it is

elder needle
#

Hi, for some reason im completely unable to create a class to render a small dot on the screen would anyone be able to help i cant figure out what im doing wrong

#

afaik im creating the class correctly to just be a simple rect with xy hw stuff and color

#

but it never shows up

oblique parrot
#

hi 🙂

i'm new to coding and i just want to learn and become game development what language should i learn. can anyone advice me pls

vagrant saddle
#

so better use 1024x600 ( or adjust for ratio ) and let browser upscale

dawn quiver
#

Alright thanks

little haven
vagrant saddle
dawn quiver
#

Oh that seems more cross platform

vagrant saddle
dawn quiver
#

Ah, well still useful thanks

vagrant saddle
#

there's not much in stdlib platform module 😦

dawn quiver
#

By the way, what was the sys.platform output for pygbag exactly

vagrant saddle
#

on wasm it can be emscripten or wasi

dawn quiver
#

All lowercase?

vagrant saddle
#

lowercase yes, and emscripten can run on Node or Browser

dawn quiver
#

Alright, I'll check for that when assigning the window size

wise cipher
#

So I've been avoiding pygame in my learning of python so far

#

Is pygame a good framework? I'm no artist, so I don't need something that does fancy 3d models, or uses meshes and textures

fallen rune
#

Hi i'm a beginner with Pygame and i'm looking for people to code with. I make somewhat good pixel arts too and i can make sprites

dawn quiver
wise cipher
#

well that's a bonus then :)

#

I'm kinda working on a texted based adventure and was thinking of improving it to have a visual clickable inventory, colours, maps etc

dawn quiver
#

Oh I thought you said you need it, well for 2d games i can vote for it for sure

dawn quiver
# dawn quiver

This is my current project if that helps, but you should probably check out dafluffypotato on YouTube to see its capabilities

wise cipher
#

re 3D games, I'm sure I read a tutorial about those a day or say ago

#

lemme browse my history

#

ah sorry I was looking at Panda3D

#

so pygame is 2D

#

cool

#

Sounds like just what I want

dawn quiver
olive turret
#

Hello can someone help me with turtle GUI?

#

I couldn't get help from the python-help :3

small tide
#

like ik some basics so is it with pygame?

dawn quiver
#

yeah, its written using pygame

raw pasture
#

Guys

#

Like

hushed vine
dawn quiver
#

it just does, what specifically does not work for you

raw pasture
#

I'm making a game like a infinite jumping game so like i have a baground which is like a mountain on the bottom so like when i wanna make the baground infinite so the baground keeps on repeating but u wanna use another baground for clouds but i wanna loop the clouds baground not the mountain one

#

Anyone help me

raw pasture
#

Yepp

dawn quiver
#

ive made one like that before

raw pasture
#

Like doodle jump

raw pasture
#

But i really want the first baground same but wanna loop the 2nd baground again and again

#

Help me pls

dawn quiver
#

this might be helpful

sterile moat
#

Can anyone help me fix my code?

frigid oxide
#

im having trouble create a tictactoe game can anyone help

prisma olive
#
        if self.left:
            self.x -= self.speed
            sleep(0.1)
        elif self.right:
            self.x += self.speed
            sleep(0.1)
        elif self.up:
            self.y -= self.speed
            sleep(0.1)
        elif self.down:
            self.y += self.speed
            sleep(0.1)```
for this simple snake game, im trying to make it so that it waits for .1 seconds before moving again, but, when it sleeps, it pauses the code, preventing any inputs from user, preventing the player to move 50% of the time. what is a solution?
rapid yacht
#

can someone give me a quick recap on raycasting? i want to make a doom-like horror game

gentle bay
#

Best free pygame ide?

#

Ide for pygame*

dawn quiver
#

I don't think there are IDEs for pygame

#

Personally I just use VSC with the recommended python plugins

elder needle
#

Have any of y'all put pygame into an open ai gym

dawn quiver
#

@vagrant saddle i've been waiting for a few minutes now.. but it seems to be blank
can't tell what i did wrong, I:

Build zip pygbag --archive game_folder
Upload game_folder/build/web.zip

vagrant saddle
dawn quiver
#

It's draft, anyway i can make it so only you can see it?

#

eh screw it, ill make it public

#

the jam is almost over anyways

#

This is my version info

(venv) devex  pip show pygbag       
Name: pygbag
Version: 0.7.1
Summary: pygame wasm, package and run python/pygame directly in modern web browsers.
Home-page: https://github.com/pygame-web/pygbag
Author: Paul Peny
Author-email: 
License: 
Location: D:\d\p\devex\venv\Lib\site-packages
Requires: token-utils
Required-by: 
#

awesome work btw, i wouldnt be participating in game jams using pygame if it werent possible to upload to the web

dawn quiver
#

hmm..okay silly mistake, i didnt check to make sure the code i was building actually worked

#

now i did, and packaged that code with pygbag

#

but yeah, same result

#

okay, update, it shows the first frame in the embed

#

but then it stops

#

so i know for sure my code is working to have reached that point

#

after i click "stop" when firefox prompted that it was slowing down the browser this happens

#

but its static

#

is it just... really laggy?

#

i do have one successful pygbag project from a while back

#

tried using an older pygbag version too.. 0.1.5.. but it doesn't seem to be working(almost the exact same result)

#

I give up.. I'm going to submit the game for now and then maybe add the browser support later

vagrant saddle
dawn quiver
#

it has been set to 1024x600 like you suggestd

#

and i tried edge too, i dont have chrome

vagrant saddle
#

so you fixed Game.run to run async but not yet published

dawn quiver
#

oh shit....

#

i completely forgot the async part

#

😅 .

#

let me uh, well, do that

#

also side note, how do you add an image to a submission

vagrant saddle
#

end of game.py should be something like ```py
async def run(self):
while True:
self._update()
self._draw()
await asyncio.sleep(0)

def main():
game = Game()
asyncio.run( game.run() )````

vagrant saddle
dawn quiver
vagrant saddle
#

maybe the submission takes the cover image ?

dawn quiver
#

hmm, ive given it all possible images though (bg, bg embed, image)

#

okay now moment of truth, running it with async

#

thank you @vagrant saddle

vagrant saddle
#

it is missing a font too

#

"Hack/Hack Bold Nerd Font Complete.ttf"

dawn quiver
#

🤔

#

but its running fine for me

#

what are you running?

vagrant saddle
#

maybe it's not updated

dawn quiver
#

i have updated it now

vagrant saddle
#

yep it works now

dawn quiver
#

it looks questionable with the limited display size lol, but hey it works

dawn quiver
dawn quiver
#

This is using SAT collision detection

prime jasper
#

Does anyone know a fix for top down layer sorting

#

I'm using pygame for that

dawn quiver
#

Do you sort sprites by there y position?

#

well hmm

#

yeah so sprites higher in y would be farther back and should be sorted to the back

#

you just need to decided what y position exactly to sort. Id probably find the bottom center of your sprite and use that.

little haven
#

blit in order of lowest to highest and you've got a nice overlap system

versed zealot
#

Hello
how to detect with pygame multi-keyboards events ?

#

(by example : KEY_A + KEY_B)

#
import pygame as pe
for event in pe.event.get():
    # two key detections :
    if event.type == pe.K_a and event.type == pe.K_b:
        # do something
        Ellipsis

little example with python

versed zealot
#

PROBLEM solved :

        if pe.key.get_pressed()[pe.K_a] and pe.key.get_pressed()[pe.K_b]:
            print("a and b pressed !!!")
finite solar
#

So I noticed that a lot of games use .pkg or .pk files to compress their files. Is it just a modified .zip file? If not how can I make a .pkg file in Python?

versed zealot
#

tipe on google i think bro

#

hey i have annother problem :

def who_win() -> bool or None:
    """player won : true for player 1 and false for player 2 else None"""
    global matrice

    def rangef(enumeration: any) -> None or bool:
        """return true only if all are true"""
        global matrice
        cptA = 0
        cptB = 0
        for x, y in enumeration:
            if matrice[y][x].s:
                cptA += 1
            elif not matrice[y][x].s:
                cptB += 1
            print(f"x,y = {x, y} matrix.s ={matrice[y][x].s}")
        return True if cptA == 3 else False if cptB == 3 else None

    # cut the one-liner
    forall = [[[x, y] for x in range(3)] for y in range(3)]
    forall += [[[y, x] for x in range(3)] for y in range(3)]
    forall += [[0, 2], [1, 1], [2, 0]], [[2, 0], [1, 1], [0, 2]]
    for combi in forall:
        if rangef(combi) is not None: res = rangef(combi)
    return res

# In main loop :
    if who_win() is not None:
        print(f"player {'cross won' if who_win() else 'circle won'}")
        carry = False
    elif checked == 9:
        print("no one won")
        carry = False

why this call is always True ? (matrice[y][x].s is None or False or True)

fallow finch
#

also file archive extensions arent uniform, a lot of games use the same format but the data isnt stored in the same way

#

UE5's .pak files and popcap's .pak files arent the same

#

or .arc files from nintendo arent the same thing depending on the game

#

you can use a modified zip, however decoding it will take time and some ram to decode it, especially if you don't want to temporarily store the decoded files

#

a lot of proprietary archive files in games are xor encrypted non-compressed files

#

and then they have a function to read the bytes and they can open the files nearly at the same speed than non-archived files, but encryption is weak, and you should not write this in python too

fallow finch
#

also, keep in mind music files should be streamed instead of being loaded in ram, so if you have large wav/ogg or even mp3 files, you'll have to store them somewhere in temp folder

#

you should focus on this (from most important to less important)

#

1 - loading time
2 - compression
3 - encryption
4 - amount of files

dawn quiver
#

class Grass( pygame.sprite.Sprite ):
def init( self, image, x, y, rotation=None ):
pygame.sprite.Sprite.init(self)
if ( rotation == None ):
angle = random.randrange( -1, 0 )
self.image = pygame.transform.rotozoom( image, angle, 1 )
self.rect = self.image.get_rect()
self.rect.center = ( x, y )
pygame.init()
window = pygame.display.set_mode((window_WIDHT, window_HEIGHT))
grass_image = pygame.image.load( 'Back 2.png' ).convert_alpha()
all_grass_sprites = pygame.sprite.Group()
for i in range(50):
new_x = random.randrange(window_WIDHT)
new_y = random.randrange( window_HEIGHT )
new_grass = Grass( grass_image, new_x, new_y )
all_grass_sprites.add( new_grass)

#

however i can't get the grass image clones to move pls help me

marble jewel
terse stream
#

Hi, I'm making a spaceflight simulator, I want someone who knows about astrodynamics and has experience with python. it needs a lot of calculation. my code is on GitHub page https://github.com/Jackcybox007/spacecraft-simulator. I have been coding it for a few days now. if you are interested in this please DM me for more information.

dense nebula
#

I am making a zelda like game using pygame and i have 2 questions:

How can online multiplayer be implemented?
How can a "save game progress" be implemented?

fallow finch
#

and game save can just be a text file, but i recommend using a python dict as json or pickle (both are builtin python things)

regal comet
#

hello I have this function to see if a polygon contains another polygon and I don't know why it doesn't work.

#
def polygon_contains_polygon(poly_points1, poly_points2):
    # Check if either polygon is empty or has less than 3 points
    if len(poly_points1) < 3 or len(poly_points2) < 3:
        return False

    # Calculate the bounding box of polygon1
    xmin = min([p[0] for p in poly_points1])
    ymin = min([p[1] for p in poly_points1])
    xmax = max([p[0] for p in poly_points1])
    ymax = max([p[1] for p in poly_points1])

    # Check if any point of polygon2 is outside the bounding box of polygon1
    for p in poly_points2:
        if p[0] < xmin or p[0] > xmax or p[1] < ymin or p[1] > ymax:
            return False

    # Check if any point of polygon2 is inside polygon1 using the ray casting algorithm
    inside = False
    for i in range(len(poly_points2)):
        j = (i + 1) % len(poly_points2)
        intersection = 0
        for k in range(len(poly_points1)):
            l = (k + 1) % len(poly_points1)
            if do_lines_intersect(poly_points2[i], poly_points2[j], poly_points1[k], poly_points1[l]):
                intersection += 1
        if intersection % 2 != 0:
            inside = not inside

    return inside


# Helper function to check if two line segments intersect
def do_lines_intersect(p1, p2, q1, q2):
    def ccw(a, b, c):
        return (c[1] - a[1]) * (b[0] - a[0]) > (b[1] - a[1]) * (c[0] - a[0])

    return ccw(p1, q1, q2) != ccw(p2, q1, q2) and ccw(p1, p2, q1) != ccw(p1, p2, q2)

hushed vine
#

But i agree, use a dict

upper lion
#

i got an assignment due to make a 2d adventure game and ibr i have no clue on how to start, are there any channels or videos i can look at?

fallow finch
#

json is just for dicts but can be modified by humans very easily

#

and pickle is not just about dicts, its about every python object

upper lion
foggy python
fleet grove
#

Which software did you used for creating that graphics?

fallow finch
#

dafluffypotato uses pygame and sometimes moderngl or pyopengl idk

foggy python
#

Pygame and ModernGL, yeah

sharp lake
#

Hey, is there a way to create platforms colision without having to make a list of every blocs ? I'm trying to create a little platformer but eveything that I found online use a giant list for every bloc in the game to achieve colisions

foggy python