#game-development
1 messages Β· Page 36 of 1
Watching videos is where I discover a lot, but learning it is all hands on keyboard
not sure if I want to use pygame event for anything other than mouse and button input, seems too complicated
That's pretty much all I use it for, when I need a timer, I usually use a Timer() class or just accumulate dt in a variable
It's not complicated but it does make things harder to follow. Depends on your needs. Firing off events is a great way to reduce decoupling between objects
I need to have a turn-based system with time units, and once the value of a unit has counted down to 0 it's their turn
a timer's probably the better way to handle that
and just makes more sense in general
what does decoupling mean
It means making stuff not depend on stuff
basically π
Real-life example is in my game (small plug: https://store.steampowered.com/app/3122220/Mr_Figs)
there are pressure plates.
Originally I had a pressure plate class and I'd inject the "spike" class of the spike it triggered into the constructor of the pressure plate
Now I do don't do any of that. Now, it takes a list of id's of sprites to toggle.
It's still coupled slightly but less so
The issue with blitting the enemy is that you're passing enemy_list directly into screen.blit(), but screen.blit() requires a specific Rect position, not a list. You should iterate over enemy_list to get each enemy's Rect and blit it individually. Try this inside your game loop-
for enemy_rect in enemy_list:
screen.blit(enemy, enemy_rect)
This will maek sure that each enemy is blitted at its respective position.
did the game require a rewrite for steam?
Nope, why would it?
Most games on steam aren't released as python/pygame source code. I see this game isn't yet released but still, the question is, in what form will the release be?
Ah I see what you mean.
For windows it'll be frozen as an .exe and you'll just run that
I'm pretty sure pyinstaller can do the same for Linux too so I'm hoping to bundle a single executable file on Linux rather than a bunch of scripts.
To be honest I haven't looked into it fully but I'm not too keen on just having the source fully available once purchased
hey guys, i am having some proplems with some microbit code, i have tried so many things to try and get this to work but nothing is working, this should be such a simple thing. if you guys can help at all please do, this is for a assesment where i am making space invaders on a micro bit but the most basic movent isnt working (dont mind the uncalled variables they will be used later) heres my code (from microbit import *
from random import *
screenreset = 2
flyerposition = 2
flyerhealth = 5
reset = 0
display.set_pixel(flyerposition, 4, 9) # set dot in middle
while True: # start game loop
screenreset = flyerposition # set screenreset to red dot last position
if button_a.is_pressed():
sleep(200) # debounce button
flyerposition -= 1 # set new position for dot 1 pixel left
if flyerposition < 0: # make sure it doesnt overshoot
flyerposition = 0
display.set_pixel(screenreset, 4, 0)
display.set_pixel(flyerposition, 4, 9)
if button_b.is_pressed():
sleep(200) # debounce button
flyerposition += 1 # set new position for dot 1 pixel right
if flyerposition > 4: # make sure it doesnt overshoot
flyerposition = 4
display.set_pixel(screenreset, 4, 0)
display.set_pixel(flyerposition, 4, 9))
yoooo
yoooo
!pypi ursina
idk, does the game have a visible background? if you always set the screen to match where the flyer is it could look like no movement.
or maybe something about the button functions
maybe try printing something as test if a button is pressed to see if that works
I'm not exactly sure how I want to treat enemies that are on adjacent dungeon levels. Being able to follow you if you went to another floor while they were right next to you, most likely.
but also moving around and maybe even changing floors sometimes while not directly next to player
Hey guys I made this over a year ago, well I started the project. But i was wondering what you guys thought of the idea? https://github.com/plunder707/Aithera
Aitheria: Code & Chronicles - A New Dawn in AI-Powered MMORPGs - GitHub - plunder707/Aithera: Aitheria: Code & Chronicles - A New Dawn in AI-Powered MMORPGs
I think it's a fine idea, looks ambitious
!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.
Hi everyone! I did my 3D engine with Pygame, made the movement but when I tried to do the camera rotation like in a first-person game, it did like in a third-person game and I can't figure out how to fix it.
I would be very happy if someone would help me as fast as possible.
My code: https://paste.pythondiscord.com/NCFA
It seems like the camera is roating around the objects instead of the FPS perspective you want. Try this
# Π‘Π΄Π²ΠΈΠ³ ΡΠΎΡΠΊΠΈ ΠΎΡΠ½ΠΎΡΠΈΡΠ΅Π»ΡΠ½ΠΎ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ ΠΊΠ°ΠΌΠ΅ΡΡ (ΡΠ΅Π½ΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ² Π²ΠΎΠΊΡΡΠ³ ΠΊΠ°ΠΌΠ΅ΡΡ)
x -= camera_position[0]
y -= camera_position[1]
z -= camera_position[2]
# ΠΡΠΈΠΌΠ΅Π½ΡΠ΅ΠΌ ΠΏΠΎΠ²ΠΎΡΠΎΡ ΠΊΠ°ΠΌΠ΅ΡΡ (yaw ΠΈ pitch) ΠΊΠΎ Π²ΡΠ΅ΠΌ ΠΎΠ±ΡΠ΅ΠΊΡΠ°ΠΌ
cos_yaw = math.cos(math.radians(yaw))
sin_yaw = math.sin(math.radians(yaw))
cos_pitch = math.cos(math.radians(pitch))
sin_pitch = math.sin(math.radians(pitch))
# ΠΡΠ°ΡΠ΅Π½ΠΈΠ΅ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ² Π²ΠΎΠΊΡΡΠ³ ΠΎΡΠΈ X (pitch) - ΠΎΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΠΏΠΎΡΡΠ΄ΠΎΠΊ!
rotatedY = y * cos_pitch - z * sin_pitch
rotatedZ = y * sin_pitch + z * cos_pitch
# ΠΡΠ°ΡΠ΅Π½ΠΈΠ΅ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ² Π²ΠΎΠΊΡΡΠ³ ΠΎΡΠΈ Y (yaw)
rotatedX = x * cos_yaw + rotatedZ * sin_yaw # ΠΠ·ΠΌΠ΅Π½Π΅Π½ΠΎ: + Π²ΠΌΠ΅ΡΡΠΎ -
rotatedZ = -x * sin_yaw + rotatedZ * cos_yaw # ΠΠ·ΠΌΠ΅Π½Π΅Π½ΠΎ: - Π²ΠΌΠ΅ΡΡΠΎ + ΠΈ ΠΏΠΎΡΡΠ΄ΠΎΠΊ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ
# ΠΡΠΎΠ΅ΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠΎΡΠΊΠΈ Π½Π° ΡΠΊΡΠ°Π½
xscreen = int(rotatedX * (fov / (fov + rotatedZ + 1)) + centerX)
yscreen = int(rotatedY * (fov / (fov + rotatedZ + 1)) + centerY)
return (xscreen, yscreen)```
Also I know Russian, its cool. But Slave Ukraine.
It's the same problem, but now the objects can rotate around me also on the Y axis
!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.
Try this. I ran it seems to work. Is that what you're looking for? https://paste.pythondiscord.com/2SRA
Try this
use code bar ```
you can clearly see that it's still a third-person view
And it seems like you are chatGPT generating it, I tryied soo but chatGPT made the same mistake
so yeah, don't generate the code
honestly it looks funny
try ask in #1035199133436354600
I'd like to see the answer too
The generated code i pasted doesnt do that.
I'm not sure what you're doing, but I didnt get that exxpereince you're seeing in the video.
Maybe the issue is something else.
can you record a video of your expirience?
I tryied, 4 times, no one answered and it's annoying to recreate the post every hour
are you rotating the camera at 0,0,0 and then translate it to its pos ?
Try this, it seems to work better but its hard to test because of my juypter env i think. ```def create_point(x, y, z):
# Shift the point relative to the camera position
x -= camera_position[0]
y -= camera_position[1]
z -= camera_position[2]
# Apply inverse camera rotation (use negative angles)
cos_yaw = math.cos(math.radians(-yaw))
sin_yaw = math.sin(math.radians(-yaw))
cos_pitch = math.cos(math.radians(-pitch))
sin_pitch = math.sin(math.radians(-pitch))
# Rotate around Y-axis (yaw)
rotatedX = x * cos_yaw - z * sin_yaw
rotatedZ = x * sin_yaw + z * cos_yaw
# Rotate around X-axis (pitch)
rotatedY = y * cos_pitch - rotatedZ * sin_pitch
rotatedZ = y * sin_pitch + rotatedZ * cos_pitch
# Project the 3D point to 2D screen space
if rotatedZ != 0:
xscreen = int(rotatedX * (fov / (fov + rotatedZ)) + centerX)
yscreen = int(rotatedY * (fov / (fov + rotatedZ)) + centerY)
else:
xscreen, yscreen = centerX, centerY # Handle division by zero
return (xscreen, yscreen)```
nah it's the same
Im sorry i guess i'd help if I could could move the camera and FPS view around. Its all over the place
I think yeah
might want to pop in main chat and notify some people
how do I know who to mention
@vagrant saddle
just say something like "can anyone help me on #"
it works sometimes for me
have u said collision on the camera and the floor?
i think it just literally goes thru the floor i think
that's not the problem
maybe try anchor it.. like locking it in one fixed place.. idk what to say
I can't figure out how
the thing is that you're doing it raw
so uh idk
if ur using like unity or godot it should have options for it
Hi all. I recently developed a 2D roguelike(very early stages but playable) using pygame in python along with custom music. Now I am not sure how to make it online so others can play and review on it. Can anyone guide me through the process or link me to a place I can study about it? Thank you.
I structured the code in pycharm IDE.
I too am working on a roguelike (absolutely unplayable lol)
I wanted t o make a game that uses https://gitlab.com/2009scape The runscape sorce code, but I wanted to implement my AI idea in the mechanics.
how to run this?
Sorry, it was a private repo. its still under construction, but I'd like to get the project rolling. I was starting to flesh out the files. But its a big job.
Worked on some gelatinous blob hazards today
Didn't get loads done today however. Working on a new trailer and it's sucking precisely 100% of my free time
looks awesome
I've just been refactoring again. I had all behavior of picking up and moving pieces in main, including that for both human and ai players, with conditions for switching between them. Have now moved all that behavior into a NewPlayer() class having generic player behaviors which I subclass for HumanPlayer() and AIPlayer() with each of those having specific piece handling behaviors. I think it makes more sense now, at least to me
So now in main, I just have a callback from each of the players (human and AI) to trigger the player change, then call the next player to play()
Main just does some bookkeeping, like adding the move to the move list, so got rid of a lot of code there, which was kinda the goal
Checks for game over and stuff
The artwork is awesome too, is the movement grid based?
It is grid based but still kind of smooth. You can hold a key down for example and you'll just keep travelling until you release, at which point you'll be taken to the nearest tile.
Hoping it doesn't put people off as I know it's not super common
it's like old pokemon works, seems fine
Yeah that and bomberman were my gotos for inspiration on that front
Speaking of the trailer, I just finished it. Simple but gets the point across I reckon
https://www.youtube.com/watch?v=ok3-NbCYyW0
The latest trailer for Mr Figs
If you like what you see, you can follow the progress and wishlist it on Steam here:
https://store.steampowered.com/app/3122220/Mr_Figs/
Discord
https://discord.com/invite/KndkA3BGXv
#gaming #mrfigs #solodev #indiedev #topdown #python #pygame
No man, seems fine and kinda necessary in a fast action game else it'd be hard af
can someone try my game and see what they think of it? And most importantly report any bugs
Sweet that's a relief. Thanks!
I'm wondering if it'd be worth the effort to create some sort of command system that oversees a command queue. Like I kind of already have that but not quite like a master queue, each player handles its own behavior and sets states of pieces by calling methods to trigger state changes. Like if piece is to move, player calls its get_moved() method with a square to move to, so get_moved() is basically a command but it's not queued
For normal play, human vs bot, totally unnecessary
coded this game on TechSmart with the theme of "world improvement." the idea is that you play as a robot that collects acorns (it looks like a bird) and can swap out at any time with a robot that collects rain. the seed bot can plant acorns, which become small trees, and the water bot can use rainwater to grow said trees. this is a work in progress. what are your thoughts on my work so far?
thats really cool
i really like the idea too
thx
i just finished adding the storage system
the seed bot can now carry only up to 9 acorns at a time
nice!
yeah this is a pretty unique idea you could really build on this concept
its definitely paying off
@hardy magnet
thats the neat part
i actually DIDNT use OOP!
i made the entire thing without using OOP once
nice
im a huge functional programming shill too
learning OOP is good though id look into it eventually
yeah i am
i just started learning about it today
but i dont rly wanna risk breaking my code like i have 239020293 times already sooooooo yeah
thats part of the process sometimes
you could always start a new project for the sake of learning OOP if you want
well ig yeah
when this is finished ill try reworking the code into oop as a separate project
oop is something like this right?
@hardy magnet
Yeah, classes and stuff
yep
guess if i used OOP in my program
1
1
1
yes, you used OOP
π
No. Can you send me the invite? I would love to connect.
I would play that.
Which IDE are you using?
vs code
yoo
I recieve the same problem everytime, Can someone try figure out what's wrong with it? Is it the code that i did wrong or did i forget to insert something in the code?
The code checks if the password was "password E7EN5", but you entered only "E7EN5"
Ok thank you for that.
great. Can I see some glimpses ?
Thank you s much
Just finished my first ever game without a tutorial. the code is very shit but it has exactly 100 lines which is cool. Anyone got any ideas that I could try and add?
my recording software makes it look jittery the game actually runs fine π
Very cool, I hope it was fun!
I need help making a main character class for painting that allows the user to pick a race and customize their character for a game I'm getting out the player out of the way so the world building can come in second sorry
That looks really fun
It was duper fun to create. Im mainly surprised i actually managed to make it. Im learning
Thanks, good old pong
Haven't played that in a while
Hi, I have tried to look up for a way to organize folders in games, but whatever I tried to find nothing appears is there a general way devs do to organize folders or is it just something you figure yourself?
depends on the person but a way I've found pretty intuitive is having in the main directory
-assets folder
-audio folder
-data folder
-scripts folder
-main.py
in the main.py I have the main "game object" that has the update loop and I organise the scripts by having subfolder for a group of similar stuff
so I'd have for example a folder called particles, a folder called entities and sometimes subfolders within that (e.g. having a folders for players, and another for enemies, WITHIN the entities folder)
Hey y'all, I'm working on this simple RPG videogame where you battle others' animals, and this is what it looks like so far.
What do you think?
For my chess, I did...
-Assets folder < contains sounds folder, images (in multiple folders sorted by categories),
-code folder < has all scripts including players.py, pieces.py, groups.py, board.py, main.py...etc
-stockfish folder < contains stockfish.exe
-saved_data < all saved settings (from the Save Settings button)
looks great so far the ascii art is rly good
Not for this project, for some I have
I feel like the A's seem a bit squashed but still readable
I did try something a little different with this one. Instead of instancing screen and images in main like I normally do, I instance SCREEN, and a few other globals, and load images in game_setup.py then import them where necessary
I like that it gets all the image loading out my way in main
i usually do that in the initilisation of my game object
i have a function called cache_sprites that i run before the main loop
well that in itself calls the cache_sprites class method of every object i need to load the sprites of early
Isometria Devlog 50 - Mother, New Items, Better Weather, Better Saves, and More! https://youtu.be/5xCwcKujZXc
Wishlist and play the Isometria demo here: https://store.steampowered.com/app/2596940/Isometria
https://bigwhoopgames.itch.io/isometria-demo
In Today's devlog I show you the newest boss added to Isometria, Mother. I'll also preview some of the gear you can get from her as well as mention various improvements to the game like weather and saves....
here are some cool ascii spaceships I made in python
They look really nice
I love it
thats amazng how long did that take
maybe like 2 hours to make the text and 2 hours to colour them?
I like your pfp btw lol
Basic saves working, level, position and state of the walls
elo im a bit of a beginner at python + game development in general
here's some random stuff I coded for my text adventure game
that's sick dude. i'm a beginner too and i've never thought about putting my class objects into a dictionary before. i'll probably implement that into my own stuff now too
Mostly using it so I can easily reference the stat for the respective protagonist without having to make a long list of if else statements
what is the .rpy extension?
renpy script file
The game engine has its own language but also uses python
have you made the rooms for all of the coloured keys
also suggestion from a game point of view, after u put the key into the lock thing some sort of screen shake might be useful
tho it depends on where ur going with this
Yep, missing are the sentries guarding the keyholes in that level though (deactivated them for testing)
You're not supposed to be able to walk right up and drop the key through the wall, so the sentries prevent that
But that is a great idea, some visual feedback that a wall or gate has moved or opened
That lock is actuallty a little difficult to not lose a robot once the guard is in place, making saving the game very important
You need a robot that can find its way to and park right between the two fans and thrust both left and right at the same time, spinning the fans and opening the walls above the keyhole where a second robot can enter (by itself, no hiding inside it because of the sentry) with the key in its grabber and drop it when it reaches the keyhole
The puzzles in that level are meant to be hard af
It's the super secret sixth level
I spent weeks solving the purple lock the first time
And you also need to make sure you can get your robots back, other locks may need multiple bots
So many mechanics in that game, like every puzzle is a different set of them
how long have u spent on it so far
i cant imagine how long it would take to connect every puzzle together
Total time spent making the game? Oh man, a lot, hundreds of hours for sure
sounds about right lol
The first screen in the video, at like 2 seconds, is all items in the game, too
is that like a debug room or something
Not counting things from the toolbox (gates and devices like that)
Yeah
That whole level is a test
there are multiple levels?
Yeah, 5 regular and the super secret sixth plus the lab and about 8 tutorial levels, so about 14 total
Hello.
Hi
Walkthroughs of all the gates in one level, sensors in another, and so on
Robots, Circuits, Chip burning, all kinds of em
And the saves are level based, such that if you save in level 5 only that level is saved, for instance
Over 400 rooms total, nearly 500
And why it's my most ambitious project
After playing the game, one will definitely understand digital logic at some basic level at least
I have a playlist of me playing the 2000 remake (made in java) start to finish on my youtube, but I'll keep that secret for now : )
game called legend of moth i made https://pastebin.com/KwuhjHGg
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.
i added objectives now! any objective ideas? i want to get 5+ levels into my game
maybe you could add some type of upgrade system like better / different trees that give more points
and a currency system to purchase the upgrades
hmm maybe!
for now, any simple ideas? maybe i can add a speed boost to make it easier to catch falling acorns
"simple ideas" meaning things i can add to the objectives list
yea maybe i could use points as currency (i'll make them available after level 2 of course XD)
Waiting for points to accumulate before spending it all on an upgrade is a bit annoying sometimes
yeah
anyway, got anything?
maybe an objective to stay alive for x seconds?
you could also do it like
plant 3 trees
plant 7 trees
plant 15 ... ... to like 100 or something crazy
so its like continuous
so maybe catching x acorns in a row?
yeah that could be a good one too
actually, the game resets after each objective
oh i see
i also added fires too
they deduct 0.1 points a second
and you do not gain any points
while a fire is active
you also cannot pass the objective if a fire is active
mabye you could store the users stats in a text file so players can keep their scores and stuff
whats ur thoughts about this addition?
the theme IS world improvement soo...
ohh wait i just had an idea
i can make the first 3 levels a tutorial
the first one is "plant three trees" and the second is "grow three trees" and the third is "extinguish three fires"
oh yeah good idea
maybe a bossfight?
against a fire guy who shoots fire, and you have to counter it by shooting water with the water bot
and if you manage to hit the boss x amount of times you win
maybe that can be the final level
i already found some techsmart sprites for the boss, as well as the arena
maybe we can give the seed bot a role too but idk how thats gonna work
@hardy magnet this is what i got so far
(Water and fire CANNOT spawn during level 1.)
(Acorns and fire CANNOT spawn during level 2.)
ooh very cool
still need to make one about extinguishing fires
will make around 3 fires spawn in and then only water can spawn after that
added crystals to the game now
crystals set your Growth Points (GP) to 3
now, when an acorn is planted, it is automatically grown to a big tree in exchange for 1 GP.
if the player has 0 GP, then any acorns planted will become small trees.
depends on ur game
Hello guys Iβm just getting started with python /pygame
I need some help In creating a username passird screen
DND style
do you have a screenshot of the game so far, im not sure how DND games look
what do you have so far
I have drawn the rect for the username and password and have the headers for each box
Now I am trying to figure out how I can type in the box and validate the input
But canβt
live typing is tricky, u sure u cant use tkinter for that part
What is tkintr sry Iβm new to this
tikinter is a user interface thing, it has textboxes, entryboxes, dropdown menus, things like this that you can build and use. I wonder about pygame_gui though, I haven't really checked that out so I don't really know what it can or cannot do
No I'm working on the basic mechanics first before I figure out how to do the main game for the players class and race for dragonborn etc
What is the best package for game development?
Pygame
pygame-ce, almost the same thing but the Community Edition of pygame
Im wondering on how I could go about making a map in pygame, like using blocks and placing them around in a specific order
Ive seen methods where people use something like this:
",""x"
Like , being an empty space
and x being a sprite
but no idea how to do this so if anyone knows please tell me how
How can I assign specific traits to what I want for in a game because I want to make it warm if you choose an Archer as a class you're able to shoot arrows but for warriors you would have to learn that trait
class mage:
def __init__(self):
health = 100
mana = 50
can_use_mage_progectiles = True
defence_spells = []
attack_spells = []
heal_spells = []
traits = {}
buffs = {}
debuffs = {}
```
Is this okay for a game class
searching for people that wanna code a recoil compensator for all types of games... DM me if ur interested !!!
I'm not yet I'm working on the player class but I want to make it where it's customizable you have mage etc anytime during the races which would be dragonborn human halfling elf and dwarf
what does it mean by "all 4 fields"
TypeError: Invalid rect, all 4 fields must be numeric
Make sure you're passing exactly four numeric values, such as integers or floats, in the correct order
For example: rect = (x, y, width, height)
Each of the four values (x, y, width, and height) is numeric (integer or float).
No fields are missing or None
for index, zombie in enumerate(self.cur_zomb_wave):
direction_x = self.player_pos[0] - zombie[0]
direction_y = self.player_pos[1] - zombie[1]
distance = (direction_x**2 + direction_y**2) ** 0.5
if distance != 0:
direction_x /= distance
direction_y /= distance
self.cur_zomb_wave[index][0] += direction_x * zombie_speed
self.cur_zomb_wave[index][1] += direction_y * zombie_speed
zombie_pos = [
zombie[0] - self.camera_offset[0],
zombie[1] - self.camera_offset[1]
]
self.screen.blit(self.zom, zombie_pos)
Hey guys! I am new to pygame and I found this sample code to move an object towards a moving player, but when i try it, the objects just accumulate at one point after a few seconds and collectively move towards the player, i kinda want them to spread out and like encircle the player, if that makes sense? Thanks π
Hello, I was interested in this topic around 4 years ago, I was making games for terminal, but I implemented color images.
I can share code if u need, but I am sure most part is unreadable.
What you mean ?
sounds like selling cheating program for various fps
i dont wanna sell anything, i just wanna learn methods cheaters use for my future anticheat
if you want to learn that kind of stuff : go write a C compiler / work on a risc assembly vm or wasm relooper you will learn as much : you will be legit and get a job
still R/E on a licensed cheat ( yeah even virus/cheats can be (c) work ) can be illegal in some countries
Am I able to use a class for my game?
#===[imports]===#
import pygame
import numpy
#===============#
#===[inits]===#
pygame.init()
#=============#
#===[window dimentions/ ect]===#
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 500
pygame.display.set_caption('eden')
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
#==============================#
#===[classes]===#
class races:
pass
class classes:
pass
class player(races,classes):
comanions = []
inventory = {}
pass
#===[monster classes]===#
class monster:
pass
class vault_monster(monster):
pass
#===============#
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
Here's my code I'm working on the classes first before I get into anything of the true game
@pine smelt
I dont see why not. Maybe try to put these classes to seperate files for readability
How can I make it so that tracks the player? Sorry
What do you mean?
So having them have their own python file?
Yea
You can input the player position to the functions's arguments
I've never done anything I like this so I don't really know how to use it sorry
Try learning from this video: https://youtu.be/2gABYM5M0ww?si=TinUvJSbBDJJkfBX
Making a platformer with Pygame is a fun way to learn both game development and software engineering. This tutorial covers a variety topics including tiles, physics, entities, particles, sparks, camera, parallax, enemies, AI, combat, level editing, level transitions, making executables, and more!
Project Reference Resources:
https://dafluffypot...
It is may be overwhelming but it is very easy to understand
You will get the basic understanding in that video
Thank you
I think the easiest way to track a player (or any object) is 1: get vector from chaser to chased, that is vec = chaser.position - chased.position. 2: Normalize that vector. 3: set it as chaser.direction. 4: update chaser position. chaser.position += chaser.direction * chaser.speed * dt
A most basic demonstration ```py
import pygame
from pygame import Vector2
screen = pygame.display.set_mode((400, 400))
CLOCK = pygame.time.Clock()
FPS = 60
class Chaser(pygame.sprite.Sprite):
def init(self, pos, group):
super().init(group)
self.image = pygame.Surface((40, 40))
self.image.fill('red')
self.rect = self.image.get_frect(center = pos)
self.direction = Vector2()
self.speed = 200
def update(self, dt, target_pos):
direction = Vector2(target_pos) - Vector2(self.rect.center)
direction.normalize_ip()
self.rect.center += direction * self.speed * dt
enemy_group = pygame.sprite.Group()
chaser = Chaser((200, 200), enemy_group)
while True:
dt = CLOCK.tick(FPS) * 0.001
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
raise SystemExit
screen.fill('black')
enemy_group.draw(screen)
enemy_group.update(dt, pygame.mouse.get_pos())
pygame.display.update()```
As with most of my quickie demos, pygame-ce required (for the get_frect() as opposed to regular pygame's get_rect() otherwise, we need to cast the chaser rect center ints to floats, do math on them, then assign them back to chaser rect center
Same thing but using get_rect() (this time with ZeroDivisionError checking before the vector.normalize_ip()) ```py
import pygame
from pygame import Vector2
screen = pygame.display.set_mode((400, 400))
CLOCK = pygame.time.Clock()
FPS = 60
class Chaser(pygame.sprite.Sprite):
def init(self, pos, group):
super().init(group)
self.image = pygame.Surface((40, 40))
self.image.fill('red')
self.rect = self.image.get_rect(center = pos)
self.pos = Vector2(self.rect.center)
self.direction = Vector2()
self.speed = 200
def update(self, dt, target_pos):
self.direction = Vector2(target_pos) - Vector2(self.rect.center)
if self.direction.length() > 0:
self.direction.normalize_ip()
self.pos += self.direction * self.speed * dt
self.rect.center = round(self.pos.x), round(self.pos.y)
enemy_group = pygame.sprite.Group()
chaser = Chaser((200, 200), enemy_group)
while True:
dt = CLOCK.tick(FPS) * 0.001
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
raise SystemExit
screen.fill('black')
enemy_group.draw(screen)
enemy_group.update(dt, pygame.mouse.get_pos())
pygame.display.update()```
Notice how I use self.pos, a vector using floats for .x and .y attributes, as the position of the chaser instead of its rect.center. That's because get_rect() only supports ints and doing physics with ints is not precise enough, it loses the decimals on every update
Been working on some sneaky hidden rooms today
Oh nice, gotta have some hidden areas, very cool
The music, the graphics, the movement, it's all good
Thanks, it was actually super easy to do
The mechanics look like they're working great too
Hah yeah it's getting there. a year or two left I think. It's been a slog π
That's what I'm lacking in my robot game but it'd have to be less 'actiony` kind of music, maybe I just leave that to the player to run their own music
Yeah, if you can catch a good opportunity, humble bundle do some good music/fx asset packs
I never think of using steam for assets, I should check it out the next time I need
For my second ever pygame project I wanted to make a clone of the classic fruit drop game where you catch falling fruit. I learnt about using random here and worked out how to use buttons and a game over screen I think it turned pretty neat!
I messed up the button placement during the recording somehow π€£. If anyone is interested in seeing the code let me know I can dm it
Oh yeah, if anyone has an idea on what I could do next as a challenge/project please let me know! (im still a beginner about 2 weeks in so dont make it too difficult pls)
Looking good...next project...hmmm, I don't know, maybe something with rotations, like asteroids?
Thats a great idea, challenge accepted!
Sending bullets at angles is a good thing to know
yeah thats gonna be tough im gonna try and break it down into as many chunks as i can and try and complete each one, thats my method.
Pro-tip, if not already learning them, start learning to use vectors for movement
Whats better about them?
They can be scaled to work with deltatime, math on them is easy, many many advantages. They are pretty much the industry standard for moving things in 2d space, like screens, and even 3d games
I remember learning about them in school lol.
Yeah, part of linear algebra
For movement like ive been doing which is just paddles i think just changing the y or x works but yeah for a game like asteroids i think that makes alot more sense
im gonna watch some vids on it now.
thanks for tips and feedback!
I learned a lot about them from a few youtubers, The Coding Train's Nature of Code series (not in python but the logic holds for any language, it's about the vectors, not the code), Freya Holmer, and a few others
And pygame has really useful Vector2 (and Vector3) classes and methods
as in they are already inside the pygame library so i dont need to import math or anything right?
Correct
They are in pygame.math.Vector2 but can also be accessed with just pygame.Vector2 which is why I usually just import them separately like so from pygame import Vector2 and can use it by that name anywhere
Vector 3 would be x,y,z so isnt that 3d?
Yep
I mean, not really but sometimes 3d vectors might be useful to some, I never use them
Oh right thanks i remember seeing this used once in a tutorial but i didnt understand the need to use it
Im gonna mess around with vectors for a while and try and get some sort of accelaration decellartion thign working
Good luck, fun stuff
yeah I find it really interesting actually but some of it just does not make sense at all to me π€£
Happy pygame handles the complicated stuff
Take it slow at first, it's all part of the process
For a look at all the methods in pygame-ce's Vector classes https://pyga.me/docs/ref/math.html#pygame.math.Vector2
Things like this are probably my most used with vectors, getting the direction from something to another thing, pretty basic implementation too
But many behaviors like seek(), arrive(), follow_path(), all that stuff, is using vectors
Where to spawn the bullet with a rotating cannon...vectors can figure that out in like three lines
Aiming at and hitting a moving target, particularly difficult stuff like that, also vectors
strictly 3d is borderline impossible (unless u use opengl), i dont think u can ever make a modern AAA game
HOWEVER, people have made all sorts of pseudo-3d games
2.5D (literally any doom clone), isometric (bigwhoop's isometria) and sprite stacking (like fluffy's kart game) to name a few
Yeah, they can get things working in opengl contexts and stuff, but nothing I've seen yet is really mainstream
yeah
I've used Blender a few times to make and render images of 3d objects to be used as sprites in animations
And that's kinda cool, at least the sprites look 3d
Thought about doing it for chess pieces but blender sculpting (for the knight) was never my thing
All the other pieces are just fancy extruded circles
imo it wouldn't be worth the effort anyway, you'd only ever see one face of the pieces anyway
I'd probably tip them to an isometric angle but true, they wouldn't have rotation anyway
ye
Like this little ship that does a flyover during the intro to one of them, the path it follows and images all made in blender
The entire flight takes less than a second or so, but I had to have it
That original game was from like 1981 or so, if they could do it then, how hard could it be? I'm not sure how they did it but surely something similar
Here it is
How can I difine a shape for the player?
i'd love to take a look if you can send it, nice work btw
I'm not sure I understand what you mean there but if you have a surface on which to draw your player, you could define points to use in pygame.draw.polygon() or any combination of the other pygame.draw.... methods and draw them on that surface
You could also pygame.image.load() an image
Hello
I am making War Thunder like game on python, now I am working on penetration and modules damage simulation (very simple)
Anyone knows an article to read about this stuff
?
Hi , is "Tkinter" library good for develop games?
If not please let me know which library is the best for making games in python
you may want to take a look at pygame-ce instead
Pygame-ce is great for 2d games, Ursina for 3d
Ok , thank you so much
Could someone help me with vector movement in pygame I cant work it out
Why mean is how can I define the player to be inside of the class itself sorry
I can maybe
that would be greati
Depends on what game is it π
Well, then send code
I think I will start learning pygame
Although I'm not sure where I can learn it or even where I should start with
Probably self learning
I started learning 2 weeks ago
use youtube
Only I know is
"Import pygame"
And that's all
Can you send me good videos in DM so I can learn from them
I mean about pygame
Sure
Clear Code, DaFluffyPotato, a few others have good quality videos
Tech with Tim too
one sec
Hello sorry about that. I dont have any atm I was hoping to have help actually writing it and making a player movement script with acceleration ect but I cant find a good tutorial
For example, I used tkinter to write this.
I used tkinter here because I wanted to draw in overlay
Wow that's cool , but I heard from people that tkinter is not good for games
I used tkinter here ONLY because I wanted to draw in overlay *
In my case I haven't problems with fps and other things. But as I know tkinter works badly or doesn't work at all on linux / mac
then open math schoolbook
Yo
Need some help
Im new to this server and to python
I dont understand python coding in the slightest
I wanna code a shooter game
On pygame
Or tkinter
Who needs developer?
I am fullstack, blockchain, game, bot developer.
Ok
Since no one replied I'll just say this. If you want to make something using pygame and tkinter you'd probably want to have a decent foundation first. There's tones of resources out there for learning.
^
Hey
Playing around with seek() and arrive() methods, oh and also seeing what it takes to make a ghost behave like Mario's (facing away makes him chase you) https://paste.pythondiscord.com/CFTA
And a pretty basic asteroids ship with bullets, no enemies, no asteroids, no collisions https://paste.pythondiscord.com/A6MQ
Very cool
Thanks
I wonder how difficult it is to make the ship face the mouse
Not terribly difficult, just get a vector from the mouse position to the ship's and normailize then assign it to the ship's .direction attribute (all inside the get_input() method)
See how I'm getting the keys to rotate that vector?
Instead, get the vector from the mouse to the ship
yeah I think so
It could be a little more (or even a lot more complicated if wanted that way), but surely something could be put together quickly
Your code is so clean how long have you been making games in pygame?
Like I'm damping the rotation with the rot_vel attribute, implementing that relative to the amount of difference between where the ship is facing and where that vector points might matter but I doubt it, it's very little damping anyway
Python about 15 years, pygame about 5 or 6
wow thats impressive
I see now why your code is perfect haha
I dunno about that, there are others here that can do even better : )
everythign is in a functon
well I think its great compared to the "code" I write lmao
We're all somewhere along the path, keep practicing and anyone can be pretty good
Organizing code is a big part of keep it workable or at least making it easier to work with
I sure hope so just gotta keep motivated thats really what i struggle with
yeah readability is key
If you dont mind me asking what did you use python for before pygame?
Coding Blender's API
Well, making an addon for it
Among other things
It used to have a Game Engine built in, it's since separated from main Blender branch but somewhere along the line, I went to using pygame
It took me years to complete the addon, by the way
But I was pretty new at python when I started, some prior coding though, I've been ahobby coder for a looong time
For me, the motivation was really wanting or even needing to make that addon, no matter how long it takes
And of course, other ideas and projects happen since I learned allat
Oh okay so you dont code as a job
Fair enough
I think its a great hobby too so far
Nope, just practicing, always practicing and then practicing some more
It is fun, like I still get excited af when something really hard finally works
yeah its an amazing feeling even with small projects like my recent one where i made a main menu screen
Hell yeah
As for functions and methods, I feel like there's a sweetspot between making a long method with a few comments and just breaking out some of that code to other methods and the name of the method being the 'comment' or making it readable
Then you can kind of group things together in a logical way, probably takes a lot of practice though
Hi
I'm a newbie to python programming .
As a beginner , I need a guide to complete my journey
I'm a 10th grader in Banglore, India
I recommend using youtube there are lots of videos
can anyone maybe help with this , im making a simple ai opponent in a street fighter style game https://discord.com/channels/267624335836053506/1302687505161916488
how do i make a gmae bot
How can I call materials from a class for players specifically
Anyone interested in collaborating on a JS project?
why use JS when you can do pygame/panda3d/raylib-python with cpython3.13 on web ?
Because I need to hardcode everything. I'm no good at shit like blender lol π
https://paste.pythondiscord.com/BDTQ can anyone tell me how i can fix this? once the 'ai' attacks it doesnt stop and starts spamming them forever, seems very simple but i have no idea what to do
How can I blit a class onto the screen sorry
class player(races,classes):
#player_body = pygame.rect((150, 150, 50, 50))
comanions = []
inventory = {}
pass
Make it a sprite, add it to a group, draw the group?
I still need to work on figuring out how to draw sprites why I mean is drawing the character object itself onto the screen
That's what sprites and groups do, draw objects
Sprites have .image and .rect attributes. The .image attribute defines what to draw and the .rect defines where to draw it
I don't have a Sprite seat sheet yet I'm going to do that later I just need to make sure everything's working and I'm letting it onto the screen
They don't always have to be in a group, you could just screen.blit(sprite.image, sprite.rect) in your main draw() method, too
You don't need a sprite sheet to make a sprite
I managed to add a player movement in the class no I just need to call it to draw the player and game all the information from the class
class player(races,classes):
player_body = pygame.rect((150, 150, 50, 50))
comanions = []
inventory = {}
key = pygame.key.get_pressed()
if key[pygame.K_a] == True:
player_body.move_ip(-1 ,0)
elif key[pygame.K_d] == True:
player_body.move_ip(1 ,0)
elif key[pygame.K_w] == True:
player_body.move_ip(0 ,-1)
elif key[pygame.K_s] == True:
player_body.move_ip(0 ,1)
#===[monster classes]===#
class monster:
pass
class vault_monster(monster):
pass
#===============#
running = True
while running:
pygame.draw.rect(screen, (0, 0, 255), player)
How is this class going to work? It has no __init__() method or nothing instancing it
That's what I've been forgetting I've neglected to even put a basic initiate
I'm out in the initiating definition now I just need help trying to blend the player body which do I have to put self into this definition
class player:
def __init__( player_body):
player_body = pygame.rect((150, 150, 50, 50))
comanions = []
inventory = {}
key = pygame.key.get_pressed()
if key[pygame.K_a] == True:
player_body.move_ip(-1 ,0)
elif key[pygame.K_d] == True:
player_body.move_ip(1 ,0)
elif key[pygame.K_w] == True:
player_body.move_ip(0 ,-1)
elif key[pygame.K_s] == True:
player_body.move_ip(0 ,1)
updated player class
A very basic player sprite, just a rect that can be moved around the screen https://paste.pythondiscord.com/2SYA
It has an update() method that is called from the group by player_group.update() at line 77, that's all it need to update it, and is drawn by player_group.draw() at line 74, that's all it needs
Since it has an update() method, we can read the keys inside the class itself with the get_input() method, assign the direction and update the position of the sprite
I'm not going to get into inheritance yet I'm just trying to find a way of getting all of this to work without driving me crazy
You are already inheriting from races and classes, so why not make a sprite? Or were already
Totally up to you, sprites and groups make this a lot easier. You asked how to draw a player with a player class that won't really work the way it is
Thank you I am sorry
Like how are you going to call these lines to read the keys?
If you want to use classes in pygame, I strongly recommend learning how to subclass pygame.sprite.Sprite and pygame.sprite.Group()
Sprite especially
It's really only two attributes in the sprite itself, the .image and .rect attributes, that's all you need to make anything a sprite
For me, that's much of the advantage of using pygame, the sprites and groups (along with all the other things, event loop, vector methods, so many)
As for the 'without driving me crazy' part, maybe watch some tutorials showing how to do this. Clear Code is among the youtubers I always recommend because he almost always uses pygame sprites and shows how quite clearly
Anyone interested in collaborating on a browser game? The structure of it has been completed and the base backend and frontend is already coded. I'm having some issues with my routing/redirects. There is a GitHub and everything. I just could really use a hand.
Im creating a dungeon based python game using basic python and I was wondering if anyone knows a good tutorial for top down map making. All the ones I have found on Youtube all import a lot of things and use external things like py.game and I am not allowed to use that on this project for Uni work.
Don't know much about game dev in particular, but in your shoes, I'd learn what I could from tutorials on text based game development in python and then use ChatGPT as an advisor to help structure your code (although that might be a no no for an assignment...). I'm guessing that getting the game loop and data structures right are going to be the most important parts of the game design, and those probably don't differ too much in structure with 3rd party packages. But again, not an expert
how do i make so only 1/3 of the enemies that spawn using create_enemies() function can shoot EnemyBullet while the rest dont
https://paste.pythondiscord.com/OQTQ
me
what did i do wrong? sorry
Interesting and difficult question, strongly depends on what bot should do, how world looks like. Present your case more.
forgot self. maybe ?
No swearing
Lol, sorry
Its okay
This is outside of the player class I'm not going to work on spray sheets yet because I don't have any I just want to make sure that this works I might need the code for a Sprite sheets but comment that out later till I can find something that fits sorry
Is it Player class ? If it is, then you should read about OOP and write self.player_body instead of player_body.
It takes too long to load web application.
Missed the message. Yes, just replace player_body to self.player_body.
Like this?
You cann't write code outside functions in classes. Learn basics and then try to make games.
Search in Internet "python OOP full course"
I have I just have a hard time understanding classes and I thought a game would help because in essence it's just a package not you but in code to tell the computer what to put onto the screen and how to do it
Save time
To understand classes, do not import anything, just work in IDLE. Try to write classes of objects near you. Play with inheritance and functionality. For example: container -> cup -> cup_of_tea
takes about the same time to load godot or unity
That's why most popular and playable web games, as I known, written on JS (and frameworks), examples: suroi.io, diep.io, slither.io and many others.
The main advantages of browser games are simplicity and low performance needed
that is certainly not related to use of JS+framework, but more game type and target ( webgl1/2 instead of potato )
short page loading period *
yeah more like that, which on second run has no impact
because everything gets cached
First impression and experience rule
experience says make attractives loading screens, wonderfull packaging and spend everything on marketing
if people can't wait for a free web game to load, they don't deserve the fun
big part of web players are people with very slow internet
What is happening here
import pygame
import sys
pygame.init()
WIDTH = 1280
HEIGHT = 720
FPS = 60
clock = pygame.time.Clock()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
direction = pygame.math.Vector2()
player = pygame.rect.Rect(WIDTH / 2, HEIGHT / 2, 30, 30)
def movement():
keys = pygame.key.get_pressed()
if keys[pygame.K_w]:
direction.y = -1
print(direction)
elif keys[pygame.K_s]:
direction.y = 1
print(direction)
else:
direction = 0
if keys[pygame.K_a]:
direction.x = 1
print(direction)
elif keys[pygame.K_d]:
direction.x = -1
else:
direction = 0
def main():
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
movement()
screen.fill("Black")
clock.tick(60)
pygame.draw.rect(screen, "Red", player)
pygame.display.update()
if __name__ == "__main__":
main()
Here is the whole script
Its supposed to print the vector values in the output
Please ping me when replying
@limber veldt Any ideas?
put .x here https://skrinshoter.ru/sSYEPeJY3EL?a
do same with direction.y
Thanks
But for some reason pressing do doesnt do anythign
but the others work
Sorry pressing "d" doesnt do anything
Oh I see its becuase i forgot to add print to it
all fixed thanks for help
Anyone interested in collaborating on a browser game? The structure of it has been completed and the base backend and frontend is already coded.
There is a GitHub and everything. I just could really use a hand
how to deal with offset problem. Image just starts going up and down constantly
like if condition met i move image up if not i revert back. But if i place my mouse at the bottom image it constantly offsets and return to original position
ping me if you got something
Nice start on using Vector2(). One thing I'd point out is that after setting direction, when all is done, it's a good idea to normalize the vector if its length() is greater than 0. If we think about it, we can realize why. When moving left, right up or down, we move 1 pixel at a time because that's the length of our vector, (1, 0) or (0, 1) for the x or y makes that length == 1. If moving right AND down or and up (or any combination of two directions) we get a vector of (1, 1) (both one for x and y of the vector) which makes the length() of our vector 1.4 or so, not 1, and faster than moving just one direction. vector.normalize_ip() will make that 1.4 length vector the length of 1, making all directions move at the same speed, even if at an angle
Yeah ive been messing around with them for a while, I managed to get the square to move, but really struggled with normalizing so I had to search it up π€£
Good for you, making good progress and looking things up
My next goal is to get friction and some sort of acceleration to work but its kinda difficult
Integrating motion over cartesian coordinates (screen pixels) might lead to some hits. But yeah, integrating acceleration, velicity and position is what's needed
I brb
So for that (acceleration), we usually don't affect the vector directions directly, like setting .direction.y or .x to some value. Instead, we affect acceleration and that gets added to our .direction vector. But there are many ways to accomplish this kind of integration nd me describing it here isn't one of them
I kind of faked it with increasing and decreasing .speed the scalar that I use to scale the normalized vector to our movement speed
Using two scalars on our position when adding our direction vector gives us that flexibility. position(a vector) += self.direction (a normalized vector) * self.speed (a scalar. .ie: a float) * deltatime (another scalar)
Hmm I would have to try this out
Would you use a class for handling movement becuase you self.direction?
I would keep movement of player inside a player class
All things affecting player should be in the player class but this is not a strict rule, you are totally allowed to affect player attributes from outside the class
Ive never actually used a class I think I know how to use them but at this stage i dont really see the point in using them
And that's fine too, but just know that classes will help keep your code clean. For now, at this stage of your adventure, you have discovered them, and kind of know what they are and sort of know how to use them at least a little bit, it's fine, in my opinion, if you would rather work on learning mechanics of motion and all that kind of stuff first
yeah
My code is messy atm but after I actually learn I plan on cleaning it up with functions, classes ect
Discovering what can be done is a big part of learning, but practicing what you have already discovered is probably more important
Is delta time necessary?
Oh okay I always thought it was only if you wanted your games to run at more fps
So it looks the same no matter the fps
fram independant or something
It's good in that if your game is ever ran on a faster or slower machine than the one you are currently running it on, delta time will keep the apparent speed of motion, the speed on the screens, consistent
Yeah, framerate independence
But so would lockign it to 60, no?
Yes
I'll look into adding it soon too but its very complicated right?
as in not complicated to add but how it works behind the scenes
It's mostly important for speeds dropping below that 60 fps, being higher than that and our framerate will be fine at 60
No, not at all
See the dt = something in my previous examples?
That's all I do for calculating it (in milliseconds)
Properly initializing and re-assigning it each frame isn't terribly difficult either but since pygame has a .time object and it's giving us that value with a simple call, I use it
I heared pygame .time doesnt give accurate time
like the more decimals you have the more accurate you are
Some say perf_counter (part of the python time module) is more accurate
Honestly for the small games im making right now your pc would have to be from ancient egypt to get below 60 fps
And same here
what games you making?
NOt even games just little projects to learn
Some of my games might get a little heavy on slower machines but the vast majority, those without a hundred enemies on screen at a time and each of them searching for the player, keep a steady 240 fps most of the time
nice, im making an unique card game, pretty hard honestly, sitting 4 hours deep on some small bug xD
Wow sounds comlicated, yeah I picked python and pygame like 4-5 weeks ago so im really new
oh nice, its complicated even for me being 2-3 years into programming cuz programming is easy but you need good logical thinking lots of math skills
I have literally hundreds of those through many years, many not even on my drives anymore (but in backups surely, somewhere)
They are so valuable
Yup
To me at least
Wow I think at this rate ill be in hundreds too in a few years
All little sign posts along the path I've mentioned before
Interesting video
hey @vestal iron , I'm curious if you got your state machine working (I think it was you asking about them a few days ago)
yes i was, that guy really helped me a lot π , i got it working, its simpler than what i used to do but mine was overcomplicated thing, thats my downside, i dont know how to do simple
Those (state machines) are awesome logic helpers. For me, I like that any attributes or special logic for one state is completely separate from any other state, therefor encapsulating logic to each state
you know one things is to know theory another thing is apply in practice
That's good, rock on
For sure, that application part is often much harder
like recently im pushing myself to make a mess of my code cuz its not ok refactor your state machine a month π nothing gets dont so at least its for me i have to learn to make a mess
lol yeah, refactoring takes time
its not about the time it takes to refactor, my problem is that im perfectionist, and refactoring plus that is hazardeous combo
This is my basic state pattern. Sometimes I implement a .next_state attribute too and change the pattern slightly, but it works. I'd love to learn more ways to do it, like using an Enum instead of a dict for the states (among other improvements) https://paste.pythondiscord.com/C4VQ
And those states aren't doing anything either, only looking at the pattern there
Just counting time and switching to another state to count more time
In fact, there's a typo in it, but it's ok, it's not meant to be ran
Also shows why I consider delta time pretty important for things that move, it gets sent to and used by everything that animates motion on screen, or any kind of timing pattern
There is a website about patterns and there is state pattern example in OOP way. Im giving heads up that they love abstractions and overcomplicating things.
A quick little project, seven segment display that changes its segments depending on keypresses https://paste.pythondiscord.com/674Q
Wanna make a digital clock? That's the start of one
Oh that line 81 is unnecessary, remnant from a previous iteration of the code
Hmm, I like this more, keeping the group and the method to draw it inside the SevenSeg() class https://paste.pythondiscord.com/QRQA
Another quickie side project for my library of them
And it's already been refactored to lose the long lists and instead iterate the keys to instance all the Segment()'s
Like so ```py
self.segments = []
for key in directions.keys():
self.segments.append(Segment(pos + offsets[key], directions[key], self.seg_group))```
Could even make that a comp but it's short enough already and easy to read
With a few more args and a little more logic, its size could be a parameter
Also would be handy to have an increment() and decrement() method
Could even use that in another class like NDigitDisplay() and make it that many digits with functionality to set values or increment/decrement current values
I've made digital clocks in Logisim before (with gates, converters, other stuff), so not a completely new idea
this is really cool, what could this be used for?
I dunno, some kind of counter, maybe a score keeper for a retro game
those numbers you made there seems realyl complicated to make lol
I mean the actual surface
Gates way
Yeah, a logic circuit
So what exactly is a state machine
it prints or displays states on certain input like numbers?
I pattern of coding such that there are a finite number of states an object can be in at any one time with transitions to and from other states
The state machine I use for the Segment() there is a pretty simple one, it does nothing but change the image of the sprite during each state's initialization then just idles because the .init_state variable is immediate set to False
It doesn't even need to be a state machine, since it has zero functionality actually in the states being updated constantly, but I started with it because I wasn't sure where it was going
If it had some kind of timer running in the states, they'd make more sense but I've instanced it in another class that can do timing things if necessary
And update the Segment()'s
It sounds really complicated to me but im sure one day ill understand.
I was wondering too, is it possible to set the caption on the window in pygame to the current fps?
Not too bad, just remember that state machines have states that can run in any kind of sequence or by triggers
Yes pygame.display.set_caption(f'{CLOCK.get_fps()}') assuming CLOCK is an instance of CLOCK = pygame.time.Clock()
Thanks
I usually put that line right after the while True: starting the main loop, so it's updated at every loop
Read my mind π€£ I was about to ask why it wasnt working
Anywhere in the main loop is fine, but just once somewhere there
Looking through old videos, this one from early 2023 or so. Testing how the small swarm moves, collision with the ship disabled but their mines can hit it, invincible is on...
Bigger swarm
And a massive swarm
That's me just spawning and ramming the enemy that splits into a small swarm about 8 at a time right in front of the ship
I will check it out later im in a library and the internet is awful
Videos wont even load
That's ok, it's only me reminiscing anyway
Same functionality, no state machines https://paste.pythondiscord.com/LBXA
Pretty sure there's a .ttf font out there that can make it even easier
But that's cheating, lol
For an actual project, something much bigger and already taking time, I'd probably use a font
how do i open the images which are inside the assets folder
project 1/assets/...
yeah thats what I thought
Is it possible to write a macOS screensaver using Pygame? On Windows, you can just use pyinstaller to compile it as an exe and change the extension to scr, but how can you make a screensaver using Pygame on Mac?
Does it HAVE to be written in Objective-C?
Probably something along the Mac ecosystem
It's already not known to be customizable
it is totally possible, but easy/simple NOT
average apple software flexibility
i you get to display a .bmp at 60 fps in a loop in your screensaver in objc, i will give you the C code that will run your pygame code
eg pure pygame code like this one https://pygame-web.github.io/showroom/pygame-scripts/org.pygame.touchpong.html ( do view source in tab )
that c code has no support for input or sound, never thought someone could use it, but screensaver fits
so there this function inside the Enemy() class that can make enemies shoot and this function is the one responsible for spawing an enemies. so the question is how do i implement the function that can make the enemies shoot to 1/3 of enemies in range(10)
def create_enemies():
X_position = [100, 200,300, 400, 500]
Y_position = [-100, -200, -300, -400]
exist = []
random.shuffle([X_position, Y_position])
for e in range(10):
while True:
x = random.choice(X_position)
y = random.choice(Y_position)
if [x,y] not in exist:
exist.append([x,y])
enemies = Enemy(x, y)
enemies_grup.add(enemies)
break
if i wanted to make a full blow game in python how would i go about that?
You would first have to get the hang of python then learn pygame @nocturne lance
I'd suggest this as well for 2D games ^
Quick question. Im working on a game called Airborne : Python. It's a complex text based flight simulator. If I need help with the development, should I request for help here or in #1035199133436354600 ?
Is there some kind of JIT scripting language that can compile c++? I'm pretty sure I'm asking for something absurd, but a scripting language that can instantiate c++ templates for example.
Id tell you to not learn game development with that objective, and would tell you to learn another language that is far better for game development.
Python is not good for game dev, it's a really nice language but it's not made to perform time critical operations
You will also get fewer game dev resources if you do it on python, but I may be wrong
You can still male reallly cool games with it
people's ideas of what games are seem terribly distorted by AAA-style gaming. you can make some pretty impressive stuff in just PyGame and vanilla Python
And, in the process, learn some basic (even advanced) game mechanics ideas, how to animate things among others, and carry much of that over to any language
I think, that just because Python comes with an in-built library called Pygame doesn't mean it's actually recommend to learn. If you want to get into professional game development you should start with Godot, Unity, Unreal, etc. Why waste time learning Pygame when you can start with the big engines?
One of the biggest problems I currently have, being self-taught, is wasting time learning something and then realising that that knowledge will not help you later on.
- PyGame is not in-built, it's a third-party project
- You can start learning anywhere. The point is not to make a polished, commercially viable game out of the gate; the point is to start somewhere and learn. If people begin with Godot, that's fine too
Never denied that, but I think people can get bad ideas from it.
Yup. Think one of the biggest mistakes I made was starting with Python. Should have started with C++. Now that I know a bit of Python I don't even know what to do with it.
nobody's stopping you from learning C++, go see what it brings you
The fundamental misunderstanding is that not using Unreal or some other big fancy engine is what is preventing them from making such a game, it's not. It has nothing to do with programming even, the problem is assets, no single person can make all the required assets in a reasonable time frame. This is why "AAA" game devs focus on having a ton of assets / looks / music / sound, the main advantage that they have is lots of people to make these in parallel.
While engines like Unreal are providing a ton of "free" assets, your game will look terribly generic (which is also becoming a problem for many "AAA" devs that have switched to Unreal).
Using something like Pygame can actually make even more sense for a solo dev with a smaller scope game. There is less to learn with Pygame and better iteration speed than with something like Unreal, allowing for more time for assets and gameplay (not trying to compete on just assets/visuals/etc, but instead focusing on the part "AAA" seems to be lacking, gameplay).
hi i need urgent help with my game, is anyone willing to go through my code and help?
Yep I 100% aggree
People usually prefer you to send the problem instead of just asking for help. It's so that they can see the scope of the problem first before deciding to help
ive done that the past like 10 times and nobody helpedπ
10 times? jeez. what kind of problems do you face π
im making a very simple ai for a fighting game
and my 'ai' was bugging out and throwing infinite punches
but i think ive fixed it kind of now
was stuck on this for waaay too long
It be like that from time to time lol
Have you ever tried using the dedicated help forum tho? Those usually help whenever I'm stuck
yes atleast 10 times id say haha
Made a platformer map. 1 = block and 0 = air
Might add more blocks
and a player
ik it looks scuffed im working on it lol
love to see it :)
great screenshot choices
Nice, looks like a good start to me
Bugs are weird. Idk what's going on here but if anyone can explain I'd be grateful
It doesn't work without the text having an indent
Never mind. It goes back to normal after a add a space after the first backslash for the E.
This is great. Can you make the levels randomly generate by using this process?
Not trivially
No idea how, but probably
not doing a random.choice per each grid, but you still could quite easily
well yeah its just a tile grid dude : |
Is there a way of making a field where a player won't be able to get outside of a box cuz I'm trying to make a submarine kind of game after I make a player class which I need some help trying to pack it onto the screen I tried that with a game earlier
anyone need a programmer for the November pygame jam?
the team creation channel will open in a couple days if ur still looking for a team by then
Curious, do (or will) you have an entry this time?
I won't but maybe next time
This one is interesting
I use Pydroid3 for Python related activities
I use Termux as a CLI emulator for my android
I'm quite loaded with work at the moment but I'll definitely try attempt it
it definitely won't be as big as my last jam game but experience is experience
How can I make a partial system?
partial system of?
I need help making particle system for my game to run in the background since it's going to be a submarine-based game
#===[imports]===#
import pygame
#===============#
class particals_system:
def __init__(self,pos,particalX,particalY):
self.particalX = particalX
self.particalY = particalY
self.pos = pos
pos = particalX + particalY
particles = []
print(pos)
What do you mean by run in the background?
If you are using pygame I recommend using pygame.math.Vector2 for positions.
!d pygame.math.Vector2
pygame.math.Vector2```
a 2\-Dimensional Vector Vector2() \-\> Vector2(0, 0\) Vector2(int) \-\> Vector2 Vector2(float) \-\> Vector2 Vector2(Vector2\) \-\> Vector2 Vector2(x, y) \-\> Vector2 Vector2((x, y)) \-\> Vector2
If you want bubble particles Id give each particle a small force upward and a force that oscillates from left to right.
!d pygame.draw.circle
pygame.draw.circle()```
draw a circle circle(surface, color, center, radius) \-\> Rect circle(surface, color, center, radius, width\=0, draw\_top\_right\=None, draw\_top\_left\=None, draw\_bottom\_left\=None, draw\_bottom\_right\=None) \-\> Rect Draws a circle on the given surface.
!d random
the big bubbles should in theory float to the top faster than the smaller ones
What could be cool looking is marching squares. So that the bubbles morph into each other.
What I mean is the system having this particle system to make it feel like the person's underwater
This any good?
Yes
A particle system, to me, is a sprite group with sprites that have their own movement and it stays relatively consistent until the particle dies, either by leaving the screen or by living beyond its lifetime
Nice quickie bubbles, btw
The until it dies part is kind of important for particles because if they never die, they will start adding up (in memory)
Or any sprite(s) for that matter, when they leave the screen or you're done using them kill() them
Bullets, things like this
Bubbles
Another thing that could be added is darker and lighter bubbles to get a sense of depth
also these bubbles are very much in sync
this is pretty cool
You just made this? Looks really cool
anyone familiar with this situation in pygame?
this will display the image on screen just fine:
class MonsterInfoSprite(Sprite):
def __init__(self, rect: FRect, icon: Surface, groups: Sequence[Group]):
super().__init__(*groups)
self.image = icon
self.rect = self.image.get_frect(topleft=rect.topleft)
but not this
class MonsterInfoSprite(Sprite):
def __init__(self, rect: FRect, icon: Surface, groups: Sequence[Group]):
super().__init__(*groups)
self.image = Surface(rect.size)
self.rect = self.image.get_frect(topleft=rect.topleft)
self.icon = icon
def update(self, _):
self.image.fill(WHITE)
self.image.blit(self.icon, self.rect.topleft)```
why?
wuts the error
nevermind, I found the bug - for blitting onto a surface I have to remember that the default position of (0, 0) is not the same as the window's (0,0), but always relative to the surface that calls blit()
kind of obvious in hindsight, but I got beaten hard by my own expectations
oh right it happens
i made this system for one of my games if ur interested?
Hereβs my lil roulette wheel if anyone wants to play it
If you have any ideas for it feel free to add them
Very cool effect, maybe smoke or even fire with the right colors
Maybe entering the number 1, 2, 3, 4 and so on should choose the option it represents
Sure
Then it asks color and bet
Not sure, what did you have in mind?
What do you mean? Entering the number should choose an option
Also, when entering color or bet or other values, maybe put the allowed values in the prompt...or use multiple while loops and inputs to get the choices instead of sending the player back to the start menu for not knowing the minumim bet is 100
Where Iβm from, βSureβ usually means that person is settling in a scenario like this
That makes sense
Dude this is amazing I hope I get this good one day
It was used to confirm what you said in the previous post, as in sure, why not (do what you said)
All good
Awesome it uses marching squares?
no its the most small brain solution ever
draw the white circles first, then inner circles after
i could optimise it but for my use case 600 particles per area at 60fps was good enuf
actually, it came from a fire thing i was making that came out a torch
just modified the colours and particle velocities
oh i see. very cool.
!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.
Now try it
I added a few other things too
Hey guys, I though some of you may find this interesting, I am building a turn based strategy game and we are doing it using our own in-house graphics engine, itβs entirely in python and we have been really working hard over the last few months on it. But since itβs entirely in python I was like hey these guys may enjoy it https://terra-tactica.com
https://paste.pythondiscord.com/IJKQ
hereβs my updated Roulette table. I know itβs got some bugs, but Iβm too tired to fix them right now, so if you want to go ahead, if not, donβt. I donβt really care what you do, just please someone try it π
That looks dope, whatβs the basic storyline about?
Itβs open ended and completely up to you like Civ, Age of Empires, Stellaris etc
We are looking for devs on this if anyone is interested and willing to stay on it long term
You donβt think I can be a beta tester, do you?π₯Ί
Iβd love to help you make it, but Iβm not that far yet
And I donβt know how it would work out with child labor laws
Join the discord we will be making more people testers here soonish
Released my first Python Steam game since 2019! π
https://store.steampowered.com/app/2824730/Yawnoc/
EMBRACE CHAOSThe forest (filled with suspicious quantities of ammunition) has been invaded by cellular automata! Use various weapons, abilities, and upgrades to purge the machines in the forest before the machines take over. The enemy machines in Yawnoc are living on the rules of Conway's Game of Life and other cellular automata. Will you carel...
$4.49
YAY
My mom would absolutely love that game
This looks impressive!
Very
thanks!
Nice Fluffy!
We actually used some of your videos as a basis for the research and development, I probably linked your vids to my devs a bunch of times now, for our OpenGL python game engine as we pass through some Pygame things into it as well.
Nice to hear from ya! Will definitely check out the game.
Can you dm me the link plz?
Itβs on our site! You can use the link provided before!
guys is there some of you thaT could just help me, my game looked ok and it kinda worked like i could walk around and stuff. i was just finishing my first little biome and my yt tutorial said i should add some kind of bounderies to my camera to make it smoother. i did that and now its just grey and zoomed out
need code to help
Ahh yes, when everything works nicely but an attempt at perfection results in disaster. Very relateable
but can u help?
Sorry buddy, nope
Work backwards, see what thing you added caused it. Once you figure out the cause then you can develop a solution easier.
What libraries do you use for that game?
yeah but i think it was like only the camera
Pygame and ModernGL
Thanks for the information
Is there anyone who can teach Python? I am a beginner and can do small code operations.
!res
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
Can someone help me with linking mods to a mod installer Iβm making
I canβt pull the mods from the website
Then mess with the camera
yeah but that didn't help it was cause i was loading the wrong scene
i was loading player instead of world
i'm trying to code an open/save function for a puzzle, however it does't work and i can't seem to find the mistake can anyone help me here? here's the link
Here is my current progress making a 3d game engine (with editor) in python
https://www.youtube.com/watch?v=XvEa7wMbvYI
This is a little side project of mine, trying to make an optimized and competent game engine using pygame with the use of the opengl and imgui python wrappers to achieve c++ like running speeds
what's the error message?
nice, is source available ? why not Panda3D for the 3d viewport ?
ambitious, respect for that
no not yet want to stabalize the project a bit more before releasing the source
i manly want to have full control over everything related to the rendering and also wanted to do it myself lol
well if you want to make it web runnable someday ping me, i'd be interested in an imgui integration testcase other than harfang3d
gotta own it first, eh? π
Hahahaha
sometimes I feel like I should just follow the damn tutorial, because when I deviate from it, I can't just look up the solutions to the bugs I inevitably cause
:incoming_envelope: :ok_hand: applied timeout to @north grove until <t:1731707799:f> (10 minutes) (reason: duplicates spam - sent 4 duplicate messages).
The <@&831776746206265384> have been alerted for review.
@foggy python hi, you mentioned you are using moderngl for your game yawnoc, does it replace the pygame framework?
Likely using an opengl context pygame window or display, along with the event loop and a few other pygame features and some shaders using moderngl
He has some tutorials/videos showing some of the process on his yt channel
thanks, I will check these out
Of course, I don't mean to speak for him but I offer my thoughts on the subject, maybe he can see the question some time and give us more information
I need to learn some of that, shaders for fx
Again showing that pygame is quite capable of making quality 2d games
I just use it for post-processing. Most of the rendering is in Pygame.
Looks really good, nicely done again
Hell everyone! I made a shmup browser game. I used pygame to develop initially then converted it to Javascript using pygbag so that it can be played in browsers on PC!
https://thewindmage.itch.io/quick-shmup
Wow this is amazing, well done!
Thank you! Probably my best game so far
Really cool, nice retro styling too
Where did you get this image?
that's pretty cool
Oh I thought it was ai generated
π
My wife has somewhat of an interest in AI art so sometimes her art looks ai-ish. I think she does it on purpose lol
I really appreciate you all giving my game a try, I feel like none of the stuff I ever make lives up to what I wish it would
btw pygbag does not convert game to javascript, it runs it normally with cpython webassembly instead https://www.youtube.com/watch?v=oa2LllRZUlU
Speaker:: Christian Heimes
Track: PyCon: Programming & Software Engineering
Python 3.11 alpha comes with experimental support for Web Assembly and can be built to run in modern web browsers or Node.js out of the box. Iβm going to show how we achieved the goal, which obstacles we faced, and what is missing to have fully working βPython for the w...
Fascinating! Thanks for sharing. I'll give this a watch
Hello! I'm a CS freshman in college and have recently gotten into game development with PyGame. Today I finished a class I've been working on called "AnimationController" which is meant to handle all the animation logic for an object or character in my game.
All the code is explained in the project, but here's a basic explanation: each class in the game has an attribute called "animation dictionary", which contains the name of each animation along with methods and attributes related to that animation. These include a method that will determine if animation conditions are met, a method that will run as long as the animation is playing, the animation priority, and the actual sprites of the animation. The AnimationController will use this information to correctly determine which animation and frame should be played.
I'm relatively new to Python and especially game development, so if you have any feedback or suggestions please let me know!
Below the class I have an example object to demonstrate how the AnimationController works. It has a basic loop and some basic PyGame setup to allow keyboard input and prints out to the console the animation, the animation count, and the current sprite (which right now is just a string; in a real object it would be images). Try it out and see how the output changes when you press "a" or "d" to run, and "e" to attack.
Thank you!
delegating sprite animations to a dedicated class seems like an interesting idea, could be useful if you need to play a number of separate animations in specific order. I'm new to gamedev myself, and by following yt tutorials I learned to do animations by creating an update function for the sprite class and a draw function for the sprite-group class, which would have a reference to the sprite and thus be able to draw the surfaces referenced in the sprite
This has got to be the latest reply I've ever received π
Welcome, and I'd recommend Termux as your terminal emulator
can u plz chelp me ive been trying to solve 3d sorting since forever
https://paste.pythondiscord.com/74WQ
You may get a better response in #1035199133436354600 because you can create a thread that won't get buried underneath new messages
The nice thing about having a class handle it is a lot of the repeated code can be left out, so adding new animations can be done with just a few lines of code. It also helps avoid errors
Today I finished up another important class I've been working on: the InputController for the player. Code is explained as before, but here's a breakdown:
The player has an attribute called input_dictionary that stores an input along with attributes for the it. The InputController takes the player object and uses these values to determine when the method for the input should be called. Sometimes you'd want the method to be run as long as the input is held. Sometimes you only want it to run when the input starts. Sometimes you don't want to run the method until a certain condition is met. All of this is handled within the object and makes adding controls much simpler and quicker than writing all of that code within the player object itself.
Give it a read and tell me what you think. The only thing I might change is how the attributes are obtained, because right now it's kind of a mess lol, index within index within index. Logic is sound though. There's also an example below, so feel free to compile it and try it out. A and D make the player run when they're held, E makes the player attack and has a cooldown, and SPACE makes the player jump (although there are no visuals to accompany these; they are all printed to the console for the example)
While it isn't what I originally intended, I did create a collision controller for my game. I originally tried to use masks - I don't believe I fully understand how they work or how to use them because it didn't go well, so instead I used some information about the object rects to make collision work.
Something I was able to get working is having the controller predict where your next position would be and handling your position accordingly, as opposed to putting you inside the object and then pushing you out. It takes the x or y velocity of the player and adds it to the player position (not setting the player position) and determines if that new position would put it inside the object. If it would, it instead set the player onto that side of the object, meaning the player will never actually clip in to it.
This method does have its limitations- but I'm happy with it for now and will update it as I learn more about PyGame capabilities.
Here's the code. Unlike previous projects it does use outside modules and assets, if you'd like those message me and I'll send them over. Otherwise you can watch the attached video to see it working.
Damm bro, What engine do you use???
pygame
pygame and opengl
no one can create a good game by just pygame
u need gpu!
Not Python related but if you had to improve the following logo what would you do?
π
I don't really know how to fix that, I'd have to change the font which is part of the logo and finding it wasnt even easy
Is it clearer without the Dragon or no? @mellow flint
yep
I also have this one, quite minimalistic imo
Ight
so basically it's just kind of jittery so i came up with the idea of having a smoothing slider built into my GUI it goes from 0.0 to 1.0 the middle would be 0.50 for example and so i wanted 0 to be equal to the current XHorizontal and YVertical but then closer to 1.0 would be smoother, it's really important that it doesn't just slow it down as speed and precion of these coords is very important, could anyone enlighten me?
def move(self, x, y):
XHorizontal = int((x - self.screenw) * self.scale)
YVertical = int((y - self.screenh) * self.scale)
smooth_x = XHorizontal * self.update_smoothing_factor
smooth_y = YVertical * self.update_smoothing_factor
ctypes.windll.user32.mouse_event(
win32con.MOUSEEVENTF_MOVE, int(smooth_x), int(smooth_y)
)
maybe have 2 separate coordinates the slider, the "real position" and "display position"
and lerp the display position to the real by a some quantity depending on how far it is from where it should be and the distance between either end of the slider
I finished another class I've been working on! The DrawController uses the player's position and an attribute called bound_dictionary to handle scrolling. It supports an object attribute called "offset multiplier" to determine how quickly or slowly the object scrolls relative to player movement. This is useful for background objects. Then, it uses that information along with the object sprite (determined by the AnimationController) to actually put the object on the screen, using the Draw() method.
this is cool
starman waiting in the sky. he'd like to come in meet us but he thinks he'd blow our minds.
hi im looking to make a menu for my game can anyone help?
π I got this name from a Super Mario Galaxy level
how do i get my main game program to only be shown when the start game button is pressed?
like how can i hide the game
In short, don't draw or update the main game during the time that you don't want to
How you implement that depends on how you're doing it now
can you take a look at my code and tell me what way would suit itπ
Maybe make a variable in your main code, call it game_started = False and put your call to drawGameWindow() inside an if game_started: condition. Pressing the 'Start game' button would then need to be able to set game_started = True when you click it
ok ok thank you very much
Something like so can probably work ```py
somewhere in main, before starting the main loop
game_started = False
in main loop
while True:
# get and process events
# if game is not started, check for 'Start game' button press
# and if pressed, change game_started to True
if game_started:
# draw and update game
...
else:
# draw and update menu
...```
thank you
No problem. The same kind of logic can be used to run any part of a game but at some point, it gets too messy for me, which is when start defining states for a state machine, but that's another subject entirely
Yeh
has anyone got a good video on how to start making games with python
This is the video that got me started, it's a great introduction imo https://youtu.be/6gLeplbqtqg?si=vVW-g-_O488MzN-G
Learn how to build a platformer game in Python. This game will have pixel-perfect collision, animated characters, and much much more!
βοΈ Course created by @TechWithTim
π» Assets and Completed Code: https://github.com/techwithtim/Python-Platformer/tree/main/assets
βοΈ Timestamps βοΈ
β¨οΈ (0:00:00) Project Demo
β¨οΈ (0:01:32) Project Brief/Getting St...
thank you
holy shit my game actually work
this is the first time ever
i just need to add sound effect and music to finish it
Hi guys, currently trying to learn pygame and I created a floor for my game but it doesn't seem to work and I don't understand why
player_gravity += 1
player_rect.y += player_gravity
if player_rect.bottom > 300 : player_rect.bottom == 300
screen.blit(player_surface, player_rect
It doesn't give me any error message but the player just keeps falling despite adding the line of code that creates the floor
player_rect.bottom == 300 try = instead of ==
OMG it worked, thanks
Np
Nice, working game!
Using the == basically just turns this line if player_rect.bottom > 300 : player_rect.bottom == 300 into if player_rect.bottom > 300 : False or if player_rect.bottom > 300 : True which isn't really an error but doesn't do anything either
lol
I remember making the same mistake as this guy before
Take me 1 hour to figure out that = and == is not the same
I got a prototype for my first game working! https://youtu.be/B4BOlfwmm2k?si=Mk7HgQbtaL-ddhtT
3.14 game?
a simple examples here https://github.com/pygame-examples/pygame-examples/tree/main/pgex/examples/buttons
you might want to look into the pygame.sprite API
and for moving objects what Axis said
you'll have to make te interactability yourself though
How long does it take gifts sorry
this is why im asking @vagrant saddle my apoliges
what are we seeing
It's supposed to be the power core and maybe she'll generator for part of my game so that's why I was wondering so if the player if I have to add a text box with manual typing inputs I want to play an animation to turn on and turn off the core sorry
if you want user interface interactions when you want to see pygame_gui examples
Thank you I seen for buttons anime file for running the main game thank you
Does any tile that I make for a part of the world supposed to be a bitmap? Sorry
Image, surface, bitmap, choose a name, they all mean basically the same thing within the context of displaying images on the screen
And can you drop the 'sorry` with every message, it makes me feel like you've already done something wrong
There is absolutely nothing wrong with asking questions here
a question on organizing code: is it "better" to have a sprite that also contains data not related to rendering or keep the sprite separated from the entity that it represents? this is for pygame, if it matters
I usually keep all behavior for a sprite within the sprite itself (actually a subclass of pygame.sprite.Sprite) and add it to a pygame.sprite.Group() to handle the rendering and updating, the group can draw/update all sprites within it inside my main draw() and update() methods
hey guys, I have a problem related to object rendering. i copied the code from a tutorial, this one to be more specific https://www.youtube.com/watch?v=PsBYRAYVr5Q&list=PLn3eTxaOtL2PDnEVNwOgZFm5xYPr4dUoR&index=7&ab_channel=GetIntoGameDev
and now I am trying to load a bigger obj file (Vertex count: 2083581, Total faces: 694527, Total edges: 927913) but nothing appears in the pygame window
but from my console debuging i can see that the object was read and loaded. what do you think i should do?
#gamedev #gamedevelopment #programming
code: https://github.com/amengede/getIntoGameDev
Playlist: https://www.youtube.com/playlist?list=PLn3eTxaOtL2PDnEVNwOgZFm5xYPr4dUoR
Discord: https://discord.gg/vU2PKasZdn
Patreon: patreon.com/user?u=58955910
I am sorry I did pixel art because I couldn't sleep and I exported some of them as a gift that can play an animation like the one above no I would have to convert that into a bitmap?
animations are sequences of bitmaps, usually stored as tiles horizonally or vertically in a single file eg https://pygame-web.github.io/showroom/pypad_git.html?cpython3.12#src/test_anim.py
here's the tiles used
That's a cool game of life filler pattern
It eventually reaches steady state in a mess though, since I have it wrapping around
175x200 grid size
Reference https://conwaylife.com/wiki/Spacefiller
Do I need anything specific to use a bitmap?
Interesting, I haven't tried anything like that
xbox