#game-development
1 messages ยท Page 12 of 1
i look at a stackoverflow question, it gave the same results
well glfw is probably gonna be even harder then pyglet for you
because its even more low level
if it has more functionality, i will most likely will adapt to glfw
Hey Guys Could Anyone Knows Pygame, Could You Plz Say Why The Player Is'nt In The Screen Bounds?
def player_movements():
keys_pressed = pygame.key.get_pressed()
if keys_pressed[pygame.K_LEFT] and player.x > 0:
player.x -= 50
if keys_pressed[pygame.K_RIGHT] and player.x < WIDTH - player.width:
player.x += 50
if keys_pressed[pygame.K_UP] and player.y > 0:
player.y -= 50
if keys_pressed[pygame.K_DOWN] and player.y < HEIGHT - player.height:
player.y += 50
```Please Take A Look ๐ฅบ
I wish someone comes here a bit early
just if anyone want to test with full code
this is player.png
full code:
import pygame
import os
WIDTH, HEIGHT = 900, 500
window = pygame.display.set_mode((WIDTH, HEIGHT))
player = pygame.draw.rect(window, (255, 0, 0), (2.3, 2.3, 45, 45))
TILE_SIZE = 50
NUM_TILES_WIDTH = WIDTH // TILE_SIZE
NUM_TILES_HEIGHT = HEIGHT // TILE_SIZE
BG_COLOR = (176, 224, 230)
TILE_COLOR = (255, 255, 255)
playerImage = pygame.image.load(os.path.join("player.png"))
def draw_background():
for i in range(NUM_TILES_WIDTH):
for j in range(NUM_TILES_HEIGHT):
x = i * TILE_SIZE
y = j * TILE_SIZE
pygame.draw.rect(window, TILE_COLOR, (x, y, TILE_SIZE, TILE_SIZE), 1)
def player_movements():
keys_pressed = pygame.key.get_pressed()
if keys_pressed[pygame.K_LEFT] and player.x > 0:
player.x -= 50
if keys_pressed[pygame.K_RIGHT] and player.x < WIDTH - player.width:
player.x += 50
if keys_pressed[pygame.K_UP] and player.y > 0:
player.y -= 50
if keys_pressed[pygame.K_DOWN] and player.y < HEIGHT - player.height:
player.y += 50
def game():
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
player_movements()
window.fill(BG_COLOR)
draw_background()
window.blit(playerImage, player)
pygame.display.update()
if __name__ == "__main__":
game()
Could Anyone Plz Take A Look?
@fallow finch i see your active most of the time in this #game-development i really wish you could take a look and ans whats the problem
i told u the thing in general
you'll also never make a cool looking game if the player moves from 50 pixels
but then the player won't move
aside if its grid based game
It Is a grid base game ๐
i had only have 1 year of exp in python plz help
if its a grid based game you should define the level first
dont use the limits of the screen to make the game
yea but there's something to implement first
but maybe there will be levels in the future that time i will be editing the whole code
like, in what area can the player move
don't just use the screen's limits
your screen width and height is most likely not a multiple of 50
so you can see i provided the all code & images plz use them so you can understand exactly
and you can also make code that would work for any tile size
instead of just 50
so if you want to change it you can
you might not understand if i say, even idk how to say it to you
@fallow finch just take a little play of the game you can understand ig?
i see you have a player that's limited just by the window size
which is not a really good way to do the things
why so?
yea but define a game area
you may want to change size of the tiles later
or add hud, ...
i don't have player.png btw
@fallow finch this is player.png
wdym exactly? i don't understand what u mean.
@fallow finch
so i get what the game is
you have a grid, so what you should do is to define a list of lists for the "level"
and limiting the player movement / making collisions should be done using the indexes of the list
not the position in pixels
yes, i think i do that in furtue cuz this thing is just a test for all Square's To Work, Everything's Functionalty To Work
make it so the index of the player can't be less than 0 or more than the last element of the list
don't use pixel position
how to do that if it's the level and the player i do add more right?
well you make code to handle different levels
each level can be a list of lists
you can even make levels with different sizes
uhm, but idk how to do it, i always use pixel position could you please edit the current code and send it to me?
don't
using pixel position is 100x harder and it will not allow you to change size of your game or your tiles
especially for stuff like collisions, it would be terrible to do it with pixel position
could you just fix the boundries issue?
but its not how you're intended to do it
i will do it with the images
cmon you have 20 lines of code
you made nothing for now, you can still change everything
50*
its really really a few
then we can discuss in the Dm's Exactly How The Game's Levels Gonna Be?
or here?
np for me anywhere
here's some values of your rect during runtime
you DON'T want to work with this to make the collisions and stuff
for a simple grid game
[[0, 0, 0, 0],
[0, 0, 0, 0],
[1, 1, 0, 1],
[1, 1, 1, 1]]
can be a 4x4 level
of course you can use strings or enums for the elements, integers are not really readable
means the player position right?
๐ตโ๐ซ
a level is a grid
you're confusing me
you get this ?
Yes
if 0 is void and 1 is grass, a level could be this
Shall I Say The Game Idea, so that you can me what exactly?
well its a grid game, and each tile will contain elements
i know this
you'll add boxes to push and stuff like this then ?
Game Idea: Your The Square And there are some other squares which have some abilities Some Positive Or Negative You Have To Fight With Enemies By Going on their tile if they come at you u die, the enimies and u can still dodge them, it's simple game with different levels(different blocks).
Yeah, Thanks For The Idea
i will change how they will attack
you have to push/throw things
well that's one more thing that is 100x easier to do without using pixel position
that would be good
but do you get why using pixel position is bad
ik ik
Yeah, I Understand But I Like To Do The Hard way, and most games hard way is pixel position so.. yeah?
Okay, Now Say Your Talking
if you have free move or non-grid based game you need kind of pixel position
but if you want to resize your game or use different size for the tiles, you have to make complex formulas
instead of just list indexes
uhmm, could you plz make the player to not go outside of the screen bounds
before doing this
kk
we have to create a level
Ok, Now Could You Please Say How Do I Make This Levels? like if you defeat all enimies you go to the next level instead of the Menu Screen.
you want to implement a lot of things but you have to know what to implement first
shall i create the enemy.png first?
nooo
@fallow finch
we're gonna make levels, then player movement, and then maybe enemies
your grid is 18x10
so we need a list of 10 elements, each element will be a list of 18 elements
what?
your grid is 18x10
each tile is 50x50 and the screen is 900x500
Okk
ur okay with this ?
YeahYeah
so we need a 10x18 list of lists
what elements do you want at first ?
a void tile and a wall tile ?
๐ตโ๐ซ that's a lot
hmm you mean a square right?
well if list of lists are too complex for you you're maybe not used to python enough
like different type of square right sus?
we're talking of the level in the memory
it's not complex, it's just a lot of things
not how its displayed
no its not
okok
it will be displayed as a square but now we're talking of how it will be in the list
then what's wall tile and void tile?
to make a level
oh!! How it functions?
right now all your tiles contain nothing
im not understanding
Yeah
we're not displaying a level now
we're making a list
do you want some tiles to be walls for example ?
So your saying we have to add a wall
yeah you have to add some elements i guess
or you want the grid to be always empty ?
So we shall attack the enime with blocks
i have a idea
enemies arent for now AT ALL
you don't understand a list of list and you want to add enemies...
we have some walls which are pushable but only in one direction left,right,up or down so let's make that
...
practical futre example
that's the tile i want to add..
but that's too hard for now
we're gonna make the simple things first
just a solid wall that can't be moved
and void
Ok! But even if we add it the player can go outside the boundries of the screen right? i don't want it to happen
could we do that first?
the limitation will be
the player position (indexes in the list) cant go outside of the list's length
to make the player not go outside the screen boundries?
the player cant exist without the list
because the position will be 2 indexes in the list
im not understanding this list thingy
we're NOT gonna use pixel position for logic !!!
forget about the player
we're gonna make a level and display it
then we'll re-add the player
we have NO player right now
and we want to make a LEVEL
ur okay with this ?
Okay Just wait and come to Dm's Plz
we have?
if you want this okay
hello guys i am now making a video game and i would like that the player can moove in the same time ZQSD and the mouse. How can i make my program to get several events ?
what are you using to test events
for event in pygame.event.get() : if event.type ... ....
how do we use it ?
pygame.keys.get_pressed() will return all the keys that are actually pressed
when the function is called
oh cool
while a KEYDOWN event is just when you press a key
even if you hold its still one event
i didnt know about pygame.keys.get_pressed()
trank you very much i am going to try it
you can use just KEYDOWN
it doesnt work
but get_pressed() is generaly used in games
it works, you just need to use it correctly
it just takes event one byu one
yes it's when a key is pressed
not when you hold it
there's KEYDOWN and KEYUP (pressing, and unleash it)
get_pressed() is generaly used for games, because you use a lot of keys at the same time
i actually do
ty
๐ ๐
@fallow finch hey again, pygame.key.get_pressed works perfectly for ZQSD, but how can i have the control of the keyboard and of the mouse
an idea of what ?
this
i would like to moove the mouse and have the control of the keys
let me show u
`
if pygame.key.get_pressed()[pygame.K_d] == True and Player.x < Player.New_coords(1536-400, Player.y)[0] :
Player.moove_right()
if pygame.key.get_pressed()[pygame.K_q] == True and Player.x > Player.New_coords(400, Player.y)[0] :
Player.moove_left()
if pygame.key.get_pressed()[pygame.K_z] == True and Player.y > 0 :
Player.moove_up()
if pygame.key.get_pressed()[pygame.K_s] == True and Player.y + Sprite().scale_image(Player.image)[1] < Sprite().New_coords(0,864)[1]:
Player.moove_down()
`
dont pay attention at the other part of the condition
yes i pay attention
don't mix game condition with key pressed conditions, even a nested if would fit better here
its really a bad thing for readability and maintainability, what if you want to add a main menu, a pause screen, ...
so should i make a list named "moove" which has every events ?
i know you're True == True man but don't do this too its useless
the key pressed tests should be clean
don't say "if space is pressed and the player is also shooting at a cow"
okay i get it
well the problem is that when i press any key the mouse gets locked
yes i am ๐ฅ
i am too
that means nothing
where is your code for mouse
Cursor.x, Cursor.y = pygame.mouse.get_pos() Cursor.display(0,0)
you can use tuples
there's a tuple in your name
so what happens with this
when you're pressing a key the cursor doesnt move ?
or the whole app is frozen ?
no
i just cant moove my mouse when i press a key
even outside of the game window ?
yes i can moove my mouse outside
so its just the cursor you're displaying that doesnt move ?
yes
i think it's hidden in your app (the real mouse pointer)
show it first
and then try to fix the cursor thing
the entire code ?
k
hide =/= show
still the same
the real mouse is stuck ?
yes it is
or is it just freezing for tiny moment
yes but the game doesnt freeze
but if you press a key for 10 seconds
i just cant moove my mouse when i press a key
i can moove it during a really small second
and then nothing ?
or you can move it for a small second sometimes
looks like your app is "semi-freezing" because of super badly optimized code
no i totally cannot
you're literally resizing an image for a test here, idk what you're doing with the mouse
what happens when there's a mousemotion event
maybe your code is so badly optimized that it's semi-freezing like i'm sayin
oh i think i get it
i would like to see whole code now
actually it is quite good optimized, the thing is that i am badly handling the events
no its not
this is absolutely terrible
scale_image resizes an image right ?
mh
can i see the whole code
i thought you were new to python, because of the if condition == True statements
yeah I know i can just del the == True but i am trying to make code the most fluent i can
i dont know if it is a good idea to drop the whole code online
idk
actually my whole problem is that i am not handling the events properly, this isnt cuz of the optimization
`
for event in pygame.event.get() :
if event.type == QUIT :
pygame.quit()
sys.exit()
if pygame.key.get_pressed()[pygame.K_d] == True and Player.x < Player.New_coords(1536-400, Player.y)[0] :
if two_movements_keys_same_time(pygame.key.get_pressed()) :
data['two keys pressed'] = True
Player.velocity = 7
Player.moove_right()
Player.velocity = 10
data['two keys pressed'] = False
if pygame.key.get_pressed()[pygame.K_q] == True and Player.x > Player.New_coords(400, Player.y)[0] :
if two_movements_keys_same_time(pygame.key.get_pressed()) :
data['two keys pressed'] = True
Player.velocity = 7
Player.moove_left()
Player.velocity = 10
data['two keys pressed'] = False
if pygame.key.get_pressed()[pygame.K_z] == True and Player.y > 0 : #y = 0 doesnt require to use New_coords() function (cuz it also just equals 0)
if two_movements_keys_same_time(pygame.key.get_pressed()) :
data['two keys pressed'] = True
Player.velocity = 7
Player.moove_up()
Player.velocity = 10
data['two keys pressed'] = False
if pygame.key.get_pressed()[pygame.K_s] == True and Player.y + Sprite().scale_image(Player.image)[1] < Sprite().New_coords(0,864)[1]:
if two_movements_keys_same_time(pygame.key.get_pressed()) :
data['two keys pressed'] = True
Player.velocity = 7
Player.moove_down()
Player.velocity = 10
data['two keys pressed'] = False
`
the whole thing is here
pastebin exists...
whats it
large code blocks are also a feature of discord
a site to post large text files
dont know about it
you can use use large code block so we can see indents
3 x ` instead of 1
you can edit the previous thing to fix
you cant read what i sent ?
what is this...
try to keep one test then try with none of them (for the keys)
to see if the mouse is unlocked or not
although the function s name sucks, it gives the right player's velocity when he is holding Kz and Kd for example
wait actually i dont get it
do i have to do a test without these events ?
or without one of the condition ?
hello ?
try to remove all your tests
and see if the mouse is still locked
nothing has changed
so the mouse issue is something else
i hope you're really talking of the real mouse, not your cursor image
yes, it is the same thing for both of em
so try to remove other parts of the code
are you sure you have no code related to the mouse ?
nothin
try to remove your cursor thing
idk
because there's something wrong in your project
i have already tried
i think you have to send whole code at this point
indeed
be sure to send all the files and be sure to use pastebin too
actually i cant
why
i know this errors looks like it is in a 50 lines program, but thats actually the beginning of a pretty big video games of 1000lines
1000 is mid
yes it is
i def cant send all my code to someone i dont know
if its like one of your first games made with pygame i don't see the reason
you're planning selling it or what
i'm not telling you to send all assets too, just the code
yes i am
i'm pretty sure it will still change nothing tho
this code also has secret passwords to access to my dbs
just replace/remove the passwords
or dont show the files that you know they arent related
i cant take the risk
can you at least show the file that contains the event code, like the whole file
its the whole file ?
no, just the event part
well looks like we can't help you :)
ty anyway
ValueError: Array must be 1-dimensional for mono mixer``` Im getting this error, however im using ```py
pygame.mixer.init(
frequency = frequency,
size = -8 * nbytes,
channels = 2,
buffer = buffer,
)```, so it should not be looking to use the mono mixer, right?
Im very confused, beacuse literally yesterday this exact code was working and I believe nothing changed in the meantime..
hi i want to make a healt bar in my platformer game but i cant show my bar in my screen here is the some codes about it
import pygame
class UI:
def init(self,surface):
# setup
self.display_surface = surface
# health
self.health_bar = pygame.image.load('levels/ui/health_bar.png').convert_alpha()
self.health_bar_topleft = (54,39)
self.bar_max_width = 152
self.bar_height = 4
# coins
self.coin = pygame.image.load('levels/decoration/istkart/istkart1').convert_alpha()
self.coin_rect = self.coin.get_rect(topleft = (50,61))
self.font = pygame.font.Font('levels/ui/ARCADEPI.ttf',30)
def show_health(self,current,full):
self.display_surface.blit(self.health_bar,(20,10))
current_health_ratio = current / full
current_bar_width = self.bar_max_width * current_health_ratio
health_bar_rect = pygame.Rect(self.health_bar_topleft,(current_bar_width,self.bar_height))
pygame.draw.rect(self.display_surface,'#dc4949',health_bar_rect)
def show_coins(self,amount):
self.display_surface.blit(self.coin,self.coin_rect)
coin_amount_surf = self.font.render(str(amount),False,'#33323d')
coin_amount_rect = coin_amount_surf.get_rect(midleft = (self.coin_rect.right + 4,self.coin_rect.centery))
self.display_surface.blit(coin_amount_surf,coin_amount_rect)
and there's the my main
import pygame, sys
from settings import *
from level import Level
from game_data import level_0
from ui import UI
class Game:
def imit(self):
#oyun verileri
self.max_health = 100
self.cur_health = 100
self.coins = 0
#ui
self.ui = UI(screen)
def run(self):
if self.status == 'level':
self.ui.show_health(50,100)
self.ui.show_coins(12)
pygame.init()
screen = pygame.display.set_mode((screen_width,screen_height))
clock = pygame.time.Clock()
level = Level(level_0,screen)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
level.run()
pygame.display.update()
clock.tick(60)
you can at least use triple `
i guess problem is def run
the interesting part is level.run(), and i don't have it
can you show it but in a code block this time
no we can stay here
everyone wants dm only but there's no valid reason to do it in dm
i watch the youtuber and he makes more levels
like level 1 ,2,3 but i skip this
bcz i want 1 level
looks like you're just watching a tutorial without understanding how it works
and its level_0
i really don't want to help with this, sorry ๐
no i really tryna to understand it
try to learn stuff yourself
just i dont want to make multiple levels
if you never used python and starting with this tutorial, its bad
ya he said hes new to python
if you don't get this that means the tutorial is just way too advanced for you
learn the python objects, classes...
don't start with pygame
yea its tomorrow...
make a simple thing if you can't make an advanced thing
i just cant solve the problem
i learn and make level design etc
but learn python before
so you cant help right ? ๐ฆ
no because you don't know what you're doing
i want but in my school teachers are crap...
make a hangman game in console
they dont teach anything and want big things
do u have to make a platformer game like mario?
make a hangman game in console
Or can it be other simple one
make a hangman game in console, its a good fun exercise to learn very basics of python
but im sure the teacher says its so simple...
but its expected not being able to do x 10 harder things when ur new to python
about what
why my game cant even close
it even has the while thing too
even for ev in pygame.event.get(): if ev=pygame.QUIT: run=False while the while code is while run:
is it maybe because it allow mouse input or something?
it has to be if ev.type==pygame.QUIT:
the problem was you were referring to the event itself and not its type, and you were using a single = and not == for comparison
Also, type pygame.quit() after run =False as pygame contains a bug which kinda hangs your computer unless you enter that statement
Just a suggestion
Hey, did someone have a tutorial or a simple method to create a 2d scroll ?
2d scroll for what
a platformer like game
i usually have an x and y value for a camera which i subtract when blit-ing onto the display
in case you're using pygame, that would be display.blit(myimage, (xposition-xcamera, yposition-ycamera))
i vaguely remember hearing about some built in way to do it though
@inner flower
Actually the original code was typed out again so i accidentally made a mistake while typing lol ๐๐
Ok, i never experience that before but ill just try
thx, I will try that for sure
how can i run in mac??
i legit just ran it and it doesnt show errors, but it opens then closes
code pls
what software does everyone use for game dev?
i use godot and just plain python for text based games
thank you
Pygame works for me, even if it isn't that performant.
pygame(-ce)
You need to put that statement into a while loop
Mostly pygame and occasionally tkinter
bruh, tkinter for game dev, making dinosaur games?
How do you convert .xls files to .xlsx? I have 180 of them to convert and I'm not sure how to do it quickly.
Godot here, because it uses Python-like syntax (I like Python) and because it's easy to pick up and learn.
Panda3D
gdscript is almost like python+ imo
use an online website or something I do not think you can do it so fast
It worked
If I make a computer game off an existing board game, do I need to mention the copyrights for it? I do not intend to sell it/make it available to the public
then no
you could sell it to them, lol
godot is nice
people just like being weird sometimes...
You can't copyright game mechanics, so there is no need to. What you may not use is names, artwork, etc.. And there is also the issue of at least one kind-of-mechanic having been patented, at which point my understanding ends.
Practical example: I am not writing a Connect 4 AI right now, that would be an infringement of Hasbro's intellectual property. I am writing a Four in a Row AI.
On that note, anybody here who can explain some sensible heuristic for Four in a Row game states to me? Or wanna play against what I have so far?
sure
Bad example, they're both by id Software.
wait what
Quake and Doom were made by the same company?
yea wasnt aware of this
Tell me you at least know who Carmack is. ๐
it was the doom/wolfenstein dev right
Is there a channel here for the game? Shall we abuse a help thread? Which side do you want to play? How long are you willing to wait for turns? (Max is about 6-7 minutes at 1M game states.)
Yup. Python isn't really the language for number crunching.
Expanding the state tree to one million states, filling 3GB of memory, takes around 360-420 seconds.
well just telling its python isnt relevant at this point 
waaaaa
i'm pretty sure that's not how to make an ai for connect 4 or every game of this kind
Oh, it very much is. As Python is the language I know best, it's where I can prototype all the nice algorithm to optimize the search. Once I'm done, I can still rewrite it all in e.g. Nim.
i'm pretty sure games don't do it like this
one million states in any language would take too much memory
They do. Usually they do it faster because they don't implement graph search in Python.
there's probably huge workarounds to not test all the states
so a chess game would be 1000 billion states or what
Yes, there are, e.g. alpha-beta pruning, especially with a good heuristic. But the algorithm is the same from Tic Tac Toe to The Sims: Graph search.
well tic tac toe perfect ai can be written in a few lines with prebuilt moves
(The Sims uses bidirectional A* search to create parallelized GOAP plans, but the principle holds.)
Yeah, but I'm not actually writing a Connect 4 AI, that's just my current use case. The game itself is just a handful of functions, only four or so define the game mechanics. The search engine itself I have already applied to, well, Tic Tac Toe, Connect 4, and labyrinth pathfinding, and eventually it'll to GOAP and HTN, too. It works quite well and correctly, thank you very much. ๐ It's not fully-featured yet (alpha-beta pruning is in fact next on my list), but it's getting there.
But if you are worried about the speed and memory issues, the former is very much a Python problem, and the latter can't be helped in any case, in the end filling as much memory with as many states as possible is what search-based AI boils down to.
Also, 7 minutes and 3GB are the maxima. If I shave down the max state tree size by a factor of 10, it runs ten times as fast, and only loses the last two plies of the search tree, which doesn't make it that much dumber. At a tenth of that, okay, it is a bit dumber, but you'd probably only notice it once it's too late already anyway, and now we are talking about 4 seconds.
i would like to see how cython can improve here
if you're making a library
I am, and yes. I've taken a quick look at MyPy already, but that makes weird requirements about inheritance.
when is the next Pyweek?
Looks like it'll be in September. https://pyweek.org/challenges/
do we have to make it on a certain topic?
There will be a theme, and it not being noticeable in your game may lead to disqualification, IIRC.
Otherwise everyone could just make a game in however long a time, and then submit it to the jam.
How do you mean? You can practice as much as you want.
like what should I practice to stand a chance?
Making games under extreme time pressure. ๐
You could choose a previous challenge's theme, and try to make a game catering to it in two or three weeks, assuming you have a job that you plan to take a week off of for the jam.
@leaden jacinth Are you familiar with Pygame, Panda3D, and/or other game engines?
Ursina
Huh... It's impressive how many people flock around that project. Well, then you're all set, I guess.
But I wanna push with my pygame skills
I'd recommend maximizing your skills in one engine, but you do you. Alternatively you could try tackling with raw Panda3D.
hello python have a studio for make games? and tools and compiler?
... What?
Do you mean whether there are game studios that use Python, or whether there is an editor workflow for making games in Python?
do anybody know how to clone a Surface object without controlling it with variables?
like how scratch uses "when i start as a clone"?
oh i figured it out now
est
if you want a full game engine scripted in Python, the closest thing there is to it is Godot, which primarily uses GDScript, which is pretty similar to python. (it also supports actual python via a third-party plugin).
GDScript is not similar to python at all
Why not? It's indentation based, a lot of syntax is the same with some keywords swapped, and it supports gradual typing via typehints.
Syntax is similar, language semantics are very different
Docs explicitly says:
GDScript is entirely independent from Python and is not based on it.
If someone is looking for recommendations Panda3D while lacking a editor is a pretty feature complete game engine and you can code it in both Python and C++
It is missing Physically Based Rendering (if that's your thing) out of the box so you'll either have to write your own shaders for it or rely on community made ones but overall it's really nice to work in
hi guys
hello
you're trying to make 1:1 port of the features ?
exactly
yes
my computer going wild
yea i think it should be a good thing to have one
with all the memory
Lmao, thats what you said 3 weeks ago
if the code is good it could be a good thing to check for people interested in making more complex things in python
no one is looking at my github repo
how are you managing the threading stuff btw ? with multiprocessing ?
๐ญ๐ญ๐ญ
becoming githuber is hard
well you should make videos / reddit post about it
make some when you'll have the player physics
so we can see it's a real port of the game
ture
*true
i will work it on this summer, i have to study with my ap exams though
not much time for me
there's a lot of people doing minecraft recreations in all languages
but for some reason they want to do it in 24 hours
and with their own textures
and not porting the real game code in general
the thing is, i want mine to look better than the others
i want it to be modified
no bad looking code
you should make it look just like minecraft java
keeping the performance
i am
i never thought i was going to use math for it
rn working on the biomes
i have 500 lines of code
making it simple
alpha versions
its too complicated adding mobs
i bet i will be using tensorflow with mobs just to make it interactive
huh
else i have no idea
do you know how mob textures work?
i have these, but i dont know how they function
etc
idk if thats the same in alpha
in 1.14+ there's model files
they're resourcepack/client
idk how it worked before
wish i could use a time travel machine and ask notch
this is just getting to complicated
well of course its complicated
is there a way i can use a gif
newest versions have most of the things working with json datapack / resourcepacks, its a way more solid base
loading screen is a shader
oh nooo
yeah
what about just doing it like in the base game for now
thats what i said
this loading screen isnt in the game at all
very true
and using large animated gifs in games is a bad thing
animated gifs arent a format for game dev
tbh
the main menu is a shader
what if i make pyglet render a html ๐ค
using 6 textures
could that work
i dont wanna switch now
its a very simple shader
i messed up
using 6 textures
im already broke
thats what i meant
seems like i have to buy the account ๐ญ
assets/minecraft/shaders
are you recreating minecraft
yes...
...without knowing anything in how the game works ??

i don't get it
ye i don't get the joke
appdata/roaming/.minecraft/versions/1.xx.jar
thanks bud
do you know where i can find the txtures?
or those are encoded too?
assets/minecraft/textures
nothing is encoded
the java bytecode files are just obfuscated
C:\Users<USER>\AppData\Roaming.minecraft\assets
the names are aaa, aab, aac...
C:\Users<USER>\AppData\Roaming\.minecraft\versions\1.xx.jar\assets
so its inside the .jar file?
because its a file
well each version of the game is one jar file
how can i unpack it?
its C:\Users<USER>\AppData\Roaming\.minecraft\versions\1.xx\1.xx.jar\assets actually
do i have to install java from oracle?
...
you just need to open the file to get the things inside it
but java is already installed...
well looks like you really know nothing about java and minecraft
how can you port minecraft's code like this 
i just needed winrar
7zip >>>
hahaha
7zip can open more files as archive
and in more ways
i don't think you can remove certs easily with winrar
interesting
do you know where i can find the icons?
icons of what
minecraft launcher, window, etc
the jar files are minecraft versions
the minecraft launcher isnt here
it's made in C++, not java btw
bruh
now, its gonna be worse to decompile
you want to recreate the minecraft launcher ???
but w h y
just recreate the game
the launcher just launches the jar file with a jvm argument
yeah ๐ฆ
you don't have to recreate the launcher
and i think mojang would not like this
the jvm argument will not be a thing in minecraft python edition anyway
๐ญ
i don't get what's sad
you wanted to recreate the launcher and also the mojang site or what
nahh
what about recreating the microsoft accounts too
yeah, where can i find it?
assets/minecraft/textures/gui i think
ill get them later on
its not there
well maybe it's somewhere else and i forgot
maybe they're even using a crafting table model
but iirc its in resourcepacks
not there either
in resourcepacks
how can i load svg images in pygame
what happens when you load them like other images
it's not supported
it is
maybe try to load a bytes object
but i think you can just use image.load()
on the file
wait
they don't show at all
so your surface is empty ?
so what do you have when you blit it
it doesn't show
its probaby an issue with how you blit it
it's not behind the background
be sure to display.flip()
make a new project where you just load a svg file and blit it
def show(self): self.surface.blit(self.image, self.position)```
with pngs it works
so are you sure its the right surface ?
with png
or that its not a previous image that was loaded before
with svg
i don't care
??
self.image = pg.transform.scale(pg.image.load(f"{consts.GAME_DIRECTORY}\\assets\\images\\{self.skin}\\{self.type}.svg"), (consts.TILE_FACTOR, consts.TILE_FACTOR))```
it is the right surface
import pygame as pg
import sys
window = pg.display.set_mode((640, 480))
cake = pg.image.load('cake.svg').convert_alpha()
while True:
for event in pg.event.get():
if event.type == pg.QUIT:
pg.quit()
sys.exit()
window.blit(cake, (20, 20))
pg.display.flip()
this basic code works for me
thanks
there's also a built-in width and height in the svg file
yeah but even when not scaling it doesn't blit
import pygame as pg; import consts; import cairo
class Piece:
def __init__(self, surface:pg.Surface, type:str, position:tuple=(0,0), skin:str="regular") -> None:
self.surface = surface
self.type = type
self.position = position
self.skin = skin
self.image = pg.image.load(f"{consts.GAME_DIRECTORY}\\assets\\images\\{self.skin}\\{self.type}.svg").convert_alpha() #pg.transform.scale(, (consts.TILE_FACTOR, consts.TILE_FACTOR))
def show(self):
self.surface.blit(self.image, self.position)```
doesn't work either
can u give me the svg ur using
maybe the image i use are too big
my file is 880x880
@fallow finch uh
try to set a specific size
for 500 files?
how do i change the svg content lol
it's not like i can use file.write()
well maybe
i'l ltry one sec
why ?
even when setting a specific size it doesn't work
also you're currently using scale
not using scale is better, you should focus on loading times / performances in your app
does this viewbox have to do with anything?
more than on time spent on making the files
maybe
i'm not svg expert
i'm using the simple program u gave me as an example
so not a scaling problem
Latest Isometria devlog here: https://youtu.be/uHxqKPrdeKU Hope you enjoy, remember to like and subscribe and all that jazz.
In this week's devlog I introduce the desert biome, show changes to the cave ore deposits, and give you the first look at Blobby the boss blob.
#indiegamedev #devlog #gamedev #gamedevelopment #indiedev #python #pygame #pygame-ce #pythongaming
fun watching this game progress
Thanks, feel free to make suggestions
Can anyone recommend any game development internships/companies? I'm an intermediate in python.
And you're in school for game dev? And learning more than python?
Not likely to find "companies" making games with python that also can take on interns (or any staff lol). And very unlikely to get an internship without going for a degree (most internships specify this).
guys, do i need anything other than Pygame to build a simple platformer?
i want to build something to my portfolio
platformers are definitely doable in pygame, check out dafluffypotato's videos on youtube he does a lot of platformer stuff in pygame
thanks a lot, will do
well dafluffypotato doesnt use just pygame
he also uses pyopengl/moderngl to make shaders
thats a lot of his more recent stuff, his videos mostly cover everything besides that
โค๏ธ
how are you
Does anyone here has any idea of how i can program a bot for a MMO?
Do you want to automate an already existing MMO, or write NPCs for an MMO that you are writing?
For the former you'd need a shim that does extract information from the game client, and through which you can take actions, so you have API access to the client; I have no idea how to do that, and it will depend on the client in question. Once you have done that, the rest is the answer to the second question, because essentially you are trying to write an NPC now. Depending on what exactly you want to do, you could just write a few lines of code for simple behaviors. When things get more complex, you will want to use abstractions like finite state machines, hierarchical finite state machines, behavior trees, search, goal-oriented action planning, hierarchical task networks, or, if you have far too much time and resources on your hands, reinforcement learning.
your message is too long
a newbie cheater who joined the server to get a bot for a game will never read this ๐
Well... Good? I'm interested to talk about the sort of person who sees the grab-bag of technical terms and goes "Yes, that is what I want to talk about."
Doubly so to the person who'd go "I have not heard of most of these, but have you ever heard of a Tolman-Eichenbaum machine?" ๐
I haven't heard of that machine, what is it?
Good question... From what little I have understood, it creates a learned map of positions on one hand, one of sensory perceptions on the other, then a combined map of latent space, resulting in an actual map for a given context, and then it does prediction by search on it. In the sum, it's apparently a good structure for abstracting correlations into causalities with few examples.
...and that is the kind of machine learning intelligence that I'd like to try out in complex systemic simulations, probably something Sims-like.
The fact I looked at the implementation and immediately learned fun new words like "Entorhinal" probably means I can't understand it offhand ๐
looks like it's a very neuroscience-inspired model
Solitaire game
Nice brooo
wooo thats really cool
Unreal engine or unity?
yo does anyone know if unity uses the same coding language as python?
now unity uses c#
I would recommend godot if you want a similar language to python
@glossy prism
it has gdscript or python bindings
Alr thanks
also godot is os
technically I do
...or use Panda3D if you want Python instead of something Python-like.
i dont know if turtle counts as game-development, but i tried to make a turtle, that "erases" a grey circle, but for some reason it gets stuck on the cornor, can someone give tips?
as you can see in the terminal, the numbers only change from 66 to 57, even though i set a random function to the x plane
hello guys, i am currently making a video game, but i have some trouble with the collisions. actually i d like to check if a line is touches the player. The problem is that this line rotates and so it makes a new rectangle with the rotated line + blanks in the rect. The consequences are that the player is sometimes in the rectangle without touching the line.
How can i do to detect when the player is just touching the line ?
Please mention me if have any ideas ๐
You can do pixel perfect collisions using masks, there are tutorials on YT about it ๐
assuming you're using Pygame
what's in that willi directory

I wish cats were real ๐ฆ
hey guys so im following a tutorial on how to make a doom like game and i ghave this error
TypeError: __init__() takes from 2 to 4 positional arguments but 6 were given
and this is the code
def __init__(self, game, path='sprites/animated_sprites/catto2/0.png',
pos=(11.5, 3.5), scale=0.8, shift=0.15, animation_time=120):
super().__init__(game, path, pos, scale, shift)
self.animation_time = animation_time
self.path = path.rsplit('/', 1)
self.images = self.get_images(self.path)
self.animation_time_prev = pg.time.get_ticks()
self.animation_trigger = False
i know its cause but how do i fix it?
What arguments does the superclass's init accept?
i have to look that up
well, I'm asking because the error can't refer to the __init__ you posted, as it takes like 7 arguments, it must refer to the super().__init__ you call in this snippet, which you haven't posted the code of.
should i post the whole code?
class AnimatedSprite(SpriteObject):
def __init__(self, game, path='sprites/animated_sprites/catto2/0.png',
pos=(11.5, 3.5), scale=0.8, shift=0.15, animation_time=120):
super().__init__(game, path, pos, scale, shift)
self.animation_time = animation_time
self.path = path.rsplit('/', 1)
self.images = self.get_images(self.path)
self.animation_time_prev = pg.time.get_ticks()
self.animation_trigger = False
def update(self):
super().update()
self.check_animation_time()
self.animate(self.images)
def animate(self, images):
if self.animation_trigger:
images.rotate(-1)
self.image = images[0]
def check_animation_time(self):
self.animation_trigger = False
time_now = pg.time.get_ticks()
if time_now - self.animation_time_prev > self.animation_time:
self.animation_time_prev = time_now
self.animation_trigger = True
def get_images(self, path):
images=deque()
for file_name in os.listdir(path):
if os.path.isfile(os.path.join(path, file_name)):
img = pg.image.load(path + '/' + file_name).convert_alpha()
images.append(img)
return images
What does SpriteObject's constructor accept, though? Is SpriteObject another class of yours, or from some library?
its my class
Post its init, then
def __init__(self, game, path='sprites/static_sprites/catto.png', pos=(10.5, 3.5)):
self.game = game
self.player = game.player
self.x, self.y = pos
self.image = pg.image.load(path).convert_alpha()
self.IMAGE_WIDTH=self.image.get_width()
self.IMAGE_HALF_WIDTH=self.image.get_width() // 2
self.IMAGE_RATIO = self.IMAGE_WIDTH / self.image.get_height()
self.sprite_half_width = 0
It takes game, path, pos, so you can call it from the subclass like super().__init__(game, path, pos). That would leave scale and shift unused, though. Presumably what you want, then, is to add these arguments to SpriteObject's constructor as optional ones (like, with some default values), and use them there to, well, scale and shift the sprite.
wait imma paste the code from github and see if that works
wait that worked
probably a typo from myself
Hey, I was wondering how can I make a cooldown in my code to make an animation last before anything else happend in the code ? For exemple, when my character step on a trap, he get transported to the last checkpoint, but I want my death animation happen before the teleportation.
is that a loaf
Error:
AttributeError: 'Game' object has no attribute 'sound'
Code:
import pygame as pg
class Sound:
def __init__(self, game):
self.game = game
pg.mixer.init()
self.path = 'sounds/'
self.npc_pain = pg.mixer.Sound(self.path + 'hitHurt.wav')
and
self.game.sound.npc_pain.play()
can someone help?
Does the sound in the second message need to be Capitalised?
let me fix it
yep that doesnt fix anything
No clue then, sorry
@lost kindleโโฟโ have made 3 object one button to get Money one button to upgrade how much money you get each time and one button to get an autoclicker but everyone can be clicked anywhere on the y coordinate like every hight and it does it
nope
ty !
is there an efficient way to implement global hotkeys with python? like if i wanted to do what autohotkey does and trigger actions for games in response to presses globally. i tried using the keyboard library and using a main loop, but that is very cpu intensive. i tried the global-hotkeys library, but that seems to break after a while and is inconsistent
did u try pyautogui ?
i'll try that
Opinions on this save system?
If it suits your needs it's a good system ๐
is this the most efficient way of printing a tuple? ```py
import sys
lanche = ('Hamburger', 'suco', 'pizza', 'pudim')
for cont in range(0, len(lanche)):
sys.stdout.write(lanche[cont] + " ")
sys.stdout.flush()
oh shit wrong channel srry
Iโve tried using JSON and pickle but this more vanilla approach I tried in the past is a lot easier it seems.
the pickle approach requires a lot of weird dunder overloads, it sucks in terms of UX
Tastes good but feels kinda weird I suppose
Yeah it's very elegant in some ways but also not in others
I have a lot of mixed feelings about the struct and pickle packages
but they're also at the center of the language, so it makes sense that there would be diverging interests
Someone intro me about Gaming
why stdout.write?
Hello! I have created Rectangles in pygame and I was wondering how to delete them from the surface. I have the pygame.draw.rect() as variable so itd be helpful if I could somehow delete it from there. Im pretty new to that and not very experienced. I also read the docs and didnt find anything
you can't delete what you have drawn, you can only overwrite it, which usually means that you just stop drawing what you don't want to see anymore and that's it
thnaks, I figured it out too now
!warn 580819142735691786 Please don't use this server to advertise, per rule 9
:incoming_envelope: :ok_hand: applied warning to @bright wedge.
Hello everyone !
I am currently working on a small rocket simulation project in Python and more specifically using the Pymunk module. Thinking to stumble on aspects related to the physics of dynamic objects and the difficulties not always appearing where one expects them, it's ultimately the locking of the view on this rocket that poses a problem for me. I understand that Pygame, a module on which Pymunk relies heavily, does not share the same coordinate system, hence the difficulty.
Here is the simplified source code in 50 lines:
https://pastebin.com/qx8NLvHu
Itโs, in this state, a simple rectangular Pymunk dynamic object that a downward force causes to rise indefinitely. This object begins its ascent before escaping from the surface from above, the idea being that the view is always centered on it throughout his ascent.
While there is fairly clear documentation on purely Pygame scenery scrolling and in particular techniques consisting of simulating a climb by only moving the background in retrograde motion, a dynamic Pymunk object subjected to a force moves "for real" and makes this technique ineffective.
I couldn't find any clear documentation on this and this post on Stackoverflow, despite its detailed explanations didn't seem to solve the problem, at least let's say that I have difficulty adapting it to my project:
https://stackoverflow.com/questions/55235223/side-scrolling-with-pymunk-and-pygame-how-to-move-the-camera-viewport-to-view
Do you have any leads to suggest in order to follow a Pymunk dynamic object in infinite vertical ascent?
Thank you in advance for your help
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.
You can change the color to match the background if you do not have an image or something special as your background.
It makes them invisible from the player.
You will need to disable the physics on it though
It's a monkey brain method but still a solution
if you can disable the physics, you can also just not draw them in the first place
Yeah thanks but I got it now
But then I could also quit programming it if I never drew it
On a scale of 1(use something else, maybe even another language) through 10(you should always consider this) where does kivy sit as a recommendation for making an android game
Iโve got a few months a one moderate size project under my belt with kivy and Iโm considering remaking it to appear more game-y
hello i need some help with installing pygame
i did the pip install pygame but when i import inside ILDE it says that there is no module called pygame
i played a bit with the environment variables thing so i might have fucked up a little
try: pip install pygame-ce
if your env variables are messed up just reinstall python and be sure to check the box that adds python to the path
also don't use IDLE
any ideas on how i can make doors in a raycasting game?
or just any ideas on making a transitioner to another level
Hello. I've recently started using Pygame and tried to make a little something using Isometric tiles, it was difficult so I decided to move onto hexagonal tiles instead. Still difficult but I feel like it's more manageable. I'm just trying to figure out how to draw the tiles in a hexagonal pattern. My head knows how it works, but I just can't get it onto paper.
I don't know if Pygame can really do it. I did some research and I know matplotlib can render hexagonal tiles. I found an article too where a guy took a map of the United States and overlayed hexagons and displayed data with it. I'm just trying to understand if there's a way to use matplotlib to do the calculations. Or a library like pandas or something else and then have it render in Pygame.
ANYONE!!!
def draw_bg3():
screen.blit(background_img3, (0, 0))
def next_character(screen_number):
pass
def settings():
pass
what?
Do u have a way of creating a character selector?
actually, I have an example just for that, lol
(might be in need of a rewrite, but meh)
it's definitely doable using only Pygame, you just need some maths
https://youtu.be/04oQ2jOUjkU
this might help you
Isometric games often use hand-drawn 2D sprites to add depth to a game without having to deal with full 3D rendering.
In this video, I cover how it works, the math you need to render isometric sprites on the screen, and how to find the isometric tile from a screen coordinate.
0:00 Intro
0:21 Orthographic projection
1:16 Tiling a sprite
1:40 Tr...
Ah thank you so much. Maths is really not my strong point. Thank you so much.
does anyone know if pygame is affected by the GIL
i mean isn't it just an sdl port nowadays? i tried threading a simple pygame.draw function and it's ridiculously slow compared to just single threading it
xD
In this video the guy explains that there's a unit vector between the normal grid and the isometric grid. He displays it as 1 over 0.5 but there's no division line between the 1 and 0.5. How do I display that in python ?
Ohhh wait I got it. I don't have to overdo it.
I can't explain how incredibly cool it is to me that I'm able to read code and understand it. I am able to translate from another language to Python too. I guess it's just readability and adding quotes and comments help too, but damn It's so fascinating to me.
Friendly reminder that weโve got one of the best 3D rendering pipelines of the Python ecosystem ๐
The Python stuff is, SDL threaded stuff like sounds run on actual threads
So yeah, you ain't gonna make stuff faster by using threading
what about multiprocessing
i tried using it to draw some stuff but it didn't like that i passed in the pointer to my display
i think that was it, anyway
yeah, processes don't share memory, you can't really make the rendering stuff faster this way
faster rendering can be achieved by using pygame._sdl2
or apply other optimization techniques
if your code is slow, first thing you'd want to do is optimize it
really now? there's an sld2 mode?
seems odd since pygame is pretty much just sdl2
anyway, i have no code that's too slow for anything right now
well, the _sdl2 stuff deals with GPU stuff
the only thing i could think of is my one code that's rendered at a big resolution then smoothscaled down
also pygame-ce if you hadn't heard about it ๐
basically pygame, but better
like, it still is pygame
a different distribution if you will
i'm surprised multiline text wasn't implemented already
welp, then ig it's all fine, but if you do run into some lag or sth, first step is to profile your code and then go from there
thanks
Would advanced math help someone who wants to learn game development?
Yes.
Welcome to the thrilling world of PUBG Mobile CLI Version! Get ready to experience the heart-pounding action of PlayerUnknown's Battlegrounds right from your command line interface.
In this unique adaptation of the popular battle royale game, you'll be challenged to survive and emerge victorious in intense matches set in iconic maps like Erangl...
Anyone know how fix it ? Aimbot of super Mecha champion. Previous old version work. Now new version the code not work anymore. U guys know why ?
send the code here
Do u have a way of creating a character selector?
What 
You should check the rules before posting anything
just checked after posting that
someone just told me
any ideas on how i can make ball collision in pong?
what library are you using?