#game-development
1 messages ยท Page 88 of 1
Hmm
Do you know what circular important means?
Nope
It mean the module is importing a module that is importing it
Aka
Code for module a is:
Import b
But code for module b is
Import a
So parts of code that use those modules can't be Initialized
U can try to download delete pygame and install again(latest version preferably)
Hmm alr
this is because you named your file 'pygame.py'
An import basically means that your importing a certain python file
so when you import 'requests' your actually basically taking the code from a file called 'requests.py' and using it in your file
but when you name your file the same as the file your importing from, it will import the file yourwriting
basically
just change the name of your file
how can i export a pygame game to a apk file?
To convert pygame python file into apk for android .
#pygame ,#python,#android
github link: https://github.com/Sahil-pixel/Pygame-for-android/tree/main
like, share ,subscribe
Kivy apps in google store. search
2048 Py
VideoPy
Slide Puzzle Py
Pybird
Math Puzzle Py
uh thank you ๐
Awesome, how soon can ya get here?
Such as keeping all elements in seperate files
The player object in a player.py and ect.
Then importing everything in the main file
oten tho if your game is less than 1500 lines theres no need to do this
the mess is when i try to add some new function to the game, i didn't even know where should I put it in the project... and if i find, i try to run, but a lot of bugs ... I'm using Git to fix my error bcs some the time, i'don't even know what's happen (lol)
It must really just be that you arent following good practise ๐
how is git going to help tho
roolback to the last modification where the game's run ? '-'
command z only if i remember when i have put modification ...
I'm not sure how long the undo buffer is in VSC by default, but I've never ran out of ctrl z unless I close it
Sounds, I've recorded all of the sounds from the game's test mode and cut them all into their own wav files, now to learn how to implement them
pygame has a good sound system
I'll start with some basic sounds, shoot first, pew pew pew
That was easy
And I worked out thruster sound to keep repeating but not keep adding more channels of it when the player holds the thrster key
The thruster didn't sound right when simply playing it when the key is held because it kept adding more channels
You need a closing ' in that liine: print('you lose srry maybe next time)
print('you lose srry maybe next time')like that
I don't know where that line is in relation to the code you're showing, but it's correct in the code
Look at that logo exploding...now I just ahve to do it in reverse
makae this a loading screen
its cool how like whens its done loading it just finshes colouring up the whole title
It will be an attract screen, sorta like a loading screen
whats ur game bout
r u doing this for fun or for actaully making it popular game
thats nice
the exploding kinda too like vibrant and like idk big
I already have the actual game that I can play any time, but I want to recreate it in Python
me and my friend wanna create a game but we dont know the idea 
Yeah, the game's big on particle effects, like everywhere all the time, particles
https://paste.pythondiscord.com/pahabibule.lua yo i made this chat game if u wanna play
It's a simple game with complex things, the original game: https://www.youtube.com/watch?v=wAKxa5C9jHY&t=2940s
This is Williams Defender green label on MAME, factory settings. On wave 1 I pick up all ten and force 5 through to the top of the screen. This is a bug and I always wondered what happens as they start to crawl down the screen when they reach the bottom. Gary Whittingtham has done this and I wanted to do the same myself. You can see they eventua...
Mine's getting there
good anough t i feel like only muisic missign lol i meant sound effects
Yeah, and I've started adding those too
Has ship thruster and bullet sound effects so far
They're easy to add
Just a matter of time
๐ im gonna make a pygame now since im done my 1st ever actaull project
probably gonna do snake game
Yeah, it's fun if you have something you just have to make
coding is fun when u get the basics done
Or just bored and want something to do, pygame
@limber veldt where do i put the image files
I don't have any for this project but usually I'll put them in a subfolder in the same folder as my main file
woah
damn
thats really good
im thinking of making an among us clone 4 games later
Thanks, that making it in reverse thing is a struggle but I'll get it, just a matter of getting the maths right
haha, cute
my 1st pygame so far its basiccly a square u can jsut move around so far im making snake game
@limber veldt
๐
:0 cool
did the art myself
nice!
TypeError: expected str, bytes or os.PathLike object, not BytesIO
what does it mean?
All that data you see there and in the minimap is just for the Williams animation and the logo for the attract mode
That's a lot of stuff but worth it for the effects
My game loads no images from disk, creates them all from scratch
Tic tac toe
i was making a game through a tutorial help and the guy said after the episode was done now we done something of a little stupid game
;-;
@limber veldt how do you record only the python launchers window 
No
neither does any popular game engine
other than unreal engine
or atleast ive heard
?
elaborate
collidelist()
test if one rectangle in a list intersects
collidelist(list) -> index
Test whether the rectangle collides with any in a sequence of rectangles. The index of the first collision found is returned. If no collisions are found an index of -1 is returned.
so ig if i have a list of tiles, i could just use this
nvm didnt work
Whatever Windows calls their screenrecorder, it only records the focused window @dawn quiver
And those are fun effects when things don't quite work
Looks like you making progress on your mechanics
idk why its making a new image every time tho
are you clearing the screen every frame
cause it looks like you are drawing over the previous frame
That's what I was gonna ask, my dog needed help out in the rain though
i fixed it
@limber veldt I fucking did it man!!!!
I can plot each level centered within the window now!
took me long enough, lol....
I have no idea what it is but it looks cool XD ๐
thanks, it's the first level from the PC game Doom. I'm writing a wadfile parser and level plotter. I gotta switch back over to Turtle now. It's going to look way cooler. It's going to draw the map as it was created!
once I get the plotting down and animation and GUI. I'm going to get into the networked side of it. It's going to get the level information from the idgames ftp site, pull the data to a file on disk and just draw levels at random...
then I'm going to put it onto a Raspberry PI and make a "picture frame" thing that hangs on my room wall.
it's going to be sick
it's going to look like this
it's the tk Turtle module. I draw a line then 'pull' up the pen and move to the start of the next line...
Oh okay
Do any of you have experience converting your python code to mobile apps?
coming along...
Very nice... looks like a long time to render though.
this one took 3.5 secs... any ideas on how to speed it up? This was with the 'tracer' off....
OpenGL? lol
this one.....
yeah I might be pushing Turtle a bit, lol
jeez that is really cool
Asking that is like me asking you if you know how to make my car go faster. And then tell you it's a sedan.
Not enough data.
time different parts of the algorithm and find your bottle neck.
Check the assembly code of that part and see if you can write it a different way so that it is more efficient.
and surprisingly detailed
It is very nice work
these few are from the "Whispers of Satan" pwad...
im sorry i have no clue what that is
user created levels for the old pc game "doom"
it's an 'over-head' view of the level
as seen from the auto-map
ahh ok
it's a level from a doom pwad.
i'm writing a program that parses the level data within wadfiles and plots it
:0
So far so good
๐
me and my friends are gonna make a sumarai game soon
Code for imploding that logopy def implode_row(self, offset, vel_y): loc = [self.x, self.y + offset] vel = [16, -vel_y] rect_x = 0 rect_y = offset loc_x = loc[0] - vel[0] * 100 loc_y = loc[1] + vel_y * 100 for i in range(40): particle = LogoParticle([vel[0], vel[1]], self.surface, [loc_x, loc_y], [rect_x, rect_y, 5, 5]) rect_x += 10 loc_x += 70 vel[0] -= .6 #loc = [self.x, self.y + offset] vel = [4, -vel_y] rect_x = 5 #rect_y = offset loc_x = loc[0] + -vel[0] * 100 #loc_y = loc[1] + vel_y * 100 for i in range(40): particle = LogoParticle([vel[0], vel[1]], self.surface, [loc_x, loc_y], [rect_x, rect_y, 5, 5]) rect_x += 10 loc_x += 70 vel[0] -= .6
Particle args: vel, image, pos, blit_rect
I should just add another arg to it and pass lifetime, too. LogoParticle() is exactly the same as EnemyParticle() except one has a longer age before it's killed
Velocity describes its direction and how fast it's moving, image is the image/surface to make the particle from, pos is where it's born, and blit_rect describes the source x/y/width/height in the image/surface for the particle
Since I'm using a surface of 70 pixels height and making 6x6 particles from it, I need to call implode_row() 12 times, once for each row of 6 pixels
def implode(self):
self.implode_row(0, -5)
self.implode_row(6, -4)
self.implode_row(12, -3)
self.implode_row(18, -2)
self.implode_row(24, -1)
self.implode_row(30, 0)
self.implode_row(36, 1)
self.implode_row(42, 2)
self.implode_row(48, 3)
self.implode_row(56, 4)
self.implode_row(62, 5)
self.implode_row(68, 5)
Nice but increase fps and reduce dx, dy
:0
wait wait
dont tell me
you created an object for each particle
anyways
anyone have any ideas on how to make proper matrix movement
.......
Like i want my matrix to change position when my character moves as well
i did do that but
if you watch carefully
only the image is changing position
the object itself(the rectangle) is in the same position
thats why he randomely stays in the air
because thats where the rectangle is
def draw(self):
for tile in self.tile_list:
x = tile[1][0]
y = tile[1][1]
key = pygame.key.get_pressed()
if key[K_RIGHT]:
bx -= 5
if key[K_LEFT]:
bx += 5
tile = (tile[0], pygame.Rect(x+bx, y, 30, 30))
screen.blit(tile[0], tile[1])
this
is
dumb
only lasts for one tile
Each particle needs to be a sprite so it can be added to and drawn by the sprite group
It's all objects
My list of sprite groupspy player_group = pygame.sprite.Group() thruster_group = pygame.sprite.Group() star_group = pygame.sprite.Group() bullet_group = pygame.sprite.Group() enemy_bullet_group = pygame.sprite.Group() particle_group = pygame.sprite.Group() thruster_particle_group = pygame.sprite.Group() tiny_enemies_group = pygame.sprite.Group() enemy_group = pygame.sprite.Group() enemy_spawner_group = pygame.sprite.Group() exploding_enemies_group = pygame.sprite.Group() player_explosion_group = pygame.sprite.Group() coll_rect_group = pygame.sprite.Group() attract_group = pygame.sprite.Group() human_group = pygame.sprite.Group()
I have this project setup as to have very little logic outside of objects. My main while loop just checks for keypresses and that's not permanent, since the player is controlled by keys, those belong in the Player() class
I'll probably restructure some things and add a main game class to take care of game states
Instead of player states
Hey @nocturne vale!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
why is
https://paste.pythondiscord.com/eyijuhulen.rb
not showing 2 squares for the snake
@limber veldt
No idea, it didn't work for me...hung after I pressed a couple of keys
Hey @marble bison!
It looks like you tried to attach file type(s) that we do not allow (.exe). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
o
๐ข
send a .mov file
how
ok
send a screen recording
yes i totally create virus ๐
@dawn quiver
@limber veldt
it hS MUISIC AND SOUnd effects but i had it mute
tutorial
yes ik
im gonna make a sumari game
try this
coool!!!
same thing jsut more detailed art by me code by me and my friend(who might not be able to be with me in the summer)
Was there any ML interested in this, looks very cool i wanna try, is it open sourcE?
nvm i know another algo the same thing opensource
nice
ML? Sure, it's @ https://github.com/InZane84/WADdle-Plot-CLI You'll need to 'pip install planar' and grab waddle_plot.py and waddle_plot_main.py ...
thanks!
wait u didnt use a venv?
so i cant just
-r requirments
?
woah thats a pretty big licence
do you pay for that 
Hey @grim abyss!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
bruh wow
im seeing so many op tkinter projects today
oh wait
you used turtle
# DEBUGGING ==========================================================
# self.debug_points = self.getPoints("vectors.bin")
# self.canvas.create_line()
# self._points_toFile("vectors.bin")
# ===================================================================
# ============================|
# These two are set... # |
self._wadfile = None # |
self.level = None # |
# =============================
# here... # |
self.game = "DOOM"
self.loadWad("C:\Pydevel\WOS.wad") # |
self.loadLevel("MAP03") # |
# =============================
comments lvl 100
lol, yeah turtle and tkinter. I'm trying to push the new main file. I have a map selection box
Very important behavior kind of working! Lander finds human (red block for now), descends, grabs it and head for the top. If he gets there, turns to a mutant
Clever use of hidden collision rects
let's see...
Ok, I'ma show you code that has extra stuff in it...more than necessary for the basic particle, those lines are marked with # not```py
class Particle(pygame.sprite.Sprite): # used by PlayerExplosion
def init(self, vel, pos):
super().init()
self.image = pygame.Surface((3, 3), pygame.SRCALPHA)
self.image.fill(WHITE)
self.rect = self.image.get_rect()
self.rect.x, self.rect.y = pos[0], pos[1]
self.x, self.y = pos[0], pos[1]
self.fx = float(self.x)
self.fy = float(self.y)
self.vx = float(vel[0])
self.vy = float(vel[1])
self.age = 0
self.alpha = 255 # not
self.color = pygame.color.Color('white') # not
self.color_cycler = ColorCycler(['white', 'white', 'white', 'orange', 'red']) # not
particle_group.add(self) # maybe
def update(self):
self.color_cycler.update() # not
self.color = self.color_cycler.current_color # not
self.color[3] = self.alpha # not
self.image.fill(self.color) # not
self.fx += self.vx
self.fy += self.vy
self.rect.x = int(self.fx)
self.rect.y = int(self.fy)
self.age += 1
if self.age > 60: # not
self.alpha -= int(255 / 15) # not
self.alpha = max(0, self.alpha) # not```
ayy thanks
but
We need to cast the x and y to and from floats for the math

so you mean a random position?
That part is necessary to understand what I'm doing
Hm
That's JUST the particle
but are each of the particles images or pygame pixels? 
You have to give it a starting position and a velocity
Look at the code, it's a Surface of 3x3 pixels, make it anything you want though
how to make that particle
:0
OHH
We're getting there
Now on tto making an explosion of them...
i was going to make frames for each of the particle explosions haha
this is better tho
This is way better
Sets the surface to handle RGBA colors
:0
Instead of just RGB
i need to make a red particle explosion
cause blood
hmm
thanks
this was a good idea
Color values will be 255, 255, 255, 255

actually (255, 0, 0) for red
so i have a a question
is arcade for performant than pygame?
actually it doesnt matter, solo dev, not a big diff
Like pygame.color.Color('white') is (255, 255, 255, 255)
yep
wait
isnt it
(255, 255, 255)

Nope
:0
Four values for pygame.color.Colors
ic
You can choose to ignore the fourth value, it defaults tto 255
Now, onto this explosion...
particles are interesting
Im thinking
that ill just get a center point (zombie pos) and then
make a random lenght from 10 to 15 pixels
and make a random number of particles from 12 to 23
So what you need is a partticle generator that gives them a random velocity and direction
We have the particles, just need the generator
Because all particles going the same speed just makes an expanding circle
Right?
nice talking with you!
no
So we have tto randomize their speed
Yeah
Velocity is speed
because i used vel_y for my gravity
acceleration doesnt' changes for particles
Right
yep
altho
acceleration for these particles
If you want to apply gravity then you can use that
So you apply that gravity in the Particle class itself...
For the particle generator, I'm using this...
class PlayerExplosion(pygame.sprite.Sprite): # used by Player
def __init__(self, x, y):
super().__init__()
self.image = pygame.Surface((1, 1))
self.rect = self.image.get_rect()
self.x = x
self.y = y
self.initx = x
self.inity = y
self.numSparks = 30
self.age = 0
self.exploding = False
def update(self):
#if not self.exploding:
randDir = 0
for i in range(0, self.numSparks):
self.exploding = True
randDir = random.uniform(0, math.pi)
#randDir += math.pi / 4
randSpeed = random.uniform(-5, 5)
#randSpeed = 8 # random.uniform(-5, 5)
xv = randSpeed * math.sin(randDir)
yv = randSpeed * math.cos(randDir)
particle_group.add(Particle([xv, yv], [self.x, self.y]))
self.age += 1
if self.age > 20:
pygame.sprite.Sprite.kill(self)```
xv and yv are the key
yk what i mean
hmm
well
i dont use the math module
hopefully i dont need to use it here
You'll need cos and sin where ever you get it
normally when i see the math module in pygame, i immediately feel like this is a tutorial scam haha
not really
there are other ways
Yeah
Of course there are other ways
i used cos and sin for my rotation game
I said no matter how you get it
That gets this explosion, tweak as desired
So you don't believe in doing math with something but you import a library/module for other things
sneak peak at one of the good guys in my upcomming games
What?
That's quite a thought
because those tutorials never explain the math behind it
they just use it and be like "uh yeah this is what you need to type to make this happen"
:0
Well that may be the case, doesn't make the methods any less useful
Calculators have sin and cos keys, damn hackers!
gn! gotta sleep fr now
is it good or should i make better
Go back to school and learn how to calculate them yourself, slackers
.
As a rough draft, that's fine, but he'll need some work before final production
That's quite a complex enemy. The lander grabs humans, tries to mutate them and if I shoot them on the way to the top with a human, it let's the human fall. During that fall, if the player collides with him, he will be caught by the player until gently returned to the ground
@limber veldt @dawn quiver like it now
Yeah, that's prettty good, nice cartoon attitude
my brother did it hes good at art
any charcater ideas
@limber veldt 
Rescuing humans is almost a success
I can catch them if they're falling and deliver them safely back to the ground
I don't like how squishy the humans are due to its later than player position updates
Like if I fly fast or slow, the human 'slides' back and forth down there
Best thing to do to fix would be to update the human's position in the player object which means the player object needs another flag variable to indicate whether or not he's carrying humans
And if so, which humans
So that it knows which to update
I'll just make the human, who knows that he's been caught by the player, saypy player.human_cargo_list.append(self) then the player will have them in its own list
Player that is, not human list
That's a brilliant idea
Then, I can get the len of that list to know how many bonus points to increment score when player delivers human(s) to the ground
are you using arcade or pygame ?
I can understand that! programming is fun!
lol, good analogy...
My game's a remake of an old classic so I can't take all the idea credits but this python implementation is all mine
for sure
Eugene Jarvis, head writer of the game at Williams Electronics in 1980 gets all the idea creds
Just imagine, he was doing this shit on a 6809 8-bit 2 or 3 mhz CPU with a 6808 co-processor
In assembly! no less
yeah, it's wild. i bet the workflow sucked...debugging..
I can read that code, at least a little of it and make some sense out of it but I can't find a complete disassembly only a partial one
I wish it were better documented
And more complete
But whatever, I can make do with out it
@limber veldt so there's a website with alot of 'levels' created by the community that I would like to download the .zip's from and extract them in memory and plot them. Would the library 'requests' be the best forthis? This is the site: https://www.doomworld.com/idgames/levels/doom2/g-i/
the site doesn't have any kind of 'API' exposed..
Oh man, no idea, ,never used requests or web stuff
is there a simple way to organize several sets of stats so they can be called on for encounters? (e.g. the player bumps into the goblin's overworld sprite and has to fight X many goblins + Y many slimes where X and Y are random positive integers)
spawn new enemy instances on overworld_enemy.onContact ?
in turtle how can i use WASD instead of my arrow keys ?
heres my code
onkey(lambda: change(10, 0), 'RIGHT')
Looks like I have all the states worked out for my humans and landers
Humans have these states: self.walking, self.caught_by_lander, self. falling, self.caught_by_player
Landers have these: is_alive, is_dropping, is_searching, found_human, descending and ascending
My landers have two additional collision rects. One to detect humans under it, the other to detect ground and keep the lander flying just above the ground and following the terrain
But when he detects a human underneath, it overrides the ground collision
So the sprite.collision methods return a list of group objects colliding with a sprite and we can get the group sprite with [0], like sopy human_hits = pygame.sprite.spritecollide(self.human_rect, human_group, False) if human_hits: self.human = human_hits[0]
In my case, I'm only interested in the first item in the list even if it has multiples
Because a lander can only pick up one human at a time
All sorts of nuances to tthis though
Wttf is with my t key
Like if a human is already being picked up, other landers need to ignore it....or anytthing else. That's why I needed the walking state for the humans, they can only be picked up if they're walking
The landers will need more states too because they're not always searching, sometimes they just fly and shoot at player
And when they lower down to snag a human, they hover just above for second or two firing a barrage of bullets at the player then takes off with him
hi, i need some help...
this is my script
...
and i keep getting this error
if you see this message and know how to help, pls ping me
I'm a beginner btw, i thought i'd let you know...
line 10 or sopy p.initshould bepy p.init()
Sorry, forgot to ping
Try that, see if it works
Ok, leave it as the corrected version, it needs the ()...
IMAGES[piece] = p.transform.scale(p.image.load("images/" + piece + ".png"), (SQ_SIZE, SQ_SIZE))
it says that line has an error :/
Oh, ok
So you need to find the file you're trying to load
This is likely wrongpy p.image.load("images/" + piece + ".png")
That need to point at the file you're trying to load and apparenttly it doesn't
Just to try something, you can saypy IMAGE[piece] = p.Surface((10, 10)) IMAGE[piece].fill(p.color.Color('red')) instead of the line that's giving you the error and you should get a red square for the piece and no errors. How to fix it to use the images you have depends on where you put those images on your harddrive and in relation to the file you're running
You could use an absolute path to the images but that's not best practtice
I mean, can if you want but the real fix is to point that line at the correct location of your images
This not the path: "images/" + piece + ".png"
Yes, but change all the \ to /
p.image.load("C:/Users/Shyaam/PycharmProjects/Chess/Chess/images\" + piece + ".png")```
ohhhhh
p.image.load("C:/Users/Shyaam/PycharmProjects/Chess/Chess/images/" + piece + ".png") did you mean that?
oops, I mistaked and didn't change your \ to /
ok
Corrected up there^
the pygame which pops up is just blank :/
its shud look like a chess board with pieces on it
I don't know why my t key want to intermittently repeat
just so you know, this is meant to be a chess game
but I've only programmed to draw the board so far...
you can save the image in the same folder as that of your code which is used to execute
then you won't have to write the full path
just the image name and extension
Ok, so you're running main() but I don't see where main() is calling drawGameState()
Or drawBoard, for that matter
oh
so what do I do in that case?
"""
This class is responsible for storing all the information about the current state of a chess game. It will also be
responsible for determining the valid moves at the current state. It will also keep a move log.
"""
class GameState:
def __init__(self):
#board is an 8x8 2 dimensional list, each elements has 2 characters.
#The first character represents the color of the piece, 'b' or 'w'.
#The second character represents the type of the piece, 'K', 'Q', 'R', 'N', 'B', or 'P'.
#The string "--" - represents an empty space with no piece.
self.board = [
["bR", "bN", "bB", "bQ", "bK", "bB", "bN", "bR"],
["bp", "bp", "bp", "bp", "bp", "bp", "bp", "bp"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["--", "--", "--", "--", "--", "--", "--", "--"],
["wp", "wp", "wp", "wp", "wp", "wp", "wp", "wp"],
["wR", "wN", "wB", "wQ", "wK", "wB", "wN", "wR"]]
self.whiteToMove = True
self.moveLog = []
thats another part of the whole chess engine
its in another seperate python file...
Line 39 sayspy clock.tick(MAX_FPS)just before that line and at the same indentation level, put apy drawGameState()
ok
i know is againts to rules to pay for work but i was wondering is there a server i can join to pay someone to make a script for a compress file ?
drawGameState(screen, gs)```
You drawGameState is expecting those to be passed, we better pass them
Ok, let's comment out the drawPieces() line from drawGameState(), like sopy def drawGameState(screen, gs): drawBoard(screen) #draws the squares on the board #add in pieces highlighting or move suggestions (later) #drawPieces (screen, gs.board) #draws the pieces on top of the squares
So we can just deal with getting the board drawn
Forget players or pieces, just get the board drawing
yeah ok
You should work t hrough these things as you do them, don't move on to the next until the first is working.
I'm not sure what p.Color() is but maybe you needpy p.color.Color('white') and py p.color.Color('gray') although it should be giving an error for the way you're doing it, try that way
This a perfect project for a grid class but that's beyond what we trying to do here...
oh ok
thank you very much for helping me
you were done right?
or is there anything else we can do??
I'm trying to get it running here to draw the screen or see why it's not, but you have imports that I'm not willing to install, so working around that
ahh ok
Your corrected drawBoard()....
def drawBoard(screen):
colors = [p.Color("white"), p.Color("gray")]
for r in range(DIMENSION):
for c in range(DIMENSION):
color = colors[((r+c)%2)]
p.draw.rect(screen, color, p.Rect(c*SQ_SIZE, r*SQ_SIZE, SQ_SIZE, SQ_SIZE))```
wait whatt??
hold one
what are you using?
are you using pycharm or something/
?
VSC
Same here
yeah
VSC = Visual Studio Code
hmmm
Let me share the complete file I have here...
oh ok
yes please
!paste
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
So maybe you can work from that
mhmm
I want you to notice what I changed in that drawBaord() function though
# your code....
colors = [p.Color("white"), p.Color("gray")]
for r in range(DIMENSION):
for c in range(DIMENSION):
colors = [((r+c)%2)]
p.draw.rect(screen, color, p.Rect(c*SQ_SIZE, r*SQ_SIZE, SQ_SIZE, SQ_SIZE))
ok
You're assigning colors twice
When what you really need ispy color = colors[((r+c)%2)] to assign colors to color and use color in the draw.rectt()
Damn t key
ok
loll
I like that way of oscillating the variable though
(r+c)%2
No problem, onward to getting those pieces drawn, good luck
thanks
Currently trying to squash my own bugs, this lil human should be falling after it lost the lander that was carrying it
That's the most fun of making your own game, you can spawn as many or as few of anything and be invincible, lol
Wanna test landers and humans capturing/releasing/falling, whatever interactions, just spawn hundreds of them
If there's a bug, it'll show
Like that one
does anyone know about ursina?
nice
Landers can shoot when hovering over human for a second, still need to do more random shooting but the barrage is working
I give the bullets a random target on a 120x120 pixel area around the player
No need to shoot straight at the player, just toward
just a comment: if your game window is resizable, pixel area is inconsistent as the pixel area needs to be resized too.
Doesn't matter, if everything scales, it all scales but no, it's not resizable
not resizable then ๐
hi guys just a noob question here, can you make kind of complex 2d games such as old rpgs in python or can u not
I had some extra particles being thrown into the particle group from my bullets and their particle effects, removed those and it def made a difference in performance
Most definitely
for a complex one, you might want to use a framework with hardware rendering
The performance of python starts to suffer heading into 3d games but for 2d, even with lots of things, python handles it fine
such as arcade
i dont really know what that means yet but thank you very helpful
i just started a week ago u see
basically arcade or pyglet
oh ok
oh then do pygame
That sure is appealing, the hardware rendering in Arcade
after some experience, you might want to move to arcade
i have a book called usborne coding for beginners and that eventually tells you how to make simple games
in pygame?
no
it doesnt say anything about that
i have watched videos about pygame though
this may be a stupid question but are 2d games such as hollow knight and undertale doable on python
of course they are
really thats cool, i was told python isnt ment for games
it actually isnt
c++ is what i was told is
yep. but with c / c++ bindings with python, you will be able to do just fine
i taught myself (this is getting off topic)

can somebody look at my game?
Hey @cold crow!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
!code-blocks
Here's how to format Python code on Discord:
```py
print('Hello world!')
```
These are backticks, not quotes. Check this out if you can't find the backtick key.
hai
I need help...
again
.
I'm making a chess engine
and right now
Im drawing a chess board and the pieces that go on the chess board
however
I've been trying for like 3 hours
but I still couldn't fiigure out how to get the pieces onto the board..
this is my script
scroll down to line 69
Lovely
e2
to e4
So....I made an attribute called self.captor in my human class. My enemy landers search and find the humans. In the lander code, I get a reference to the human from the sprite/group collision. But the human doesn't get a reference to the specific lander that grabbed him
And he needs one. So in the lander code, since I have a reference to the human, I can assign an attribute from the lander
The reference of the captured human is called self.human in the lander. So I just say self.human.captor = self
But there must be a better way
The humans can be shot and killed by the player and if that happens, the lander is going to need to know about it so during the human kill() method, it can tell the lander to go back to attacking or searching
Basically to stop mutating
Wait just a minute
Upon further inspection of the game, when the human is killed, they continue to mutate anyway
if __name__ == "__main__":
main_pygame = pygame_instance((200,200),"HP")
main_pygame.inst()
screen = sys.modules['__main__'].main_pygame.screen
print(type(sys.modules))```
Would it be bad practice to access screen like this from other modules? Or just in general python usage?
finally have a File menu to open wadfiles...
a 'progress' bar is surprisingly hard to implement. I guess you have to spawn it in a new thread and poll something. I don't even know. Gave up on it after about 45mins.... I'll get it working eventually....
Splashscreen done except for copyright notice
Almost exactly the same as the game it copies
And those maps are lovely, I remember making them myself, big ones too. I made a pyramid level with multiple 'floors' and shit, was pretty good
Doom couldn't really do 3d
So rooms or floors atop one another weren't really possible
But you could fake it with clever switching player locations
yeah, really the only reason I'm working on this application is because I've been messing with it, literally since I started programming with Python. It's time to finish it now and move on to something else. There's alot of work left though. I want to add in some kind of file browser from the ftp.idgames site and remotely display wads from the zipfiles on the ftp site...
So what are you, implementing Defender in Python?
from the ASM source?
Yes, but not really from source. The source I posted is useless to me since it's incomplete
From visual reference
ahhh cool
woahh
Hello everyone, I have a super basic question. I was trained in matlab for my degree as my first/most frequent code that I have used. I am following a tutorial on how to create your own version of Space Invaders and want to use some numpy arrays to keep track of vertical and horizontal movement. But the code is not working. Should I abandon my use of arrays or is there a way to put said arrays in the following function?
enemy_pos = np.array([0, 0])
%%Function I am calling to put in enemy position
def enemy(pos):
screen.blit(enemyImg, enemy_pos)
%%Game loop
While (condition that i know works)
%%Controls code
%%Movement code
enemy([enemy_pos])
I started on Sunday with pygame
At worst, you can always convert a numpy array to a normal list (.tolist) if some function doesn't like dealing with one.
Thank you for replying, I will look into how to work with tables
There's a module for it, or you need only pygame?
!pypi progress
!pypi better-progress
pretty sure they mean graphical progress bars in tk or whatever framework they are using :^)
I am new at game development
will you all see something?
please
uhh how do i make my py file into an exe, dmg and debian
using auto-py-to-exe?
you have to do some simple steps:
Execute the Following commands in the terminal:```
pip install auto-py-to-exe
auto-py-to-exe
then just select the options you want
and It will do the trick
thx mate
Hey @pliant elbow!
It looks like you tried to attach file type(s) that we do not allow (.zip). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
can you please check out my game https://github.com/KavyanshKhaitan2/Transfer ?
please run the main.py file if you do want to
the loading.py file is also nessecary
hmm i will try it out after i upload my game
You forgot =
Just before your highlighted selection, the letter p in pygame, put =
self.screen has to equal something, it's an assignment, you need the = for that
Question: If you have and are using only one instance of a class, is it more appropriate to use class variables for some data than instance variables?
Or even global variables, for that matter
They're constants
If anyone is new, I have example code for basic Pygame here: http://programarcadegames.com/index.php?chapter=example_code
...and Arcade here:
https://arcade.academy/examples/index.html
https://arcade.academy/examples/radar_sweep.html#radar-sweep is interesting... wish I understood the math required to implement it though...
Yandere Simulator would prolly run better in Python, and if it had good programming like dear god
mhm
Well, I do
But well beyond the scope of the help I can get here : )
ok
well
im tryna get pieces to move
ive done the prgraamming
but i cant figure out how to fix some of the errors :/
@limber veldt
What do you mean when you say move?
Disappear from one place and reappear in another or actually animate them sliding on the board?
Right
Get a reference to the image or surface that you want to move and find how to drag it around the screen
wait whats that link for me to upload the script?
Constraining the pieces to grid squares on the board
right
I can think of how I would do it but it's totally different than how you're doing any of it
My board would be a grid of separate objects with attributes like x, y and image
Oh ok
When you click on one of the objects with an image, that image follows as you drag then, when you drop, the image changes location from old to new
yeah thats why I did this:
if len(playerClicks) == 2:
move = ChessEngine.Move(playerClicks[0], playerClicks[1], gs.board)
print(move.getChessNotation())
gs.makeMove(move)
sqSelected = ()
playerClicks = []
That keeps the images perfectly centered in the square, too
Ask questions about games or share what you've learned or whatever
this is a coding server
...
you can go to #โ๏ฝhow-to-get-help
thhere are several coding languages..
do you know any?
if not, you might want to learn some basics...
this server is specifically for the python coding language..
hmmmn
you can search some tuttorials on youtube...
im not the right person to ask here
but
like I said before
you should consider going to the #โ๏ฝhow-to-get-help channel
and from there some other members will be able to help you (:
@dawn quiver You might want to look at https://learn.arcade.academy if you are just getting started.
Hi, me and my friends want to create a monopoly game but we hesitate between python and java
What do you think is the best language for this?
We also think of developing the game with new features like income from stock exchange in game
I would say that Java is not a good language for this. At least when I made a game, there's a lot of boilerplate code.
Thanks
i have a question about pygame:
is there a way to use polygons for collision detection instead of rectangles?
because i'm coding a car game, and i want the car to be slower when touching grass, but when going diagonally the rect is giant and always touching grass, which is why i wuold like to use 2 polygons at the cars edge instead of one giant rectangle. is this possible to do?
code for collision detection:
def update_drag(self, screen):
pxa = pygame.PixelArray(screen)
tl = self.rect.topleft
pxa = pxa[tl[0]:tl[0]+self.rect.w, tl[1]:tl[1]+self.rect.h]
# t0 = time.time()
# if (np.any(np.isin(pxa, 25885))):
# self.roll_resistance = self.grass_roll_resistance
# else:
# self.roll_resistance = self.street_roll_resistance
# print("time np = " + str(time.time() - t0))
#this is acutally faster then using numpy for some reason
if (25885 in pxa):
self.roll_resistance = self.grass_roll_resistance
else:
self.roll_resistance = self.street_roll_resistance
can someone help me with making a menu in pygame? I made it so when you click a button it does a function where it makes the screen red. But it only makes it red for a split second...
@wicked lintel You can use the "shapely" library to manage polygon collisions. It includes functions for that. It is pretty quick too. (If you aren't married to Pygame, the Arcade library automatically makes polygons off a sprite for more accurate collisions without the effort Pygame requires.)
I'm completely new to making games using python. In the past, i used java and in it none, then greenfoot, then a self written one.
so i'm open to new things
maybe i'll take a look at the arcade libary
https://arcade.academy if you are interested. Best of luck!
I have a question about a bit of code that I got from https://pygame.readthedocs.io/en/latest/2_draw/draw.html#draw-a-pologyon-line-with-the-mouse which I'm using to learn the basics of pygame. What does True do in line 52 of the code. If it is removed, I get a TypeError: points argument must be a sequence of number pairs.
Oops maybe question is unclear because there is no question mark: What does True do in line 52 of the code?
an example of the program when it is running
Thanks in advance for anyone willing to give me a hand.
Commentator, What's bugged on it? Want to make sure it gets fixed.
Im making a flappy bird game in pygame having some issues where if the user escapes to the menu screen then clicks to play, the pipes do not appear as expected and creates an impossible game. Any ideas how i can resolve this issue, or what might be causing it?
Hey @pine marlin!
Uh-oh! It looks like your message got zapped by our spam filter. We currently don't allow .txt attachments, so here are some tips to help you travel safely:
โข If you attempted to send a message longer than 2000 characters, try shortening your message to fit within the character limit or use a pasting service (see below)
โข If you tried to show someone your code, you can use codeblocks
(run !code-blocks in #bot-commands for more information) or use a pasting service like:
if you want the full code with sprites and stuff to test it yourself
https://github.com/Asianguy123/Flappy-Bird
any help would be appreciated, thanks in advance
65 sprite objects in my game, many of them having multiple instances during game play O.o
Some of them tiny, like the background stars, they're only a couple of pixels, or the ground cells which are nine pixels, but there are thousands of them
well your randomizing the game
obviously there will be impossible ones to solve
what you need to do is randomize with limits
make the values your randomizing based on the current situation of the player
and makes sure its possible to go there
for example
if player is in pos (100, 100)
then make sure that the random value at which the gap is, is somewhere between random(x-some value, y-some value)
that way it will always be possible to solve
also keep a uniform distance between each of those poles
can anyone give me some games project I can try to do by my own as a python beginner?
monopoly
ehhh, idk much about monopoly but I guess I'll try, thx
chess
eh, that can work
can u send me the game so i can try
sure, but I'm not gonna start yet tho, I'm trying to learn pygame fully
pygame is good
I see
just wanna ask, can I use tkinter to actually make games?
I see
pygame is okay
so in order for the game to run smoothly
tkinter is good for UI
I should just use pygame?
of apps
oh ok
well for that, and its more supported so you will get more help
I see, thx for the info
ohh
:>
tkinter is good tho
dont let anyone tell you that pyQt5 is just way better and you cant do shit with tkinter
search up thonny
it was made with tkinter
pyQt5 is good
im not saying its bad
but tkinter is also very powerful
for making apps
oh alright
desktop apps
I only learnt how to use tkinter for apps so
@glossy quarry
but probably will try those you mentioned in the future
thats what im working on with pygame
ive made a lot of games with it
anyways
im more into system design, ML and all
cool
so im doing that
I see
not UI design ๐
eh
in system design
all those ''self'' are from a class right?
You need to draw blocks and explain how different services interact with each other, for example, the app, location, payment service ect
yeah
oh I see
Using OOP is a good way to both minimize and organise your code
ok got it
Those long lists of datas, I moved them to a separate file and import them. Nice having all that out of my way in the main file
Watching a video of a streamer coding pygame and he's complaining that the pygame docs suck...they kinda do. Like I understand that docs are docs, not tutorials, but is there anywhere that actually teaches how to do those things besides youtubers who could be right or wrong about what they're showing?
Hi, someone has been using Ursina? I want to detect when an entity with a MeshCollider collides, ive been searching for hours but there is no tutorial about it on the internet
Hi, with the turtle module, how would you go about adding a pause function, which method or function would you use?
but just making a boolean to decide if you are paused or not is better imo, but i dont know how turtle works and i have never used it so i dont know how would that go for it

just make a variable which stores True if you want stuff to be paused or False if not, if the variable is False draw your usual stuff, and if its True draw the pause screen
thx for help
And toggle your variable between True/False with the key you want to use for pause, like if variable is named 'paused', just do paused = not paused


