#game-development

1 messages · Page 59 of 1

pastel ice
#

Ok..

edgy rampart
#

hi, i'm doing a console text game for a GameJam

random frigate
#

@pastel ice Im not to sure about it,but why I asked the question because I want to make a game where every character has its own ability and things

pastel ice
#

@random frigate the best thing would be to create a character class.. and ability class.. and integrate them together... But it's better if some expert gives opinion

silent flower
#

when im using pygame and socket.recv is waiting for a connection, the pygame window will be "not responding"

#

i understand that pygame has to be constantly updating to work, but cant find a way to make it constantly update while socket is waiting for a connection

calm thistle
#

@silent flower You need to run your networking on a thread, or use asyncio and turn your game loop into a coroutine

silent flower
#

i found that socket.settimeout() does the trick

#

i may rewrite the code to be asynchronous some day though

vocal ermine
#

Hey there,
I want to make little Harrypotter indiegame with pygame and am looking for some nice people who want to participate.
DM me if you are interested.
Ps: Im New to this Server and dont realy no if this is the right Chanel for that
😅

spice ridge
#

I also want to know what channel to post this

#

Topic

calm thistle
#

There is an #680716760134975491 channel but I guess if you're looking for game dev team-ups here is as good as anywhere

#

But I'd suggest pitching your whole idea and some sketches and things, because everyone probably has loads of game ideas, and you need to make a case for why your idea is worth running with

craggy rain
#

Hi there I am using pygame to make jsut a screen filling with lines of color and I wanted to use a function to randomly choose a color and not be the same as the last color picked, The problem as it says its invalid as a color. I can show what I have but right now it is ugly because I cant use a function so its a mess, anyone know how I can like get around that?

#

Actually now that I put in the function it isnt throwing an error but instead just filling with white instead of random colors, should I post my code?

dreamy swan
#

Maybe use a list of colors it can use, then set a variable to the last color used, check if the color it wants to use is that variable, and if it is, pick a new color

craggy rain
#

Thats basically what I did but it doesnt work for some reason

#

Should I post my code for you @dreamy swan

dreamy swan
#

I can’t look rn, but it was just an idea

craggy rain
#

Yeah thanks, but for some reason if I use the code that is in the function in each place where it would be used it works, but if I just put the function there (That has the same code) it doesnt work and I dont know why, When I use the function its just white lines

latent raft
#

so I've been using tkinter up till now and making a couple of games/tools with it but it's starting to get too slow with lots of vector graphics and I want to start making more complicated games/demonstrations, notably using 3D graphics or 2D graphics that look 3D. I don't know a single thing about opengl. should I start with pyglet or pygame?

rich siren
#

tell me who is making a game in python, you guys are insane i would rather use even haskell

fathom sky
#

a lot of people use python for games, it’s really easy to get into for beginner users. pygame is great for small 2d games, check out DaFluffyPotato on YouTube for example, his games are crazy and really show that pygame and python are valid options for game development

#

@rich siren

cold storm
upbeat plinth
#

hy guys, so i have been working on this game using pygame and want to code a inventory system for it. would it be a good idea to use a matrix for the storage of the items or is there a better way of doing it?

fervent rose
#

@upbeat plinth well, if each entity only has a list of items, it is better to represent it as a 1D array (list), and then put it into 2d when you are rendering it (really nice graphics btw)

nova stag
#

In a simple space invaders type game, how would I change my ship sprite to an explosion sprite when hit by an alien?

frozen knoll
#

What library are you using?

nova stag
#

pygame

frozen knoll
#

Ah, my examples are all Arcade. Someone else might have some sample code.

craggy rain
#

How can I make this smaller?

#
async def RockPaperScissors(ctx, input: str):
  options = ["rock", "paper", "scissors"]
  BotPick = random.choice(options)
  #ROCK OPTIONS
  if BotPick == "rock":
    if input == "rock":
      await ctx.send("Draw, I chose Rock")
    if input == "paper":
      await ctx.send("WINNER!, I chose Rock")
    if input == "scissors":
      await ctx.send("You lose, I chose Rock")
  #PAPER OPTIONS
  if BotPick == "paper":
    if input == "rock":
      await ctx.send("You Lose, I chose paper")
    if input == "paper":
      await ctx.send("Draw, I chose paper")
    if input == "scissors":
      await ctx.send("WINNER!, I chose paper")
  #SCISSOR OPTIONS
  if BotPick == "scissors":
    if input == "rock":
      await ctx.send("WINNER!, I chose scissors")
    if input == "paper":
      await ctx.send("you lose, I chose scissors")
    if input == "scissors":
      await ctx.send("draw, I chose scissors")
frozen knoll
#

Try using elif and else to begin with.

#
  if BotPick == "rock":
    if input == "rock":
      await ctx.send("Draw, I chose Rock")
    elif input == "paper":
      await ctx.send("WINNER!, I chose Rock")
    else:
      await ctx.send("You lose, I chose Rock")
proper peak
#

Maybe make a function beats(choise1,choise2) --> int, and rewrite those giant if trees using this function and f-strings.

#
result = beats(BotPick,input) #1 - win, 0 - draw, -1 - lose
if result == 1:
  await ctx.send(f"You lose, I chose {BotPick}")
elif result == 0:
  await ctx.send(f"Draw, I chose {BotPick}")
elif result == -1:
  await ctx.send(f"WINNER! I chose {BotPick}")
jolly axle
#

I want to add npcs to my pyscroll / pygame game, but for whatever reason I can't get them to render. Should I be adding them to my main pyscroll group (the one my player is in), or making another group, and if so when should I render that group?

craggy rain
#

@proper peak Sorry, im newer and I dont really understand what you mean by all that

#

I understand making a function but I dont know how to make a function to detect a win or loss

#

@frozen knoll I did now change it to use elif and else but whats really the benefit doesnt it do the same?

proper peak
#

and can be further shortened by putting those 3 if-cases into a two-layer ternary:

result = beats(BotPick,input) #1 - win, 0 - draw, -1 - lose
await ctx.send(f"{'You lose,' if result == 1 else ('Draw,' if result == 0 else 'WINNER!')} I chose {BotPick}")
craggy rain
#

How does that even know that rocks better than scissors or anything like that?

proper peak
#

That goes into beats:

def beats(choice1, choice2):
    if choice1 == choice2:
        return 0
    if (choice1=="rock" and choice2=="scissors") or (choice1=="scissors" and choice2=="paper") or (choice1=="paper" and choice2=="rock"):
        return 1
    return -1
#

With type hints:

def beats(choice1: str, choice2: str) -> int:
    if choice1 == choice2:
        return 0
    if (choice1=="rock" and choice2=="scissors") or (choice1=="scissors" and choice2=="paper") or (choice1=="paper" and choice2=="rock"):
        return 1
    return -1

craggy rain
#

oh I see how that could work, wouldnt you have to have a really long list of that return 1 list though

#

or no

proper peak
#

Not sure what you mean

craggy rain
#

wouldnt what you have be it?

#

nevermind

#

I was thinking you would have to write out each scenario but you wouldnt need all that

#

how does this work?

await ctx.send(f"{'You lose,' if result == 1 else ('Draw,' if result == 0 else 'WINNER!')} I chose {BotPick}")

like how come those if statements are after and why dont they need to like have a semi colon and all that

proper peak
#

Python doesn't have a ternary operator condition?expr_if_true:expr_if_false, but it allows using ifs without any parantheses or anything. Basically, this f-string:

a = f"{'You lose,' if result == 1 else ('Draw,' if result == 0 else 'WINNER!')} I chose {BotPick}"

is equivalent to:

a = ""
if result == 1:
  a+= "You lose,"
else:
  if result == 0:
    a+= "Draw,"
  else:
    a+= "WINNER!"
a+= " I chose "
a+= BotPick
#

(expect it probably doesn't actually calculate all the string concatenations, but does it in one step - same result, less computation)

#

note how while in python " and ' are equivalent, I had to use ' for all the inner strings inside my main one in the first example - because if I'd used " it would mean the end of the outer string.

upbeat plinth
#

@fervent rose that might be a good way to do it! Thx

jolly axle
#

I want to add npcs to my pyscroll game, but for whatever reason I can't get them to render. Should I be adding them to my main pyscroll group (the one my player is in), or making another group, and if so when should I render that group?

shadow sonnet
#

Someone here could help me with a blackjack game? My purpose is to develop the game using OOP and I have an UML to get start, but how I am learning, I have some doubts... if someone could help me, send me a private msg

frozen knoll
#

Text or graphical?

unborn hull
#

hi we are making a server with Indian teen coders if u meet the condition dm me

merry echo
#

Heya, I'm trying to make caustics using noise (simplex, cellular, etc. ) with glsl shaders. Does anyone have resources for doing this?

noble minnow
#

Long story short:

I'm looking for a 2d rpg engine. I remember one but can't remember the exact name. Does anyone know of any?

frozen knoll
#

libtoc probably

covert sigil
#

hey im trying to make a text rpg, and i need to import a class from another file into multiple files

#

before i just added the duplicate code to the top of every file, but it is tiresome to change

#

i wondered if there is was better way to do it

fervent rose
#

What is the snippet you are copying?

cloud saddle
#

btw apparently they licensed everything under creative commons :).

dawn quiver
#

how to calculate the time
like to make a daily reward without using lots
of threads??

fierce wraith
#

you could use something like sched and call its run function in your game loop

upbeat plinth
#

hey guys, so i have been working on an inventory system for my game but i cant get it to work properly. all items are in a one dimetional list but i cant get it to display them in the next row. does anyone know how to do that?

proper peak
#

It really depends on how you're displaying those items in general. Do you need help with splitting an array into 6-element rows, or with displaying them in general?

upbeat plinth
#

as you can see the items just blit in a row wich is fine as long as there are less than 6 images, but i cant get it to display them on the next row when the list gets longer than 6

fierce wraith
#

you can convert into a 2d position by taking x = index % row_len and y = index // row_len

#

that will give you at what x,y index the item should be

#

to get pixel coords, just multiply by width, height

upbeat plinth
#

ooh thats interesting! thx

upbeat plinth
#

thanks a lot @fierce wraith

fierce wraith
#

np!

#

you also have to account for the little dividers though

dawn quiver
#

I am trying to make my game 700x700 while it is full screen, but the screen started to flicker all the time it is opened

#
    global win
    run = True
    button_newgame = Button((0,0,0), (Width/2)-(350/2), 300, 350, 75, "New Game")
    button_loadgame = Button((0,0,0), (Width/2)-(350/2), 350 + 75, 350, 75, "Load Game")
    button_quit = Button((0,0,0), (Width/2)-(350/2), 400 + 75*2, 350, 75, "Quit Game")
    def redraw():
        win.fill((0,0,0))
        button_newgame.draw(win, (255,255,255))
        button_loadgame.draw(win, (255,255,255))
        button_quit.draw(win, (255,255,255))
        pygame.display.update()
    while run:
        clock.tick(FPS)

        for event in pygame.event.get():
            pos = pygame.mouse.get_pos()
            if event.type == QUIT:
                quit()

            if event.type == ACTIVEEVENT:
                if event.gain == 1:
                    win = pygame.display.set_mode((Width, Height), FULLSCREEN)

            if event.type == MOUSEBUTTONDOWN:
                if button_newgame.isOver(pos):
                    characterGender()
                if button_loadgame.isOver(pos):
                    pass
                if button_quit.isOver(pos):
                    quit()

            if event.type == MOUSEMOTION:
                if button_newgame.isOver(pos):
                    button_newgame.color = (0,175,0)
                else:
                    button_newgame.color = (0,0,0)
                if button_loadgame.isOver(pos):
                    button_loadgame.color = (0,0,175)
                else:
                    button_loadgame.color = (0,0,0)
                if button_quit.isOver(pos):
                    button_quit.color = (175,0,0)
                else:
                    button_quit.color = (0,0,0)

        redraw()```
upbeat plinth
karmic mesa
#

someone help me make a key detection system for the dji tello drone go ahead with w go back with s
and go sideways with a and d

dawn quiver
#

@upbeat plinth Amazing game! The sounds are so chill and good.

upbeat plinth
#

Thx bruv

frank fieldBOT
#

Hey @eternal mirage!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

dawn quiver
#

@everyone If anyone is working on a game and needs music I would love to participate (:

crisp fern
#

@dawn quiver where can I listen to your music?

dawn quiver
#

should have probably DMD lol @crisp fern

dawn quiver
fierce wraith
#

It's pretty good

frank fieldBOT
#

Hey @limpid pilot!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

limpid pilot
#

import turtle

canvas=turtle.Screen()
canvas.title("Pong Game")
canvas.bgcolor("black")
#Size of the widow
canvas.setup(width=800, height=600)#0,0 is center
canvas.tracer(0)# stops the window from updating automatically

#Paddle
pa =turtle.Turtle()#This is our turtle
pa.speed(0)#Speed of animating
pa.shape("square")#different shapes u can try
pa.color("red")
pa.shapesize(stretch_wid=5,stretch_len=1)#uncomment to increase the size
pa.penup()#so that is doesnt draw a line while moving
pa.goto(-350,0)#initial position of paddle

#Paddle B

pb=turtle.Turtle()#This is our turtle
pb.speed(0)#Speed of animating
pb.shape("square")#different shapes u can try
pb.color("green")
pb.shapesize(stretch_wid=5,stretch_len=1)#uncomment to increase the size
pb.penup()#so that is doesnt draw a line while moving
pb.goto(350,0)#initial position of paddle

#Ball
ball =turtle.Turtle()#This is our turtle
ball.speed(0)#Speed of animating
ball.shape("circle")#different shapes u can try
ball.color("blue")
#ball.shapesize(stretch_wid=5,stretch_len=1)#uncomment to increase the size
ball.penup()#so that is doesnt draw a line while moving
ball.goto(0,0)#initial position of paddle
ball.dx=3#ball moves 2 pixle in x direction
ball.dy=3#ball moves 2 pixles in y direction

score=turtle.Turtle()
score.speed(9)
score.shape("square")
score.color("white")
score.pen()
score.hideturtle()
score.goto(0,200)
score.write("player A : 0 / player B : 0 ",align="center",font=("courier",24,"normal"))

Score

score_a = 0
score_b = 0

#

#Functions
def pa_mov_up():
y=pa.ycor()#get the y cordinate
y=y+40#increase value of y to 20
pa.sety(y)#set that y cordinate of the paddle

def pa_mov_down():
y=pa.ycor()#get the y cordinate
y=y-40#increase value of y to 20
pa.sety(y)#set that y cordinate of the paddle

def pb_mov_up():
y=pb.ycor()#get the y cordinate
y=y+40#increase value of y to 20
pb.sety(y)#set that y cordinate of the paddle

def pb_mov_down():
y=pb.ycor()#get the y cordinate
y=y-40#increase value of y to 20
pb.sety(y)#set that y cordinate of the paddle

#Keyboard
canvas.listen()#listens for keyboard input
canvas.onkeypress(pa_mov_up,"w")#whenever user presses w key it calls the function pa_mov_up
canvas.onkeypress(pa_mov_down,"e")#whenever user presses e key it calls the function pa_mov_up
canvas.onkeypress(pb_mov_up,"o")#whenever user presses o key it calls the function pa_mov_up
canvas.onkeypress(pb_mov_down,"p")#whenever user presses p key it calls the function pa_mov_up

#

#Main loop
while True:
canvas.update()#updates screen everytime the loop runs

#Move the ball
ball.setx(ball.xcor() + ball.dx)#updates x cordinates
ball.sety(ball.ycor() + ball.dy)#updates y cordinates

#Part4**********Move the ball
#Border Check
if ball.ycor()>290: #is ball's y cor is greater than 290
    ball.sety(290)#it sets the cordinates to again 290y
    ball.dy*=-1#reverses the direction

if ball.ycor()<-290: #is ball's y cor is greater than 290
    ball.sety(-290)#it sets the cordinates to again 290y
    ball.dy*=-1#reverses the direction

if ball.xcor()>390: # everytime ball goes outside 400 it again start in the middle
    score_a += 1
    score.clear()
    score.write("Player A: {}  Player B: {}".format(score_a, score_b), align="center", font=("Courier", 24, "normal"))
    ball.goto(0,0)   # with reverse direction
    ball.dx*=-1
    
if ball.xcor()<-390:
    score_b += 1
    score.clear()
    score.write("Player A: {}  Player B: {}".format(score_a, score_b), align="center", font=("Courier", 24, "normal"))
    ball.goto(0,0)
    ball.dx*=-1
    
#Bounce
#if the ball is the edge of the paddle ot touching the paddle and y cordinate of ball is same as that of paddle
if ball.xcor() > 340 and ball.xcor()<350 and pb.ycor()-40<ball.ycor()<pb.ycor()+40:
    ball.setx(340)
    ball.dx*=-1
    
if ball.xcor()<-340 and ball.xcor()>-350 and pa.ycor()-40<ball.ycor()<pa.ycor()+40:
    ball.setx(-340)
    ball.dx*=-1
#

so this is the code for a ping pong game that i made

#

i am using only turtle so tell me what you think about it

frozen knoll
#

No, you don't.

#

What exact error message do you get?

#

Not exactly sure what you are saying, but Arcade does require OpenGL 3.3 support, which most modern computers have. Pygame's graphics don't use a lot of the hardware support Arcade does, so it does run on things like the Raspberry Pi.

#

Yea, 3.1 was released back in 2009.

heavy sigil
#

well neither using pygame nor pyopengl for me, i am using tk, and I need some help (logical help)

#

I need to zoom in a cube

#

how can I do that

#

main.py:

import tkinter as tk
import os,draw,sys,os,platform,time
from constant import *

item = {
    'cube': {
        'size': 100,
        'startx': 10,
        'starty': 10
    }
}

moves = {
    'w': False,
    's': False
}

def kp(event):
    global root,moves
    if event.keysym == "Escape":
        root.destroy()
        quit()
        return
    if event.keysym == 'w':
        moves['w'] = True
    if event.keysym == 's':
        moves['s'] = True
def kr(event):
    global moves
    if event.keysym == 'w':
        moves['w'] = False
    if event.keysym == 's':
        moves['s'] = False

def main():
    global moves,root,item
    root = tk.Tk()

    root.update()

    root.bind_all('<KeyPress>', kp)
    root.bind_all('<KeyRelease>', kr)
    while True:
        try:
            if moves['w']:
                item['cube']['size'] += 1
            if moves['s']:
                item['cube']['size'] -= 1

            c = tk.Canvas(root)
            c = draw.cube(c,item['cube']['startx'],item['cube']['starty'],item['cube']['size'],outline='#fff')
            c.place(x=0,y=0)


            root.update()
            time.sleep(0.005)
        except tk._tkinter.TclError:
            return 0
if __name__ == "__main__":
    main()
#

draw.py:

import tkinter as tk

def rectangle(canvas,startx,starty,width,height,/,outline=None,fill=None):
    """Create a rectangle with width and height"""
    startx = abs(startx - startx % 2)
    starty = abs(starty - starty % 2)
    width  = abs(width  - width  % 2)
    height = abs(height - height % 2)
    canvas.create_rectangle(startx,starty,width,height,outline=outline,fill=fill)
    return canvas
def rectangle_wend(canvas,startx,starty,endx,endy,/,outline=None,fill=None):
    """Creates a rectangle with end x y coor"""
    width = endx - startx
    height = endy - starty
    return rectangle(canvas,startx,starty,width,height,outline=outline,fill=fill)
def poly(canvas,pt:tuple,/,outline=None,fill=None):
    """Creates a polygon"""
    canvas.create_polygon(pt,outline=outline,fill=fill)
    return canvas
def cube(canvas,startx,starty,length,outline=None,fill=None):
    """Creates a cube"""
    x  =       startx
    x1 = length/3  +x
    x2 = length/3*2+x
    x3 = length    +x
    y  =       starty
    y1 = length/3  +y
    y2 = length/3*2+y
    y3 = length    +y
    canvas.create_polygon((x,y1,x1,y,x3,y,x3,y2,x2,y3,x,y3,x,y1,x2,y1,x3,y,x2,y1,x2,y3,x2,y1,x,y1),outline=outline,fill=fill)
    return canvas
plush stratus
#

Can someone help me with this?

frank fieldBOT
#

Hey @plush stratus!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

#

Hey @plush stratus!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

#

Hey @plush stratus!

Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:

• If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)

• If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:

https://paste.pythondiscord.com

iron galleon
#

...can you read what the message says?

somber path
#

hello

#

is this the place to ask for pygame help

#

?

iron galleon
#

yes, indeed

heavy sigil
#

gtg get ratio when zoom in

#

cuz the cube has to be formed with rectangles only

fluid lintel
#

who codes with panda3d

steel geyser
#

I do

near wedge
#

I also use Panda3D.

tall pewter
#

Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?

#

Or are they better?

lunar dawn
#

Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?
@tall pewter you mean live2d or love2d?

tall pewter
#

love2d

lunar dawn
#

Haven't heard of it

tall pewter
#

Well , it's in lua

#

Maybe that's why you never heard of it

lunar dawn
#

Im still a baby at python so...

tall pewter
#

Oh

stiff iron
#

wow dead chat

tranquil girder
#

lol, what?

tall pewter
#

Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?
Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?

severe saffron
#

are you attributing that quote to a mr or mrs 'Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?'

green sage
#

Hey guys! Very, very new to Python and I've heard that you should start working on projects as early as possible, so I'm trying to make a very simple text adventure game. Here's the relevant code:

help_command = """You can type commands such as 'take', 'push', 'look', etc. followed by the name of the object
or person you would like to interact with."""

has_flashlight = False

flashlight_get = "You take the flashlight. You can turn it on or off by saying 'flashlight on' or 'flashlight off'."

#this function will continue to be called until user gets flashlight
def room1_function1():
room1_prompt1 = input("""
What would you like to do? """)
if room1_prompt1 == "HELP":
return help_command
elif room1_prompt1 == "take flashlight":
return flashlight_get, not has_flashlight
else:
return "You can't do that."

#this code makes room1_function1 replay
while has_flashlight == False:
print(room1_function1())

Basically, the point of the room1_function1 function is that it replays until the user types in "take flashlight," at which point the has_flashlight variable is set to True and the code moves on to the next function. However, it seems that the code does not move onto the next function for some reason. I would think that after the user types in "take flashlight", it would stop replaying room1_function1 but it seems to keep replaying. Can anybody explain why this is? Thank you so much! Having a lot of fun so far.

severe saffron
#

you never set has_flashlight

#

not has_flashlight just returns whatever the opposite of has_flashlight is

#

so you return the text string, and True

#

also using functions here probably isn't the best idea

green sage
#

Ahhh okay. That makes sense and seems totally obvious now lol. Yeah I figured that using functions would be really clunky but I'm just messing around with my limited Python knowledge. What would you suggest for a better solution?

#

Thanks for your reply 🙂

dawn quiver
#

Any pygame devs

tall pewter
#

Well seems like no one knows love2d lol

tranquil girder
#

It's not Python. And there's a lot of questions about it further up

tall pewter
#

But for game dev , love2d is definately better than PyGame/Arcadde

#

Arcade*

tranquil girder
#

I'm confused. You keep asking the same question and answering it yourself

dawn quiver
#

Haha

merry echo
#

For game dev, Assembly definitely is better than all ya'll frameworks smh my head

merry echo
#

kidding aside, there has been a some nice games made in LÖVE 2D, like mari0 and Move or Die, and the language used, lua, is used quite a bit as a scripting language in games. Though I don't know much about the community on it. seems to be nice

fierce wraith
#

@tall pewter if you are serious about creating a game, i suggest looking into one of the opengl bindings for python. its quite a bit more complicated than something like arcade, but performance and options are endless!

#

if you just want to make 2d games, arcade and pygame will do the trick

tall pewter
#

but like

#

pygame has problems rotating images

#

And so much more

#

I am not a Game dev . But I worked with pygame for like 6 months and it has problems rotating images/rectangles

steel geyser
#

If you want to make a game with python, I recommend panda3d.

tall pewter
#

Not 3d games

#

2d

steel geyser
#

Oh ! Okay, no problem. In fact, you can build 2D games with panda3d (the game I made with it was 2D).

tall pewter
#

oh nice

halcyon girder
#

Hey! By working with rust some I became aware of the ECS (Entity Component System) and came to think I'd like to try and use it for some of my py games. However, due to the little control over memory we have in python, is it worth it in your opînion? Sure an ECS gives more than improved performance but it also isn't perfect, so what would by your point of view on this?

near wedge
#

In Python, you should be using ECS for the organization and not for performance. You don't have enough control in Python to get caching benefits from an ECS.

halcyon girder
#

In Python, you should be using ECS for the organization and not for performance.
I sontrgly agree with that!

near wedge
#

And I am not saying you "should" be using ECS, just if you're evaluating it, you should focus on the organizational benefits/promises.

frozen knoll
#

Arcade can rotate things just fine.

halcyon girder
#

wdym Paul?

dawn quiver
#

anyone made any games with something like django channels and websockets?

tall pewter
#

Arcade can rotate things just fine.
@frozen knoll I'll just stick with love2d . It's fun . But only for game making

dawn quiver
#

I'm thinking about learning OpenGL/Vulkan

near wedge
#

OpenGL is far easier to get started with if you're new to graphics programming.

olive parcel
#

Yeah, Vulkan is a nightmare to implement

dawn quiver
#

My belief is being cemented lol

#

Yeah OpenGL looks better

calm thistle
#

I don't see any point in using ECS in Python, but I think the PursuedPyBear and Kivent engines are both ECS-y

#

Hmm, looking at PursuedPyBear again it's definitely not an ECS, it has "Systems" but they don't act over components of entities

dawn quiver
#

this is a kinda game dev related question

#

im taking a prerecorded mit class on python rn (by that i mean its not an actual class its just recorded lectures)

#

and one of the assignments was to make a hangman game

#

and im trying to figure out how to make one of the functions

#

im trying to make the code output a list of underscores and letters to keep track of whats been guessed so far

#

and ive made a list of underscores

#

and im trying to figure out how to replace the underscores with the correct letters at the correct location

#

if anyone can help it would be greatly appreciated

sullen minnow
#

You can change the specific element by doing hangman_list[some_index] = "a"

dawn quiver
#

yeah but is there a way to referance an objects position in one list

#

and replace something at the same position in another list

sullen minnow
#

Can't you use the same index then? I'm not sure I understand the question.

dawn quiver
#

oh

#

sorry

#

i didnt give enough context

#

since its hangman

#

the word is random

#

so i dont know the index

sullen minnow
#

You might be able to use "hangman_word".index("a")

dawn quiver
#

could you do <list 1>[<list 2>.index(<an object>)] = <another object>

#

sorry i typed it wrong

sullen minnow
#

You could. Is the object a letter?

dawn quiver
#

yeah

sullen minnow
#

and the lists are words?

dawn quiver
#

broken up into strings of individual letters

sullen minnow
#

Hmm, not sure what the lists are here. One is the hangman word and the other is the list of chosen letters?

dawn quiver
#

one is the word

#

one is the guessed letters

#

and also the one with underscores

sullen minnow
#

and you want to return ["_", "_", "t"] ?

dawn quiver
#

if theyve guessed t

#

yeah

#

and its right

#

would

guess_output = []
    secret_word3 = secret_word
    secret_word3 = list(secret_word3)
    for x in secret_word3:
        guess_output.append(" _ ")
    for x in letters_guessed:
        if x in secret_word:
            letters_guessed[secret_word3.index(x)] = x

work

sullen minnow
#

Well, I would try it and see 🙂

dawn quiver
#

true true

#

thats probably what i should have done

sullen minnow
#

so you don't need secret_word3 since .index works on strings too

dawn quiver
#

oh

#

nice

#

thanks

#

so it doesnt give me an error

#

but it also doesnt give me the right output

#

so

sullen minnow
#

and [" _ "]*len(secret_word) would give you the list

dawn quiver
#

i gotta think it over

sullen minnow
#

Alright, good luck!

dawn quiver
#

thanks

sullen minnow
#

what are you trying to do in the last for loop?

dawn quiver
#

lengthy explanation

#

hold on

sullen minnow
#

Well, I would just check there and make sure you're doing what you actually want to do.

dawn quiver
#

so if the secret word is "apple", i want guess_output to print "_ _ _ _ _"

#

and when someone guesses a right letter (ie "l")

#

i want guess_output to update to "_ _ _ l _"

sullen minnow
#

Hmm, okay, so when do you update guess_output?

dawn quiver
#

thats what i thought the last for loop was doing

#

but

#

thats been proved wrong

#

so now im trying to figure out how to fix it

sullen minnow
#

I would reread that line 🙂

dawn quiver
#

yeah yeah

#

thanks

#

ive had an idea

#

i should use the debugger

#

thats built into the ide

violet vault
#

can anyone send me the link to a tutorial video for learning python from scratch

#

??

sullen minnow
#

!resources

frank fieldBOT
#
Resources

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

sullen minnow
#

@dawn quiver That's a good idea.

#

It's always a hassle for me personally though.

dawn quiver
#

mine is pretty nice

#

it keeps track of all the variables

#

and their values

#

in a big list

dawn quiver
#

ok

#

cool

#

so

#

i got it to spit out this

#
[' _ ', 'p', ' _ ', ' _ ', 'e']
None
#

i cant figure out where the none is coming from

#

i fixed it

#

nevermind

broken sequoia
#

hello, making a text based rpg.

#

how do I make enemy stats scale w player stats?

#

alright

#

def Event(text, action, action2 = None, action3 = None)

#

is it possible to use a event function something like this

#

where action gets executed?

#

using event internally

#

like

#

Event('You stumble upon a chest!', P1.gold += 2)

#

something like taht

#

because I want to setup a way to be able to trigger events

#

thats less messy

#

ig

#

out of curiousity though, how would I execute the action?

#

thats passed in as a parameter

broken sequoia
#

also, best way to do an exp system?

pliant dust
#

@broken sequoia it depends on what you want to have level up. If it’s just stats, have a variable for each stat assigned too a class for the character, one variable being exp. in the main loop, or after a battle depending on the game type, check for if the expierience has reached a certain point. If so, increase the stats by a fixed or random amount. That is one method you could use, and is more of an RPG system like Pokémon.

dawn quiver
#

@dawn quiver Tech with Tim just made a video on hangman's game I believe

vast snow
#

If anyone knows pygame, your presence in #help-chocolate would be greatly appreciated

winged tide
#

Hello, im trying to do a game , using pygame, and in the moviment part i have a problem, the moviments with a,d .. w,s is ok, but when i click two key, like w and d, it moves diagonally, and I just want movements for vertical and horizontal, im making trying to make a snake game... (im new at progaming)

dawn quiver
#

hello every one

#

who know a lot about pygame?

#

i need your help for my project

#

who can help me?

#

heeeeeeeeeeeeeeeeeeellllllllllllllllllllllllllllllllllllllllllllllllllllllllllllo?

pliant dust
#

@winged tide that can probably be solved by setting up if statements/elif statements. so that if one direction is already pressed, another cannot be pressed.

dawn quiver
#

I most make 3D game with pygame , who can help me?

pliant dust
#

@dawn quiver a lot of us can help, but specific questions will allow us to assist with what you need.

winged tide
#

@pliant dust oh thanks

strong belfry
#

hey guys!

#

how can I develop a game in Python?

#

like, some courses, or something

#

just asking 😄

#

anyone here?

near wedge
#

@dawn quiver PyGame is not well suited for 3D games.

frozen knoll
empty elk
#

wait pygame can render 3d?

#

wat

burnt stump
#

are there python tools made for 3D or are you just out of luck for that

frozen knoll
#

Panda3D, or just to OpenGL with like ModernGL or one of the other bindings.

burnt stump
#

interesting, not a dame developer myself, but always interesting to know what's out there

dawn quiver
#

hello guys

#

who can help me to make a complex game?

#

it must be with pygame

#

who know pygame lot

mint zenith
#

If you have a specific question about it, just ask

tranquil girder
#

You break the complex game into simple parts and go from there

empty elk
#

Anyone that knows pygame that can help?

craggy rain
#

I am having trouble creating a small square inside of Pygame. I was trying to use pygame.draw.rect but then says it takes no keyword arguments and idk why?

#

Heres my code

    for item in AsteroidsStartLocation:
      item[0] += 1
      pygame.draw.rect(screen, white, width=0)
#

wait

#

I probably need a location

empty elk
#

its not correct

#

you have to give x,y coordinates as tuple

craggy rain
#

in another part of my code I havef


AsteroidsStartLocation = []
for i in range(5):
  x = 700
  y = random.randrange(0,850)
  AsteroidsStartLocation.append( [x, y] )
``` does that count?
empty elk
#

I'm not sure, I have a similar problem

#

I have a function that should spawn an asteroid but I never see it, like it only renders it for 1 screen

craggy rain
#

Oh you might be rendering the black background ontop of it or not updating consistently

#

I have done that beforfe

#

You got pygame.display.flip() right? like at the end of your code?

empty elk
#

not this is at end of loop py pygame.display.update() clock.tick(60)

#

but its the same

craggy rain
#

I personally would try adding pygame.display.flip at the end just to try to see if it helps but idk

#

Update should basically do the same but

#

I have it at the end of my while true loop

empty elk
#

tried it but it didnt help

#

I can send you the code if you wanna take a look

craggy rain
#

I can look, im still learning myself but sure I will look

stiff iron
#

Hi there! I am trying to make a rotating coin sprite in pygame but I am having issues scaling it.

#
gold_coin = []

for image in range(30):
    gold_coin.append(pygame.image.load('Sprites/Gold/Gold_{}.png'.format(image + 1)).convert())

    pygame.transform.scale(gold_coin[image], (50, 50))```
#

i want it to be 50 x 50 but rn its like 200 x 200 or something

#

ping if you respond

merry echo
stiff iron
#

thank you

#

ohh yea since its a function it will return something so i can append what it returns back to coin

#

but instead of appending I can replace an existing index right?

#

oh it doesnt work I have tried this @merry echo ```python
for image in range(30):
gold_coin.append(pygame.image.load('Sprites/Gold/Gold_{}.png'.format(image + 1)).convert())

gold_coin[image] = pygame.transform.scale(gold_coin[image], (50, 50))```
merry echo
#
for image in range(30):

    coin_texture = pygame.image.load('Sprites/Gold/Gold_{}.png'.format(image + 1)).convert()
    pygame.transform.scale(coin_texture, (50, 50))

    gold_coin.append(coin_texture)
#

You don't need to append the loaded image, just the transformed one. It would look more like this

stiff iron
#

I have tried it and its still the same size

frozen knoll
#

If it is fixed, you might be better off saving it as a different size.

#

Then loading it that way. Your program won't have to spend the time resizing.

merry echo
#

@stiff iron Oh whoops append the transformed Surface instead like this

for image in range(30):

    coin_texture = pygame.image.load('Sprites/Gold/Gold_{}.png'.format(image + 1)).convert()
    gold_coin.append(pygame.transform.scale(coin_texture, (50, 50)))
pliant dust
#

@raven goblet I believe it is supposed to be pygame.QUIT, I don't remember though.

round sonnet
#

Yes is it pygame.QUIT

#

pygame.QUIT is an attribute which has the interger value of 256

#

and you are saying that if event.type(also == 256) == pygame.QUIT(256), then quit

#

all events in pygame have the .type attribute which is an interger

#

and instead of finding the interger you can use the attributes which pygame gives you to make it easier

cerulean bronze
#

hey guys, I'm looking to make a browser game / website using Python and WebSockets, I was wondering does anyone have a recommendation of a stack to use for this?

#

I have experience using Django, but it looks like then I'd have to go with a fairly complex library for sockets called Channels, so I'm thinking maybe I'll use flask or something else? and then do you guys have any advice for what library (if any) I should use for keeping track of game state? Basically I'm planning on making a 2d sidescroller game, so I'd mainly need to keep track of the position of players and in-game objects and update them each frame and send the new data to the player

storm bolt
#

Hello I am brand new to pygame haven't used it till now

#

How to start

#

Wnt to get started with 3d

frozen knoll
dawn quiver
#

hello

#

who can help me to make a game? (3D game with pygame )

#

(when you agree i explain you the game)

#

(please i need your help)

#

😭

#

I know but i can't do any thing! i just know python

#

@dawn quiver try to work on simple projects first if you're a beginner tbh

#

no i am not beginner(in python!), i learn python and i don't know about other programing languages!

#

python have any other lib for 3D GUI?

#

python have any other lib for 3D GUI?

dawn quiver
#

no one know ?!!!!!!!!!!!!!!!!!!!!!!11

mint zenith
#

That Stack overflow answer listed 2 libraries capable of 3D. Are they inadequate?

olive parcel
#

@dawn quiver Maybe you want to try Panda3D.

fierce wraith
#

hey @exotic fern how did you create the rays for your raytracer?

#

using trilinear interpolation or by calculating them some other way?
edit: figured it out!

merry echo
#

I believe there's only two 3D game libraries for Python, Ursina and Panda3D

fierce wraith
#

there are plenty of opengl, dx11, vulkan etc bindings though

merry echo
#

Yeah but that would be a bit lower level

#

Not sure if I'd recommend that for someone starting out

#

As for making a browser game, you could make the server side in Python, as for the client side, I believe there's no Python wrapper for the web Canvas API, so I'd recommend doing it in JavaScript instead, or another language that has a wrapper for Canvas, like C++

winged tide
#

Hello, im have a question, im trying to make an a snake game, im new at progaming, so i make some things, but in the "rule", when snake eat the apple, i dont have any ideia to make it more length when eat aple, is this difficult? some ideia?

#

(sorry for my english, im not good with it)

tropic lantern
#

by apple do you mean normal pellets or is the apple a special object that gives more length than consuming the pellet?

winged tide
#

its a rect, an the player(snake) is a rect too, and when they colid , (snake eat aplle) and gives more length

#

i want to do that

#

i can share my code, is this possible here?

merry echo
#

sure you can use

#

!paste

frank fieldBOT
#

Pasting large amounts of code

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

After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.

winged tide
#

oh one minute please

#

i go to send

merry echo
#

you could make your snake an array of rects

winged tide
merry echo
#

then move the last rectangle to the front, giving the illusion of the snake moving

winged tide
#

im watch an video, but its kind complicate to me, using list and append

stiff iron
#

@merry echo it didnt work, I guess I have to try to convert all of the images to a lower size

#

nvm it works thank you

fierce wraith
worn crow
#

is it a raytracer or a raycaster? 👀

fierce wraith
#

the one where you start at the camera and go into the scene @worn crow

#

i always confuse the two

#

after googling, i think raytracing is the correct name

#

i dont have secondary rays yet, but they are up next 🙂

dawn quiver
#

do you guys think you can make a gud game wit pythn??

#

im curious, im a begineer-ish

merry echo
#

Cool! What are you using to render the raytracing, shaders or per pixel using an image? Also what resources did you use to learn raytracing? would you recommend Ray Tracing in One Weekend ?

fierce wraith
#

@merry echo a compute shader, and ive read the raytracing in one weekend, but also his longer versions (also free)

#

i liked them

#

ive been playing around with raytracing for quite some time, so im acquainted with the math and techniques used but couldnt point to one all defining resource

#

just play with it i guess?

#

try stuff out

#

i started with a super slow cpu raytracer, just a 2d for loop in python

#

ofc it took 10 min to render a 1080p image but oh well ¯_(ツ)_/¯

craggy rain
#

How can I get the location of a pygame rect?

#

I to have it when I click a rect it just deletes

#

but idk how to track the postion of the rect

exotic fern
#

The beginnings of a raytracer 🙂
@fierce wraith looks nice!

#

very neat shading

severe saffron
#

i can't tell if there is shading or not

#

my brain says theres a bit of fresnel

dawn quiver
#

Quick question for ray marching

#

Are the formulas for the shape of the object you are marching to or from

#

I'm imagining it's the shape of the object you are marching to

#

But that seems to make it pretty complicated to have lots of different shapes

#

Nvm I think I'm kinda getting the concept

stiff iron
#

does anybody know an application that takes like a video and takes a picture of it every little bit or so, then later I can add it to pygame as a sprite animation?

#

its easy to make a spinning coin in blender and animate it to spin around, but taking pictures of every single part is tedious

#

Is there a way to take a video and have it converted to photos?

bleak spruce
#

Is it normal when the sprite image starts blinking in arcade.py?

#

I started learning arcade today

#

Which do you prefer? Pygame ou arcade?

dawn quiver
#

does anybody know an application that takes like a video and takes a picture of it every little bit or so, then later I can add it to pygame as a sprite animation?
@stiff iron Any video editing software and just export it as a sequence of images

fierce wraith
#

@exotic fern @severe saffron it just the r value set to the distance, makes for a cool effect, but not real shading

ionic oak
#

Is python really good for game development??

severe saffron
#

Not really good but it's very good for smallish projects and learning

quiet osprey
#

Hi is kotlin similar to python syntax

fervent rose
#

A little yeah

#

You might want to go to an off-topic channel for that

#

!offtopic

frank fieldBOT
winged tide
#

Hey how can i do to back a loop

#

like , when gameover , gameloop stop, and gameover loop start. and when game over loop stop, i give a condicional to game loop start

tropic lantern
#

put the loops in functions ig

winged tide
#

yes thanks

#

so i finish my game , how can i do to send my games to other people play?

near wedge
#

@winged tide PyInstaller is likely your best bet. However, the library you're using may have other tools available. I know Panda3D does, and I think Kivy also does.

dawn quiver
#

so like i went to pygame website
installed pygame and in vs code i tried this
import pygame
pygame.examples.aliens
but it says pygame has no attribute named examples

#

how do i fix this

violet vault
#

hi guys,
i know python, but want to learn pygame
can anyone give me any crash course tutorial orsomething like that?
pls ping me

dawn quiver
#

hi.guys

#

I am a full stack developer.

#

if you have any project, let's do it.

#

and then let's share the money

#

😄

#

and then we can get the more money.

tiny bison
#

@dawn quiver yes this is a great idea

#

join the voice channel in this server

frozen knoll
violet vault
#

okay

sullen swan
#

Hello

frozen knoll
bleak spruce
#

Can you guys help me on the concept of sprite animation in arcade?

#

I ve already made it move and change its direction

#

But i having trouble with the walking animation

#

I ll show you

#

it moves at last. Just couldn't figure out a way to animate the walking

frozen knoll
#

Wait, I'm a bit confused. If moves, but doesn't animate?

bleak spruce
#

yes

frozen knoll
#

Have you got code to do animation and it doesn't work, or you don't have code yet to do animation and need it?

bleak spruce
#

i need the code

#

i know there is something to do with rewriting the update_animation() function

frozen knoll
#

I'd suggest looking at this code:

bleak spruce
#

ok

#

tks

frozen knoll
#

Specifically the PlayerCharacter

#

You might not need jump or fall textures, which would simplify it a bit. Take a stab at it. Ping me if you get stuck.

bleak spruce
#

sure

bleak spruce
#

@frozen knoll it worked!

#

i just dont know how to show

#

but it worked

#

tks man

frozen knoll
#

Awesome!

dawn quiver
#

Wait a minute......
Can I combine Kivy With renpy???

#

@frozen knoll uhhh.... You made a game but how will you change it to .apk?

unique kernel
#

Guys I am new to pyhton can you tell me the best module for game devolpment

bleak spruce
#

I like arcade

#

But it requires OOP knowlegde

#

Try pygame

#

Theres a guy on youtube that makes good games with pygame

#

Hold on a second

frozen knoll
frozen knoll
#

If you want it as a sprite, just resize using my_sprite.scale.

#

If you only know the width in pixels, just use a bit of math to get there.

unique kernel
#

@bleak spruce @frozen knoll Thank you very much guys I will certainly try these out

#

OUR server is so good

frozen knoll
#

If you want to stretch, you'll need to manually set the hitbox. Stretching sprites makes things weird.

#

It leaves 'scale' in an bad state.

#

I've worked on this a while and haven't come to a conclusion on how I wanted to handle it.

#

Some docs:

frozen knoll
#

That is a possibility, but it would break all current code using the scale. And for the projects that don't want to break the aspect ratio, they'd have to juggle two numbers instead of one. There's always trade-offs.

#

Right now scale is done at a hardware-level. At some point I'll probably revisit it, but the risk of breaking backwards-compatibility and the risk of slowing the code with additional checks doesn't make it high on my list of things to do. Plus, I don't see many use cases where people want to stretch sprites.

#

Images are loaded into textures that are sent to the graphics card/GPU. A "shader" on the GPU does the scaling, positioning, and rotation. Older graphics, like Pygame 1.9x do this with the CPU instead via Python or C code.

#

This makes Arcade super-fast with sprite drawing, but means you need at least OpenGL 3.3.

tranquil girder
#

You should try ursina, @Yaduarjindia

dawn quiver
#

hey guys anyone up for a challenge? i made a script which generates a minesweeper grid and expands a starting area. and im so confident in it, i dare you guys to make something faster than mine. I outputed the time at the bottom, it gets larger for every larger grid. good luck >:))) https://repl.it/@CloudModMod/minesweeper#main.py

dawn quiver
#

long shot but does anyone know a pyglet discord server?

potent ice
wind smelt
#

hey got a question

#

i drew a rectangle with pygame and now i wnat to load an image on this rectangle. for some reason the picture is not being loaded above the rectangle if you know what i mean🙈

#

its like the rectangle is in front of the picture

#

how can i change that?

proper peak
#

are you drawing the rectangle after the picture, perhaps?

wind smelt
#

oh wow my mistake was so dumb that i didnt even notice😂

#

thanks tho

dawn quiver
#

@potent ice thanks

bleak spruce
#

Sorry

#

Two times

#

@frozen knoll this was the animation i was struggling with yesterday

#

Now its done

frozen knoll
#

Hey, good work!

dawn quiver
#

Hello guys! Im learning pygame, Can someone help me with pygame?

merry echo
#

he do be walkin tho

#

If you have any questions, you can ask them here, and if you want resources, I'd recommend DaFluffyPotato's tutorials on Youtube, and then you can check the pygame docs for other information too

jade owl
#

Ace of Spades for Solitaire that I'm coding with a buddy of mine using PyGame!

#

made this in gimp

#

probably will change the AKQJ symbols on the topleft and bottom right to be in line with the suit (width change)

#

numbers are a size of 25x6 pixels

#

I made the Ace and Jack symbols this size temporarily (hopefully anyway, only have the Spades folder as a WIP)

pliant dust
#

@jade owl it looks really good, are you just using the mouse to draw? I’ve been looking into using gimp but not sure how to set it up for pixel art.

bleak spruce
#

If you have any questions, you can ask them here, and if you want resources, I'd recommend DaFluffyPotato's tutorials on Youtube, and then you can check the pygame docs for other information too
@merry echo yeah, always read the docs!

fallow sorrel
#

whats the best library/ program for beginner dev?

frozen knoll
dawn quiver
#

Hey guys! Im working on a perlin noise function for a game I am working on, Its pretty slow does anyone have any ideas on how to speed this up?

#
def noise_perlin(seed, x, y, frequency):

    #Set get
    def get_noise(seed, current_range, x, y):
        seed += (x+y*1234)
        random_set_seed(seed)
        return (random_range(0, current_range))

    #Set range
    max_range = 100
    current_range = max_range/2

    #Noise
    noise = 0

    #Repeat
    while(frequency > 0):

        #Get indeces
        index_x = floor(x / frequency)
        index_y = floor(y / frequency)

        #Get pos in chunk
        tx = (x % frequency) / frequency
        ty = (y % frequency) / frequency

        #Get corners
        r_00 = get_noise(seed, current_range, index_x, index_y)
        r_10 = get_noise(seed, current_range, index_x+1, index_y)
        r_01 = get_noise(seed, current_range, index_x, index_y+1)
        r_11 = get_noise(seed, current_range, index_x+1, index_y+1)

        #Lerp corners
        r_0 = lerp(r_00, r_01, ty)
        r_1 = lerp(r_10, r_11, ty)

        #Add to noise
        noise += lerp(r_0, r_1, tx)

        #Alter frequency
        frequency = floor(frequency/2)
        current_range = floor(current_range/2)
        current_range = max(1, current_range)

    #Return 
    return noise/max_range
jade owl
#

@ancient ginkgo I am using the mouse but I use the pencil tool with lines. (Shift)

#

each suit symbol on the card template I have has “cores” marking the center, which I use to handle the placement of the symbols on the cards.

dawn quiver
#

Guys I need help with touchscreen input, is there any way to replace the KEYDOWN modules with something that works with touch? Because I made a game using the KEYDOWN partition on pc. But now I'm having difficulty porting the game to be compatible with a touchscreen device.

empty elk
#

did you look through the official docs ace?

#

I don't know if pygame supports touchscreen events

dawn quiver
#

did you look through the official docs ace?
@empty elk It does, it's the "MOUSEDOWN" and "MOUSEUP" modules working with the "MOUSEPOS" module

#

The problem is idk how to replace the "KEYDOWN" and "KEYUP" functions with the "MOUSEDOWN" and "MOUSEUP".

fierce wraith
#

@dawn quiver id suggest using the noise library, i think it has the noise functions implemented in c

dawn quiver
#

Hmm

#

Ok ill check to out @empty elk

empty elk
#
             rect.y = random.randrange(0, 479)
+        if event.type == pg.MOUSEBUTTONDOWN:
+            target_vec = pg.Vector2(event.pos)
+            direction_vec = target_vec - position_vec
+            direction_vec.normalize_ip()
dawn quiver
#

The vector is seemingly a bit complicated to me. But I'll see

tardy tangle
#

Can you guys help me with Photon 2?

craggy rain
#

How can I get the location of a pygame rect? I want to have it when the mouse is over it and you click it dissapears or does some action

jade owl
#

Like a button?

merry echo
oak juniper
#

Are there any good tutorials for an expandable inventory system?

tranquil girder
#

It's not really different from a non-expandable one. maybe you can just create a new one at a bigger size but keep the items? if that's what you meant that is

oak juniper
#

I want to have the ability to add custom items later either through random generation or manual entry

#

like having a function generate a +n item of effect and plop it in the list for next time

dawn quiver
#

can i ask a pygame question here?

near wedge
#

@dawn quiver Yes.

dawn quiver
#

ok

warm bloom
#

Is there a pygame event that supports holding down a key? (I tried KEYDOWN but it didnt work)

merry echo
#

you would use a boolean value, set it to true when the key is pressed, and false when it is released

warm bloom
#

ah ok

misty phoenix
#

pygame.key.get_pressed()

dawn quiver
#

is there any youtube series you would recommend to learn pygame easily?

frozen knoll
fickle wyvern
#

Hey guys. A pygame game is showing images on windows. But not on linux. Any reasons?

fervent rose
#

The paths aren't the same on Linux and windows, maybe that's why?

#

You shouldn't hardcode paths and use pathlib for them to keep it platform independent

#

!d pathlib

frank fieldBOT
#

New in version 3.4.

Source code: Lib/pathlib.py

This module offers classes representing filesystem paths with semantics appropriate for different operating systems. Path classes are divided between pure paths, which provide purely computational operations without I/O, and concrete paths, which inherit from pure paths but also provide I/O operations.

../_images/pathlib-inheritance.png If you’ve never used this module before or just aren’t sure which class is right for your task, Path is most likely what you need. It instantiates a concrete path for the platform the code is running on.

Pure paths are useful in some special cases; for example:... read more

fervent rose
#

Here is the pathlib documentation

dawn quiver
#

thanks guys

inner leaf
#

hello guys! I decided to start a non-comercial-just-for-fun-and-love side project.

My focus will be on a 2d turn-based game. I also want to make a lot of procedural generation (sprites overlaps or simply drawing on the screen) I think that pygame can handle it well, right? Or is there another project that I should check out before?

frozen knoll
#

I'll always suggest looking at Arcade as well.

soft oar
#

listen i'm new in python but the only way i know it to devloppe a game is pygame but i want a way to developp some 3d games so help me if u can ?

inner leaf
#

I'll always suggest looking at Arcade as well.
@frozen knoll Really interesting! I think i'm going to use that

dawn quiver
#

how to make an image full screen in pygame?

neon wedge
#

Game of Life Implemented in Python.

Problem is with the logic. There is something wrong with how cells are being updated and I can't figure it out.

def game_logic(display, buffer):
    for r in range(1, rows - 1):
        for c in range(1, columns - 1):
            total = 0
            total += display[r-1][c-1]
            total += display[r-1][c]
            total += display[r-1][c+1]

            total += display[r][c-1]
            total += display[r][c+1]

            total += display[r+1][c-1]
            total += display[r+1][c]
            total += display[r+1][c+1]


            if display[r][c] == 1:
                if total < 2:
                    buffer[r][c] = 0
                elif total == 2:
                    buffer[r][c] = 1
                elif total == 3:
                    buffer[r][c] = 1
                elif total > 3:
                    buffer[r][c] = 0
            elif display[r][c] == 0:
                if total == 3:
                    buffer[r][c] = 1

Display is the 2d grid that's displayed to screen. Buffer represents the memory buffer.

After this function call, there is an assignment where
Display = Buffer
To update the display

Link to full code: https://github.com/marcin-wojtkowski/game_of_life/blob/master/main.py

iron galleon
#

@neon wedge feel free to share in #303934982764625920. you'll probably get more attention there!

#

just make sure to add an open source license to your repository

lone crag
#

Can anyone help me resize a ListBox in tkinter using .grid ?

steel geyser
#

What do you want to do ?

dawn quiver
#

thanks

lone crag
#

@steel geyser I'm making a chat in python using tkinter. I am at the moment using Label to show messages but than if they are to much messages, it streches the window and it is anoying. I would like the messages to be displayed in a ListBox but messages are to big to be dysplayed so i would like to be able to resize them

steel geyser
#

@lone crag I suggest you to use a tkinter.Text object instead of the ListBox to display your message.

lone crag
#

how ?

#

TextBox ?

#

How can i setup a scrollbar on a TextBox ?

steel geyser
lone crag
#

I already was on this post lol 🤣

#

well scrollbar doesn't seem to work

steel geyser
#

Wait, I had done this before. Let me try to find that code.

#
self.scroll = Scrollbar(self)
self.scroll.grid(row=0, column=0, sticky="ns")

self.text = Text(self, yscrollcommand=self.scroll.set)
self.text.grid(row=0, column=0)

self.scroll.config(command=self.text.yview)
#

Here ! This should work.

#

@lone crag With this, you can scroll on a Text object.

#

If this is to display the text in a chat application, I suggest to set "disabled" state on the Text object so that the user can't modify the text that is displayed.

#

You will have to switch the state to "normal" again each time you want to modify it (even when modified from code).

lone crag
#

@steel geyser Each time I send a message, it sends me all the way up to the first message. Any idea of how to fix that ?

steel geyser
#

You mean, it scrolls up ?

#

When you add text to the tkinter.text object ?

#

You should be able to use set method of the Scrollbar to set it to the bottom.

jaunty terrace
#

can we develop a game with python

frozen knoll
#

Yes.

#

There are other libraries too. There's also Pygame, Pyglet, Kivy, and more.

grave lodge
vast marten
#

the get_rect() basically only returns the size of a surface; to check if you are pressing it, you need to create a new rect that has the topleft coordinates and width and height

#

so for example the rect should be: HIT_IMG_rect = pygame.Rect(WIDTH - HIT_IMG.get_width() - 50, HEIGHT - HIT_IMG.get_height() - 50, HIT_IMG.get_width(), HIT-IMG.get_height) and then you check the collison on this rect: if HIT_IMG_rect.collidepoint(mouse): ...

grave lodge
#

Thank you ! i will try that out

lone crag
#

Anyone knows how to put automatically a text in an entry to make a auto-register systeme ?

vast marten
lone crag
#

ok 🙂

dawn quiver
#

Who want to work on game with me

warm bloom
#

So uh when making a game in Pygame, do most people use the draw function or should I use a sprite to create a character?

#

Im a pretty new developer to python so sorry of it's a bad question... I try though!

dawn quiver
humble siren
#

@warm bloom sprites will be much easier to use

warm bloom
#

ok

torn heath
#

@dawn quiver where is the output there is only the code

#

or have u not comleted yet

dawn quiver
#

@torn heath hello how to do that?

dawn quiver
#

done

frozen knoll
solemn kernel
#

sorry if this question has been asked before, but, is there any good resource on how to make a chess game and teach the AI to play good?

#

meaning, I want to teach the AI from scratch all by myself

cursive pumice
#

Hello. Does anyone know how to embed tkinter or wxpython in pygame? I'm not sure is it possible or not. The pygame window will be for an emulator and the tkinter/wxpython panel will display the dissassemler output.

dawn quiver
warm bloom
#

Is Tkinter able to be used in Pygame? (like for making buttons and textboxes)

humble siren
#

I don't think it can be used in the actual game

#

but you can make another window

dawn quiver
#

Is this an extremely common issue with arcade?

SoLoud dynamic link library /home/shaen/PycharmProjects/arcadetest/venv/lib/python3.8/site-packages/arcade/soloud/libsoloud.so not found. /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by /home/shaen/PycharmProjects/arcadetest/venv/lib/python3.8/site-packages/arcade/soloud/libsoloud.so)
Warning, can't initialize soloud name 'soloud_dll' is not defined. Sound support will be limited.
frozen knoll
#

It is in Linux.

dawn quiver
#

Right

frozen knoll
#

Requires GLib 2.29. So usually happens on somewhat older images. Maybe Long Term Support images.

#

You can still run Arcade, just no sound support.

#

But Pyglet will work if you use their libraries.

dawn quiver
#

I tried this ... is the issue that it doesnt exist or that its not in my sources?

#

i see that it requires an update beyond what is available

frozen knoll
#

Looks like you have 2.27.

#

I think I had to use Ubuntu 19

#

Or greater.

#

Ubuntu 18 LTS doesn't work.

dawn quiver
#

that is what someone on Reddit said. Its possible I will just move this project to a Windows machine. That being said, a lot of my friends will use Linux so maybe I would prefer to figure it out.

#
$ lsb_release -a
No LSB modules are available.
Distributor ID: neon
Description:    KDE neon User Edition 5.19
Release:        18.04
Codename:       bionic

I regret installing KDE neon instead of Ubuntu + plasma sometimes lol

#

Thanks

frozen knoll
#

Cross-platform sound on Python has been a serious hassle for me to figure out. Sorry you ran into that.

dawn quiver
#

If it works on Ubuntu 19 that is better than nothing.

potent ice
#

FYI: Arcade 2.4 beta 1 is released : pip install arcade==2.4b1

fervent rose
#

\o/

potent ice
#

Was 13 alpha releases before this one, so it has been quite a long journey finally getting to beta 😄

sonic forge
#

How can I make a sprite rotate in Pygame? I'm trying to make a game but all of the things I've tried have failed...

dawn quiver
#

I need an advice from someone more expert than me, i need a DEAD simple 3d framework. Can you give me some names from your experience?

pearl mango
#

What are your needs?

dawn quiver
#

What are your needs?
@pearl mango I want to create a 3d visualization of a file format.

pearl mango
#

Hmm, interesting. What format is it?

solar spire
#

plotly is alright

dawn quiver
#

Hmm, interesting. What format is it?
@pearl mango .class java file

pearl mango
#

If it's not too intensive, matplotlib or as @solar spire says plotly might be of use

#

...ah, that's new to me

dawn quiver
#

...ah, that's new to me
@pearl mango I like to do crazy stuff

solar spire
#

yeah, matplotlib is good, plotly gives you interactive 3D plots though, it's quite nice

pearl mango
#

what specifically is 3D in the .class? a defined object?

dawn quiver
#

what specifically is 3D in the .class? a defined object?
@pearl mango I'd like to represent it as whole. Then you can "dissect it" going deeper and deeper

#

yeah, matplotlib is good, plotly gives you interactive 3D plots though, it's quite nice
@solar spire Okay, i'll check that

pearl mango
#

that's a little abstract @dawn quiver

#

would you know what coordinates you are plotting?

#

or do you want something that "creates" a set of coordinates defining the shapes that are being plotted?

#

the former is easy, the latter might take a lot of artistic work tbh

dawn quiver
#

that's a little abstract @dawn quiver
@pearl mango Yes, i know
would you know what coordinates you are plotting?
@pearl mango Not really, i have to define a visualization (figure out how to represent it, yes it's artistic
the former is easy, the latter might take a lot of artistic work tbh
@pearl mango 100% agree with you

#

Thanks everyone

pearl mango
#

ahh, I see now

#

do you mean like windirstat-kinda visualisation?

#

how many lines of code are taken up by certain functions, or somesuch?

dawn quiver
#

how many lines of code are taken up by certain functions, or somesuch?
@pearl mango Yes 😄

pearl mango
#

nice one! try seeing how tools like that function. some of that ilk use logarithmic sizing to better represent things

near wedge
#

@dawn quiver It is more game focused, but you might want to take a look at Ursina Engine (https://www.ursinaengine.org/) if you need something not easily represented by graphs/plots.

pearl mango
#

especially if you have many small helper functions

dawn quiver
#

@dawn quiver It is more game focused, but you might want to take a look at Ursina Engine (https://www.ursinaengine.org/) if you need something not easily represented by graphs/plots.
@near wedge Nice, appreciated your suggestion, i'll look at it too

near wedge
dawn quiver
#

Thanks again everyone

fierce wraith
#

Congrats @potent ice and @frozen knoll !! Awesome release

frozen knoll
#

Thanks! Still beta, but getting so close!

marsh atlas
#

@lime finch ask here

lime finch
#

can anybody tell moi how to make animation with spritesheet/gif?

gloomy ingot
#

Frameworks have their different ways of doing it

#

An example Pyglet has certain functions that load gifs and allow animations with it

#

As well sprite sheets

lime finch
#

in normal pygame in pycharm?

gloomy ingot
#

Depends on the engine

lime finch
#

hmm

gloomy ingot
#

Really pycharm is an IDE

lime finch
#

yeah sorry

gloomy ingot
#

I could do the same on IDLE or VSC, it wouldn't affect

lime finch
#

yrah

gloomy ingot
#

Either ways you should check the documentation on loading gifs / sprite sheets for pygame

#

I'm not into pygame, as I'm more of a Pyglet user

lime finch
#

oh okay

#

thanks for the tips

gloomy ingot
#

You're welcome! 😀

marsh atlas
#

Actually this guy is shy and didnt understand what you said

#

please explain with examples

gloomy ingot
#

Oh, sure

#

Sorry for the misunderstanding

lime finch
#

-_-

#

Actually this guy is shy and didnt understand what you said
@marsh atlas i understand wut pyglet and stuff is

frozen knoll
#

This tutorial has an example of animating a character at the end:

lime finch
#

thanls

#

thanks

frozen knoll
#

...but with the Arcade framework.

lime finch
#

oh

gloomy ingot
#

I found a video

lime finch
#

yeah?

gloomy ingot
lime finch
#

oh

#

thanks

marsh atlas
#

@gloomy ingot Thanks for your valuable time it was very helpful.

gloomy ingot
#

👍👍👍

dawn quiver
#

Another way to use sprite sheets is to make a function that utilizes pygame's Surface.subsurface

#

you could have a dictionary that has the action (as the key) and the images in a list (as the value).

main crown
#

oops

#

my bad

dry jacinth
#

I thinks it's all bcz of file location @main crown

main crown
#

ok

#

does windows matter

#

@dry jacinth

dry jacinth
#

Windows means what?

main crown
#

nvm

#

also

#

@dry jacinth it opens for half a second and closes

dry jacinth
#

It's a attribute error

main crown
#

how do i fix that

#

@dry jacinth

dry jacinth
#

Ohh

#

I get it

#

Dude

#

Change your file name

main crown
#

i did

dry jacinth
#

U can't import pygame when your file name was pygame.py

main crown
#

like before

dry jacinth
#

Is it working now?

main crown
#

nope

#

@dry jacinth it opens for half a second and closes
@main crown

dry jacinth
#

Check line 4

main crown
#

i did

dry jacinth
#

So what u want to display?

#

Do more coding

main crown
#

ok

#

yeah

#

ill try that

#

i should really be working on my auto mod for discord bots

#

but ok

gloomy ingot
#

Hello

#

Anybody here knows some pyglet?

round obsidian
#

Ping

#

er, @gloomy ingot

gloomy ingot
#

So

#

This is the issue

#

I'm looking for certain help on updating the position of a sprite

#

I have these two variables; self.bomb_x and self.bomb_y

#

Basically if the main player shoots another player, these two variables are supposed to start going up by 10 every one 30th of a second

#

So far so good, but really, it doesn't update its movement on screen, it updates internally

round obsidian
#

ok, how are you changing the sprite position, exactly?

gloomy ingot
#

(I'm debugging so that it checks the current position of this bomb sprite)

#

ok, how are you changing the sprite position, exactly?
@round obsidian by calling the update function

round obsidian
#

and you're supplying new coordinates to the update function?

gloomy ingot
#

Once the player fired it should start moving, and the sprite bomb x and y is set to those two variables, which update in that same method

#

Should I send some code?

round obsidian
#

yes, go ahead

#

(be slow for a few)

gloomy ingot
#

Alright, hold on as I am a little busy atm

gloomy ingot
#

Sorry for taking so long

#

Here it is

round obsidian
#

Is self.bombSpr the bomb sprite?

#

@gloomy ingot

gloomy ingot
#

yes, it is

round obsidian
#

ok, because I don't see anywhere in this code where you actually set its x and y properties

gloomy ingot
#

hmmm... maybe I didn't copy enough code

round obsidian
#

make sure you set self.bombSpr.x and self.bombSpr.y to modify its position.

gloomy ingot
#
def __init__(self):

        # Firing system
        self.fired = False
        self.who_firedBomb = 0
        self.bomb_x = -10
        self.bomb_y = -10
round obsidian
#

nope, you're modifying self.bomb_x, not self.bombSpr.x

gloomy ingot
#

oooooh

#

I'll check that out and update you on the topic

#

oh hey! It works!

#

silly mistake of mine...

#

thank you!

round obsidian
#

YW!

fiery lily
#

Is this a good place to ask for help with my Tetris bot?

native nebula
#

it says "invalid destination" for blit

#

i am using a part of a list and a normal variable to blit an image

#

what can i do?

calm thistle
#

I've just released a new version of the Wasabi2D, engine with support for tile maps and groups of objects. More info here:

#303934982764625920 message

hasty aspen
#

i have a basic gui built with tkinter and i want to access it in games like csgo, like how you would access the discord overlay. im using windows. more info- the gui has a mp3 player speech to text ability to open apps search(it will give you info in the gui) has weather and a clock

Thanks in advanced 🙂

green thunder
#

Appears you have to hook in directly into games (or that's how Steam does it) via Direct3D or OpenGL

limpid patrol
#

can sm one give me a good yt video on python game dev?

hasty aspen
#

@limpid patrol its a good starting point

limpid patrol
#

@hasty aspen ty

near wedge
limpid patrol
#

ok no more but ty

frozen knoll
raven grail
#

what's the best library to make Pixel art Games?

frozen knoll
#

Lots to choose from that are good. I'd suggest looking at Arcade, Pygame, Pyglet, Kivy, and maybe more. Look at the examples, docs, etc.

raven grail
#

@frozen knoll thanks for your suggestions

trail escarp
#

how Can I use pyinstall ( or if you know of anything else) to make my pygame into an executable that people can download. My issue is that my script needs multiple other files like the background images and the audio files, but they dont get incorporated into the exe by pyinstaller and the game doesnt work for that reason

#

ping me if you can help

hasty aspen
#

@green thunder thanks man, looks like its going to be crazy but hopefully ill get it done

green thunder
#

@green thunder thanks man, looks like its going to be crazy but hopefully ill get it done
@hasty aspen I don’t envy you 😝 good luck!

still jungle
#

@trail escarp I'm pretty sure, when you type the pyinstaller command into the command prompt or whatever you are using, you can add the flag "--onefile" to make it all in one file. So like this: "pyinstaller Game.py --onefile" I also suggest adding --noconsole for graphical games, but that's up to you.

#

I personally never used it because I just had a whole folder that was zipped, so I'm unsure of exactly how well it works, but I know it's a feature

trail escarp
#

it puts the exe into one folder but it doesnt encorporate the external files @still jungle

near wedge
#

@trail escarp PyInstaller does not know of those external files by default, but there may be some way to tell PyInstaller some extra files to pack.

silk marsh
#

anyone know why i cant see my turtle?

trail escarp
#

@near wedge yeah I tried but it still wasnt working

proper peak
#

Is it a good idea to use the in-development Pygame 2?

stuck shadow
#

pygame.display.update()

#

pygame.display.flip()

#

wats the difference

humble siren
#

nothing if you pass no arguments

raw shadow
#

this channel is just questions on questions

dawn quiver
#

@trail escarp I'm pretty sure, when you type the pyinstaller command into the command prompt or whatever you are using, you can add the flag "--onefile" to make it all in one file. So like this: "pyinstaller Game.py --onefile" I also suggest adding --noconsole for graphical games, but that's up to you.
@still jungle are you one of those tooo beeee toooo teaaaa developers

still jungle
#

What? No. I play 2b2t and develop games on my own...

#

Am I not allowed to do both...?

dawn quiver
#

oh i thot u wurked for housemustard

still jungle
#

Right...

dawn quiver
#

its a joke sorry :/

#

i do both too

still jungle
#

Oh

#

My bad

#

The way you said it sounded really weird, but now that you point out that it was supposed to be a joke I suppose that makes sense

#

I guess I have a different type of humor :P

#

Neat, I actually thought I was one of the only ones who did both because most 2b players would use their programming knowledge to create hacked clients that would probably be backdoored or something

dawn quiver
#

oh sorry, i do a lot in other langs but just opened up my first py project and have since written my first py game in like 4 years, and am working on learning discord.py to try and make a bot

foggy python
#
class CubicBezier():
    def __init__(self, *points):
        points = list(points)
        if len(points) not in [2, 4]:
            raise Exception('InvalidArgumentCountError')
        if len(points) == 2:
            points = [[0, 0]] + points + [[1, 1]]
        self.points = points

    def calculate(self, t):
        x = (1 - t) ** 3 * self.points[0][0] + 3 * t * (1 - t) ** 2 * self.points[1][0] + 3 * t ** 2 * (1 - t) * self.points[2][0] + t ** 3 * self.points[3][0]
        y = (1 - t) ** 3 * self.points[0][1] + 3 * t * (1 - t) ** 2 * self.points[1][1] + 3 * t ** 2 * (1 - t) * self.points[2][1] + t ** 3 * self.points[3][1]
        return [x,y]

    def calculate_x(self, t):
        return self.calculate(t)[0]
green kelp
#

anyone that can help me with a few basics in pygame?

#

i just started using it but have run into some trouble

#

dm me if u can

fierce wraith
#

nice @foggy python

twilit shuttle
#

Lol, How do I make a Ubisoft-like game in Only 2 mins?

#

With as less codes as possible

#

I wanna make games but dont know anything

#

I mean I know the basics lemon_smug

solar spire
#

Ubisoft-like game in only 2 minutes? there is only one way

#
  1. download ubisoft game
  2. select the .exe
  3. rename it
#

done! you've stolen created an ubisoft-like game in only 2 minutes!

#

the truth is, game dev is slow

#

and takes a lot of time

proper peak
#

make a program that shows a black fullscreen for a few seconds and crashes, compile to exe with pyinstaller

solar spire
#

if I had to rate making games versus making web apps, making games is actually slower

proper peak
#

it will mimic quite a few games, not just Ubisoft ones even.

solar spire
#

ooh, burn

fervent rose
#
Medium

Learn how to process credit card payments in minutes!

In this Django project we teach you how to add stripe payments to your project. In the previous video we showed you how to build a shopping cart so make sure you've watched that before this tutorial: https://youtu.be/vccUP3jdpBg.

https://learn.justdjango.com
☝ Get exclusive c...

▶ Play video
dawn quiver
#

Does anyone know why in this code snippet, the x (and y) value is updated before the index is found?

trail escarp
#

@dawn quiver I found a stackoverflow which I followed in which I had to use some weird function in my script to import all my files then edit the .spec file to add my data and run it, and after that it finally worked for me. But then when I sent the file to my friend to download, it would not run for him on his pc and it gave the error that it could not load in the data.

potent ice
proper tendon
#

Hi, I asked this in the main channel but figured you guys may know

#

I am doing some data processing which will eventually end up in UE4, But I need to preview the data in a 3D Viewer inside the notebook

#

Is there any library which can do that

#

Specifically, I need to visualize point clouds (from numpy arrays) and polygon data (from shapely.polygon objects)

potent ice
proper tendon
#

well, I need something which can quickly render in a notebook window, I dont need to create a sperate renderer

#

but thanks, Ill look into this later

potent ice
#

You can render headless and dump out a texture

proper tendon
#

do you know if there is a vulkan wrapper for python?

#

I want to try using the new shaders

#

mesh shaders

#

what in looking for is some kind of libary which instantiates a renderer inside the python notebook

#

so I can just send some lib.draw(polydata) and it passess it in as an object to the scene

#

and it has tools like navigation control, wireframe/shaded views etc

potent ice
#

looks like webgl

proper tendon
#

yeah

#

pretty sure most of them use webgl/three.js

#

this one too

#

ideally, something which could create a vulkan window inline, lol kinda asking a lot there though

#

something which sets up and instantiates a vulkan preview window with some navigation controls

potent ice
#

vulkan window inline running in the brower client side?

proper tendon
#

in a jupyter notebook

#

I am doing datascience processing and I need to preview the datasets in 3d

#

actually, I need to write some mesh shaders, and preview the results in the notebook, because that's where I have the parameters which need to be sent to the shader/gpu

potent ice
#

Can just use gl 3.3 for that. Don't need vulkan

proper tendon
#

does gl3.3 have the new meshlet/mesh shader pipeline?

#

I dont know the status of the open source implementation

#

I know nvidia made it for dx12, and then there was a vulkan port

potent ice
#

Get a time machine and move to 2025 or something 🙂

proper tendon
#

uh

#

why is it called json?

potent ice
#
ctx.run([
    {
        'type': 'create_instance',
        'id': 'instance',
        'application': {
            'application_name': 'Application',
            'application_version': '1.0.0',
            'engine_name': 'Engine',
            'engine_version': '1.0.0',
            'api_version': '1.0.0',
        },
        'layers': [
            'VK_LAYER_KHRONOS_validation'
        ],
        'extensions': [
            'VK_EXT_debug_utils',
        ]
    },
    {
        'type': 'select_instance',
        'instance': 'instance',
    }
])
proper tendon
#

oh

potent ice
#

dump in your setup as dict/json etc..

proper tendon
#

interesting

potent ice
#

Greatly simplifies the setup

proper tendon
#

I know this sounds lazy, but I really enjoy using notebooks, helps me work through my code a lot easier

#

for example, if I could just have a vulkan instance running and windowed in a notebook, and then send commands into it via notebook, such as draw commands/shader programs, that would be ideal

potent ice
#

Probably some ctypes wrapper out there if you really want to go that route. I think even python glfw are playing with som vulkan stuff now

#

It's hard enough to get people into gl 3.3 core, so vulkan is even more out of reach for most people 😄

proper tendon
#

what is GL3.3? Isn't that a pretty old version of OpenGL?

#

afaik they are focusing their efforts on vulkan for new features, right?

potent ice
#

3.3 core is still pretty powerful. It kind of matured around 2012

proper tendon
#

yeah, I am sure it's still pretty good for most things, unfortunately I need to use the new mesh shader pipeline

#

seems like they are available in OpenGL now

potent ice
#

Geo shader + tessellation I guess is the equivalent

#

You can do that with moderngl

proper tendon
#

well

#

I think the mesh shader is more like a compute shader

#

not sure though

potent ice
#

Yup. they are more like compute shader

proper tendon
#

I saw the new UE5 demo is running on a PS5

#

it has "nanite" technology, which lets you load huge meshes into GPU memory and only render the triangles which are on screen

#

they didnt specifically say which graphics API it was using, but as its on PS5 it's not DX12, And think they need to use vulkan for lower-level hw integration

#

so yeha, I need to start using the vulkan pipeline for generating geometry on the GPU and then referencing that memory in the shader program

#

found this, which is a pretty simple mesh viewer, but it uses webGL and only lets you send triangles/points into a scene, wont let you write new shaders

potent ice
#

That's one of the nice things with vulkan I guess. In gl you often end up sending too many primitives to the assembly stage and things slow down. So much more control with vulkan

#

Easy to see in opengl when you cull 2d sprites with geo shader. Speed boost is significant.

proper tendon
#

yeah, it splits the mesh up into batches and does depth/occlusion testing early

potent ice
#

order independent transparency etc etc..

proper tendon
#

oh, one other question

#

do you know any libs which can generate meshes from arrays

#

I have some data like "shapefile polygon" I want to send it into a function and it returns an OBJ file

#

and I can do stuff like shell/extrude the face

#

I mean, I know blender has those mesh transformation functions written in C, But I dont think there is some way to use them in Python

potent ice
#

I've mainly used trimesh, but I don't need anything fancy

proper tendon
#

yeah, I have data in the form of Shapely Polygon objects, So I should probably use TriMesh

potent ice
#
  • trimesh is easy install...
proper tendon
#

it uses WebGL, Right?

#

``If called from inside a jupyter notebook, mesh.show() displays an in-line preview using three.js to display the mesh or scene. For more complete rendering (PBR, better lighting, shaders, better off-screen support, etc) pyrender is designed to interoperate with trimesh objects.

`` oh

potent ice
#

nice

proper tendon
#

yeah it was pretty easy to setup, but the notebook viewer isnt as functional as the standalone I guess

#

if I convert the notebook to a py file, it will launch the viewer via pyglet and more functions work

shadow ruin
#

@proper tendon u have any running project now

#

i want to join u to further improve my skill since it look like u working on colab , if im not wroing

proper tendon
#

sorry, this is work related

past jungle
#

Hello. I'm trying to make a small text based RPG played in the console window using Python and i need help figuring out how to handle an input not being given an acceptable response and jumping back to have the player give a new input, if that makes sense...

proper tendon
#

you probably want to make a switch/case statement

#

you would need to check if the input exists in the dict, if it does, get it and return it, if not, then return and error and take a new input\

#
b ={
    'a' : 122,
    'b' : 123,
    'c' : 124,
    'd' : 125
}


def getinput():
    # take user input
    inp = input('input a character : ')
    print('The result for inp is : ', b.get(inp, -1))

def tryagain():
    print('key doesnt exist! try again')
    getinput()
    
getinput()
#

something like that?

past jungle
#

I'm not quite sure if i get it... I currently have the player choose 1 or 2 depending on where they wanted to go. So i'd make a dictionary, then check if the input matches a value in that, and if it doesn't then try again?

proper tendon
#

oh, that code doesnt work, sec

#

yeah, the general idea is you have a bunch of cases, and the it switches to whichever case you chose. if you chose an invalid case, it asks you to input again until you choose one which exists

past jungle
#

lemme see if i can't get it to do what i want...

proper tendon
#

you cal also use if, elif, else

#
if switchvar == value1: 
   ... 
elif switchvar==value2:
   ... 
elif # as many more as you need

else: #default
   ... 
#

apparently that is not very optimal though

#

its better to use switch, but python doesnt have switch, so you have to make one

idle mesa
#

im very very new to python and am currently struggling with a qns is anyone able to help me with it

dawn quiver
#

@proper tendon you can just use dicts for that

#

Where each key references a function, that way you can call them by key which is much more effective than running through an if elseif tree.

#

Or you design your tree as a search tree, but that makes your code look weird

#

The elseif tree I'm talking about

rocky heath
#

@stone hatch Ayo fam where that repo

stone hatch
#

@rocky heath workin on it fam trying to relearn some class stuff

rocky heath
#

All good, just let me know if I can help

stone hatch
#

will do

frozen knoll
#

Arcade 2.4 has been released.

#

Lots of new stuff.