#game-development
1 messages · Page 108 of 1
create your event with pygame.event.custom_type()
await the word and send the event
NEWWORD = pygame.event.Event("num idk rn")
#in the appropriate func
await self.get_word()
pygame.event.post(NEWWORD)
like that?
more like ```py
NEWWORD_EVENT = pygame.event.custom_type()
async coroutine():
global CURRENT_WORD
while more_words:
CURRENT_WORD = await get_word()
pygame.event.post( pygame.event.Event(NEWWORD_EVENT) )
loop.create_task(coroutine())
and in event loop test for if event.type == NEWWORD_EVENT:
you did have a look to https://github.com/pygame-web/pygbag/issues/16 ?
so i should make a new coroutine function?
and where should i put loop.create_task(coroutine())
also thats missing the def lol
can i nest an event (e.g.) ```py
if event.type == MOUSEBUTTONDOWN:
if event.type == NEWWORD_EVENT:
pass
that's pseudo code you will have to figure out yourself, no you cannot nest event use if : elif : elif :
how doable would it be to make a game in python that runs on my console?
its extremely easy
Do I really need a database to store information for a website or can I use my pc as database?
a database is recommended
Is it free though?
there are tons of free databases
like mongodb
i think sql is free aswell
Alright, thanks
Oh and is it possible to add images with python?
to your console?
take like a super baisc game like pong(which i made using turtle), how could i make it in a way to play it on my xbox
im not sure, but you can edit images in python
im not sure of a way to port turtle to xbox
No to a website for example. I just started with python but my idea was to make a website with python and html that shows shelfs with books. And you can like add your own book to it. But I need to know if it’s possible to add those book images to it.
it doesnt have to be done with turtle, thats just what i made my pong out of
definitely you can
yes you can port a gui application to your xbox
Oh okay, so I wouldn’t waste time trying?
no
i guess my first question would be, how do i put a python file on a USB drive that runs when its plugged in
or is that the wrong route
how would i render a word from 1 to 9 characters in the center of the screen every time
man idk
you'd have to research yourself or get someone more competent than me
to help you
🤷♂️ all i know is that its possible
pff
what just happened
i sent you a discord invite to pygame community it was removed
ah
sent in pm
i don't use pygame myself, i just ported it to wasm so you'll get better answers there
i got the enemies to start moving as well as a beginning to a functional inventory and index on the game
i also added a floor level system, so you can climb down stairs to go to new, more difficult floors (this also reduces lag when reseting the map)
I wanna know who came here with question regarding GMTK game jam
Not I...
whats the best ide for python using macOS
Ask this is one of the available help channels to get the fastest answer
does anyone here use sublime
ive been working on the game index
obj = {}
def reg(name, cl):
obj[name] = cl
def get(name):
if name not in obj.keys(): return
return obj[name]
class A:
def __init__(self, x, y):
self.x = x
self.y = y
reg("test", A)
class B(A):
def __init__(self, x, y):
super().__init__(*args)
def foo(self, a: int):
self.x += a
reg("test2", B)
args = (100, 200)
b = get("test2")(*args)
print(b.y)
b.foo(100)
print(b.x)
Class register like in source
Wait
Asinio in pygame
Wow
So asincio can optimizate the pygame game?
not really, but it's usefull for short blocking I/O ( typically websockets) and allowing running on web
threading is an Os thing, not a python thing
anyone know how to make a rectangle in pygame?
The Pygame Summer Jam was an awesome experience
Thanks to everyone who helped and gave their feedback
Enjoy the journey of making of Alien Dimension
Get Alien Dimension here !
https://quantum-hg.itch.io/alien-dimension
Join me On Discord for Gamedev, physics, simulations and pygame talks and programming!!!
https://discord.gg/rGuseq6HpX
Made Using Pygame !!
Get all of my games here :-
https://quantum-hg.itch.io/
#games
#gamejam
#pygame
#programming
#python
#gamedev
Use pygame.Rect() class
Btw, have anyone of you ever used Blender Game Engine?
pygame.draw.rect ya ik but it wont wokr
smth to do with repl.it
the site is just not made for pygame i htink
There is an option for pygame
ik but its relatively new and its very buggy
but my coding teachers want me to use it
¯_(ツ)_/¯
whats priv?
npnp
Have anyone heard about it?
heard of it
No, thanks. I was thinking about trying making games in it with python, so I asked to know if you have tried it and what is your opinion about it? Blender Game Engine / Unity / Panda3d?
i think kivy is best
because you can make both 2d and 3d directly
but you can prefer 2d pygame or 3d ursina
yep, it's all in Python 🙂
yo does anyone need a tutorial on requests and webscraping
as web games are also mobile, i'd remind both pygame and panda3D can run on webassembly and use dekstop python code for that no need to learn another engine
hi
i am trying to add an obstacle to my code in pygame
i have a moving sprite
and i want another sprite
to appear on the window
here is my code:
Hey @hardy lotus!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
any help would be rlly appreciated
How much python should i learn before i start learning pygame? I currently have the basics like variables, conditionals, loops, functions, but i havent learned oop yet.
You'd do well to learn oop. Almost everything that I'm doing right now in pygame needs classes. I say needs as in - it would be incredibly difficult to create a decent complex game without knowledge of oop.
death to oop 🔥
i made a game, a little Guess the number game but its only a code how do i give it a display, an interface, how to just convert the game code into a game
is oop important in pygame?
oop is quite toxic in games, use entity component system model instead
but if not using pygame for a game ( eg someting like nodezator ), oop is usefull
then i'd say you need python classes skill, but not specifically oop
I don't think one should jump into ECS right off the bat. Especially not by trying to write their own ECS architecture rather than using existing tools like Esper or PECS, which also requires considerable knowledge with classes and such.
OOP is a fine choice when starting out, but dont even think about the paradigm you are using when doing so, as Tim Peters once implied, you would be better off creating a class to contain your functioanality where it is appropriate, and a function where it makes more sense.
Also, I think the advice a little above implied "OOP" just meaning that they throw some class definitions around, rather than structuring your entire game to use it, by utilizing its features.
Regardless of whether or not you want to structure your codebase to use OOP, you should definitely learn how objects and types work in Python, as everything in Python is an object, and modules extend functionality to you by letting you use them. Understanding how they work can be largely beneficial.
what is pygame? and is python even good for game development?
pygame is a wrapper around SDL library which is used for a lot of games or games engines, here you can find some demos that don't require installing https://pygame-web.github.io/
python classes are very versatile you can use them with inheritance (oop/c++/java) or composition(ECS/C) it's up to your design choices, you can even do polymorphism and mutations if you want to mess things up 😄
Is there a way to render images with transparent canvas with Pygame?
I can't find much information on the subject...
Hello guys I've been using pygame for almost 2 years now but I want to switch to 3d what do you recommend ursina or panda3d?
if you like simple?
or simpler abstractions
Nah man I want the one with the best advantages ,I don't care if it's hard/easy
Thanx man :)
Is there a way to render images with transparent canvas in Pygame?
do you mean images already set with an alpha channel or drawing any kind of image on a transparent background ?
for me canvas is something you draw "on" not "with"
I have a 100+ game customizations in .png format that I need to render simultaneously to form a game character. However, regular Pygame image rendering causes the image backgrounds to be white, not transparent.
https://pastebin.com/f2A16a1V I have the code in here, for some reason when I try to move a paddle, it actually increases size instead of moving, I have tried finding the issue but I can't find it....
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
right_paddle = Paddle(PADDLE_HEIGHT, PADDLE_WIDTH, WINDOW_WIDTH - 10 - PADDLE_WIDTH, WINDOW_HEIGHT//2 - PADDLE_HEIGHT//2)
left_paddle = Paddle(PADDLE_HEIGHT, PADDLE_WIDTH, 10, WINDOW_HEIGHT//2 - PADDLE_HEIGHT//2)
``` @dawn quiver
Is that the problem?
Ahhh nothing is working, i dont get why 😭
Make the shader/program after the geometry/triangle : https://stackoverflow.com/questions/54181078/opengl-3-3-mac-error-validating-program-validation-failed-no-vertex-array-ob
Can anyone give me ideas to code
Hey, does anyone know any good libraries to acces the JoyCon's gyro and accelerometer?
I only want the world position and rotation of the joycon
Traceback (most recent call last):
File "d:/VSC/Pygame/Spaceships #1/main.py", line 184, in <module>
main()
File "d:/VSC/Pygame/Spaceships #1/main.py", line 181, in main
main()
File "d:/VSC/Pygame/Spaceships #1/main.py", line 181, in main
main()
File "d:/VSC/Pygame/Spaceships #1/main.py", line 181, in main
main()
[Previous line repeated 1 more time]
File "d:/VSC/Pygame/Spaceships #1/main.py", line 170, in main
draw_winner(winner_text)
File "d:/VSC/Pygame/Spaceships #1/main.py", line 115, in draw_winner
draw_text = WINNER_FONT.render(text, 1, WHITE)
pygame.error: Library not initialized```
I want my game to restart once the game has announced a winner, however it seems to freeze/lag once the game is over
Any ideas on the issue or whether this is pygame related?
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the 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.
i noticed that you added the line pygame.init(), the program still doesn't work?
It still doesn't work with and without, i'm pretty confused
What are people's thoughts on pygame vs pyglet, in terms of beginner-friendliness?
(for simple game dev)
Try removing pygame.quit() after you set run to False
It doesn't quit your program, but it's uninitializing all pygame modules, so, when you try to draw, it will raise an error
Just did that and now I literally can't close the pygame window, help
It's probably because after the loop you call the main function again, try removing that as well
Just close the terminal in which you executed the core
The main function is only called there if I click play
You also call it in line 182 after the loop
Yes
To repeat it
Otherwise, the programme will end after 5000ms
But clearly it isnt repeating
Why would it close after 5000ms?
I set it like that
That should happen only if you have a winner
Thats what I meant
The winner text displays for 5000ms
But how do I restart it?
If you have a winner, before breaking out of the loop, call the main function again
Oh, you also need to reset the HP for both players @austere kraken
@austere kraken I would also remove all your game code outside the main loop and use the main loop to only control when and if the game runs. Like, create a func "StartGame" and put your events and all that in that function. Then when there is a winner have that function finish and give control back to the main loop, where you could prompt the user to play again ('restart') and if not, quit the program.
is there a way i could switch glRotate to a camera rotation function ?