#game-development
1 messages · Page 59 of 1
hi, i'm doing a console text game for a GameJam
@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
@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
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
@silent flower You need to run your networking on a thread, or use asyncio and turn your game loop into a coroutine
i found that socket.settimeout() does the trick
i may rewrite the code to be asynchronous some day though
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
😅
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
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?
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
Thats basically what I did but it doesnt work for some reason
Should I post my code for you @dreamy swan
I can’t look rn, but it was just an idea
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
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?
tell me who is making a game in python, you guys are insane i would rather use even haskell
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
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?
@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)
In a simple space invaders type game, how would I change my ship sprite to an explosion sprite when hit by an alien?
What library are you using?
pygame
Ah, my examples are all Arcade. Someone else might have some sample code.
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")
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")
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}")
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?
@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?
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}")
How does that even know that rocks better than scissors or anything like that?
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
oh I see how that could work, wouldnt you have to have a really long list of that return 1 list though
or no
Not sure what you mean
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
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.
@fervent rose that might be a good way to do it! Thx
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?
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
hi we are making a server with Indian teen coders if u meet the condition dm me
Heya, I'm trying to make caustics using noise (simplex, cellular, etc. ) with glsl shaders. Does anyone have resources for doing this?
There's a shadertoy that does this but I don't know what noise they're using. It's called BCC noise but I haven't found any info about it
https://www.shadertoy.com/view/wlc3zr
Then there's this article but it uses a program. https://docs.arnoldrenderer.com/pages/viewpage.action?pageId=76808726
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?
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
What is the snippet you are copying?
found this interesting youtuber, makes games soundtracks - thought some people might like it https://www.youtube.com/channel/UCL-D7jMqIW58tnTgB9ku2Pg
btw apparently they licensed everything under creative commons :).
how to calculate the time
like to make a daily reward without using lots
of threads??
you could use something like sched and call its run function in your game loop
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?
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?
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
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
ooh thats interesting! thx
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()```
update on the game
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
@upbeat plinth Amazing game! The sounds are so chill and good.
Thx bruv
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:
@everyone If anyone is working on a game and needs music I would love to participate (:
@dawn quiver where can I listen to your music?
Have any of you guys used this https://godotengine.org/ ? It's not python, but it looks like it might be powerful and the license on it is probably the most interesting part.
It's pretty good
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:
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
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.
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
I made sth like dis... (please ignore the flickering idk why it exists in the first place)
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()
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
Can someone help me with this?
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:
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:
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:
...can you read what the message says?
yes, indeed
who codes with panda3d
I do
I also use Panda3D.
Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?
Or are they better?
Btw guys I've heard about "love2d" . Is it better than PyGame/Arcade/Pyglet for game dev?
@tall pewter you mean live2d or love2d?
love2d
Haven't heard of it
Im still a baby at python so...
Oh
wow dead chat
lol, what?
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?
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?'
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.
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
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 🙂
Any pygame devs
Well seems like no one knows love2d lol
It's not Python. And there's a lot of questions about it further up
I'm confused. You keep asking the same question and answering it yourself
Haha
For game dev, Assembly definitely is better than all ya'll frameworks smh my head
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
@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
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
If you want to make a game with python, I recommend panda3d.
Oh ! Okay, no problem. In fact, you can build 2D games with panda3d (the game I made with it was 2D).
oh nice
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?
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.
In Python, you should be using ECS for the organization and not for performance.
I sontrgly agree with that!
And I am not saying you "should" be using ECS, just if you're evaluating it, you should focus on the organizational benefits/promises.
Arcade can rotate things just fine.
wdym Paul?
anyone made any games with something like django channels and websockets?
Arcade can rotate things just fine.
@frozen knoll I'll just stick with love2d . It's fun . But only for game making
I'm thinking about learning OpenGL/Vulkan
OpenGL is far easier to get started with if you're new to graphics programming.
Yeah, Vulkan is a nightmare to implement
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
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
You can change the specific element by doing hangman_list[some_index] = "a"
yeah but is there a way to referance an objects position in one list
and replace something at the same position in another list
Can't you use the same index then? I'm not sure I understand the question.
oh
sorry
i didnt give enough context
since its hangman
the word is random
so i dont know the index
You might be able to use "hangman_word".index("a")
could you do <list 1>[<list 2>.index(<an object>)] = <another object>
sorry i typed it wrong
You could. Is the object a letter?
yeah
and the lists are words?
broken up into strings of individual letters
Hmm, not sure what the lists are here. One is the hangman word and the other is the list of chosen letters?
and you want to return ["_", "_", "t"] ?
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
Well, I would try it and see 🙂
so you don't need secret_word3 since .index works on strings too
oh
nice
thanks
so it doesnt give me an error
but it also doesnt give me the right output
so
and [" _ "]*len(secret_word) would give you the list
i gotta think it over
Alright, good luck!
thanks
what are you trying to do in the last for loop?
Well, I would just check there and make sure you're doing what you actually want to do.
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 _"
Hmm, okay, so when do you update guess_output?
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
I would reread that line 🙂
yeah yeah
thanks
ive had an idea
i should use the debugger
thats built into the ide
can anyone send me the link to a tutorial video for learning python from scratch
??
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
mine is pretty nice
it keeps track of all the variables
and their values
in a big list
ok
cool
so
i got it to spit out this
[' _ ', 'p', ' _ ', ' _ ', 'e']
None
this is the code
i cant figure out where the none is coming from
i fixed it
nevermind
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
also, best way to do an exp system?
@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 Tech with Tim just made a video on hangman's game I believe
If anyone knows pygame, your presence in #help-chocolate would be greatly appreciated
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)
hello every one
who know a lot about pygame?
i need your help for my project
who can help me?
heeeeeeeeeeeeeeeeeeellllllllllllllllllllllllllllllllllllllllllllllllllllllllllllo?
@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.
I most make 3D game with pygame , who can help me?
@dawn quiver a lot of us can help, but specific questions will allow us to assist with what you need.
@pliant dust oh thanks
hey guys!
how can I develop a game in Python?
like, some courses, or something
just asking 😄
anyone here?
@strong belfry 2D games? Start here: https://arcade.academy/
@dawn quiver PyGame is not well suited for 3D games.
Also see https://learn.arcade.academy if you are new to programming.
are there python tools made for 3D or are you just out of luck for that
Panda3D, or just to OpenGL with like ModernGL or one of the other bindings.
interesting, not a dame developer myself, but always interesting to know what's out there
hello guys
who can help me to make a complex game?
it must be with pygame
who know pygame lot
If you have a specific question about it, just ask
You break the complex game into simple parts and go from there
Anyone that knows pygame that can help?
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
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?
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
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?
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
I can look, im still learning myself but sure I will look
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
@stiff iron pygame.transform.scale returns a Surface object, so you should use append that to gold_coin instead. You could check out the docs for more info: https://www.pygame.org/docs/ref/transform.html#pygame.transform.scale
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))```
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
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.
@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)))
@raven goblet I believe it is supposed to be pygame.QUIT, I don't remember though.
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
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
Hello I am brand new to pygame haven't used it till now
How to start
Wnt to get started with 3d
Might also look at Arcade. Get started at https://arcade.academy
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)
😭
@dawn quiver you can't use Pygame to make 3D games https://stackoverflow.com/questions/4865636/does-pygame-do-3d#:~:text=No%2C Pygame is a wrapper,to use%2C especially the latter.&text=Well%2C if you can do 2d you can always do 3d.
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?
no one know ?!!!!!!!!!!!!!!!!!!!!!!11
That Stack overflow answer listed 2 libraries capable of 3D. Are they inadequate?
@dawn quiver Maybe you want to try Panda3D.
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!
I believe there's only two 3D game libraries for Python, Ursina and Panda3D
there are plenty of opengl, dx11, vulkan etc bindings though
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++
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)
by apple do you mean normal pellets or is the apple a special object that gives more length than consuming the pellet?
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?
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.
you could make your snake an array of rects
then move the last rectangle to the front, giving the illusion of the snake moving
im watch an video, but its kind complicate to me, using list and append
@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
The beginnings of a raytracer 🙂
is it a raytracer or a raycaster? 👀
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 🙂
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 ?
@dawn quiver If you're just starting out, you can try the Arcade library. There's a tutorial here https://learn.arcade.academy/
@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 ¯_(ツ)_/¯
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
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
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?
Is it normal when the sprite image starts blinking in arcade.py?
I started learning arcade today
Which do you prefer? Pygame ou arcade?
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
@exotic fern @severe saffron it just the r value set to the distance, makes for a cool effect, but not real shading
Is python really good for game development??
Not really good but it's very good for smallish projects and learning
Hi is kotlin similar to python syntax
Off-topic channels
There are three off-topic channels:
• #ot0-psvm’s-eternal-disapproval
• #ot1-perplexing-regexing
• #ot2-never-nester’s-nightmare
Their names change randomly every 24 hours, but you can always find them under the OFF-TOPIC/GENERAL category in the channel list.
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
put the loops in functions ig
yes thanks
so i finish my game , how can i do to send my games to other people play?
@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.
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
hi guys,
i know python, but want to learn pygame
can anyone give me any crash course tutorial orsomething like that?
pls ping me
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.
@violet vault You might look at http://programarcadegames.com for Pygame. Or alternatively, look at https://arcade.academy for Arcade, which is similar to Pygame.
okay
Hello
Explosions using particles.
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
Wait, I'm a bit confused. If moves, but doesn't animate?
yes
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?
i need the code
i know there is something to do with rewriting the update_animation() function
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.
sure
Awesome!
Wait a minute......
Can I combine Kivy With renpy???
@frozen knoll uhhh.... You made a game but how will you change it to .apk?
Guys I am new to pyhton can you tell me the best module for game devolpment
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
I make games and tutorials with/for Python/Pygame! :D Website here: http://dafluffypotato.com
@dawn quiver Are you attempting to set a background image? Try: https://arcade.academy/examples/sprite_collect_coins_background.html#sprite-collect-coins-background
@unique kernel You might want to look at http://arcade.academy to get an idea what Arcade does.
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.
@bleak spruce @frozen knoll Thank you very much guys I will certainly try these out
OUR server is so good
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:
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.
You should try ursina, @Yaduarjindia
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
long shot but does anyone know a pyglet discord server?
@dawn quiver It's linked in #315249263103967242
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?
are you drawing the rectangle after the picture, perhaps?
@potent ice thanks
Sorry
Two times
@frozen knoll this was the animation i was struggling with yesterday
Now its done
Hey, good work!
Hello guys! Im learning pygame, Can someone help me with pygame?
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
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)
@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.
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!
whats the best library/ program for beginner dev?
Might want to consider Arcade. Https://arcade.academy and if you are learning, see https://learn.arcade.academy
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
@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.
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.
did you look through the official docs ace?
I don't know if pygame supports touchscreen events
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".
maybe this will be usefull to you https://becomingpygamer.book.tiainen.cc/en/latest/pygame/movingthings.html#moving-object-with-mouse-click
@dawn quiver id suggest using the noise library, i think it has the noise functions implemented in c
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()
The vector is seemingly a bit complicated to me. But I'll see
Can you guys help me with Photon 2?
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
Like a button?
you already have the location of the rect with the x and y attributes, if you want to know if the mouse is intersecting the rect when you click it, use collidepoint(x, y). you can get more info in the pygame docs
https://www.pygame.org/docs/ref/rect.html#pygame.Rect.collidepoint
Are there any good tutorials for an expandable inventory system?
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
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
can i ask a pygame question here?
@dawn quiver Yes.
ok
Is there a pygame event that supports holding down a key? (I tried KEYDOWN but it didnt work)
you would use a boolean value, set it to true when the key is pressed, and false when it is released
ah ok
pygame.key.get_pressed()
is there any youtube series you would recommend to learn pygame easily?
If you aren't set on pygame, might also want to check out Arcade: https://arcade.academy and https://learn.arcade.academy
Hey guys. A pygame game is showing images on windows. But not on linux. Any reasons?
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
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.
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
Here is the pathlib documentation
thanks guys
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?
I'll always suggest looking at Arcade as well.
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 ?
I'll always suggest looking at Arcade as well.
@frozen knoll Really interesting! I think i'm going to use that
how to make an image full screen in pygame?
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
@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
Can anyone help me resize a ListBox in tkinter using .grid ?
What do you want to do ?
thanks
@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
@lone crag I suggest you to use a tkinter.Text object instead of the ListBox to display your message.
https://www.tutorialspoint.com/python/tk_text.htm for more informations on textbox.
Python - Tkinter Text - Text widgets provide advanced capabilities that allow you to edit a multiline text and format the way it has to be displayed, such as changing its color and fon
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).
@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 ?
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.
can we develop a game with python
Yes.
See https://arcade.academy for example code.
There are other libraries too. There's also Pygame, Pyglet, Kivy, and more.
Hi! I am using pygame to make a card game. Anyone has any idea why my image coordonates are 0, 0. I need to make check for mouse collision with the mouse but every button is on 0,0. Do i need to insert other parameters? I will link the code from github https://github.com/corinbz/Projects/blob/master/blackjack_gui/pygame_window.py
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): ...
Thank you ! i will try that out
Anyone knows how to put automatically a text in an entry to make a auto-register systeme ?
maybe go into #user-interfaces and ask there
ok 🙂
Who want to work on game with me
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!
i want to make the board full screen i don't know how to do that?
https://github.com/Chiggy-Playz/Chess/tree/all-img-of-pieces-board
@warm bloom sprites will be much easier to use
ok
@torn heath hello how to do that?
done
Tutorial on using the graphics card to manage particle drawing:
https://arcade.academy/tutorials/gpu_particle_burst/index.html
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
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.
@solemn kernel https://www.chessprogramming.org
Is Tkinter able to be used in Pygame? (like for making buttons and textboxes)
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.
It is in Linux.
Right
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.
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
Looks like you have 2.27.
I think I had to use Ubuntu 19
Or greater.
Ubuntu 18 LTS doesn't work.
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
Cross-platform sound on Python has been a serious hassle for me to figure out. Sorry you ran into that.
If it works on Ubuntu 19 that is better than nothing.
FYI: Arcade 2.4 beta 1 is released : pip install arcade==2.4b1
\o/
Was 13 alpha releases before this one, so it has been quite a long journey finally getting to beta 😄
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...
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?
What are your needs?
What are your needs?
@pearl mango I want to create a 3d visualization of a file format.
Hmm, interesting. What format is it?
plotly is alright
Hmm, interesting. What format is it?
@pearl mango .class java file
If it's not too intensive, matplotlib or as @solar spire says plotly might be of use
...ah, that's new to me
...ah, that's new to me
@pearl mango I like to do crazy stuff
yeah, matplotlib is good, plotly gives you interactive 3D plots though, it's quite nice
what specifically is 3D in the .class? a defined object?
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
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
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
ahh, I see now
do you mean like windirstat-kinda visualisation?
how many lines of code are taken up by certain functions, or somesuch?
how many lines of code are taken up by certain functions, or somesuch?
@pearl mango Yes 😄
nice one! try seeing how tools like that function. some of that ilk use logarithmic sizing to better represent things
@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.
especially if you have many small helper functions
@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
There is a sample of using the builtin UI tools to make a bar graph: https://github.com/pokepetter/ursina/blob/master/samples/culumn_graph.py
There is a sample of using the builtin UI tools to make a bar graph: https://github.com/pokepetter/ursina/blob/master/samples/culumn_graph.py
@near wedge I'm checking it
Thanks again everyone
Congrats @potent ice and @frozen knoll !! Awesome release
Thanks! Still beta, but getting so close!
@lime finch ask here
can anybody tell moi how to make animation with spritesheet/gif?
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
in normal pygame in pycharm?
Depends on the engine
hmm
Really pycharm is an IDE
yeah sorry
I could do the same on IDLE or VSC, it wouldn't affect
yrah
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
You're welcome! 😀
Actually this guy is shy and didnt understand what you said
please explain with examples
-_-
Actually this guy is shy and didnt understand what you said
@marsh atlas i understand wut pyglet and stuff is
...but with the Arcade framework.
oh
I found a video
yeah?
Part of a series using Pygame and my own add-on library, Pygame_functions.
Get the module here: https://github.com/StevePaget/Pygame_Functions
And if it's your first time using pygame_functions, start here:
https://www.youtube.com/watch?v=gmBW_AVDsNY&feature=youtu.be&list=PL...
@gloomy ingot Thanks for your valuable time it was very helpful.
👍👍👍
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).
I thinks it's all bcz of file location @main crown
Windows means what?
It's a attribute error
i did
Is it working now?
Check line 4
ok
yeah
ill try that
i should really be working on my auto mod for discord bots
but ok
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
ok, how are you changing the sprite position, exactly?
(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
and you're supplying new coordinates to the update function?
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?
Alright, hold on as I am a little busy atm
yes, it is
ok, because I don't see anywhere in this code where you actually set its x and y properties
hmmm... maybe I didn't copy enough code
make sure you set self.bombSpr.x and self.bombSpr.y to modify its position.
def __init__(self):
# Firing system
self.fired = False
self.who_firedBomb = 0
self.bomb_x = -10
self.bomb_y = -10
nope, you're modifying self.bomb_x, not self.bombSpr.x
oooooh
I'll check that out and update you on the topic
oh hey! It works!
silly mistake of mine...
thank you!
YW!
Is this a good place to ask for help with my Tetris bot?
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?
I've just released a new version of the Wasabi2D, engine with support for tile maps and groups of objects. More info here:
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 🙂
Appears you have to hook in directly into games (or that's how Steam does it) via Direct3D or OpenGL
can sm one give me a good yt video on python game dev?
Welcome! This is a simple Python game made using the turtle module. The game features a player moving left and right at the bottom of the screen. There are falling objects which need to be caught, and falling objects which should be avoided.
►►►►LINKS
►►GITHUB: https://githu...
@limpid patrol its a good starting point
@hasty aspen ty
@limpid patrol I think this site has some video tutorials mixed in with the text tutorials: https://arcade.academy/
ok no more but ty
Details on the new features coming up for Arcade 2.4, currently available as beta:
https://arcade.academy/release_notes.html
what's the best library to make Pixel art Games?
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.
@frozen knoll thanks for your suggestions
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
@green thunder thanks man, looks like its going to be crazy but hopefully ill get it done
@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!
@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
it puts the exe into one folder but it doesnt encorporate the external files @still jungle
@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.
Looks like --add-data and --add-binary: https://pyinstaller.readthedocs.io/en/stable/usage.html#what-to-bundle-where-to-search
anyone know why i cant see my turtle?
@near wedge yeah I tried but it still wasnt working
Is it a good idea to use the in-development Pygame 2?
nothing if you pass no arguments
this channel is just questions on questions
@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
What? No. I play 2b2t and develop games on my own...
Am I not allowed to do both...?
oh i thot u wurked for housemustard
Right...
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
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
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]
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
nice @foggy python
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 
Ubisoft-like game in only 2 minutes? there is only one way
- download ubisoft game
- select the .exe
- 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
make a program that shows a black fullscreen for a few seconds and crashes, compile to exe with pyinstaller
if I had to rate making games versus making web apps, making games is actually slower
it will mimic quite a few games, not just Ubisoft ones even.
ooh, burn
If you were to create an ubisoft game, there are the important resources : https://stories.mlh.io/adding-payments-functionality-to-your-python-app-in-10-minutes-using-the-authorize-net-api-99f5e3e403ab https://youtu.be/6aQanCJZx04 https://testdriven.io/blog/django-stripe-tutorial/ [insert 50 similar links here]
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...
Does anyone know why in this code snippet, the x (and y) value is updated before the index is found?
@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.
Cube inside cube inside cube... playing with arcade 2.4 beta (low level rendering api) https://github.com/pvcraven/arcade/blob/development/arcade/experimental/examples/3d_cube_with_cubes.py
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)
Point clouds are not that hard to make with moderngl if you look at some example : https://github.com/moderngl/moderngl
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
You can render headless and dump out a texture
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
https://plotly.com/python/3d-mesh/ this is the only one I've found so far
looks like webgl
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
vulkan window inline running in the brower client side?
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
Can just use gl 3.3 for that. Don't need vulkan
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
Get a time machine and move to 2025 or something 🙂
I know this is a pretty cool start : https://github.com/vkjson/vkjson
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',
}
])
oh
dump in your setup as dict/json etc..
interesting
Greatly simplifies the setup
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
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 😄
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?
3.3 core is still pretty powerful. It kind of matured around 2012
yeah, I am sure it's still pretty good for most things, unfortunately I need to use the new mesh shader pipeline
Introduction to Mesh Shaders (OpenGL and Vulkan)
seems like they are available in OpenGL now
Yup. they are more like compute shader
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
A simple fast 2d and 3d mesh viewer
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
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.
yeah, it splits the mesh up into batches and does depth/occlusion testing early
order independent transparency etc etc..
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
yeah, I have data in the form of Shapely Polygon objects, So I should probably use TriMesh
- trimesh is easy install...
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
nice
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
@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
sorry, this is work related
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...
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?
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?
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
lemme see if i can't get it to do what i want...
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
im very very new to python and am currently struggling with a qns is anyone able to help me with it
@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
@stone hatch Ayo fam where that repo
@rocky heath workin on it fam trying to relearn some class stuff
All good, just let me know if I can help
will do