#game-development
1 messages · Page 40 of 1
but if you give it a object like a self.people it will work as a generator if im not wrong where everytime you make a new person it will be added as the next in line
!e
def gen():
for i in range(10):
yield i
for i in gen():
print(i)
:white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | 0
002 | 1
003 | 2
004 | 3
005 | 4
006 | 5
007 | 6
008 | 7
009 | 8
010 | 9
but lets say the range(10) is the len of peoples everytime you add one it gets increased so it yields further and further everytime
hence why your aplication is in infinite loops since you didnt define a maximum of when it should end
ohh so basically for each iteration its like the function is called meaning it continuously updates?
i see!
yeah the for loop only ends cause you limited the range to be your window height and size other wise it would keep adding persons untill it crashes
https://github.com/steellight541/my_pygame_packages/blob/master/main.py
updates so far:
- rebased the GUI
- button is "finished"
- reworked the styling
- started a parser idea to go from yaml -> pygame
That is the Bevy library yeah!
what questions do have about it ?
I was looking for people who have used it.
And who are familiar with it. I am a lead developer on a project, we are in a new hiring phase right now.
ive not used it yet but i was planning on doing a project with it after my pygame package one (or in between ) so if you have questions about it just ask i think ive read the docs to some extend alr to be able to help a hand out with questions
Cool, I am looking for new developers to bring onto the project at the moment.
nice also check out the rules tab to not get in future trouble
im just saying incase you make a sentence that can seem misleading since they can be very strict about it
Yes absolutely, I remember someone mentioning that before! Thanks Steel
How do you download like pygame? Powershell isn't recognising that I have python on my computer so I can't install shit
can you use pip
py -m pip install pygame-ce
(assuming you want pygame-ce)
On windows you usually use py -m pip instead of pip or py instead of python
I got two books on my game and Panda 3d!!!
try
py --version
python --version
py worked
nice no worries
i never tried using py
I got building video games with python a practical guide to my game arcade and Panda 3D and developing video games using pygame , arcade, Panda 3D
keep up the good work
Visual studio
mmh the run command is probably using a different python
dunno if it made a venv or not
could you send me your folder structure
Wdym
Kay gimme a sec
Sorry for late reply
press on the triangle next to python 3.9
yes pygame is not in your venv
right click on Python 3.9
i think there should be a add dependency button
or go to view and view terminal
and type
the install command there
Please react with ✅ to upload your file(s) to our paste bin, which is more accessible for some users.
@steel thanks for your help earlier, heres how the simulation is currently looking! be glad to take any further suggestions or input
Please react with ✅ to upload your file(s) to our paste bin, which is more accessible for some users.
very nicely done
also take a look at pygame_gui if you want to focus more on the simulations so that you dont need to pay attention to the rest
i think im the only one that codes inside the python idle by creating a new .py
am i outdated
😅
I used to do that
Vs makes it too easy though
makes sense
noice
Idk what going on but it lookscgood
hi, could anyone help me please ?
I have a state of my class Player which is self.state and I have a Animation class in a animation.py file, and I have a dictionnary "animations" which is not in the class Animation but just in the file, and I need the instance of player in it but I can't find how, please help me 🥲 .
PS : sorry if my english is bad and if I didn't explain well
is this made in python??
yes
very nice
i want to learn how to make this 3d games u made
i saw ur website
what libraries do u use?
this ursina is what creates 3d games?
where do you get the samples? (houses, objects...)
I make everything myself
this website has same games u have in ur portfolio, did u create ursina?
this is ur game engine
yes
the 3d models?
for the terrain and level design I use a voxel editor I made specifically for this game
for the rest of the models, like the character model and animations, I use blender
okok
and then u can use this samples in python
i dont have the time now but i will take a look at this ursina engine later
i've tried pygame, u can do nice things too, but im not that good with it
what other things do you create ? besides games
It's mostly games, or tools for making games, like level editors, but I've also made other programs like a python-like programming language transpilable to javascript that can run in web browsers, a mobile game/software framework, drawing/painting software, text user interface for git, a python profiler that shows how much time each line of code takes, and a markdown inspired language to make websites. You can do a lot with Python
i see, very nice
please anyone ? ^^'
Send some code cause that whole sentence doesn't track gng
Not in my mind atleast
you should provide some code and what modules your using it could make more sense for us to help you with
Tryna come up with a new protocol for defining logic circuits in a simulator. Currently using a dict to describe the wires connecting the devices, like so py {'flip': True, 'fromgate_index': 10, 'outport_index': 4, 'togate_index': 4, 'inport_index': 0 } Says gate at index 10 has a wire from its port 4 to the gate at index 4 and its port 0
This way works but it's tedious, and the same kind of method will be used to save and load circuits for game saves
I could lose the dict and decide on a proper format for those attributes
I suppose the trade off there is losing readability
In the game, some levels have circuits in them by default, like level 1 starts with all three robots pre-wired with circuits to solve the puzzles of that level. So the protocol needs to be used to initialize some levels and, when playing and creating your own circuits, to save them
The entire first level (early footage)
Yes okay my bad, but I guess I found but thx
Looks clean
I have an idea ill share in a sec it might be dumb tho
I'm open to any ideas, kind of reworking the game and will consider everything
It's a massive game, so reworking much of it will be quite an undertaking
I'm just not satisfied with some of it
All levels are composed of rooms, in all, the game has ~450 rooms
I need a better foundation, circuit descriptions being part of that, and how to save a level in progress, which means serializing everything
{
"flip": true,
"gate": {
"input": 10,
"output": 4
},
"destination": {
"input": 4,
"output": 0
}
}```
might seem dumb tho
damn thats a lot
Yeah, and I'm describing all those with 2d lists
wutttt
They're all grid, well blocks (walls) on grids
Which can sometimes change, like walls move to open pathways
So saving game means saving that state too
oh you mean like
[
[Cell(white), Cell(blue)]
]
Pretty much
yeah
so you want to find an "readable" and optimal way to structurize this to the serialize and deserialize to save
Yeah, pretty much. My main struggle at this point has been saving robots (which have rooms inside them that can have other robots that have a room inside them and so on) and the recursion to deal with all that
oh yeah that can be a struggle
Like the level has 50 rooms + whatever robots are in the level
And they can all be nested
i think you need to save the bots more like this
{
"bot1": {
"inside": "bot2",
"states": { },
},
"bot2": {
"states": {}
}
}
I'd even write a bytecode if I needed to, like the protocol doesn't really need to be readable but it has to be very well defined before building on it
i dont think you nest them just link them
if that makes sense
Right, save the bots separately from level rooms
you can have the nesting in python but then the linking in save
yes
you can also do like ```json
{
"bot1": {
"inside": "bot2",
"room": 52,
"states": { },
},
"bot2": {
"states": {}
}
}```
as a quick example for rooms
Yeah, makes sense, the devil is in the details
As usual lol
Like if a robot is inside another robot, the outer robot needs to be parsed before the inner one
yes but you can store the once that have none linked than link them to the upper once
you should make a little load menu for this cause +-300 rooms and lets say like 50 bots can take a moment
It's such a good game and I'd really like to finish it. It's been backburnered for a few months but I want to release it eventually
it looks really well man
Thanks, all digital logic, gates and stuff
It's basically a digital simulator wrapped in a game
Originally released by The Learning Company on Apple2e or so in like 1985, so mine is a remake in python
Robot Odyssey was the og name
Was rewritten by Thomas Foote in 2000 in Java for play on modern machines
bots = [...]
unlinked = []
linked = {}
for i in bots:
if i.get("inside", None) is None:
linked[i.keys()[0]] = i
else: unlinked.append(i)
# just for general idea need recursion here
for i in unlinked:
if b:=linked.get(i["inside"]):
b["inner_bot"] = i
this might make some sense
I have the java version, still works!
ooh sounds nice
It's one of those things that is so complex that I need to work through it piece by piece
Sounds very cool
i think as soon as you get your head wrapped up in it that you will get it in an easier way
And avoid the so-called painting myself into a corner
Write 200 lines of a bad idea before realizing its a bad idea
XD
lol
(had it multiple times happen)
Same
Been there so many times, all learning experiences though
Nice, you did quite a lot for it
folder struct atm
styles is fully functionall for current and future gui elements
tooltip i hope to make it work for everything aswell
Sliders too?
rn working on sliders
Nice to have, espeically for tweaking or debugging
jup i wanna make a lot of gui elements in it
exactly
also want to make addaptations of my button
checkboxes, slider boxes,...
Just for the fun of it, this is a list of all items ['FLIPFLOP', 'ANDGate', 'NANDGate', 'ORGate', 'NORGate', 'XORGate', 'XNORGate', 'NOTGate', 'BUFFERGate', 'NODE', 'NODE90', 'NODE180', 'NODE3', 'SmallChip16', 'SmallChip', 'Prototype16', 'Prototype', 'Token', 'ExitTicket', 'WhiteKey', 'RedKey', 'BlueKey', 'GreenKey', 'OrangeKey', 'PurpleKey', 'YellowKey', 'WhiteGrabber', 'BlueGrabber', 'WhiteThruster', 'BlueThruster', 'WhiteBumper', 'BlueBumper', 'WhiteAntenna', 'RedAntenna', 'BlueAntenna', 'RedCrystal', 'BlueCrystal', 'BlackCrystal', 'WhiteCrystal', 'BlueSentry', 'WhiteSentry', 'AmpireBot', 'Ghost', 'SonicLock', 'BinaryKey', 'Polarizer', 'Train', 'Handle', 'StormCloud_NA', 'StormCloud', 'Triangle', 'WhiteTriangle', 'Square', 'WhiteSquare', 'Hexagon', 'WhiteHexagon', 'Form_F12', 'ElevatorKey', 'RedDisk', 'YellowDisk', 'WhiteDisk', 'GreenDisk', 'BlueDisk', 'StormShield', 'VentFan', 'Helpers', 'Helper', 'SpyCam', 'Turbine', 'PowerButton', 'VentGrill', 'ElevatorArrow', 'PlayerBlocker', 'Form12Trashcan', 'Buttons', 'Pen', 'menu_indicator_red', 'menu_indicator_grey', 'Player', 'skyway0', 'skyway1', 'skyway2', 'skyway3', 'skyway4', 'skyway5', 'skyway6', 'skyway7', 'trapped0', 'trapped1', 'trapped2', 'trash', 'Logo', 'junk', 'ChipTester', 'Recycle', 'Slider', 'Slider_BG', 'Button_Off', 'Button_On']
slider boxes basically just a slider with steps
Well, everything with an image in my image dict, that is
damn
Currently working on that dict
Moving all the images into image.load instead of drawing them
? what do you mean
Currently drawing them with pygame.draw calls
how did you draw your images before 😭
Now drawing them, saving them, and going to load them
aaah
yeah it might be easier and more optimized
also make sure to preload them
and not continues load
Oh yeah, that was lesson one long ago, but thanks
I've been pygaming for about 8 years so far
nw i sometimes remake this mistake XD
My main class usually loads all them and passes them around to the objects
With this game, I have them all being drawn in a separate file and added to a dict that is then imported where needed, so any file can get access to any image
Like a global images dict, just needs imported
ooh nice
if one were to make their own engine does gui framework used matter ? and if so, which to choose and why ?
Hey guys, I created a small module I wanted to share with you.
This module, using the render_text_to_surface() function, will automatically size and draw a piece of text to a surface, using a provided Surface, text, and PyGame's Font() arguments.
I created this because I didn't want to manually determine the font size needed when creating text. For example, if you were creating a menu and wanted to create a play button, instead of manually trying different font sizes until you find one that fits, this function will automatically calculate the optimal size and draw it for you.
Additionally, you can provide a margin, which will be used to keep the text a certain distance from the sides of the surface. You can also provide an alignment, which is centered by default.
Feel free to check it out! https://paste.pythondiscord.com/EENQ
Hi, someone use unity hub and can help me ? I can't start new project..
I’m down
Alright, Let's Go
its definitely possible
mine looked a bit jank theres better examples in the pygame server
ive done some procedural 2d world generation in pygame couple of years ago
its so old and the code quality is so bad.. idk how it even manages to run
its possible
its also not to hard
and it can be efficient if you code it the right way
Hey where can i ask for help for my program
Hello, so after taking @robust egret and @vagrant saddle suggestions, ive rewritten the game-state library to v2 and optimized many parts of it! Here is a working example of the library-
# Creating two screen where the first screen displays green
# and the second screen displays blue with a moveable player
import pygame
from game_state import State, StateManager
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
speed = 100
pygame.init()
pygame.display.init()
pygame.display.set_caption("Game State Example")
class ScreenOne(State, state_name="FirstScreen"):
def process_event(self, event: pygame.event.Event) -> None:
if event.type == pygame.QUIT:
self.manager.is_running = False
if event.type == pygame.KEYDOWN and event.key == pygame.K_c:
self.manager.change_state("SecondScreen")
def process_update(self, dt: float) -> None:
self.window.fill(GREEN)
pygame.display.update()
class ScreenTwo(State, state_name="SecondScreen"):
def on_setup(self) -> None:
self.player_x = 250
def process_event(self, event: pygame.event.Event) -> None:
if event.type == pygame.QUIT:
self.manager.is_running = False
if event.type == pygame.KEYDOWN and event.key == pygame.K_c:
self.manager.change_state("FirstScreen")
def process_update(self, dt: float) -> None:
self.window.fill(BLUE)
pressed = pygame.key.get_pressed()
if pressed[pygame.K_a]:
self.player_x -= speed * dt
if pressed[pygame.K_d]:
self.player_x += speed * dt
pygame.draw.rect(
self.window,
"red",
(
self.player_x,
100,
50,
50,
),
)
pygame.display.update()
def main() -> None:
screen = pygame.display.set_mode((500, 700))
state_manager = StateManager(screen)
state_manager.load_states(ScreenOne, ScreenTwo)
state_manager.change_state("FirstScreen")
clock = pygame.time.Clock()
while state_manager.is_running:
dt = clock.tick(60) / 1000
for event in pygame.event.get():
state_manager.current_state.process_event(event)
state_manager.current_state.process_update(dt)
if __name__ == "__main__":
main()
you can check its github and docs here-
https://github.com/Jiggly-Balls/game-state/tree/main
https://game-state.readthedocs.io/en/stable/
open to any suggestions
I'd recommend keeping controls in a JSON file and loading it dynamically so that you can more easily change the settings. Here's some code I wrote in my software template that can do that. https://paste.pythondiscord.com/SFKA
You could also use this to store settings like framerate, colors, fullscreen toggle, and anything else.
the library i've written is mainly focused on managing various screens in an organized manner
dont think id be adding any general utility stuff to the library tho
Prolly a longshot but do yall know/have any actual books targetting procedural generation (terrain, maps, textures even) using Python?
you can research about perlin noise generation
I would recommend asking ChatGPT
hii, im loooking for some developers to create an application , need some help like alot , sorry i will not be able to offer pay as yet but it will definitely be a fun experience , Feel Free to message me for learners and expertise , if your up for the challenge!
please dont
just do some research on perlin noise like jiggle balls said its a good one for handling procedural generation
they starting to look fancy
only 70 lines so far for this
Is there anything in panda for generating a random environment? Panda3d
AI is really useful for pretty much anything, including programming. I use it on a daily basis
Hi All, I am new to game development. I am working on a checkers game and trying to make the AI smarter. I ran into a roadblock when adding : Piece value (kings are more valuable).
Board control.
Threats and vulnerabilities.
Distance of pieces to becoming kings. The game keeps crashing when it is the AI's turn at the start of the game. Any help would be appreciated.
Is there an error message?
I used it like once.. maybe? I vaguely remember the API
Which renderer do you want to use?
Im trying to use imgui to try it but it always give me over 470 errors and i cant get pass it, ive been trying to set it up for 3 months now. i just want to have this on my pc
I have friends that know how to work imgui but there in collage and dont have time to help me
@balmy pilot could u help me?
Sure, I can try. Let me try making a "Hello World" with this thing
if u send me the example code for it i dont know how to import code into visual studio 2022
Wow this library is not super freshly maintained
I'm having to use Python 3.9 to get pyimgui to work; it won't build for me against 3.12
Oh I see, there's a better binding, let me try that instead
OK yeah this is way better. This works for me on MacOS, should work on Windows too. Requires pip install dearpygui
https://paste.pythondiscord.com/SZNA
Just make a new file in Visual Studio called 'hello.py' (or whatever_you_want.py) and paste that into it
pygame is so nice
i just used it for the first time in a basic scrip to learn
its so much simpler than turtle
turtle sucks
How can I make a spawning radius in a specific area?
Dude what
These are what I get.Traceback (most recent call last):
File "Checkers_v24.py", line 859, in <module>
game = Checkers()
File "Checkers_v24.py", line 49, in init
s.SetupBoard()
File "Checkers_v24.py", line 57, in SetupBoard
s.Play()
File "Checkers_v24.py", line 65, in Play
s.CompTurn()
File "Checkers_v24.py", line 132, in CompTurn
best_move = max(s.moves, key=lambda m: evaluateMove(s, m))
File "Checkers_v24.py", line 132, in <lambda>
best_move = max(s.moves, key=lambda m: evaluateMove(s, m))
NameError: global name 'evaluateMove' is not defined
I wanted make a game with enemies now if I can figure out a way of making it so that the player has an inventory in places a key within a slot it's bonds five enemies for them to fight and that's how they get resources and I want it to spawn within a specific range so when does that randomly spawn on a different side of the map making it not give anything
So I'm super confused but I think you mean when key "4" (for example) pressed 5 enemies spawn in.. you want them to be in a random place but not too far from the player.. am I correct?
@tired reef
Ahh so
import random
#player co ordinates can be switched to any spawn centre
playerCor = [0, 0]
#size of spawn area
a = 0
b = 20
#list of spawn locations for enemys
enemySpawn = [
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
]
#append to enemy list using spawn area rule
for i in range(5):
enemySpawn[0][i] = playerCor[0] + random.randint(a, b)
enemySpawn[1][i] = playerCor[1] + random.randint(a, b)
print(enemySpawn)
thats kinda what i would do.. this makes it so you can easily move the circle of spawn around and choose the size, i would re work it a little and slap it in a subroutine so u can make them wherever
Choose a random distance and degree of rotation around the circle with the player in the center
Maybe another way to think about it
you would only need the random degree of rotation he wants the size to be constant
Create a vector with the length of circle radius, rotate it some random amount between 0 and 359 degrees, add it to the center
Or use polars
That is, create a random radius and angle (in radians) and convert to x/y with x = radius * cos(angle) and y = radius * sin(angle)
I Don't Understand this... Can someone explain??
?
Polar to cartesian conversions?
Quick demo, 1000 points at 50 to 100 pixels from the center and at random angles
can anyone look at my code in having alot of troubke with an onclick section
Please react with ✅ to upload your file(s) to our paste bin, which is more accessible for some users.
I want to make a Roblox TikTok edit script
I had to ask an LLM but now I get it haha
apparently a "TikTok edit" is a short clip with visual effects
<@&831776746206265384> isn't this against the rules?
why its against the rules? <@&831776746206265384>
!rule paid
hmm
allr , my bad @idle yacht
i just need some help with the script
if y all can help for free , thats fine by me
allr thnx
i need somebody to help me- im a minecraft bedrock player who's making a client (check bio) and im having trouble coding, so it would be a great help if you could join our dev team
ain't mc bedrock made in c++?
but the client's being made in VSC in python lol
did a little silly game where you talk with ai generated souls freshly dead and decide their afterlife, you can see their past, chat with them, see their hobbies and a lot more, check it out, totally free https://pyoneerc1.itch.io/spu
thats sick
oh, that thumbnail is AI generated
It's that just making a menu? I'm sure there are very simple libraries that allow you to that.. I wouldn't know though I've never dabbled
Also I think this would be better suited for #user-interfaces
nuh-uh, not a menu, a full client
a client is just a couple menus stacked no? its not like youre actually booting the game as with bedrock you just launch an exe.. you can do that with one line of code
also, im making a client with many menus so i can take help
nvm
its not too hard man you kinda just fuck with the code until you get the menus to work
hardly need a dev team for that
either way #user-interfaces
anyone know what the best way of detecting collision is? I'm using pygame and the collision doesn't work all the time, specifically when velocity is too high and also how to detect what side the player is hitting, currently im using raycasting sorta
it really aint, did it in canva lmao
its really cool
thanks giggly balls! if you play the goofy game please lmk what you think, wanna do more of this kind.
Hey Jiggly, ended up just doing this, forget the strings and the cross referencing, just link the index to the class ```py
def handle_toolkit(self):
pressed = pygame.mouse.get_pressed()
if any(pressed):
if self.toolkit.rect.collidepoint(pygame.mouse.get_pos()):
self.selection_index = self.toolkit.click(pygame.mouse.get_pos())
if self.selection_index is not None and not self.active_selection:
self.add_gate(self.selection_index)
def add_gate(self, selection_index):
idx_to_class = {
0: devices.ANDGate, 1: devices.NANDGate, 2: devices.ORGate, 3: devices.NORGate,
4: devices.XORGate, 5: devices.XNORGate, 6: devices.NOTGate, 7: devices.BUFFERGate,
8: devices.NODE90, 9: devices.NODE3, 10: devices.NODE, 11: devices.NODE180,
12: devices.IOSwitch, 13: devices.FLIPFLOP, 14: devices.Receiver
}
if selection_index not in idx_to_class.keys():
print('selection_index out of range')
return
gate_class = idx_to_class[selection_index]
gate = gate_class((0, 0), self.current_room)```
That's messy in discord
Anyone? I have no clue
Can you extract/show your code? Ray casting sounds plausible to me at first, maybe it’s just a coordinate precision thing we could fix?
Woah damn, goodjob dude
Thanks saiko, what did you like most?
Hello team,
I'm not sure if I'm on the right channel, but I'm reaching out to you regarding game development in Python. I've been getting into it for 3 years and have made a few personal projects using Pygame. However, I recently heard about Ren'Py, which seems to be mainly for Visual Novels. Is there a more advanced library than Pygame? I've heard of Pyglet and Arcade, but I haven’t tried them yet. Your experiences on this topic would be really helpful! Thanks
Hello. I’m a beginner in python (I started yesterday). I used ChatGPT to create a game and it’s still early and ugly in graphics. Right now I would like to know how to make 2D characters turn around their front, like how GTA Chinatown Wars does.
umm
u can use sprites
and if u made a game already you probably know how to get pressed keys
to move
sorry bad english
and
I used ChatGPT
for character to change its sprite direction u better firstly set a attribute in his class
and then like
when u press key it changes
and if it changes u gotta use pygame.transform.flip
to flip the image
sorry i’m bad at explaining
for computer to know what keys are you pressing you gotta use pygame.key.get_pressed()
Ok
my english is kinda bad and i’m also a newbie so sorry if i explain badly
oh and the main thing that chatgpt don’t use most of the time is that you better make classes for everything in the game
like the player
game class
and such
I can send you the code
yeah sure
Click here to see this code in our pastebin.
bruhhh
Yeah?
i’d recommend you to start to code on your own
I can’t even make 2 * 2 in a print
So, what do you think?
u can watch tutorials on utube
Ok. Can you upgrade the game?
if i were you i would delete all this and start it over
No way. I can barely survive and you want me to delete my first police simulator
ok then start to code another game
💀
You don’t understand. I’m motivated to do this
i could’ve tell you how to code a game like this properly but i don’t have much time rn because of exams
Ok
Oh man, globals are not where to start.
I am angry at this code, that’s probably not healthy
More confirmation that gpt can't code
“Mutation is expensive” maybe needs to be the first prompt? Jesus.
whats the most beginner friendly engine that uses python?
Pygame?
Wait pygame isn't an engine
does godot or game maker use them
Panda3D seems pretty cool https://docs.panda3d.org/1.10/python/index
Godot uses a scripting language called gdscript or something
It looks like python
oh ok i heard renpy is really good idk
-# me using pygame to code my little mario game
What kind of game? If you want 3D the list is quite a bit shorter than for 2D
pygame >>> 2D
2d im still learning but wanted to use what i learned to maybe make a start toward a career and maybe make a game in my spare time
I feel like pygame would help you learn a lot because you need a lot of manual implementations which betters your understanding of what happens under the hood ┐('~`;)┌
Yeah, start with PyGame given what you just said IMO
ok
But definitely dabble in the others once you get more comfortable. Panda3D seems good if you want to expand to 3D.
arcade is fun too
Pygame isn't that difficult
I found a really good video and learned most of it in one day
You mainly just need to know how it functions and then you can look up the rest
In this video I will explain how to get started in Pygame from scratch.
This is aimed at those who have not used Pygame before and will go through the steps of installing Python, installing Pygame as well as looking at a few different editor options.
Then I will explain the basic structure of a game and put together some simple code to demonst...
I'd watch his follow up videos too if you find it difficult
You don't necessarily get "engines" for python because python isn't really used for game development on account of being unoptimised so you kinda just have to use libraries
Sorry for the nitpick, but it's not "unoptimized". It is optimized to the best of what it can be almost, but the language is fundamentally designed in a way that needs to allow for certain possibilities, which cannot be made that much faster. Also it is an interpreted language
However its speed isn't the reason that Python is not used for more commercial games, it is simply its popularity for that purpose
Yeah so it's not optimised for game development
Especially 3D game development if you want to move past boxes
i think Disney went way further than boxes with python, and now it is MIT licensed https://www.panda3d.org/
( bonus added simple games can run on web same as pygame-ce )
Isn't panda 3D made with c++ backend
it is a full integration with cpython c-api with a 1:1 c++ match so you can compile your prototype to market
It uses c++ for physics and rendering no?
yes if you are familiar with pybind11 then https://github.com/panda3d/interrogate works the same
So what's the point in bringing that up to say python is good for game development
game development isnt about directly interacting with graphics APIs
because an essential part of game dev is prototpying not coding the final product
thats maybe, engine development
We are talking about python as a tool for game development not what makes up game development
Using panda 3d to say python is good for game dev is such a non point
right, and game development is about building games. not tinkering with graphics APIs
you dont need the C++ part of panda3d to shape your game
that's part of the engine development process
C++ literally powers panda 3d
godot uses a scripting language called GDScript, the backend of GDScript calls are all C++, but we use GDScript and Godot's UI to make the actual game
If it didn't use it panda 3d wouldn't work
yes, to make the engine/framework, not the game
game development is more than just the engine/framework
also when it comes to uploading shaders to a gpu there's not real point to use a statically compiled lang. this is coded in python https://demozoo.org/productions/356463/
- Graphics Rendering
Handles DirectX, OpenGL, or Vulkan rendering.
Manages shaders, textures, geometry, scene graph traversal, etc.
Optimized in C++ for performance.
- Scene Graph Management
Maintains and updates the 3D scene graph (a hierarchical structure of all objects in the scene).
Efficiently determines what should be rendered each frame.
- Collision and Physics
Includes a built-in collision detection system.
Interfaces with optional physics engines (like Bullet).
-
Audio
Manages 3D spatial sound through backends like FMOD or OpenAL. -
Input Handling
Captures mouse, keyboard, gamepad input. -
Memory and Resource Management
Handles efficient loading, caching, and management of models, textures, animations, etc. -
Multithreading and Performance Optimization
Implements threading models for culling, rendering, and other tasks to optimize performance.
Ahh yes just the engine
...those are all things that constitute the engine
Yes also all the things it needs because python alone can't do it
those dont implement anything specific for your game, when you want to make your game you can write the source in python
python (statically typed) could do it but it appeared than async engine of cpython is not a match for game engine use
The user codes in python it's not the same as the rendering done not by the user
Still can't do it now ;-;
Dk why ur coming up with theoreticals when the point I'd python as it is could not do panda 3d
Is*
it could i just pinpointed the problem
fyi i'm a bit into games engineS and cpython compilation
What??
python is a very versatile language, cpython is a general purpose implementation that try to satisfy the big nunbers, but nothing forbids you to make a python implementation dedicated to game dev
except maybe find some funding 😄
Can't do it at all or can only do it slowly? Because I am pretty sure with ctypes anything is possible.
a bit slower ( becxause integer range checking has a cost ) so i would try to use most of mypyc compiler
since the point would be to use python for game dev there would be no point trying to slap some python on a c/rust lib ( does not mean they should not be used later to make it more efficient )
Hey chaps
I'm doing a dungeon generator, visualizing in the console
This is an example output - with rooms and corridors and 's' for the entrance
What do you think? I dived into procedural generation
'r's are what, doors?
Gotcha. Looks good to me; it's all contiguous etc. Cool.
Thanks man, I appreciate it.
Not that it's an issue but I'm just curious, why have you made the rooms 2x2 ?
The best thing about this is that every layout is unique
This was just an idea of mine, to make the rooms more obvious - like whole squares or rectangles, not just a single cell
Oh okay makes sense
I imagined them that way
I can send some other layout if you guys are curious
it's just a script for now, lol
However, not every generation is good or perfect like these
How are you gonna actually implement it so you can read what rooms are next to the current ?
You mean how I've done the spacing between rooms?
ensuring that no rooms spawn on top of each other or next to each other - is this what you mean or?
This is cool! I should do something like this too, I often feel like procedural generation would come in handy so it'd be nice to learn
Thanks man, I appreciate that you guys liked this, this is actually my first project on this topic
https://github.com/anton-mirazchiyski/Procedural-Generation
This is the repository. Feel free to give me a star if you want and liked it and/or clone it if you want to try it.
Cool. The only thing that really caught my eye is 'position_is_available'.. the list of locations to check feels a little brittle. What do you think about this?
def position_is_available(row, col, dungeon):
for row_delta in range(-1, 3): # rows from row-1 to row+2 inclusive
for col_delta in range(-1, 3): # cols from col-1 to col+2 inclusive
current_row, current_col = row + row_delta, col + col_delta
if dungeon[current_row][current_col] != '#':
return False
return True
That way you can change the 'radius' of the check easily without having to update that list
I appreciate that you checked the code! And yeah that looks like a good improvement and actually I was thinking for a solution like this when I was making this function.
No I mean, when you are in the game, how are you going to track what part you are in and what parts are unloaded and when they should be loaded
I haven't implemented something like this in a game yet
How would you do it though, I'm assuming a dictionary of some sort
osu copy i made in python
Win11
just missing the nightcore music
and some other things
yup
Hello, I'm trying to have fun coding a rpg type game but I'm struggling with something. I'm learning so it's not well coded but I need someone's help pls (should not take long)
Sorry some names are in writen in french
lets MAKE THE GAMESS!!
It doesn't remove the item from the inventory
Oh cool!
Paste the code as text, not a screenshot
Ok
only the remove item part sir
I used this
ok
def equip(self,item):
if item in self._inventory:
self._inventory=[i for i in self._inventory if i != item]
olditem=self._equipement[str(item._kind)]
self._equipement[str(item._kind)]=item
self._inventory.append(olditem)
self.activate()
self._fakeinventory=[i._name for i in self._inventory]
does it change something ?
So I should write an unequip fonction then an equip ? I can do this but I don't see how that would change something
I think you are unequiping but moving to your inventory
I'm trying to 1 unequip the item 2 take the last equipped item 3 equipe the new item 4 put the old item in the inventory
im so confused you are removing the item from inventory then adding olditem
self._equipement[str(item._kind)] is the item which were equiped
yeah i would break that one function into more so that it's more clear
I'll try this
def unequip(self,item):
if self.itemInInventory(item):
self.removeFromInventory(item)
self.moveToInventory(item)
self.activateInventory()
I'll try this
as you can see if i group your code into functions it makes no sense
because your removing then adding it back in
OK
IT WORKS
Yours didn't but it's not your fault, without all the code you couldn't use the rights attributs etc..
But
I tried to separate equip and unequip
and it works
Tx bro
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
anyone know how to delete class object within a subroutine within the class
'delete' in what sense exactly?
One way is to just set the class attribute holding the object to None and let the garbage collector handle it
Python has a del keyword you can use but I suspect it's not what you want here given that sentence
the del doesnt work within the class
can you make us imagine a scenario where we must delete that object? code samples going to be helpful
flappy bird pipes
hit other side of screen
boom delted
i dont want to make 50000 objects
class pipes():
def init(self):
self.y = random.randint(100, 500)
self.x = 700
def drawPipe(self, Y):
pygame.draw.rect(window, (0, 255, 0), (200+ self.x, 200 + Y, 50, 500))
def pipeLogic(self):
#speed of pipes
self.x -= 4
if not self.x < -100:
self.drawPipe(self.y)
self.drttawPipe(self.y - 700)
ive got it to just not draw them atm
I am gonna assume that the pipes are an array of pipe objects, checking if the pipe is out of the window you could pop till from the list
and done it should not draw the pipe again
I may need more context than this
!paste you could paste the code here
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
@spring zealot You need to keep a handle on the rectangles you're drawing, IMO, so that you can clean them up, but maybe I'm missing something
I guess you're just moving the viewport and letting pygame clean up things that are off-screen? Sorry not a pygame expert
why container is an attribute of pipes, instead of being global?
I was the same case as you at some point so ye I totally get it
When you delete a Pipe you just need to do the reverse of self.__class__.container.append(self)
really?
!d list.remove yop
No documentation found for the requested symbol.
self.__class__.container.remove(self)
ye...
alr thxx
it will then get garbage-collected by the runtime
python bot doesn't have list documentation for some reason
del self?
doesnt work within class
In this case you don't really want del because it's an entry in a list you want to remove, IMO
no- I suppose that would error out
it doesnt, it just doesnt do anything
i tried lol
oh nvm, ye you are right it just deletes self from the variables
!e
cookies = 14
name = "tommy"
del cookies
print(cookies)
print(name)
another aproach could be reposistioning the pipes instead of creating and deleting
:x: Your 3.12 eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "/home/main.py", line 4, in <module>
003 | print(cookies)
004 | ^^^^^^^
005 | NameError: name 'cookies' is not defined
dude
they scroll ofscreen anyway
point is i dont want a super long ting
not that it matters cause its flappy bird but whatever
and i need to create lest i have only one on at a time
yeah i made mine with like just repositioning i had a set of 16 pipes that just reposition as soon as they hit the left border
lol that like doing
print("1")
print("2")
print("3")
instead of
for i in range(3):
print(i)
? its not
im saying its more effort than its worth to make 16 pipes and move them
takes like 4 lines to just make them
okay that's enough, we already found a solution and we should remember that everyone has their own creative solutions
there are thousands of ways of making code do the same thing frl
pipes = {pipe() for p in range(16)}
first DOOM now this: https://games.slashdot.org/story/25/04/05/2329252/microsofts-new-ai-generated-version-of-quake-2-now-playable-online
Microsoft has created a real-time AI-generated rendition of Quake II gameplay (playable on the web).
Friday Xbox's general manager of gaming AI posted the startling link to "an AI-generated gaming experience" at Copilot.Microsoft.com "Move, shoot, explore — and every frame is created on th...
reason why i had 16 was cause i made a stretched out flappy birds version where you can see the future pipes better was for a friend that was playing on a stretched monitor
horror
? do you not understand the implications of this?
triple AAA game studios are going to be extinct in 10 years when AI can generate a game from a prompt
true but i was trying to say to him that its not because its a different aproach that it will take more lines or anything but that he read it in that way is his thing 🤷♂️
I am still reading, when I read ai I immediately gone to "horror"
i've had the idea in my head for 2 years now and Microsoft has implemented it. kinda flattering...
also we never know
just go here: https://copilot.microsoft.com/wham
quake 2 like
puhleez! it's coming. if not them somone will do it!
i wanna work on it but just don't have the time....
there just something in humans that will beat AI. basically it feels much better if human wrote it than AI
how can humans compete with AI that can pump out 100 games per day? prompt driven. Make a Tekken clone...
triple AAA game studios will not exist soon!
there is a difference between a clone and a originall idea
creativity, those games are soulless, buggy, uncomfortable to play
presently, the tech is in it's infancy. it will get better to the point that you won't be able to distinguish between a triple-AAA studio game and an AI created one
Diffusion Models Are Real-Time Game Engines
Everyone's just going to be using AI to cheat in games
Some estimates are that up to 30% of online players are using cheats of some kind, just going to get worse as ai gets better
Triple a games pmo so bad
pmo?
per my observation ?
😭
That's a very good guess I'm ngl
yo guys
look at this physics engine test for my new ( in development) python package
Could you not have just sent the video 😭
aren't opening that
there is a lot of online websites you could use to post a big video
i know that's right. when I see a google-drive URL i run
which one/
tell me
cuz i dont know any other
more than 10 mb
discord limit
wait when u open a google drive it doest get ur computer hacked then why?
?
y
compressed it
to become 18mb
Youtube?
how is this tho?
Cool
how you do it?
Not like they can realistically do anything if you open it
thats wht
😭
are you sure this time is real?
Is it possible to create a path of an actor with python script in the unreal engine sequencer ?
What do u mean by that?
the time in physic simulation is really so fast
yea
it is in real time'
🙂
so why it's really so fast
its trying to replicate irl gravity
oh
nah
i think the video is corrupt
the video is playing a bit faster
it's
it loop 6 or 7 times and the video in only 20s
oh sorry about this
yea
thats a issue with code
the looping is
the rest is not
do you do this?
becuase is really cool
ik
its in python and cpp
buts it still has some issues
😭
like ur phasing through the walls
it's really really cool
i have to fix the charecter and position calculations
i love 3d things
but i hate math
lol
do you use glsl for this?
glsl is really greate thing for this
with nice shaders too
what you use?
nothing
its built from scratch
from 0
im planning to use external libs tho
other than standard libs
😭
i gtg now
this is amazing
3d is really hard
It's many many orders of magnitude slower than a GPU, so there are many tasks you'll need to offload.
But that's true of all languages that run on the CPU at the moment so it's just a matter of degree.
If I invested many hours into dev using python though, it wouldn't be wasted, correct? i.e. i could always port out problem areas at a later date to a gpu?
Yeah; the hard part of game design is the design, IMO, not using a language/engine
awesome, thanks man
distribution probably. porting to ps4, xbox, switch etc.
but if you only want to target the desktop, it's a solid choice. the limitation becomes your asset, team, design etc. as with any other game
you can checkout pandas3d, pyglet or pygame depending on the type of game you're making
also note, pyglet does offload the rendering the GPU
and same for pandas3d and its derivatives (ursina, etc.)
pygame normally doesnt, but you can apply post processing with moderngl. check out dafluffypotato on youtube to get a sense of what you can do with pygame
THANK YOU for this! Seriously the most helpful message I have received. Appreciate you
I made a 2D vector module I wanted to share with you guys https://paste.pythondiscord.com/RRIA
What are my options for graphics I can export to web? I've only really seen pyxel which is really nice but I'd like something more general. I would love to use raylib actually
What's the status of python raylib wasm? I checked in last year and there was something
In particular I found that you can run the main loop in separate thread in a python repl and you can keep using the repl while the game is running
Wrap everything in a try catch you can resume and it works fairly well, have to flesh it out
But I really want web export. I want to build a showcase of algorithms and whatnot on my website
Just found this
you have a test + CI setup to produce github page runnable here https://github.com/pmp-p/untitled-asteroids-pyray/
sound may glitch when switching/closing tab, resizing window can be funky. it's alpha stage
pygame-ce web is robust, Panda3D web close enough to beta
Ok I'll check it out, thank you
I like your code style, I should probably docstring everything more than I do
Your Timer reactivating itself is a nice functionality, I may borrow that idea
I usually reactivate mine at the end of the func being called if I want a repeat
not mine just looked into it to port on web for a pyray test
Yeah, I noticed, thanks for sharing anyway
guys how do i escape tutorial hell help meee
try making shit without tutorials
@pine smelt
hello?
Rewrote my Bumper class, much better https://paste.pythondiscord.com/FWGA
This is a bumper that goes inside robots and has a collision 'bumper' outside the robot. When the outer bumper touches a detectable wall, the internal bumper's port turns True (red to indicate it's on)
I'll have to change a couple of things since I'm just testing it without a robot yet
The tiles it iterates will have to change to those of the room that the robot is in, instead of the room it is in
can anyone give me a game idea to make in py
Tic tac toe, pong, space invaders
Space Pirate Trainer, if you want to be more ambitious
is even good for write comments inside code while coding ???
not to the point where there's more comments than code but it is good practice for larger blocks of code
especially if u need to quickly understand it when u look at it again weeks or months later
U mean like for complexed places in my code for write mini comments whats that function doing or line ?
yeah
oh i got it , thank you SH !
additionally, you can look at how to make docstrings for your functions, classes too which make them more readable
you can follow either numpy or google docstring standards
okay , thank you Balls
I made a module that treats physical dimensions like data types and allows you to perform operations with them https://paste.pythondiscord.com/C57Q
hey n
oki
Hey
I created a chess board with chess pieces in pygame. I could use some help on the math of calculating possible moves given a type and position of a selected piece. Thanks
I've done that before but it is difficult to explain. Each piece has a list of directions it can move as x and y pairs. Like for bishops, they move in angles so all four directions can be represented like so ```py
self.directions = [
{'x': 1, 'y': 1},
{'x': 1, 'y': -1},
{'x': -1, 'y': 1},
{'x': -1, 'y': -1}]```
So hard to explain, here's the video that showed me the idea, it's not in python but the logic is solid https://www.youtube.com/watch?v=fJIsqZmQVZQ
Finds all safe squares for all pieces of the current player in one method
It's not a simple matter
Is it possible to get something like either raylib or pygame to run from the REPL in a way that doesn't block it? What I'm looking for is the ability to make edits to a game live without having to restart
And have the REPL available both to send commands but also run anything I need
I tried starting the whole thing in a separate thread but not having a lot of luck
Ok, I got something working actually
This isn't bad
is it possible to use dearpygui + pygame?
i think so but probably it depends on what exactly need to be combined
My big refactor/rewrite is going great, sometimes I wonder wtf I was thinking when I originally wrote some of the old code
A lot of it has been total rewrite while referring to the old code
Got my antenna working fine. These are devices inside robots that have two ports, an input and an output. When the input is hot, the robot broadcasts a signal that can be 'heard' by all antennas. When any antenna hears a signal, it's output becomes hot. So one robot can send signals to all robots
I've made 5 channels. With four robots each broadcasting on its own channel plus the fifth, a global channel
And made receivers that can tune into any of the channels
So like one robot can be made to listen to only one other specific robot
hey guys how can I get some beginner help on desiging my chess game?
I've already coded about five or six files and a few hundred lines of code.
However, in order to add functionality, I'm going crazy trying to fit it all in my head.
I'd like to find a resource on what graphs I can draw to model my program and also how I can rubber-ducky more effectively and get out of the mind-blank I'm drawing on my chess game.
Did you happen to see the video I posted a couple of days ago? (I know it was barely relevant)
no I didn't, what's up?
Well, I have done what you're trying to do but I'd struggle a lot trying to explain it without using my code as an example, so I shared a video a couple of days ago of a tutorial using Javascript.
The first advice that comes to mind is to get your chess simulation working totally 'headless' first, so your tests are passing, you have code that knows how the pieces move, etc.. and then only then build a graphical view of it.
And I think for anyone kind familar with python and the concepts we use, js is pretty close, at least the logic explained in the tutorial is excellent
There's a standard syntax for chess moves, you could consider accepting that on STDIN so that your game can 'play' an existing match
or support like mychessgame -f ./some_chess_moves.txt
Then you could write tests that ran chess games and you could assert that they came out the way they should
right, I was tweaking the syntax because I wasn't sure my data structure was gonna work with the notation
https://www.youtube.com/watch?v=fJIsqZmQVZQ This is it, if I had one that in depth but in python, I'd gladly share it too
Learn how to code a chess game that can be played against another person or a computer, using the Stockfish API. The tutorial uses JavaScript and Angular, but you can follow along if you don't know Angular.
💻 Code: https://github.com/awsomeCStutorials/chess-game
Stockfish API: https://stockfish.online/
✏️ Course created by @RobertsTech...
Glad to help getting started with testing if that sounds interesting
The method he uses to find all safe squares is amazing
yes, defiler, I appreciate the general direction but I was just about to ask for some more invovled help
I would have never thought of how he did it
let's do it, sst, let me watch this soon
It's long, and complicated, but worth it, you seem quite motivated
thanks, sst, that makes me feel good!
I heard about some javascript apis like "chessjs" or something, but I was writing Python, not javascript
I could just share code with you but that kind goes against my own policy, I got great satisfaction of writing it in python myself
also, I knew it would be a challenge to jump right into a fully written library and try to grasp it
so I wrote some python from scratch that draws a chess board and no more
I implemented Stockfish for the CPU opponent, he's really good
Or for both players, in fact, so stockfish can play stockfish
Stockfish sounds really advanced 🙂
Implementing it wasn't terribly difficult
But yeah, it's a whole project to get allat working
If it's cool, I will @ you in #unit-testing to show some getting started pytest stuff, so we don't bore this channel
definitely @balmy pilot I should be free the rest of this afternoon
My chess project stalled at mass-undoing and redoing moves but everything else is working ok
Quick video of robot antenna. Orange robot gets its bumper output connected to its antenna so when it touches a wall, it's antenna sends signal. Blue robot gets antenna output connected to left thruster and moves to the right when the orange robot hits the wall
I meant white robot instead of blue, but we get the point, antennas working fine
That's so fun, I like writing the code as much as playing with it
that friggin cool, @limber veldt
Thanks, remake of an old game, so not my idea, just me writing it in pygame
That's just a little test level, a few items added to it, some locks (they work too)
A little sentry demonstration, won't let player pass but can sneak in a robot
My little periscope working fine too
Next code is for the robot grabber, so they can pick up items, making them even better bots
The game will also have blue sentries, indicating they can smart block meaning one cannot sneak past them in a robot, the sentry pins any robot with a player inside. Or even any robot with a robot with a player inside...recursively
The blue tile is a portal to level 2, the red crystally shapped tile is a crystal recharger. Because robots have a charge that gets drained as they use their thrusters and crystals can charge them, so I need something to charge crystals too
And the locks have two modes, can either be wide or narrow. Wide means the key only has to touch the lock to open it, narrow means the key must be places really close to the key shape in the tile
It is, it's basically a digital simulator wrapped in a puzzle game. The game has six levels of puzzles to solve
And some of them are over the top difficult
Has all the basic logic gates and the not versions of them, some flip flops, switches, all kinds of fun stuff
In fact, the sixth level is entirely secret, so forget I mentioned it, lol
Can only be reached by finding the secrets in each of the previous levels
Which is where all those colored keys come in, each level has one of them hidden in it somwhere
The original game was called Robot Odyssey published by The Learning Company in ~1985 for Apple2e. In 1999-2000, a guy named Thomas Foote rewrote the game in Java for play on (then) modern machines, which still works today, but I'm rewriting it in python just for the fun of it. The original game had only five levels, Foote added the sixth and I like to call that level "Robot Odyssey's revenge", that's how hard it is
I've completed Foote's version, that takes dedication
lol
Foote was crafty, his source code is on github
this was for the time pretty groundbreaking stuff. Ditto Pinball Construction Set, released a few years earlier for Apple II and other machines
Yeah man, before everything exploded, the internet and all
The company had another title called Rocky's Boots, it was the predecessor to RO
yes! I remember that one
Some said they were the hardest games of all time at the time, I don't think that's still even close to true
Pinball Construction Kit blew me away at the time. I remember coming home from the store with it.
Stuff that had been static in every game so far was suddenly under my control.
But I dunno, Foote's level six is still incredibly hard
Yeah man, I was just learning how to code in those days, writing basic and some assembly
Actually I should try building my own version of it
Then of course adulthood took over and my hobby remained just a hobby and still is
I don't know if I'm any good at it but it's a fun hobby
Yes, you should even if only for nostalgia
Old games are a never ending source of project ideas
Many of my own game projects were either recreations or inspired by
I should also do one for the excellent game Particle Mace. The developer passed away I believe, it's just been abandoned on Steam for years.
Have you done many games?
(Super clever game design though)
Not really; I did right in the beginning, as it's what made me want to learn to program.. but I then have lived a whole life without really doing it as part of my career or etc
How should I implement some type of recasting for my game
Right on, same here, I worked in mass transit for years
I've built media players and plenty of other GUI things but it's been years since I tried making a complete game
Yeah I will do this
Your Robotron is excellent, have you done many other games?
Xtaloid was the only other big one, but I also started on a snake implementation (why not!) that was also gonna be a shoot-em-around
My main limitations are time and attention; I have many other things going on that prevent me from really devoting myself :D
Yeah, time is not so much a problem for me as much as attention
The big thing I'm working on now is sorta game related, it's basically a mini-Discord but it's intended for use as a RPG chat system
Plus it's good to take breaks after some of the marathon sessions I get started on
It's been about a year since I "finished" this game but I wasn't happy with some of it
So consider the first one a test run, lol
Which is kind of nice that I don't have to work out every little piece of logic again but all of it is getting re-thought
"Oids" was amazing too, since I'm remembering old games tonight.
I don't remember that one
Vaguely a descendant of Lunar Lander you could argue, but it ventures pretty far from those roots
I guess it's more like a more-degrees-of-freedom Choplifter.
How do I make a map using pygame
I mean, I'm definitely not an expert, but one way is to make something with https://www.dungeonscrawl.com/ and then just import it into pygame as the background image for a view
(or https://inkarnate.com/ if you want a different style etc)
I've made a tilemap editor and it's on my itch page... Check it out if you need!
I'm using modern gl and I was going to use dearpygui to move the objects
but the problem is that dearpygui already has its own window system
and whenever I try to put dearpygui inside the pygame window, it doesn't work
you could try writing a class for the mathematical stuff
because you don’t need to do everything with one library
but like i said sometimes it depends in how and what you want to do
I want to make a game on my cell phone, I can?
Sure. Do you want to use Python, or do you not care?
If using Python, one way to do it is to use this https://kivy.org/
hey defiler, I'm back to ask for some help 🙂
@balmy pilot and other viewing eyes, please review my updated classes, now with defiler's advice taken and restructured and all that.
https://github.com/DustinWestGlow/Dustin-chess-game/blob/main/definitions.py
Please also review the tiny project as a whole because I refactored a ton to make it cleaner and with better practices like descriptive variable names.
Contribute to DustinWestGlow/Dustin-chess-game development by creating an account on GitHub.
Now, I'm asking for some help implementing the functionality. Currently, the game only displays a chess board. I want to be able to do two things.
- Play a chess game without an AI, just by clicking a bunch.
- Use a special "replay" mode where moves are made or rewind by using arrow keys.
Both of these features were partially implemented before the refactor.
Sure, let me take a look.
I would love to write another markdown file with these goals in mind and get some basic advice on how to plan on these features.
My main problem is my brain is blanking on how I would do this.
I also don't want to look at a pre-made chess engine code yet because I want to figure this out from scratch. Thanks.
OK so I would make a separate directory for the code to live in, commonly named src or the same name as your project, e.g. chess or radproject.. Your goal is to organize things into 'modules', where each module has a single responsibility that's easy to explain.
The main things I'd focus on are move validation and game state management.
By the first one I mean stuff like computing the valid moves for a piece, and checking that a move you're attempting is one of them.
By the second I mean stuff like remembering which player's turn it is, detecting check and checkmate..
Also I'd add a README.md to help organize your ideas/plans/status
you didn't like the /docs .mds?
That's cool, but there should be a README at the top level too
If you want to not write your own chess-move code, there's actually a library you could use https://python-chess.readthedocs.io/en/latest/
okay, for move validation, let's say I know the piece's soldier (king's bishop or pawn) and it's position on the board (3, 5). That should be enough to know whether I can make a move to a destination position (x, y). Because I can check that I'm not being blocked by my own pieces and may even take an enemy piece.
Here's kinda the TODO list that comes to mind..
[] Handle mouse clicks to select (first click) and then move (second click) pieces.
[] Validate moves either yourself or using a library like python-chess
[] Update the board after each valid move
[] Alternate turns between players
[] Remember a history of moves
[] Add a replay mode that can step through the history
Yeah, all you need to know is the type of piece, where it is now, and where it wants to go, and you can check whether that's a valid (x,y) for it.
cool, I didn't know if there was a hidden hang up
The more interesting question comes later when you're building your AI player; how do you take that definition and use it to get a list of all possible moves for a piece etc
well a "list of all possible moves for a piece", that should be easy, right? A queen might have a lot and a pawn a few so a single piece would probably be real easy to implement.
Is it that you want to state->action->state->action into the future to test multiple possible consecutive moves?
What's fun is trying to solve it more-efficiently than looping over every square and asking "is it valid for this piece to move there?"
The more moves ahead you want your AI to be able to plan, the more possible positions you have to think about.
But you can save that problem for later, certainly
I got two books and python game development as I'm whenever used a book by Jade L. rhodes
@tired reef are you talking to me? I love books!
Just in general
Is it this one? https://nostarch.com/inventwithpython
That series is always a fun read
gotta take a little break from making this game
phew, just been concentrating for too long
move validation is kinda fun so far
I can just write validation for one type of piece at a time and that way I can test my pygame every few minutes
I have that book
Just testing some things, player blocker walls that block player and robots if player is inside
Might as well grab that key while I'm at it
And of course, it's recursive so even if player is inside a robot inside another robot, it will still block
And, while the sentry is redundant in a room that blocks player from even entering, it works too, it pins player and robots with player inside
Need to move him to a room where he can do his job
@balmy pilot Device https://paste.pythondiscord.com/IGWQ still a work in progress on the refactoring but it's working
And Item just has interface behaviors, like picking up, dragging
Fun
The flip flop in action
Almost everything is subclassed from Item, even the player and robots. I thought about just extending the Item or Device classes with classmethods but the inheritance is convenient
I wish I could come up with a better way to make sprites with several components. One way is to draw those things on the sprite image like I do with the stems on gates. Another is create smaller sprites and update them at offsets from the main sprite
Do you have a "sprite group" sort of abstraction?
The robots update their external devices, those bumpers, antenna, grabber, as they move or are carried
Oh yeah, it's all I use, I rarely blit things manually
Groups make everything easier to manage
Multiple groups, in fact
OK, so isn't a sprite with several components just a group?
I could make a custom group for them...I think
Pygame has .sprite.Group()s and they're easy to subclass too
With the version I have now, I'm in a good place to change anything without breaking everything
where are you getting the sounds ? are you making them ?
U did u make drag n drop feature?
How*
Imma need to learn from you sensei
Awesome 😊👏
All items have this update method py def update(self, dt): if self.carried_by: self.rect.center = self.carried_by.rect.center + self.offset if self.selected: self.rect.center = Vector2(pygame.mouse.get_pos()) And I control that .selected attribute in the main game
So an item can be carried by the player or dragged by the mouse
When player presses space, he checks the current room for items within 100 pixels and picks up the closest one, assigning an .offset to the item and setting its .carried_by flag to self (the player)
This way, when something is carried, it remains in the same position relative to the player as he moves around
In main, when right clicking, it checks the current room for .grabbable items (most things are .grabbable = True) under the cursor. If it find one, it sets the item's .selected to True
Actually, all items have a grabbable and a mousable flag that can handle these interactions
Grabbable means player can pick up, mousable means mouse can pick up. Picking up wit mouse is a game hack, and probably won't be in the final version for any items
Too easy to cheat with it, but fact is, I don't really care if anyone cheats
Like, one could just edit the code to change anything they want
So how much effort should be spent on anti-cheating...not much
I could just turn it off for items and leave it on for devices to keep circuit editing and building easy
But things like keys wouldn't be mousable
The cool thing about carrying vs mousing items is that even if you mouse a key onto a lock, the lock won't open. All items only interact with the world when carried by something and that something is moving
Every time player moves (and robots) they check the room for collision with tiles (walls) and if they're carrying something, that gets checked too. This way carried items can affect walls
As for dropping, in main I have a .active_selection attribute that gets set True when an item is picked up with right click. When left clicking, I check for active selection, if there is one, set its .selected flag back to False so it no longer follows the mouse
What's convenient about this way is that the mouse can carry multiple items at the same time. Like hover, right click, hover another, right click, and both items will stick to the cursor. Which is handy for recycling old circuits, just mouse all of the devices and drop em in the trash
Called from my left click event ```py
def drop_active_selection(self):
if self.active_selection:
room = self.level.current_viewer.room
items = room.room_items.sprites() + room.room_devices.sprites()
for item in items:
if item.selected:
self.handle_mouse_drop(item)
def handle_mouse_drop(self, item):
if self.trash_can.sprite.rect.collidepoint(pygame.mouse.get_pos()):
if item.can_be_recycled():
item.recycle()
item.selected = False
self.active_selection = None
else:
item.selected = False
self.active_selection = None```
The recycle bin only appears when hovered in the lower right of the screen
Suit case cannot be recycled
Nor can crystals
Only devices, those things from the toolbox
The suit case has a room inside it that the player can enter. So it's a basic inventory system. Since player can only carry one item at a time, if he puts items inside the suit case and carries it, problem solved
So in this way, one can carry many things at once, even to a different level (from level one to two here)
The level progression here is linear, in the game, one cannot teleport to previous levels, but I can for testing things
Well, I'm to the point now where I can start rethinking how to save and load levels
Mostly how to deal with robots inside robots
I think I'll parse all the rooms of a level first, saving the attributes of any robots found in those rooms (robot type, position, room number that it's in) and these will be the roots of recursion to populate their rooms
the design reminds me of some old game
Oh yeah, it should, it's an old game, it wasn't super popular but was a fun game
I played the year 2000 version, but it was orginally made in 1985 or so
import direct.directbase.DirectStart
#load model
panda_model = loader.loadModel("models/panda") # loads panda model
panda_model.reparentTo(render) #render model to the scene
#spins camra around model
panda_model.hprInterval(5, (360, 0, 0)).loop()
#set camra positions
base.camera.setPos(100,-50,0)
#points camra to model
base.camera.lookAt(panda_model)
run()#runs game
how do i make the model smaller?
Because the camera is inside the model if you run the code in the basic python IDE
Just bumped into this again after years, still very good https://www.youtube.com/watch?v=Fy0aCDmgnxg
Try the game here: http://grapefrukt.com/f/games/juicy-breakout/ (ESC for menu)
Fork us on github: https://github.com/grapefrukt/juicy-breakout
"A juicy game feels alive and responds to everything you do
tons of cascading action and response for minimal user input. "
Big thanks to Niklas Ström for making music and sound effects for us and to ...
Can someone please link me to an explanation or explain to me how game engines utilize the gpu? I know there cuda and RockM and stuff like that, but game engines work with almost anything, meaning I can run a game with my Inter/AMD iGPU or any other GPU. How is it done exactly? I’m asking here because this is the only programming server I’m familiar with lol
There are several graphics APIs, CUDA and such are just for general purpose computation on the GPU (GPGPU). Others are for rendering and also may have some general purpose compute part (most do now). These APIs include things like OpenGL, Vulkan, DirectX, and Metal.
Some are specific to a certain operating system, others are meant to be cross platform. And APIs like CUDA are tied to specific hardware.
There are also some things like OpenCL, which can be used to do GPGPU, but can also run on the CPU or other hardware (e.g. FPGA).
Overall, the state of GPU programming is a big mess, so we have libraries built on top of these so you can write portable code. These include things like https://github.com/bkaradzic/bgfx .
Game engines also are like this, they internally use various APIs depending on which platform they are on / what is available.
Some may use bgfx.
This is also why game engines often have their own custom shading languages, they want the user to be able to write shader code without having to worry about which specific underlying APIs are used.