#game-development
1 messages · Page 77 of 1
@potent ice do u try using : ) and it gets translated to 🙂?
?
: ) feels good
🙂 feels soo dangerous
There you have arcade using a tmx map with pymunk physics : https://www.youtube.com/watch?v=cr2swAA_Tb8
This uses the "Arcade" and "Pymunk" libraries from Python to create a physics-based platformer.
For the code:
http://arcade.academy/examples/pymunk_platformer.html
I am thinking about learning Ar...ca...de..?
You can do that in pygame as well, just a bit more work
huh
yup ig its fine
ive only used pygame and u pretty much have the most basic features in it
like drawing lines and boxes
so ull learn more with pygame, but it will take time and ull gain some skills u probably wont use ever
but arcade will be faster to learn and easier to use ig
?
um... does it have to do with game dev?
nope
cuz this is a game dev chat
oh sorry
'tis ok
send it in anyways
you can try claiming a help channel
cya then/:
yeah
can i send it in private dm's?
bc it's like 25 questions
Matters who
😕
is it school homework?
BTW I am a noob so don't ask me
yes it is
im pretty trash too, but someone will help
ok
yo u the dude who puts
"to whomever may read this, have a nice day"
in the end of every yt vid?
@dawn quiver you can either try claiming a help channel (and sometimes if the questions are about the same code you can ask your other ones in that same channel) or try the #python-discussion if they are smaller questions
no...
xD'
if its school homework people will get irritated
yeah
yeah but sometimes it is fine
ig
thanks @low shadow and @potent ice !
I think when choosing a library you should spend some time looking though the documentation and examples
Then you will get a better feeling what the library is about
@potent ice
sorry for the ping but it was the only way to contact you
are you there?
do you know a programming language?
nope
I would start there
can you teach me?
No, there are many resources on the internet and I'm sure there are schools around you that could help you
Find some beginner tutorial
learn programming with arcade : https://learn.arcade.academy/
learn programming with pygame : http://programarcadegames.com
free books
Or seek out the official docs for either of these projects
What's a good place to find riddles or puzzles to solve that I can add to my game?
Is https://realpython.com good for Pygame?
hello
einarf, any idea on how to fix the overlining of pieces?
def vinnare():
drag = [x for x, letter in enumerate(spelbord) if letter == '' and x != 0]
move = 0
for drag2 in ['O', 'X']:
for i in drag:
spelBord2 = spelBord[:]
spelBord2 [i] = drag2
if isWinner(spelBord2, let):
move = i
return move```
@potent ice sorry for tagging but how does that look?
yo
im not really using any particular framework, just vanilla python
im new to game dev stuff and i want to make a turn based game
i can create an actor function for entities like the player and enemies
but how would i go about designing the actual battle/gameplay loop
but which website can i use to make a game?
What kind of game?
So a 3D game?
Or you can use Panda3D directly
That's at least the easiest way to make that kind of game with python
You can use other game/graphics libraries as well, but those are more low level (more effort)
If you have never worked with 3D before and find this very difficult you might want to try something 2D first 🙂
There is a Panda3D discord server as well
@civic kernel You could start with this free book using arcade : https://learn.arcade.academy/
A lot of the concepts there translates well to other game / graphics libraries as well
einar
ive made a lot of improvements
been awake for a long time
but now this error comes up line 117, in Manniska pjaser(-280,80)
TypeError: 'list' object is not callable
does anyone know what is the best software I should use to create pixel art?
okie
okie thanks anyways
Hi ! Sorry to disturb you all but I have a quick question : How can we replicate a cmd-style shell of our own in Python ?
Hello, I have a sudoku.py file that works on someones computer(Mac OS) and it doesn't work on mine (Windows)
Send it here
I'll check it out
I don't know if i can fix it tho
okay 1 sec bro
Aseprite
Krita
Aseprite is the best, but it's paid,
but the GitHub code is open to all so there are many downloadables available for free. u can download a .exe application from people who have already compiled the GitHub code or u could compile it yourself by following some yt vid
I'll check it out in some time
i appreciate it a lot honestly, more than you think thank you very much!
https://paste.pythondiscord.com/yeketubuqo.apache this is a fixed one that one couldnt run onscreenclick
@low shadow hello, how did it go?
Hello everyone. Im currently working on game in pygame. But Im sort of stuck. I need to rotate a image so that its facing the mouse cursor. In other words I need to calculate the what the angle of the mouse is and then rotate the image. Ive done the rotating bit, its just working out the angle of the mouse now. Any ideas would be great!
Heres what Ive done so far:
https://paste.pythondiscord.com/aloqefafix.properties
I have same issue in my project, I am using 2 vectors for rotation. try again with vectors, You wrote angel = pos[1] I think pos[1] not a angle so you cant use it for angle.
i checked it and its turtle lib and its 300+ lines
i dont know turtle but ill try learning some basics and then ill help you
as of now, i wont be of much help
and i dont understand the comments. I dont know the language you have used
so it will take me some time to analyse the code properly too
its fine no need ill try to get help from someone else, thank you a lot for trying atleast, its urgent thats why xD
k dude
sorry i couldnt help
if i do fix it tho, ill dm you
check tech with tim's vid on projectiles. He talks about finding angles in the vid becuase projectiles make use of angles to calculate their velocity. He also provides the code for finding angles
that should help u orient your pic to your mouse cursor
Any idea what the vid is called?
@gleaming zealot knk Turtle ile pygame arasında ne fark var ?
i tried finding the vid but couldnt find it
but ill tell you what u should do
u should first calculate difference b/w sprite and mouse pointer's x and y pos
then you should divide y/x
then fin tan inverse of mod of that
btw mod means only positive
so if its -5, its mod is 5
if its 5, its mod is 5
that should give you the angle with respect to the x-axis
@fickle lion sorry i dont understand
It's not pygame, but I do the math here: https://arcade.academy/examples/sprite_bullets_enemy_aims.html#sprite-bullets-enemy-aims
I like using Piskel but it's online
There is a downloadable version though
Anyways, can I load a gif with pygame?
cuz that would save lots of time
P.S. I am not a professional so maybe check it out for yourself first
I'm making a little shoot-em-up in python using the Pyxel engine, it's pretty easy to use. https://twitter.com/helpcomputer0/status/1358525830587113482?s=20
Worked some more on the little shmup today #pixelart #pyxel #Python https://t.co/dt3lQg9zhd
Hi guys, I tried to make a simple game in which a player can shoot after a 3 seconds countdown to increase his score. However, if the player shoots, before the countdown ends, I want him to get minus points at his score. Everything is working fine, however I have one problem: I tried to deal with the countdown with a simple "time.sleep()" function, however, while I was running the "if" statement, the player was unable to shoot... can anyone help me? Im using pygame...
waiting = True
if event.type == pygame.KEYUP:
#If the player presses "g" the game begins
**if event.key == pygame.K_g:**
**pygame.time.wait(1000)**
**print("3")**
**pygame.time.wait(1000)**
**print("2")**
**pygame.time.wait(1000)**
**print("1")**
**pygame.time.wait(1000)**
**print("GO")**
**waiting = False**
#If the player shoots while "waiting" is true, he gets points subtracted
**if waiting:**
**score_value -= 1**
**else:**
**score_value += 1**
The countdown works, but while it is running, the player is unable to shoot bullets... Can anyone help?
Hey @dawn quiver!
It looks like you tried to attach file type(s) that we do not allow (.exe). We currently allow the following file types: .3gp, .3g2, .avi, .bmp, .gif, .h264, .jpg, .jpeg, .mkv, .mov, .mp4, .mpeg, .mpg, .png, .tiff, .wmv, .psd, .ai, .aep, .xcf, .mp3, .wav, .ogg, .webm, .webp, .flac, .afdesign, .m4a, .csv.
Feel free to ask in #community-meta if you think this is a mistake.
Ive made a game, human vs bot but the bot doesnt seem to start what code do i put in, i want the human to activate the bot after placing a piece
sorry, i don't know pygame, only pygame 0
my game:
my entry for pyweek30
not interessted rn im having a mental breakdown not being able to solve this issue
i can't make good games on turtle
can you solve my problem?
um, can u send me ur code?
howdy did you ever figure this out
it's fairly simple trigonometry, but idk how much you've done
and it's harder to figure out when it's code
hi so like, ive tried out ursina, installed it using terminal but for some reason when i go to pycharm and try to import it, pycharm cant find the ursina module or whatever, it worked earlier(idk how but when i did import ursina it managed to work), but i had a problem and decided to restart, and i cant get it to work again.
really gives me a headache
Is this possible?
so i making a game and i need to do onscreen help allready googled so i dont know what to do
im not very experianced with python
maybe- idk how to find ursina at ALL and how to fix it
@blissful depot yes possible
how?
@atomic mural ?
@blissful depot this will help you
to understand
thats not answering my thing i need to like a help system
its a text based game on each scene it needs to display a help menu
I can't write entire steps but
you can use Pygame.surface to create menu
search it
but its not coded in py game
so idk. I am sorry
Hey
if im trying to create a modular powerup system how do i reference the variable that im altering right now im using a constant defined in another file
would it be better to have 2 variables like
original stat = X
boosted_stat = 0
then whenevre the player gets a boost just alter boosted_stat
that way theres no bad referencing going on
also would appreciate any resources available on this im probably not doing a good job of explaning it and cant find much online in the way of tutorials
can I make pygame press a key
Hello, ive made an X and O game, code for bot and code for player. The issue i have right now is that when i try to run it and play i both control the X and the O when im only supposed to control X, can someone look over this?
Can you share your code?
Manniska() is X and i want Data() to be the bot playing against Manniska()
i know i need to make a function for it to work
but idk how
TYSMMM
yup 
new problem: "IndentationError: unindent does not match any outer indentation" level this stupid error keeps popping up. i dont even have any spaces as indentation i just use tabs- and the worse part is: I DONT EVEN HAVE AN INDENT IN THIS LINE LIKE- BRUH!??!
or maybe im just dumb
Looks like the next line is indented though
just send the code
thats kind cool. I didnt know it existed
app = Ursina()
test_square = Entity(model = 'quad', color = color.red, scale = (2,1), position = (3,4))
pp = load_texture('assets/Sans.png')
sans = Entity(model = 'quad', texture = pp)
test_cube = Test_button()
app.run()
is it a multi file program or something?
if it is not, send the full code
and there is this one problem with sublime and the idle
the indentation blocks are not the same
huh
Sublime will take 1 tab as 4 spaces
but when u open the same file using idle, the tabs will be doubled
i used to get such errors a lott
then i had to set up sublime so that such errors dont occur
the pissing off part is ud have to re-indent the entire code so that it works again
and it takes forever
send the code in anyways tho
from ursina import *
class Test_cube(Entity):
def init(self):
super().init(
model = 'cube',
color = color.blue,
texture = 'white_cube',
rotation = Vec3(45,45,45)
)
class Test_button(Button):
def init(self):
super().init(
parent = scene,
model = 'cube',
texture = 'brick',
color = color.green,
highlight_color = color.red
)
def update():
if held_keys['w']:
test_square.y += 4 * time.dt
if held_keys['s']:
test_square.y -= 4 * time.dt
if held_keys['a']:
test_square.x -= 4 * time.dt
if held_keys['d']:
test_square.x += 4 * time.dt
app = Ursina()
test_square = Entity(model = 'quad', color = color.red, scale = (2,1), position = (3,4))
pp = load_texture('assets/Sans.png')
sans = Entity(model = 'quad', texture = pp)
test_cube = Test_button()
app.run()
lmao next time u paste code, use the dicord pasting code format thing
yeah it does- the prob is that i cant get the sans texture 😦
it works fine in pycharm, but when i go to sublime the indentation error pops up
ahh yea i told you the problem
i fogot what i did to fix it, but if i do find what i did, ill tell u
Hi I've a problem with my code..
print('login Successful')
else:
print('login fail,please try again')
while True:
entered_user_name = input("Please enter the user name:")
entered_user_name.title()
entered_password = input("please enter your password:")
if entered_user_name == 'abc' and entered_password == '123':
print('login Successful')```
Can someone explain to me why it does not print login successful?
k i found it out ig
go to settings<preferences
2 windows will open
the left one will be the default
the right one will be the part u can edit
"translate_tabs_to_spaces": true
add that thing
okk
it still popped up
i even put it all to spaces
maybe you can try ctrl+f and search for space, just to see if everything's ok
and make sure it's all spaces
!code
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.
Hello, I need help with a python program. The goal of the program is to give a match list (to make a tournament) according to the number of teams. Except I don't have a clue how to do it, could you help me?
Trigonometry is pretty important for anything in game development that uses angles. I made this video to cover a couple very common uses of trigonometric functions.
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions a...
To whichever person asked about angles
Traceback (most recent call last):
File "/Users//Desktop/UPPG2_.py", line 460, in <module>
Poang()
File "/Users//Desktop/UPPG2_.py", line 402, in Poang
Rad(-100+100*i,150,-100+100*i,-150,"red")
File "/Users//Desktop/UPPG2_.py", line 382, in Rad
turtle.pu()
File "<string>", line 5, in pu
turtle.Terminator
>>>
anyone?
how to do anything with pygame?
"simple Vr Actor" living default cube added
Wrectified XR - Added Tiny fire control logic to tiny RC car script
who needs help with anything?
so u are in brackeys discord server
ok new problem..(ugh) i got an OS error now
Me ahahha
I want to create a noframe window but I need to move it around
Hi, this might be a silly one but I have a problem in Unity with a simple car racing game I'm trying to make.
The verticalInput is not responding with any key and basically the car is not moving (not accelerating). The front wheels are turning so the horizontalInput seems to be working and all 4 wheels are also not falling through terrain.
Would anyone have an idea if this would be a problem in the script or the colliders or something else entirely?
@modern marsh yea I was trying to make games with unity before, but I ditched it pretty soon
tru
too bad he stopped making vids tho
edit:spelling
plus the brackeys game jam is the biggest indie dev gamejam i think
yah
Is there a simple (ish) way to draw clouds using bezier curves?
anyone seen @potent ice lately?
I read the channel when I have time 😉
i thought something happened to you man
Let's say I was making a clone of terraria as an example, is it more beneficial (performance or otherwise) to move the terrain around the player or the player (centered with moving camera) around the world?
well either way you're not moving anything physically
either way you only draw the bits of the terrain that you need to draw, from a performance perspective those two are exactly identical just with positive instead of negative numbers
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'm trying to make a standard srs implementation of Tetris
I tested line clearing by filling the grid with o cells, and seems like i fked up a little too much...
any game engine that uses python
you can use python in godot but godot is not optamized for python
https://paste.pythondiscord.com/dokupoduyu.rb main.py
https://paste.pythondiscord.com/urumewabig.lua Ship.py
https://paste.pythondiscord.com/axehijinec.rb Planets.py
if you accept to give feedback, there are files of my first pygame experiment 🙂
I have try to use vectors and I want my ship to move parabolic with using keyboard but I couldn't it. I did it with using mouse coordinat
It depends what you mean by "game engine"
alr so i use pygame, is there any way to make a button inside of the game which closes the game? if yes could you help me please, im stuck
two most well-known "game engines" that use python are pygame and godot, but technically godot uses a seperate language called GDScript that is similar in syntax to python but is mostly different from what i've heard. but there's a lot more like kivy, arcade, and etc. check out pins if you're interested in those
@hushed bear pygame is not really a game engine. It's a lower level graphics/media library.
When people say "game engine" it's not always easy to know what they mean
Outside of python a "game engine" or "game framework" is probably Unity, UE4, Godot etc, but that's often not what people are asking about in the context of python programming.
Might be better to say "high level" and "low level" game/media libraries
Low level libraries can for example be: pygame, pyglet, pySDL, OpenGL, Kivy
High level libraries can be : Panda3D, Ursina, Arcade, cocos2d, Wasbi2D, RenPy etc
The basic concept is you need to make a rectangle and then check if the coordinates of the cursor when mouse button is clicked lies in the rectangle then you can just do pygame.quit() and sys.exit()
ah, ok. thank you!
Check this out
There are lots of examples related to buttons in pygame if you search a bit 🙂
can anyone explain sprite
It's really just an image
It's a name from 70s and 80s game systems
Just think of them as images with a size, position etc
It was mainly used in the past for player characters and enemies
What makes it a sprite is the additional functionality they provide. For example collision detection
import pygame
from pygame.locals import *
pygame.init()
#setup screen
screen_width = 1000
screen_height = 1000
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption('window')
#define game variables
tile_size = 200
#load images
sun_img = pygame.image.load('img/sun.png')
bg_img = pygame.image.load('img/sky.png')
def draw_grid():
for line in range(0, 20):
pygame.draw.line(screen, (255, 255, 255), (0, line * tile_size), (screen_width, line * tile_size))
pygame.draw.line(screen, (255, 255, 255), (line * tile_size, 0), (line * tile_size, screen_height))
class world():
def __init__(self, data):
self.tile_list = []
#load images
dirt_img = pygame.image.load('img/dirt.png')
row_count = 0
for row in data:
for tole in row:
if tile == 1:
image = pygame.transform.scale(dirt_img, (tile_size, tile_size))
img_rect = image.get_rect()
image_rect.x = col_count = tile_size
image_rect.y = row_count = tile_size
tile = (img, image_rect)
self.title_list.append(title)
col_count += 1
row_count += 1
world_data = [
[1, 1, 1, 1, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 1, 1, 1, 1],
]
#game instance
run = True
while run:
screen.blit(bg_img, (0, 0))
screen.blit(sun_img, (0, 0))
draw_grid()
print(world.tile_list)
#quit code
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.display.update()
pygame.quit()``` i am getting the error ```Traceback (most recent call last):
File "game.py", line 65, in <module>
print(world.tile_list)
AttributeError: type object 'world' has no attribute 'tile_list'```can anyone help
dw i got help
ah i see, ty
I have a problem... Nothing moves unless I move my mouse or press any button, can someone tell me why?
import pygame
import time
import random
pygame.init()
screen = pygame.display.set_mode((1000, 1000))
clock = pygame.time.Clock()
gravity = 1
monkey_movement = 0
grass = pygame.image.load('D:\game\grass2.png')
monkey = pygame.image.load('D:\game\monkey.png')
monkey = pygame.transform.scale(monkey, (260, 400))
pygame.display.set_caption("Monke!")
floor_x_pos = 0
while True:
for event in pygame.event.get():
screen.fill((0, 150, 230))
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
print('kaka')
monkey_movement += gravity
screen.blit(grass,(floor_x_pos,1080-200))
screen.blit(monkey,(0,monkey_movement))
clock.tick(120)
pygame.display.update()
#10,255,110 best color
pls 👉 👈
your for loop iterates over pygame.event.get()
so if it's empty, none of the code inside the for loop will run
you want all your movement and drawing code outside that for loop
@brave elm
Indentation problem.
It should be
import pygame
import time
import random
pygame.init()
screen = pygame.display.set_mode((1000, 1000))
clock = pygame.time.Clock()
gravity = 1
monkey_movement = 0
grass = pygame.image.load('D:\game\grass2.png')
monkey = pygame.image.load('D:\game\monkey.png')
monkey = pygame.transform.scale(monkey, (260, 400))
pygame.display.set_caption("Monke!")
floor_x_pos = 0
while True:
for event in pygame.event.get():
screen.fill((0, 150, 230))
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w:
print('kaka')
monkey_movement += gravity
screen.blit(grass,(floor_x_pos,1080-200))
screen.blit(monkey,(0,monkey_movement))
clock.tick(120)
pygame.display.update()
#10,255,110 best color
This part of your code
monkey_movement += gravity
screen.blit(grass,(floor_x_pos,1080-200))
screen.blit(monkey,(0,monkey_movement))
clock.tick(120)
pygame.display.update()
was getting executed only when you pressed a key or moved a mouse because it's indented inside the for event in pygame.event.get() loop. So whenever there's a event then only it's was going to execute
As rightly mentioned by @severe saffron
@crisp junco Thanks bro, helped me
is the turtle module good for game development as beginner?
imo it's not good for game development regardless of experience
but for beginners it's not that important what you start with, just that you start developing
thanks!
has anyone worked with the processing.py?
Try Arcade: arcade.academy
https://www.pygame.org/project/5502, this is my tic tac toe game; everyone is welcome to take it apart and learn from it
Downloaded it and tried to run it
According to pycharm there are a lot of unresolved references
Firsts thing first, why create an 800 line program?
Why not separate into different files?
Can be easier to share I guess?
But yes. Would be better to share in a public git repository neatly split into several modules 🙂
bruh this is gigantic
awesome work
but it would be cooler if u could make it with gui
but that would take forever
Not forever, but it would certainly take longer 🙂
The monopoly game is awesome
here's my current structure for an action method
anyone familiar with the tcod roguelike tutorial care to help me with something? should be fairly simple..
ok?
I want to get the player's x and y position as readable values into Main.py, but everything I've tried so far hasn't worked.
Thank you...yes I am working on a gui
I'm not really good at pygame but maybe I can help
not pygame, tcod
hey no worries, thanks for the offer
Any package recommendation to switch your py app into exe? I have tried a few (pyinstaller) but it seems windows defender always detects a threat and removes it
@polar latch this is an issue with using most software that turns python scripts into standalone executables.
hi guys
is there anyone who makes 3D games with Python?
i just wanna make some but i can't find how to
if you use any game engine, please tell me which one should i learn
Godot it probably your best choice
Though I'm not entirely sure if it supports vanilla python
hmm
what I do know is that it has its own language very similar to python
But I believe I saw something at some point about support for normal CPython
i actually found a engine that creates only 3D but it's not popular and this creates a problem
the engine called UPBGE
Never heard of it
i want to use it but because it's not popular, it creates a problem for support
what i mean is that if you had any problem it's hard to find solution bc there is so few people using it and they might not have seen this problem before
Ok after a quick google search it doesn't seem that CPython is supported
but if you already know python
learning GDscript shouldn't be hard
thx
i heard about Panda3D
is it good?
i don't prefer only-script engines
because you gotta see another things
and make them with your hand i guess
so do you think Panda3D is good?
I'm not familiar enough with it to know
Sure. Panda3D is great. Can even use Ursina .. it's using Panda3D : https://github.com/pokepetter/ursina
currently im passing the instance of my class around to random sprites, and the only time theyre using the reference its to add to the main.all_sprites
would it be better to just make all_sprites a class variable
also the only videos i see on this stuff just put these as globals
i dont really want to do that cause it consfuses me is there like a good read on structuring game code
arr = [[0 for row in range(n)] for column in range(n)]
for row in arr:
print(" ".join(str(cell) for cell in row))
print("")```
I was trying to make a minesweeper game , Can someone help me explain this code ?
The second line is a listcomp to create an n*n nested list of zeros.
Then it gets printed (using a generator expression on the fourth line).
Thank you
My pygame.draw.rect is not working, it always shows: pygame.draw.rect(screen, RED, (player_pos[0], player_pos[1], player_size, player_size))
TypeError: rect argument is invalid.... help
My code:
import pygame
import sys
pygame.init()
#NESSESARY NEEDS
WIDTH = 800
HEIGHT = 600
player_pos = [400, 30]
player_size = [50]
#COLORS:
RED = (255,0,0)
screen = pygame.display.set_mode((800, 600))
game_over = False
while not game_over:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.K_DOWN:
x = player_pos[0]
y = player_pos[1]
if event.type == pygame.K_LEFT:
x -= player_size
elif event.type == pygame.K_RIGHT:
x += player_size
player_pos = [x,y]
screen.fill((0,0,0))
pygame.draw.rect(screen, RED, (player_pos[0], player_pos[1], player_size, player_size))
pygame.display.update()
give player size outside paranthesis
import pygame
import sys
pygame.init()
#NESSESARY NEEDS
WIDTH = 800
HEIGHT = 600
player_pos = [400, 30]
player_size = [50]
#COLORS:
RED = (255,0,0)
screen = pygame.display.set_mode((800, 600))
game_over = False
while not game_over:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.K_DOWN:
x = player_pos[0]
y = player_pos[1]
if event.type == pygame.K_LEFT:
x -= player_size
elif event.type == pygame.K_RIGHT:
x += player_size
player_pos = [x,y]
screen.fill((0,0,0))
pygame.draw.rect(screen, RED, (player_pos[0], player_pos[1], player_size), player_size)
pygame.display.update()
Hey @sinful wyvern!
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:
):>(
make a hastebin to submit file if it is too big
https://paste.pythondiscord.com/
go here, paste, and send link
website?
u mean like an engine?
u can use unity or unreal or godot
godot if u want python
unity and unreal is diff language
thx!
do you have the code?
for the game?
i am stuck
and which version should i get?
oh ok
¯_(ツ)_/¯
hi
Guys, help, who knows how to do it. I have a SWF file from the game, I run it through the flash and play. Is it possible to upload it to the server so that it works on a permanent basis?
just start using godot, its good for the community
what are you thinking about this "hurt" animation?
Why do so many people say Python is only for data science?
Cz it isn't
Wdym?
I mean, clearly there are ways to make games with python (with all the game engines mentioned in the description)
?
Lookin hella fine
amazing
@woeful brook This is a python discord and help in DMs is not a good thing.
Yes. It's a huge misconception that python is too slow for games. It really infuriates me at times.
Should you make cutting edge AAA games with python? Probably not.
.. but there is a lot of area between a simple "pong" game and a cutting edge AAA game python can cover
Will it be harder than using a game engine with UI? Most likely.
Would you sometimes have to be a bit creative to make things run fast? Most likely.
.. but there is so much to learn from python game dev
I think a lot of people start out with pygame and judge python game development from that experience alone
There are other options out there. Pygame is awesome for what it was built for. If you need more performance or use the gpu more efficiently there are lots of other options.
Oh I see
I don't blame pygame or people for this. It's just how it is. People make assumptions 😉
So i'm not at all sure if this is the correct channel to post this in but here goes. So I am trying to make a bot that moves the character’s viewpoint in a first person game but when I use the pyautogui or the mouse modules they don't move my viewpoint but the modules do work on a normal cursor that is not locked to a window any help is greatly appreciated.
Hello can i ask it is possible to code good game in pygame?
yes
@dawn quiver ask here
Yes, but it depends what kind of game.
HI! I'm new to Python and Programming Concepts. I wanna make games. Help a guy out!?
Just kidding!
learn the basics first folks....
games are complex systems interacting with each other!
hmm is there a way i can get rid of that in between grey color
is this an image you got from the internet
# importing tkinter
from tkinter import *
# main
window = Tk()
window.title("Flashie - A Simple Flashcard App")
window.configure(bg="#B1DDC6")
# canvas for flashcard portion
canvas = Canvas(width=800, height=526)
flashcard_img = PhotoImage(file='../flash-card-project-start/images/card_front.png')
canvas.create_image(400, 265, image=flashcard_img)
canvas.grid(columnspan=2, padx=50, pady=50)
# run window
window.mainloop()
also which grey color
i think a canvas can't be transparent in tkinter, not sure

actually
hmm
apparently you can draw images with trransparency onto a canvas
ah but
if the canvas background is white
then it will show up as white not green
oh i think theres a fill paramter
or something
oh wait thats for text nvm
hmm

that grey still bothers me

ok this is the closest i got it
and its by setting the canvas bg that color as well
# importing tkinter
from tkinter import *
# main
window = Tk()
window.title("Flashie - A Simple Flashcard App")
window.configure(bg="#B1DDC6")
# canvas for flashcard portion
canvas = Canvas(width=800, height=526, bg="#B1DDC6")
# canvas img
flashcard_img = PhotoImage(file='../flash-card-project-start/images/card_front.png')
canvas.create_image(400, 265, image=flashcard_img)
canvas.grid(columnspan=2, padx=50, pady=50)
# canvas text objects
title = canvas.create_text(400,150, text='Title', font=('Ariel','40', 'italic'), justify='center')
word = canvas.create_text(400,263, text='Word', font=('Ariel','60', 'bold'), justify='center')
# run main
window.mainloop()
how?
you can just make the canvas the same color as its background widget
Might need to alter the image a bit?
hello
anyone might help me with pygame
I want to draw a circle inside a rect
cuz drawing a circle is way too problematic
nevermind ellipse is better
Circles are just symmetrical ellipses
How does OpenGL render curves?
Ik there’s some math involved but anyone know what it is?
Depends what kind of curves
and what method.
Can calculate a curve in python writing to a buffer and/or calculate curve in shader
Wanna build a text life sim game... Not sure how to go about it
what is this and why here?
what's the difference?
@last moon pre-calculating the curve in python vs having a shader do it realtime
Can be translated to python of course 🙂
There are simpler curves as well. Points with tangents.
Then you have Catmull-Rom splines (easier)
oh so you'd iterate through that to get your line?
Iterate through what?
the bezier function you just sent
As long as you have an extra start and end point 🙂
With splines you normally calculate p1 -> p2 when passing in p0, p1, p2, p3
They needs the info from neighbors
so does a spline interpolate the rest of the pixels based on the start & end point + 2 other points on the curve?
my understanding of a bezier curve was that it uses the start & end but 2 control points that aren't on the curve
vectors 
Well. points unless they are tangents I guess 😄
These are great for NPC pathing for example : http://graphics.cs.cmu.edu/nsp/course/15-462/Fall04/assts/catmullRom.pdf
Unless you like them moving in squares (depends on style)
ill take a look at it later, that's too much math rn 😄
You can find the simplified formula elsewhere 😉
Cheap in 2D!
It's all about picking the right type of curves/splines for the use case
You have no clue, im dying rn
I was trying to draw a square
how do you mess up a square?
That is GL?
ya
show the vertices
oh I've got 10 instead of 100 nvm
actualllly funny story this isn't python
Using vbos or glBegin stuff?
im using Processing for a computer creativity course im taking
ah right. Not using GL directly then?
I thought it was?
sprite = createShape();
sprite.beginShape();
sprite.fill(255);
sprite.vertex(x, y);
sprite.vertex(x+100, y);
sprite.vertex(x+100, y+100);
sprite.vertex(x, y+100);
sprite.vertex(x, y);```
ah. That is a bit higher level.
I kinda figured considering it's a 100 course
You still have to define the geometry. That is the important part 😉
The rest is just syntax differences I guess
I think processing is doing the rendering based on opengl version.
im pretty sure it is but the docs don't get too specific about it
Still close enough!
ya idk im having fun with it and it's helping a lot of concepts that I've heard about/seen here click for me
I thought you literally told sprites to move, not that 'moving' was redrawing them
Yeah you have to redraw everything per frame
Each frame starts with a blank screen
Usually the underlying graphics driver is exposing a double or triple buffered surface
You draw in the hidden surface and it's swapped to the front when ready
The previous surface is hidden and cleared ready for a new frame
Speed today relates to how much you can batch draw first an foremost
You have about 1000 draw calls per frame before it starts to become sluggish. Sprite systems will in most cases collect all the data and batch draw it all in the end.
how do i access the subclass of a class,
specifiaclly i want to access the specific class in a sprite group
when i itterate through a spritegroup, it only gives me the sprites, not the class im wanting to refer to
guys i wanted to start learning pygame
can i get some suggestions of how to start?
Learn how to use Pygame to code games with Python. In this full tutorial course, you will learn Pygame by building a space invaders game. The course will help you understand the main game development concepts like moving characters, shooting bullets, and more.
💻 Code: https://github.com/attreyabhatt/Space-Invaders-Pygame
🎥 Course created by bu...
This one is gooder👀
how is ursina?
Pretty nice, but that is subjective like anything else
Take a look at the api and examples I guess
hello everyone
so im making a simple game using pygame
so my problem is with the coordinates
is there some graph that could help with the coordinates of the display?
i cant tell where is point(0,0) where is point (125,300) for example
yea they r kinda fucked up in pygame
the top left side is 0,0
the y axis is inverted
the bottom left is 0,500 - or whatever screen size u have
So i cant really tell where is for exmaple the point (300,25) ?
Is there some sort of app to help me with it?
Like where i would put a screen size and move my cursor wherever in the screen and it would show up the coordinates?
Just print out the mouse position?
I'm pretty sure 0,0 is upper left corner both for mouse coordinates and pixel coordinates
And how do you do that?
# This function will kill each square on the grid
def kill():
for _ in square_group.sprites():
pygame.sprite.Sprite.kill(_)
would this be able to kill all sprites in a sprite group
wait no that works
def set_fields(self):
for _ in square_list:
coord = _.coord # stores the values returned
if _.click:
if self.placement[coord[0]][coord[1]] == 0:
self.placement[coord[0]][coord[1]] = 1
else:
self.placement[coord[0]][coord[1]] = 0
i want this to replace 1 element in a 2d array, but it replaces an entire column
So is the batching + precalc done on different threads on the cpu or are they delegated somehow to the gpu? You mentioned a double/triple buffered surface, how is that set aside / created?
what's the 1st step to learn game development ?
i'd like to learn about it
i'd appreciate any suggestions about where to start
Upload geometry to gfx memory and do as much processing with gpu. Framebuffer setup really depends on drivers I think. Most window libraries do support specifying double buffering or not.
What is your goal?
Simple 2D games?
well, where should a beginner start?
Also python beginner?
i am codding with python for nearly a year
although i only know the basics and a bit more
I can assume you wanted to play around with simple 2D games?
oh
cool, thx a lot
Arcade is a bit a bit higher level, so maybe that is a good start
okay, i appreciate it
Then move to https://arcade.academy/ later
A lot of things translates well between 2D game libraries anyway
nice
shapes, sprites, collision etc etc

neat thanks ill have to look into it more
If we're talking about simple sprite systems on the cpu it will of course be somewhat different. Moving all the sprite logic to gpu is not always that easy. You can still update data to gfx memory every time something changes. Stil.. most sprites will probably be rendered in one more more batches 🙂
You might have a buffer for sprite positions (xy)
Maybe a few more attributes like rotation/color or whatnot
.. but all that data is at least at some point synced up to gfx memory for drawing 🙂
A huge tilemap that doesn't change stays in gfx memory and are easy to just draw
Moving players and enemies is something completely different
In a 3D scene the cpu is often calculating rotations and translations, but the geometry is already ready on the gpu
There are ways to transform data on the gpu as well. Lots of techniques to solve common problems.
hello can i ask something, is here some1?
You just ask. That's it
oh ok
Never ask to ask 🙂
I’m ngl I understand about half of that 😄
Might make sense in the future 🙂
Hopefully..
i just want to ask why the console says:
line 28, in normal_cursor
screen.blit()
TypeError: function missing required argument 'source' (pos 1)
pygame?
How do quaternions fold into all of that?
They are converted to matrices
@jolly arrow You are missing some parameters here : https://www.pygame.org/docs/ref/surface.html?highlight=blit#pygame.Surface.blit
Always good to look up and fully understand each function in the official docs
k thank you !
it means faster progress 🙂
You are missing an argument for example.
Screen.blit() means draw something on the screen. But you didnt give the function anything to draw.
For example you could have a file called monkey.png
So you want to draw it.
You would go screen.blit(monkey.png)
Hope that helps
You have to put it in a while loop or it would appear for 1 second and dissappear
Hmm
Wait a second
Do this
Lets say
Monkeyimg=pygame.image.load("monkey.png")
Then do
Screen.blit(Monkeyimg)
@jolly arrow
See if that works?
i go try it
so i shouldnt give that in def?
I think no
Unless u r going to use it multiple times for multiple images
@jolly arrow oh i forgot
You need to give the x and y coordinates for the picture
like for both of them?
screen.blit(monkeyimg,x,y)
yep
Np ❤️
thank you!!
@ancient surge It's available to most languages. Why mostly C#?
can someone help me with pygame?
post your code and your issues
`import pygame
import random
BLUE_COLOR = (0, 64, 255)
WHITE_COLOR = (255, 255, 255)
WIDTH = 150
HEIGHT = 200
KADOR_SIZE = 10
class Kador:
def init(self):
self.x = 0
self.y = 0
self.move_x = 0
self.move_y = 0
def create_kador():
kador = Kador
kador.x = random.randrange(KADOR_SIZE,)
kador.y = random.randrange(KADOR_SIZE,)
kador.move_x = random.randrange(-2, 3)
kador.move_y = random.randrange(-2, 3)
return kador
def main():
pygame.init()
pygame.display.set_caption("")
size = [WIDTH, HEIGHT]
screen = pygame.display.set_mode(size)
kadorim = []
kador = create_kador()
kadorim.append(kador)
bye= False
while not bye:
for event in pygame.event.get():
if event.type == pygame.QUIT:
bye = True
elif event.type == pygame.KEYDOR:
kadorim.append(create_kador)
for kador in kadorim:
kador.x += kador.move_x
kador.y += kador.move_y
if kador.y > HEIGHT - KADOR_SIZE
or kador.y < KADOR_SIZE
kador.move_y *= -1
if kador.x > WISTH - KADOR_SIZE
or kador.x < KADOR_SIZE
kador.move_x *= -1
screen.fill(WHITE_COLOR)
for kador in kadorim:
pygame.draw.circle(screen, BLUE)
pygame.display.flip()
pygame.wait()
if name == 'main':
main()`
i am new to this sry
this is my first game
Could you run the code and paste the error message from the terminal?
Well for starters, you have some syntax errors in your code. There are some typos, wrong indentations and you're missing semicolons
you need to choose the python.exe for your pycharm project
OK ty
i want to do AI
any python programmer here?
so im making a rocket to fire when i press the space button
but here is the problem
i assigned the location of the rocket to be the same as the player location
for example
PlayerY=300
#then i made a code that changes the playerY value when you press any arrow
GunY=PlayerY
but the gunY dosent update when playerY is changed
that is because the variables arent linked
only lists do that (from my knowledge)
is ursina game engine good?
That is subjective. I think it's pretty nice. Might be better to just play around with their examples https://github.com/pokepetter/ursina/tree/master/samples
im a game dev ( i know unreal(not ver much ) , Unity(very much experienced) , pygame and im happy to learn other langs or API as well
Im looking for a team or to put it in simple words .... I WANNA WORK ON A PROJECT AND COMPLETE IT .
DM ME)
Nice!
i have a question do u mind?
so im trying to make multiple enemies
but only one enemy moves
Not much time here, but there are lots of sprite examples here : https://github.com/pythonarcade/arcade/tree/development/arcade/examples
hm ok thanks
do you know anywhere good to learn video based?
@potent ice
No idea. I just looked at the examples I linked above
ok, thanks
Well I know SDL2 is (I've used it with C++) but I was just wondering if it was doing that software rendering thing again 👀
I suppose it's okay if it's not, I shouldn't be doing anything too crazy.....yet
@solemn bridge There is an sdl2 channel on the pygame community discord : https://discord.gg/h8ujJGCcq3
I think some things may be hw accelerated in pygame 2, but for the most part it's cpu rendering. Still the new sdl2 module opens for a lot of interesting things.
I'm guessing the big win is when you can batch draw things with sdl2
Can probably get a bit closer to the performance of Arcade's SpriteList.draw() this way
Py game.
So i made a func that renders a font in the screen
If the player and the enemy collisions
But the problem is it only happens during the collision
And dosent stay after the collision ends
Is there a way to make it appear for a specific amount of time?
Anyone know how to add a menu in pygame
You would have to store a state somewhere like a list. Keep track of when it was added using pygame.time.get_ticks() and remove it after some time.
I did something else
Just assigned a variable to True or false
When collision happens it is true
When the player presses r it is false
Then added if variable=="True"
It will run the function
Anyways thanks for the help einraf
❤️
No problem.
Hello all!
My assets vs my results...not sure why convert_alpha() isn't working, last time I tried it I got clean results
I'm taking from a large sheet and cutting and blitting, no idea where the black comes from
I convert_alpha() when I import the image, IDK
Found it! I wasn't using thepygame.SRCALPHA param in when chopping and splicing and merging
ok
y'all making 2D games, I wanna make 4D minesweeper
I want to make a survival games, but I think for now I'll focus on just getting my simple games to work lol
Wait, how would you even make 4D games?
Not quite gamedev, but the channel topic says "and frameworks". Made this partially using Pygame:
https://youtu.be/tOBOBIaO4VE
I hacked up the example script for face-api.js to forward the data to my Python/Pygame script. Then I did some trig and other math things to get a very rough estimate of facial rotation based on facial landmarks (from face-api.js) so that I could map it to a cube. \o/
(face-api.js uses machine learning to place facial landmarks)
⭐ Kite is a ...
User can manip time?
Man i never knew u were part of this server
i love ur vids dude. Keep up the good work
uve taught me more than any teacher ive had
you have a grid, but each cell is a grid
and the cells coordinates require (w,x,y,z)
you could use a single integer but it'd essentially be something like interpreting this binary:
0101111000000111
as opposed to (0101, 1110, 0000, 0111)
Im confused how ecs improves performance by working with the cache, can somone pls explain?
Would duplicating data across components to satisfy the cache be okay?
hi, what should i do if my fivem liveries aren't dropping into open iv
def collision(x,y,X2,Y2,distance1):
distance=math.sqrt((math.pow(x-X2,2))+ (math.pow(y-Y2,2)))
if distance<distance1:
return True
else:
return False
collison2= collision(enemyX[i],enemyY[i],gunX,gunY,30)
if collison2:
if score_value==score_highest:
score_highest+=1
gun_state="Ready"
score_value+=1
enemyX[i]=random.randint(0,736)
enemyY[i]=random.randint(0,150)
explosion_sound=mixer.Sound("explosion.wav")
explosion_sound.play()
(The indentedation here is stupid but is it is perfect in the code)
i still dont understand why is there collision happening when the bullets dont hit them
2d games? Maybe.
3d game? Absolutely no
Learn C++
yeah ok
Yes, it's great both for 2d and 3d. Symon doesn't know what they're talking about
Try ursina or panda3d
oh ok
Oh really? Good for both? Are you gonna compare unity and unreal engine with ursina?
That is why most 3d games r made in C++

Python is good for data science AI and web development
Python isnt made for games
Python is good for data science AI and web development.
If you are into game development. I recommend C++ pokepetter dosent know what he is talking about. Most popular 3d games r made with C++ using Unreal engine or Unity. Which works with C++ and not python.
This is the python discord. We like doing things with python 🙂

@tall vine The thing is that for example Panda3D is written in C/C++, but the api is python
The same goes for moderngl. It's a python api written in C++ for performance
Even the same situation with numpy
It's a huge misconception that python is only good for data science, ai and web development. There is a lot you can learn from making games in python
Will it be easier than usingUnity or UE4? Probably not. Will you learn new things? Definitely.
thank you both
i actually asked if its efficent only to know.
i dont think you should say other people doesnt know what they are saying
to both of you
Yes, there are probably better ways.
But .. @tall vine is kind of arguing with the creator of Ursina here.
I do understand the frustration. Both me and pokepetter are developers on opensource game engine / graphics libraries for python.
@tall vine Example: moderngl (python library) is C++ 🙂 : https://github.com/moderngl/moderngl/tree/master/moderngl/src
Hello guys i would be happy if anyone could recommend a good tutorial to learn pygame(Excluding videos)
it has one problem it doesn't have any softwares like unity or unreal and blender game engine is also gone it was heart breaking
Guys Are There Game Engine Using Python?
there was blender game engine but on older version now its closed
Oh No Why They Closed it?
u can try ursina or panda 3d
very less users
oh Thx
oh F thx for that
But even with ursina I use Blender as a level editor for 3d games
@tranquil girder do u use UPBGE ?
And it's always a good idea to make a custom editor if you want to be productive. With unity for example, there's always a lot of work put into making tools anyway
No
But they post some updates on the development here sometimes
I don't know, I haven't used it
It has good graphics, but I'm not sure about how it is to program for it. There's also the licensing issue
what licensing issue?
It's GPL
ok
So guys, I been messing with pygame now for about 2 days, and I have built a 2D camera, scaling, and can basically load tilemaps up to 1500x1500 tiles from Tiled before Tiled whines and almost crashes 😅
All while getting around 180 fps with a core i5
I'd say pygame is pretty suitable for 2D games in such case. I mean 1500x1500 is kind of overkill, it was just a test. 😄
I know people say "For 2D games" but that isn't really self-explanatory. Something like Starbound is 2D and requires a decent PC to play, and it's even C++.
I think pygame+python is capable of doing something like Starbound but you'd definitely need to do some optimizations.
It can definitely perform well. I'm not sure how well it would handle doing lights, but there might be some tricks.
Do you render the tiles to a surface, then display? You don't draw 2.2 million tiles every 1/60 of a second, do you? Or is that sparsely populated?
I assumed it was organized in chunks
@solemn bridge right? 🙂
you guys know how to use ursina? i just found out about it
@frozen knoll @potent ice Kind of. I only render and process within a set tile radius around the player.
ah ok, so it can be done faster by rendering to surfaces I guess.
Usually 4 surfaces each containing a chunk
Separate animating tiles drawing them manually etc
@tranquil girder arent you the guy who coded ursina?
Yep
Does anyone know how to make a sprite face/ look at another sprite in pygame(2d)
Do you know how to rotate them?
hello, I am making a somewhat game/assignment for my python class this semester, I have made it fully with turtle
But I cant seem to find out how I can stop a program when it hits the bin
this is the assignment
turtle.bgcolor("grey")
# Bin #
turtle.penup()
turtle.goto(200,-300)
turtle.pendown()
turtle.begin_fill()
for i in range(2):
turtle.forward(100)
turtle.right(90)
turtle.forward(20)
turtle.right(90)
turtle.end_fill()
# Bouncing Ball #
turtle.penup()
turtle.goto(0,0)
turtle.shape("circle")
turtle.penup()
x, y = 0, 0
xdir, ydir = 3, 3
xlimit, ylimit = turtle.window_width() / 2, turtle.window_height() / 2
while True:
x = x + xdir
y = y + ydir
if not -xlimit < x < xlimit:
xdir = -xdir
if not -ylimit < y < ylimit:
ydir = -ydir
turtle.goto(x, y)
turtle.mainloop()
Here is my code
I asked to use pygame, yet the professor didnt want me to use it
Wish I could get pygame running....
whats wrong with it @dawn quiver
Every time I use cmd prompt it sends me to Windows Store to install python 3.9 and I've already installed in with python installer.
Have you added it to your path?
I thought I had but I'm not sure. I don't recall checking the box before installing.
Uninstall it and reinstall it and hit the checkbox
see if you can run then, if not ill do research
Yeah, I should try that.
Yes?
I installed the windows store version as well an it seems to work now. But I'm not sure if that is going to cause any confliction.
just try uninstalling and reinstalling
10-4
I will give that a try
can you do pip --V in the cmd?
what about pip --version
@dawn quiver ^
im not familiar with windows though
are you sure the python your running is in your path variable?
sorry nevermind
im trying to learn oop
like if i want to make a quest system
do i make a base quest class
and then created each quest as an object
#help-carrot please help me
Hi
Hi
How to download pygame module in python idle 3.9 version?
go to cmd type the following pip install pygame
It's not working...
You seem to be new to this field🤨
Ok i will try...
It's my 3rd day with python...😅
maybe you could put all the non setup stuff in a loop with a runnning flag, so when your ball hits the bin running = false and the program stops
Who uses Python Turtle Grahpics?
@lofty viper I’ve created 2 programs from it, whats up
Nice, what for programms.
It’s was a simple house and mountain code and now it’s a bouncing ball game
Ok, I am watching an advanced tutorial for python Turtle grahpics called Space_Arena.
Nice
is this classified as a 2d or 3d game:
That would be 2D. It's an isometric tile map.
thank you
Each tile has the same size. There is actually no perspective here
what would it be called if the tiles are straight on the vertical axis but still at that angle?
liek this:
but not exactly that
so the tiles are straight down but still at an angle
still here are no perspective here.
The closest you can get to "3D" with that kind of setup is "2.5D" : https://en.wikipedia.org/wiki/2.5D
Even this 2.5D game does not have perspective projection. It uses parallel projection : https://upload.wikimedia.org/wikipedia/commons/4/4b/Lincity-ng.png
This has perspective projection : https://i2.wp.com/css-tricks.com/wp-content/uploads/2017/06/cube_min_ani.gif?ssl=1
This cube does not : https://media1.giphy.com/media/67sbrfNMsjwmTYwygV/giphy.gif
Because the points further away from the eye does not get "warped by space"
hi, @foggy python how did u created those waves in your one of the platformer?
@worldly flare There's quite a bit of info in videos already https://www.youtube.com/watch?v=QXVu6xhcpVQ
This is the second devlog in my new Python/Pygame gamedev project. I had a lot of fun with this one. New GFX elements are always interesting to implement. In this case, water, wind, and grass physics may not be as difficult to simulate as you may think.
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The...
Somewhat related: I think this is a great video getting people in the right frame of mind when programming anything really : https://www.youtube.com/watch?v=h1o5UzKfZcQ
There's a basic process that you'll need to use to code most things, but it's rarely taught. It comes down to breaking down the complex feature you want into tiny logical chunks until it's almost pseudocode. At that point, you convert it into actual code.
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. T...
I always have a notebook and a pen. Worst case I fill two notebooks in a month.
But people are different of course. I find it useful to visualize things.. or at the very least break down complex problems into smaller ones.
is there anyway to keep this clean
i tried making a credit card system
for example there are vip card, vip+ card, vip++ card, mvp card, mvp+ card, mvp+++ card, god card
i created 1 class for each card and at last a total of about 15 classes were made as they all have totally different features
is this how oop works im still learning
That's for what, a random int in some range?
If that's in seconds, you might want to check out numpy.random - it's faster if you need a lot of random numbers:
import random
for N in (10**i for i in range(0,5)):
%timeit [random.randrange(100) for i in range(N)]
Results:
1.14 µs ± 63.4 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
6.58 µs ± 539 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
57.4 µs ± 979 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
626 µs ± 46.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
5.86 ms ± 308 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
With numpy's random:
import random,numpy as np
for N in (10**i for i in range(0,5)):
%timeit np.random.randint(0,100,N)
# starts off pretty slow:
18.3 µs ± 450 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
19.8 µs ± 1.69 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
# overtakes random at 100 elements:
18.8 µs ± 966 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
27.3 µs ± 360 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)
# is 52 times faster at 10000 element:
112 µs ± 2.92 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
for 1 million, random takes 622ms and numpy.random 10.2ms.
hi so I'm pretty much of a noob just finished a bootcamp and some other tutorials and was wondering whether a battleship game (with no GUI - just printing the board) is a realistic first on-my-own project. I already done some basic game projects like tic-tac-toe, war and blackjack (with classes and all) but not sure if a battleship project isn't a bit of a deep-water for beginners. what do y'all think?
Seems ok to me. The complexity is higher, but not by much.
self.image, self.rect = load_png('ball.png')
what is happening in the code
(dx,dy) = (z*math.cos(angle), z*math.sin(angle)) this is tuple unpacking ...ikr
but wbt?
nvm i used pycharm to go to the function {load_png} implementation and discovered it returns two values img and rect.... and i totally forgot tuple unpacking can be done without without parenthesis.... i left python for long went creating apps with java lol
Hey, I am trying pygame, and this script is causing an error.
win.fill((12, 24, 36))
The Error Is IndentationError: uindent does not mach any outer indentation level. exit status 1
Does Any1 Know how to fix this?
@wooden hearth wrong indentation aka wrong number of spaces from the margin
K thanks for telling me this, was able to figure it out.
game_board_pos = [(2.0, 198.0), (202.0, 198.0), (402.0, 198.0), (2.0, 398.0), (202.0, 398.0), (402.0, 398.0), (2.0, 598.0), (202.0, 598.0), (402.0, 598.0)]
for p in range( len( game_board_pos ) ):
px, py = game_board_pos[ p ]
if px < x < px + 198 and py > y > py - 198: # if mouse in is box and display X shape in the box @game_board_pos to get box area
pygame.draw.line( screen, red, [ px, py ], [ py, px ] ) # trying to make a X shape
pygame.draw.line( screen, red, [ px, px ], [ py, py ] )
print(f"Mouse pos: {x},{y} in current box pos: {px}, {py}")
#Mouse pos: 143,358 in current box pos: 2.0, 398.0
How can I fix my code to properly display an x in the box my mouse is currently in
line(surface, color, start_pos, end_pos, width)
Got it fixed
Not much of Game Dev (outside of building the game from scratch but its not the most challenging) but the generation AI got no talk in #data-science-and-ml so I decided to share my AI here
@void glacier Maybe use the modulo % operator on the mouse coordinates to figure out what box you are in? Then it should be a simple enough formula to find the center of each box.
To play music in loop just do pygame.mixer.music.play(-1)
So, the final code should be:
pygame.mixer.init()
pygame.mixer.music.set_endevent()
def play():
playlist = ["teso_main_theme.mp3", "teso_elsweyr.mp3", "teso_greymoor.mp3", "teso_morrowind.mp3", "teso_dovahkiin_metal.mp3"]
choice = random.choice(playlist)
pygame.mixer.music.load(choice)
pygame.mixer.music.play()
end_of_song = pygame.mixer.music.get_endevent()
if end_of_song:
pygame.mixer.music.load(choice)
pygame.mixer.music.play(-1) #Plays the music in loop
The exe compiled by pyinstaller is considered to be a Trojan by antivirus software. anyone know how to fix?
I suppose you're using --onefile
ain't you?
Yep 😦
Try not using it, windows defender and any other antivirus software detects those files as trojans
Quite irritating though
