#game-development
1 messages · Page 83 of 1
@dawn quiver you could try this tcod roguelike tutorial: http://rogueliketutorials.com/tutorials/tcod/v2/ Some python knowledge is recommended but not strictly required. Also check out the pins here. https://inventwithpython.com/invent4thed/ seems like a good place to start.
@steel wing Check out https://Arcade.academy
Also @dawn quiver . Might help get you started. Lots of examples and tutorials.
what do i need to study before i get to game dev?
@cloud nest
- a programming language
- MATH!
can you explain more in detail?
@cloud nest
consider this example:
-
I wish to create a basic Mario-styled platformer game! I need to study a programming language and its basics. Suppose i use Python to make it. First i need to master the basics of python. Then i learn a game library like Pygame (in Python for instance). I use resources on the internet to do that!
-
finally, i need MATH. I need at least high school math for this. Math, is for making you character move, calculate his jumps, and calculate collisions with Objects, also much more, like calculating fireball throws.
-
Optimizations! - You just cant publish a buggy game can you? You need to optimize it by getting to make it smoother. Optimizations may include increase in the device's processing power, or formatting your code better.
@cloud nest
The math depends on what tipe of mechanics you want in your game
not really. you need math at every point in the game. even in drawing objects
You cant just go about drawing objects anywhere! you need to know about the cartesian coordinate plane!
But thag is too easy
You are scaring this guy saying mathematics like if it was super complex stuff
@cloud nest
Look bro just start with pygame or arcade. Do some simple stuff and then you can get into the mathematics one step at the time
then get stuck with math.
Just dont get this guy discouraged with math. He can make it
for now, i think i just need to learn the basics
im kinda gifted with math
Look im awfull at math and im still making it
Usually the guys that are intrested in making games are gamers and i think that the gamer are usually the guys that dont care about maths but who knows
can i tag you again sometime?
Ok
how do we get out of pygame infinite loop
whenever i click the pygame x button it says not responding
import pygame
pygame.init()
#[...] some part of code here
while True: #loop
for event in pygame.event.get():#List of events like mousepress,keydown etc.
if event.type == pygame.QUIT: #Check if 'X' button is pressed
break #Exit the loop
pygame.display.update()
pygame.quit() #De-initialize pygame
sys.exit() #Exit
does hovering of mouse come under events
yeah
jus a min ill get back to u
👍
i dont know how to explain my problem
im actually doing a project
we are almost donr
done*
but this one is troubling
its a hobby project
what's the problem @odd cypress ?
basically to start the program running, we wait until the event is mousebuttondown
as soon as mousebuttondown is captured, i create a loop for checking the events eithin this
within*
import pygame
pygame.init()
#[...] some part of code here
while True: #loop
for event in pygame.event.get():#List of events like mousepress,keydown etc.
if event.type == pygame.MOUSEBUTTONDOWN: #Check if mousebutton is pressed
#[...] Your code here
pygame.display.update()
pygame.quit() #De-initialize pygame
sys.exit() #Exit
alright
which problem?
the error on your code
I was helping him
sry
@odd cypress can you give me the error?
basically when the game is running if im trying to click on close button it says not responding
did you save it?
@crisp junco shall we have a discord screen share meet
Didn't you see the code that I provided you?
this one
i checked but there are some problems which im not able to explain
What's your code?
just copy the error
while running:
for i in range(0, 3):
screen.blit(image, rect)
pygame.display.update()
pygame.time.delay(250)
screen.fill((255, 255, 255))
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
mouseX, mouseY = pygame.mouse.get_pos()
print(mouseX, mouseY)
A1 = Ant(mouseX, mouseY, (0, 0, 0))
move(A1)
while event.type != pygame.QUIT:
showSteps(A1)
# modified the available screen area according to the counter frame
if A1.AntX in range(0, 251) and A1.AntY in range(0, 71):
break
elif A1.AntX < 799 and A1.AntY < 599:
move(A1)
else:
break
running = False
pygame.display.quit()
pygame.quit()
else:
pass
please see my code
is it supposed to be if you pressed your mouse then it dose all of the things? is it the indentation?
yes
then the pygame quits?
try something like ```py
mouse_pressed = pygame.mouse.get_pressed()
if mouse_pressed[0]: # Checks if the mouse left button is pressed
codes here!
@unreal river ??
sorry thinking
ive done same only right/....
?? wdym
this is same as my logic right
oh i get the code
why it say the "running" is wrong?
see your creating a while loop without ```py
for event in pygame.event.get():
if event.type == pygame.QUIT:
# CODE HERE
the second while loop
while running:
events = pygame.event.get()
for i in range(0, 3):
screen.blit(image, rect)
pygame.display.update()
pygame.time.delay(250)
screen.fill((255, 255, 255))
pygame.display.update()
for event in events:
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
mouseX, mouseY = pygame.mouse.get_pos()
print(mouseX, mouseY)
A1 = Ant(mouseX, mouseY, (0, 0, 0))
move(A1)
while event.type != pygame.QUIT:
events = pygame.event.get()
showSteps(A1)
# modified the available screen area according to the counter frame
for event in events:
if event.type == pygame.QUIT:
#CODE HERE
if A1.AntX in range(0, 251) and A1.AntY in range(0, 71):
break
elif A1.AntX < 799 and A1.AntY < 599:
move(A1)
else:
break
running = False
pygame.display.quit()
pygame.quit()
else:
pass
set a variable that stored the pygame events
set the variable on the first loop and then do the same in the second
it says "NameError: name 'running' is not defined"again!
that happened to me also
you can set the running variable in a class and create an object that is part of the class and it will be defined
class Game():
def __init__(self):
self.running = True
game = Game()
while game.running:
#CODE HERE
while running:
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.MOUSEBUTTONDOWN:
while True:
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
pygame.quit()
define the variable in the loop and store the pygame events in it
its like the for event in pygame.event.get()
except its in a variable
@odd cypress ```py
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
elif event.type == pygame.MOUSEBUTTONDOWN:
while True: # Cant get to the if statement below because this keeps looping
super useful
it's not just about game dev, it highly useful in every area
can you please explain y u have told to do that way or ewhat is wrong with my approach? @unreal river
I help though :v
bro your second while loop doesnt check if you click the X button on the top right
DM me the full code
ok bro
just do this:
if event.type == pygame.QUIT: pygame.quit()
further you can add exit() after pygame.quit() if it still doesnt quit.
@odd cypress
pygame.quit() simply quits the pygame window if the X button is pressed. pygame.QUIT is the event for pressing the X button.
thanks for info
does anyone know how to increase pixel size in pygame?
anyboddy??
can you briefly explain what code formatting is?
hey! i am trying to make a boss ai if anyone has created one then plz guide me
also the game I am making is a dungeon crawler so I want to make random maps with procedural generation IDK hw to archieve that so please help me with that.
if we ask in correct group, u ppl wont reply
if we ask in multiple grps , u ppl call it spamming
Maybe you should ask your question more clearly. I have no idea what "increasing pixel size" is supposed to mean.
Starting from pygame 2.0, you can use the SCALED parameter to pygame.display.set_mode
yeah right
I suffered from this
If people in the correct channel don't know the answer to your question, what makes you think that people in an entirely unrelated channel will know it?
It's like if you entered your local hairdresser shop and told them "My greengrocer doesn't have any carrots, do you have any?"
but I am asking for the right stuff in the right channel!
I would have made a list of things the boss can do like jump, shoot, etc. Then have python randomly pick them from the list.
I was addressing @odd cypress
So I am asking my hairdresser for cloths not for some fricking carrots
its actually same
to whoever u said
kinda good thought
So confusing when people change their nickname mid-conversation…
Well first thing number of askers would always be greater than the number of persons who answer. So maybe just ask in one channel then try to bump the question rather than just type the whole question everywhere all the time.
can you please send a sampke cose
sample code*
or the way u write that
pygame.display.set_mode((640, 480), FULLSCREEN | SCALED)
will make a fullscreen program with everything scaled up
so you draw to the screen as if it was 640x480, even though it's however big your monitor is
scaled not defined
im actually inverting pixel colors
im on pycharm
how to checj version
check*
of pygame
just do pip install -U pygame
oh kk
Also, https://www.pygame.org/docs/ref/display.html#pygame.display.set_mode <-- docs for SCALED
thank u doing it, pls dont leave ill get back to u if i have problems'
i was unable to terminate the program in this mode
and the pixels are not enlarged
only the screen is enlarged
please help me with pixel enlarging @torpid silo
guys ayone pls help me, i hope im asking in the right grocery shop
Can you explain what you mean by enlarging pixels?
you could do pygame.transform.scale and pass in the sources surface, the pixel size u want the display to be enlarged to, and the destination surface as arguments
That should do the trick ig 
Is turn game over network complicated?
I want to make a fighting game. Where do I start?
from random import randint
win_tracker = []
#create a list of play options
t = ["Rock", "Paper", "Scissors"]
#assign a random play to the computer
computer = t[randint(0,2)]
#set player to False
player = False
while player == False:
#set player to True
for i in range (3):
player = input("Rock, Paper, Scissors?")
if player == computer:
print("Tie!")
elif player == "Rock":
if computer == "Paper":
print("You lose!", computer, "covers", player)
t.append("loss")
else:
print("You win!", player, "smashes", computer)
t.append("win")
elif player == "Paper":
if computer == "Scissors":
print("You lose!", computer, "cut", player)
t.append("loss")
else:
print("You win!", player, "covers", computer)
t.append("win")
elif player == "Scissors":
if computer == "Rock":
print("You lose...", computer, "smashes", player)
t.append("loss")
else:
print("You win!", player, "cut", computer)
t.append("win")
else:
print("That's not a valid play. Check your spelling!")
#player was set to True, but we want it to be False so the loop continues
def result():
if int(t.count("win")) >= 2:
print (" YOU DID IT! YOU WON!")
else:
print("YOU LOST!")
result()
this is my code where can i put in a parameter
yes
nah like where can I add one into there
do you know what a parameter is?
sorta
what is it then?
i think issa variable sorta idrk
def list(a_list):
for val in a_list:
print(val)
print(list([1,2,3]))
what do you think happens when that code is run
not sure
ah
have you read automate the boring stuff
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
I see
Ill check it out
Do you think you could give me an example real quick tho of how i could use a parameter in the rock paper scissors tho
you could have a function that takes strings from both players
and then just put a shit ton of if elif conditions
aight thanks bro
if this player chose rock and this player chose scissor
then the player that chose rock won
bet
in a game where you drive a car around like gta 5 how does the game know that when your on a hill and that the car should go upwards also?
First learn pygame. Watch a couple of YouTube videos.
wanted to view the individuaal properties of pixel in enlarged version
as im using mouse click to begin
i wanted the coordinates not to be disturbed
at the same time be able to view in bigger version
import math
def ballPath(startx, starty, power, ang, time):
angle = ang
velx = math.cos(angle) * power
vely = math.sin(angle) * power
distX = velx * time
distY = (vely * time) + ((-9.8 * (time ** 2)) / 2)
newx = round(distX + startx)
newy = round(starty - distY)
return (newx, newy)
def findPower(power, angle, time):
velx = math.cos(angle) * power
vely = math.sin(angle) * power
vfy = vely + (-9.8 * time)
vf = math.sqrt((vfy**2) + (velx**2))
return vf
def findAngle(power, angle):
vely = math.sin(angle) * power
velx = math.cos(angle) * power
ang = math.atan(abs(vely) / abs(velx))
return ang
def maxTime(power, angle):
vely = math.sin(angle) * power
time = ((power * -1) - (math.sqrt(power**2))) / -9.8
return time / 2
this a physics module that I made for game development
this module I used for another game
opinions about this code?
what is best(most optimised) in pygame to code a game like pokemon ?? i thinking to use tiled to make the map and import it as csv and blit it onto a Xscreen ,and some sort of camera that will crop the Xscreen and display it on the displayscreen depend upon the player position ................ Any suggestions will be appreciated
Does anyone know a way to share games made with pyxel with android users?
what is the rect for ?
It's the way pygame identifies rectangular objects
while running:
for i in range(0, 3):
screen.blit(image, rect)
pygame.display.update()
pygame.time.delay(250)
screen.fill((255, 255, 255))
pygame.display.update()
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
mouseX, mouseY = pygame.mouse.get_pos()
print(mouseX, mouseY)
A1 = Ant(mouseX, mouseY, (0, 0, 0))
move(A1)
while event.type != pygame.QUIT:
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
break
showSteps(A1)
# modified the available screen area according to the counter frame
if A1.AntX in range(0, 251) and A1.AntY in range(0, 71):
break
elif A1.AntX < 799 and A1.AntY < 599:
move(A1)
else:
break
running = False
pygame.display.quit()
pygame.quit()
else:
pass
guys in this the second while loop has a for loop to check if user quits in between the game or not
it works fine
but i have a doubt
if we click on quit button
doesn't it break out of for loop and continue with while loop statements
please clarify this guys
Yes it should
But it doesn't because you are setting running = False whent the event == pygame.QUIT
im new to python but i wanna start making games. Where do I start?
Can someone help me with my question? #help-candy
start watching some pygame tutorials bruv
Hi all, why would people choose to use pygame over game engines?
pygame has great librarys and makes it easy to define screen, sound, and button imputs
they keep using complicated stuff and dont even explain what it does
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
is there anyway to use pypy to compile python programs and if so can it compile with modules such as pygame?
im also looking for this
a physics engine???
does anyone know a documentation on pygame ui?
Yes
or a tutorial
what is it then?
Basically we may need to build pygame in tkinter or pygui
You can make a game only with tkinter
Tkinter is a Python binding to the Tk GUI toolkit. It is the standard Python interface to the Tk GUI toolkit and is Python's de-facto standard GUI. Tkinter is included with standard Linux, Microsoft Windows and Mac OS X installs of Python. The name Tkinter comes from the Tk interface.
For this game, I used the Tkinter module instead of using th...
No need of pygame
ok
I am using pygame rn
I need a ui that can display a message
with pygame
if it can be imported into a pygame script
then I will use it
@restive estuary
@gusty wave you may use
https://pyimgui.readthedocs.io/
does it work with pygame?
S
?
Short form of yes
ok
Bye
is there a tutorial on yt?
is there any ui stuff in the pygame package?
What do you mean?
If you want to make it with just pygame, then just do that.
Do you know how to do collision detection between a point and a rectangle?
Just text? Then just render text, pygame has that.
Where it says none in the first line you have to put a font file
what font should I use?
The 24 is the size of the text
In the second line 'hello' is the text to be rendered
Using None will load the default system font.
Blue is a color and the way pygame handles color is using a tuple like
Blue = (0,0,255)
\
The color is in rgb (red,green,blue) and in the tuple you have to choose a value between 0 amd 255 for each color
The screen in the last line is the surface where you want to display the text img
BRO
can you just help me
like
show an example
how how the code should look like
font = pygame.font.SysFont("Arial.ttf", 24)
img = font.render('hello', True, BLUE))
screen.blit(img, (20, 20))
the blue var
is some where else
in my code
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
GRAY = (200, 200, 200)
is above the text piece of code
wdym
just wait and i will make you an example
screw it
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
GRAY = (200, 200, 200)
font = pygame.font.SysFont("Arial.ttf", 24)
img = font.render('hello', True, BLUE))
screen.blit(img, (20, 20))
yea like that
screen = pygame.display.set_mode((700,400))
blue = (0,0,255)
font = pygame.font.SysFont("Arial.ttf", 24)
img = font.render('hello', True, blue))
screen.blit(img, (20, 20))
EZPZ
what is wrong?
are you blind?
the blue is an error
the font is an error
img = font.render('hello', True, blue))
^
SyntaxError: unmatched ')'
wdym
img = font.render('hello', True, blue)<--)
oh
display.blit(img, (20, 20))
AttributeError: 'tuple' object has no attribute 'blit'
then uh
how 2 fix
pygame.init()
display = (1200,900)
pygame.display.set_mode(display, DOUBLEBUF|OPENGL)
it should look like this
display = pygame.display.set_mode((1200,900), DOUBLEBUF|OPENGL)
this line returns a surface
gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
TypeError: 'pygame.Surface' object is not subscriptable
gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
TypeError: 'pygame.Surface' object is not subscriptable
pygame.init()
display = pygame.display.set_mode((1200, 900), DOUBLEBUF | OPENGL)
icon = pygame.image.load("assets/icons/logo.png")
pygame.display.set_icon(icon)
gluPerspective(45, (display[0]/display[1]), 0.1, 50.0)
glTranslatef(0,0, -10)
glRotatef(25, 2, 1, 0)
in display[0] and display[1]
you cant do that
you only do that for list or tuples
and display is not a tuple
gluPerspective(45, (---->display[0]/display[1]), 0.1, 50.0)
just use 1200 and 900
or put those two in a variable
confused a lot lot m
pygame.display.update()
pygame.error: Cannot update an OPENGL display
i cant help you with that since i dont use openGL on my stuff
let me see
display = pygame.display.set_mode((1200, 900), DOUBLEBUF | OPENGL) <--change this line for:
display = pygame.display.set_mode((1200, 900))
can you just give me a stupid tutorial?
do you know about indexes in lists and that stuff?
omg
tell me do you know?
idk
looks like you need to learn a little bit more than just pygame
is it ok if i talk game design here?
no. you cant. that is why the channel is #game-development .
what would be the best way to fit the tile image on the whole window?
should i resize or draw multiple tiles from a loop
Depends what you are using, but assuming it is pygame, a for loop seems to be the best
nice rounded corners btw ! what wm is this ?
i3 gaps
used picom (git version) for the rounded corners
so ye a for loop works thanks, thought it would have performance issues but i dont seem to have any
Has anyone noticed an issue of their sprites getting slightly distorted while moving diagonally in pygame?
or is that just me
I wonder if it's due to the fact that it's moving quicker diagonally.
does pygame have cross-platform support?(mobile, console)
well it'll run anywhere where python can run i think, try searching for python libraries that allow you to tanspose your code to different platforms
Can anyone help? My self.kill() is not working in pygame
It's for me?
Nm
@green relic Did you figure it out?
I am using arcade. When I try to load a sprite like this: self.player = arcade.Sprite("prisoner.png", 2, 600, 400) I get Exception: Error: Attempt to draw a sprite without a texture set.. The first part of the traceback printed is saying it can't locate the sprite. Please help.
what does DOUBLEBUF|OPENGL) do??
not really sure i dont use them
find more about them in the pygame documentation
https://www.pygame.org/docs/ref/display.html#pygame.display.set_mode
anyone have a reccomendation on how to start game development for python? I want to start off fresh and want to know everything about python and game development, and would be nice if you could send me a playlist on youtube or a video on everything about python
learn the language first, you can probably find videos on youtube from freecodecamp, and game development is honestly just about how you can understand the module you are using, and how everything works together.
each software isn't easier or harder, it's a different can of worms
hello everyonehello everyone
how can i create perspective view custom in the game ?
in every 3d games
inject py file to games and making custom camera ...
I am new , what game should I make first
what is hardware accelerated rendering
dude what framework are u using
?
are u using python
and the art is amazing
Unity or Unreal Engine
they both have support(but hard to add and use)
I wouldn't use python for game/engine development
I would most likely use something like C/C++ or Java
maybe even C#
and if you want to use python, try Kivy, Pygame, Panda3D, Arcade, Pyglet, Cocos2D, Pyxel, Wasabi 2D, Ursina, PursuedPyBear
python is not suitable for large game development right??
It is
@dawn quiver some large games like EVE Online, Toontown, Pirates of the Caribbean Online, and several others have been made using Python.
I think Civilization IV also is made with a lot of Python.
not Assassin's creed or Death stranding or Red dead redemption, these aaa titles are far too complex for python only
but majority of it is made using c# c+ right?
The underlying engine for those games will be written in something like C/C++, but the higher level game logic and scripting can be done in Python
I'm reading here Battlefield 2 uses Python as well
hmm, intresting
A good approach is to start prototyping and writing the game in Python, and if parts of it become slow, you can rewrite the slow parts in C/C++
Or to pull in a C extension from PyPI to speed up those tasks
can someone tell me a good book to learn pygame?
I'm working on a platformer with snow elements, I don't have a good idea for gameplay though. See vid for gameplay.
i might be kinda stupid but i'm new to this in general, how would you load an image file on python, where do you store it?
import PIL
image=PIL.Image.Open("file_path")
the lowercase image now holds the loaded image
you would install it with pip
either PIL or pillow, pillow being the more modern and almost always better version
ok, i couldn't find PIL to install using the standard: py -m pip install (name)
Omg the game looks fantastique. Are u using pygame??
Yeah pygame and numpy for the snow :)
You could also use the in-built tkinter module to create a window with the image
Never done it before but I know it's possible
Arcade 2.5.6 is out. Fixes an issue with PyInstaller making it easier to turn an app into a .exe. https://arcade.academy
i am trying to import some old game's animation into blender but i can't get them to work since i don't know how to manipulate quaternions
( image 0 are the values i believe to be the quaternion rotation of one of the leg bones )
( image 1 is what the armature looks like when applying these rotations to the leg bones )
( image 2 is legs and arms )
( in image 3 we can see that clearly something is inverted, the left and right arms have 'switched places' )
( image 4 is the armature with most* bones rotated, note that the character is now facing the opposite direction )
i don't know if the problem is with the quaternion value or with the armature itself since it was imported using a blender addon
i also don't know how to correctly manipulate the quaternion to fix it if it is at fault
@normal silo Why Ursina?
Ursina is a lot like processing: https://processing.org/
It just has everything setup for you. And Ursina already has an entity system making things very convenient.
I also want to be able to add shaders as I please, which it lets me do.
I know processing and funnily it was not my introduction to graphics - that was Python, when I was making the rendering engine with this guide - https://github.com/ssloy/tinyrenderer/wiki. Good times, it was slow as hell 😄
I just throw the slow parts into numba.
I found that later too! I still think that it is an awesome project!
I wanted to rewrite everything to CUDA then 😄
My first software renderer was in C, I actually could not be bothered to deal with the OS windowing (annoying, though I know it now more than I want to), so I just rendered it in the terminal (ascii).
I must go, it's really late here (GMT+2), but I will probably be here tomorrow, see ya!
I got multi-layer parallax working in numpy / pygame 🙂
It's more apparent when there's an x vector on the snow
Guys can i make a game like fortnite or minecraft with its graphics by pygame or no???
i dont think pygame would do much good when it comes to 3d
check out panda3d or ursina
ok can panda3d or ursina make a game like fortnite??
or i need to use game engine like unity??
also, other languages and game engines are better for 3d game development, but python would be almost ok i think
fortnite is a pretty big game
do u mean python is for small game
tbh, i have not done any 3d game dev in python so i am not sure if it is possible, but its sure gonna be harder than using some game engine which has a lot of more features
these days you can make pretty big games in python, especially in the 2d field
but its not the best choice when it comes to 3d
ok ty so much
you still can try out panda3d, there are a good amount of 3d games made in python
ok
Well, EVE Online is written in a variant of Python, so I really wouldn't worry myself about the language that much.
I don't want to preach the Nike ideology, but starting and doing seems to be the best languages, at least for me.
It requires a lot of commitment to learn 3D properly. It's a very complex area. If you can start playing with that using higher level tools.. good!
The best option for a large 3D game with python is using Godot with python support.
You can then also use C++ if needed.
But you can get decently far with panda3D / Ursina and something like numba or cython.
You can make something like minecraft, but you will have to do many parts in cython or numba like terrain mesh generation.
And enemy AI (path finding).
Godot will have many things already implemented in C++ (there are modules made by others that you can download for stuff), so you can just script some of the game logic in python on top of that and in that case python's speed won't matter much.
https://github.com/Zylann/godot_voxel could be used, and may be faster than minecraft java edition.
is ursina still good for 3d game? 3d building
So does pygame have professional-level potential? Like, are there any big games out there that use it?
can someone help mepls
I keep on getting this error
i am trying to make a rectangle, for the collision in a game
and i get this error:
Traceback (most recent call last):
File "C:\Users\askhu\AppData\Local\Programs\Python\Python39\Scripts\Blaviken, Dawn of the Elves\RPG.py", line 25, in <module>
player_rect = pygame.rect(player_location[0],player_location[1],player_image.get_width(),player_image.get_height())
TypeError: 'module' object is not callable
>>>
and i have done everything right sooo
i dont know where i am going wrong
pygame.rect != pygame.Rect
ye i fixed it, thx tho
pygame.rect is a module as the error states
mhm, syntax is reaaaallly important in python lmao
That goes for any language 😉
You get used to the naming rules. Classes usually start with a capital letter at the very least.
Hey @eager umbra!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
surf.blit(pygame.transform.scale(display, WINDOW_SIZE) you're missing a )
np, id suggest including the traceback next time tho
or at least the line it's occurring on
Hi! What 3d game engines are based on python that I can use for free? I am a beginner.
@elementFire#5071 2D: Arcade, 3D: Panda3D, Ursina
Hello I need help with a task, can someone help me?
How can we know whether we can help you if we don't know the problem?
I have to create 3 levels of difficulty for a hangman with python
I had planned to do it according to the number of characters that the word contains + 6 attempts
the problem is that I can't find a way to write it to code
So if I want to build a game using python where can I go to test it
If panda3d is derived from C++, does that make it fast enough to make large games?
Yes
@earnest hinge It's been used for some commercial large games, so I'd say yes
has anyone made a fps in python
Yes probably, but trust me that wouldn't be a great idea
If you mean by using python as a scripting and such backend then use most games probably do, but a game purely written in python isn't exactly a great idea
yes, I made one for last pyweek where you shoot arrows
it's more like a prototype though, not a full game
How do i add a Python background color for my game
color_name = (r,g,b)
wait so which language would be a good idea
cause i was planning to use python
to create some game
s
you can use python for sure, most* libraries use either opengl or sdk hooks (tkinter might be an exception to that?)
but c#/unity and godot are pretty popular for starting out
c# + unity, blueprints + unreal
no game engine???
Is anybody experienced with the Panda3D game engine here?
yeah i was wondering that as well, the games mentioned are terrific
You don't need a game engine to make a game, or another way of thinking about it is that you make a very small engine specific to the game being made.
yeah, sort of
you might wanna join the Panda3D discord for anything about that
pygame
check the pins
can games made in pygame runs on android?
Is there a community for Pygame Zero?
@midnight girder there are a lot of ways to do so. You might want to check out https://arcade.academy and https://learn.arcade.academy
Yas
I agree
I think that it is possible but it isn't as easy as making PC games
why should someone use that?
how does panda3d / ursina compare to unity/unreal engine?
The first two are open-source Python software libraries, the last two are massive commercial engines for C#, they don't compare in the slightest
I guess ursina is slightly inspired by Unity, with the Entity/GameObject similarities, automatic update function, Mesh class and some functions like invoke(). That's about it though
how can you put a rect on top of a rect in pygame?
draw an image of what you mean by "on top" @distant wind
Do you have the y position of the bottom rect?
top_rect_y = bottom_rect_y - top_rect_height
im getting a problem in my raycasting function
def ray_casting(player, textures):
walls = []
texture_v, texture_h = 1, 1
ox, oy = player.pos
xm, ym = mapping(ox, oy)
cur_angle = player.angle - HALF_FOV
for ray in range(NUM_RAYS):
sin_a = math.sin(cur_angle)
cos_a = math.cos(cur_angle)
sin_a = sin_a if sin_a else 0.000001
cos_a = cos_a if cos_a else 0.000001
# verticals
x, dx = (xm + TILE, 1) if cos_a >= 0 else (xm, -1)
for i in range(0, WIDTH, TILE):
depth_v = (x - ox) / cos_a
yv = oy + depth_v * sin_a
tile_v = mapping(x + dx, yv)
if tile_v in world_map:
texture_v = world_map[tile_v]
break
x += dx * TILE
# horizontals
y, dy = (ym + TILE, 1) if sin_a >= 0 else (ym, -1)
for i in range(0, HEIGHT, TILE):
depth_h = (y - oy) / sin_a
xh = ox + depth_h * cos_a
tile_h = mapping(xh, y + dy)
if tile_h in world_map:
texture_h = world_map[tile_h]
break
y += dy * TILE
# projection
depth, offset, texture = (depth_v, yv, texture_v) if depth_v < depth_h else (depth_h, xh, texture_h)
offset = int(offset) % TILE
depth *= math.cos(player.angle - cur_angle)
depth = max(depth, 0.00001)
proj_height = min(int(PROJ_COEFF / depth), 2 * HEIGHT)
print(depth, offset, texture)
wall_column = textures[texture].subsurface(offset * TEXTURE_SCALE, 0, TEXTURE_SCALE, TEXTURE_HEIGHT)
wall_column = pygame.transform.scale(wall_column, (SCALE, proj_height))
wall_pos = (ray * SCALE, HALF_HEIGHT - proj_height // 2)
walls.append((depth, wall_column, wall_pos))
cur_angle += DELTA_ANGLE
return walls
it gives me this error wall_column = textures[texture].subsurface(offset * TEXTURE_SCALE, 0, TEXTURE_SCALE, TEXTURE_HEIGHT) KeyError: 1
nvm i fixzed it
i dunno where to put this so ill put it here
can png's store more than just pixel data
i had a HGT height map (satellite data height map) turned into a png and my python PIL png reader is somehow reading the actual height of what each pixel is representing rather than the coulour of the pixel. (its a grey scale image for visualisation so i got no clue how this happened)
im not sure if its a bug or if this is some magic
hey someone can tell me which programs i can use for game development?
So I'm making a 2d top-down battle game, basically you move your little knight around fighting baddies lol. What is the best way to detect if a bad guy is hit when the knight attacks?
My idea of doing this is just by creating a loop that goes through a list of all the baddies (lol) and checks if anyone of their coords are in front of the knight to get hit by the sword. But I feel like this will be slow and there is probably a better and faster way to do this... any advice?
Also, I'm doing this with pygame
actually that math is pretty easy to calculate, Pygame is heavily reliant on rectangular collisions (because it's fast). You give the baddie a rectangle, and then give the sword a rectangle and check to see if they collide on each frame. There are also pixel masks, which detect collision based on overlap of individual pixels (not as slow as you'd think but still slower than rectangles)
If there is a 4.th value on top of an a set of R, G, B values, it might be the 'alpha' value a.k.a the level of transparency of that pixel 0 is full transparency, 255 is opaque. Do the values go above 255?
no. 255 is the max val. 0 - 255 is like the 0-1 scale.
and yes 0 is transparent and 255 is opaque.
@analog barn yea im getting numbers from 0 , 7 digits
and theres no RGB array either
PIL is reading each pixel as a int
what would be the best way to implement a dialog-box in pygame
the way i want it to work is if you are near an interactive object and press e everything freezes the dialog-box shows up and then text is displayed everything remains paused until the user presses e again
you just stop listening for events, and only display the dialog box on the screen.
create a boolean called dialog_open and set it to True if it is open. now , when checking for keypresses, just add an if statement checking whether dialog_open is False, or not. Freezing everything becomes quite simple then. if the player moves, by pressing keys, then if the keys wont respond, the game doesnt move on.
@dawn quiver thank you so much, this makes so much more sense to me now 👍
I will try to have the program stop listening to events in the main loop but create a separate loop to wait for the second e press
my only concern is that pygame will process everything so quickly that the one e press will constitute the dialog box opening and then immediately closing
not really. for instance:
for event in pygame.event.get(): if event.type == pygame.KEYDOWN: if event.key == pygame.K_e: # check dialog box open status if dialog_open == True: # skip the current dialog contents # just an example: dialog_box.clear() # write new contents: dialog_box.write("new contents) if dialog_open == False: # check for player interactions if . .. .. .. ... .. .. else: pass
that wont happen until you include pygame.keys.get_pressed(), which might cause unexpected bugs.
and if you want the dialogues to in some sort of order,
you can create a new variable that keeps on incrementing when you press e, when interacting with something.
and use that index to access contents to be displayed in a dialog box, that may be stored in an array of some sorts.
im trying to load sprites into a dictionary like this
import pygame
import os
WIDTH, HEIGHT = 900, 900
sprites = {}
for filename in os.listdir("client/resources/sprites"):
sprites[filename[:-4]] = pygame.image.load(f"client/resources/sprites/{filename}")
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Battle Ship")
pygame.display.set_icon(sprites["YouWin"])
# Game Loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
but get this error
will i have to load the sprites one by one, or is there a better way?
anyone knows about pygame objects' textures
what do you want to know?
how to use them
and how to then animate them and all
like if wanna have a moving ant
maybe not animate
that might be too hard
but at least a texture
@tender dagger do u know how to do it
I don't know pygame obj, but I know other texture file types
jpeg, png, targa
you can make a sprite for a 2d animated ant, but it depends on what you are doing to make the game element and how you set it up
I know more 3d than 2d
well i need specifically with pygame
i just wanna basically use an image and be able to rotate it instead of having like a square
not sure, but this data here might get you started https://ehmatthes.github.io/pcc_2e/beyond_pcc/pygame_sprite_sheets/
but for 2d anim i would recommend using sprites or a sprite sheet, not sure on pygame able to use transparency
def on_update(self, delta_time: float):
# ignore from this line
self.enemy.change_y = 0
self.player.change_y = 0
if self.up_pressed and not self.down_pressed:
self.enemy.change_y = 5
elif self.down_pressed and not self.up_pressed:
self.enemy.change_y = -5
if self.w_pressed and not self.s_pressed:
self.player.change_y = 5
elif self.s_pressed and not self.w_pressed:
self.player.change_y = -5
# ignore to this line
if self.ball.left < 0:
self.player.add_score()
print(self.player.get_score())
self.setup() # focus on this
elif self.ball.right > SCREEN_WIDTH:
self.enemy.add_score()
print(self.enemy.get_score())
self.setup() # focus on this
is there a better way of doing the self.setup() part that conforms to arcade conventions?
usually you'd want to only call your setup method once to set up your spritelists, base objects, etc and have everything be drawn in your draw method
i need to reset the positions of the player, ball and enemy and some fields though
def setup(self):
""" Set up the game here """
self.player.center_x = 5
self.player.center_y = SCREEN_HEIGHT/2
self.enemy.center_x = SCREEN_WIDTH - 5
self.enemy.center_y = SCREEN_HEIGHT/2
self.ball.center_x = SCREEN_WIDTH/2
self.ball.center_y = SCREEN_HEIGHT/2
dir = uniform(0, 1) * 360
print(dir)
self.ball.change_y = BALL_VELOCITY * math.sin(dir)
self.ball.change_x = BALL_VELOCITY * math.cos(dir)
this is what setup looks like btw
class Player:
def __init__(self, starting_position: Vector):
self.starting_position = starting_position
def reset(self):
self.position = self.starting_position```
ei keeping the original position in the objects instance
that does look neater
also it's a personal opinion but having a vector class is super useful especially for readability
even something as basic as
class Vector:
x: float
y: float```
so instead of having 2 different variables .._x and .._y, you can access it by it's methods pos.x, pos.y
- if you want to get real funky, you have operator overloading available if you need it
np
i need some direction in how i would go about doing this. basically, i am polishing my pong game and i want to have some sort of timer before the ball moves when a round starts. A round starts when 1) when the game starts 2) when someone scores (when ball touches left or right edge of the screen). I am using arcade btw.
@olive parcel Hey, how do I change the target frame-rate for Panda3D in python, and how can I uncap the fps (run as fast as possible) for a Task. I tried setting vsync to false, no difference.
@normal silo The setting is "sync-video false". Note that some drivers ignore it, in which case you need to look for driver settings or driver-specific environment variables like __GL_SYNC_TO_VBLANK
To limit FPS, you can set clock-mode to limited and clock-frame-rate to the desired FPS.
self.vsync = ConfigVariableString("sync-video")
self.vsync.setValue("false")
Is how i'm trying to change the settings, maybe i'm doing it wrong
Well that's going to produce a warning that you're changing the type of a ConfigVariableBool
You also need to make sure it's set before you initialize ShowBase.
vsync = ConfigVariableString("sync-video")
vsync.setValue("false")
app = MyApp()
app.run()
So before, but also ConfigVariableBool, not String
I actually don't get any warning from this.
The typical way to do it is loadPrcFileData("", "sync-video false")
That func is imported from panda3d.core
See above though, some drivers don't obey Panda's requests.
Yeah it's probably my drivers then, there seems to be no effect.
There are other ways to override this, depending on the vendor
They're not Panda-specific.
It does
But it only limits, never increases.
So it can't undo the effects of vsync.
Yeah
There are other clock modes that do increase frame rate, but only by lengthening the definition of "second", eg. for video recordings
I guess I will have to try setting the environment variable.
Going to bed, afk
What should i learn first? Ursina or panda3d?
I am hosting a Game Jam, is this a good channel for putting it in?
I would send a modmail to get permission regarding advertising, they'll also direct you to the appropriate channel if approved
ok thank
first of all, it is not true it is True for python.
secondly, it is set_mode() not set_mod()
third, replace your code with mine:
import pygame pygame.init() display = pygame.display.set_mode((800, 600)) pygame.display.update() open = True while open: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() pygame.display.flip()
how to start learning pygame
i dont know if there is the right place, but i'm working on a simple ant colony simulator, i'm trying how to create a smooth random movement
does anyone have a good solution?
is pygame okay with asyncio tasks?
nop, i'm using ursina engine
i tried making pong online, tasks just never run
did you use sockets?
im using websockets
either way you shouldn't be using async for sockets, it doesn't actually run on separate threads
async def move_enemy(ws:websockets.WebSocketClientProtocol, enemy, lobby, host):
print("moving enemy")
package = {
"reqtype" : "getCoords",
"host" : host,
"lobby" : lobby
}
await ws.send(json.dumps(package))
resp = json.loads(await ws.recv())
enemy.y = resp
async def update_coords(ws:websockets.WebSocketClientProtocol, player:Player, lobby, host):
print("posting Coords")
packet = {
"reqtype" : "postCoords",
"host" : host,
"lobby" : lobby,
"ypsos" : player.y
}
await ws.send(packet)
async def main():
lobby, host, ws = await setup()
player = Player(300)
enemy = Enemy(300)
run = True
win = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
while run:
asyncio.create_task(move_enemy(ws, enemy, lobby, host))
keys = pygame.key.get_pressed()
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if keys[pygame.K_w]:
player.moveup()
if keys[pygame.K_s]:
player.movedown()
refresh(win, player, enemy)
asyncio.create_task(update_coords(ws, player, lobby, host))
pygame.quit()
quit()
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
asyncio.get_event_loop().run_forever()
never updates player coords or enemy coords, shame
idk if this is the reason its not working or not but id suggest using multiprocessing or even threading
so do i create threads where i update player and enemy pos every x amount of time?
that should be controlled by your main thread, but you need to create others for sending + receiving the data / what's been updated
do i need to switch from websockets to sockets?
ive heard that async doesnt behave well with threading
https://stackoverflow.com/a/49899135 looks like it's possible but im not familiar with websockets sorry
i think i got it
async def move_enemy(ws:websockets.WebSocketClientProtocol, enemy, lobby, host):
print("moving enemy")
package = {
"reqtype" : "getCoords",
"host" : host,
"lobby" : lobby
}
await ws.send(json.dumps(package))
resp = json.loads(await ws.recv())
enemy.y = resp
async def update_coords(ws:websockets.WebSocketClientProtocol, player:Player, lobby, host):
print("posting Coords")
packet = {
"reqtype" : "postCoords",
"host" : host,
"lobby" : lobby,
"ypsos" : player.y
}
await ws.send(packet)
async def main():
lobby, host, ws = await setup()
player = Player(300)
enemy = Enemy(300)
run = True
win = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
_thread1 = threading.Thread(target=between_post, args=(ws, player, lobby, host))
_thread2 = threading.Thread(target=between_move, args=(ws, enemy, lobby, host))
_thread1.start()
_thread2.start()
while run:
asyncio.create_task(move_enemy(ws, enemy, lobby, host))
keys = pygame.key.get_pressed()
clock.tick(30)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if keys[pygame.K_w]:
player.moveup()
if keys[pygame.K_s]:
player.movedown()
refresh(win, player, enemy)
asyncio.create_task(update_coords(ws, player, lobby, host))
pygame.quit()
quit()
def between_post(ws, player, lobby, host):
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(update_coords(ws, player, lobby, host))
loop.run_forever()
def between_move(ws, enemy, lobby, host):
loopx = asyncio.new_event_loop()
asyncio.set_event_loop(loopx)
loopx.run_until_complete(move_enemy(ws, enemy, lobby, host))
loopx.run_forever()
.png image not accepted in pygame sus
yeah cant do that either so I can't make my game :(
yes;(
hello
i have a problem
so if i have an arrow and its facing upwards, to move it i would decrease y
if its facing right, i would increase x
and etc
my question would be, how would i know how much x/y should i change by if the angle is unknown
for example if the object is facing upwards the angle is 0
if right then 90
and etc
but if the angle is for example 233, how would i then know by how much should i change x/y if i want to move it upwards
@olive parcel In Panda3D where does taskMgr come from? I don't see it imported in the docs.
You can import it from direct.task.TaskManagerGlobal
For historical reasons it gets written to the builtins scope of the Python interpreter
ok, what exactly is direct? Why is it called direct? Would something like this not be in core normally?
@normal silo direct is a Python library on top of the core Panda engine, which is c++. They used to be separate things when they were being developed at Disney: PANDA stood for Platform Agnostic Networked Display Architecture, and DIRECT stood for Disney's Interactive Real-time Environment Construction Tools.
You could also use vectors and rotate them
That works really well
i already solved that
now i have a solely pygame problem
i need help on how can i recreate the last example of rotation in the first gui's response
this one
@restive lantern
Look you have to rotate the image then make a rect of the rotated image and then set the center of that rectanlge to a single point
You have to look into the pygame documents
There are functions for rotating and for making a rect out of an image
no no
that guy in the stack overflow made his own functions
cuz the original pygame.tranform.rotate is complete shit if im being honest
if u look at that stack overflow post i linked that guy shows how he did it how i want
but its very difficult
so i need help figuring it out
But at the end of the day he is still using the pygame transform and get_rect
Its the exact same thing but this guy makes a function that also rotates it around a diferent point
And to be honest he did some things wrong
I cant right now
k
dude why you gay
You can post your query here.
I think I finally know how to properly word what I was trying to ask here, altho it might be more of a system architecture question. How does the vertex buffer actually get loaded into vram from ram? (im assuming it'd get loaded into ram first?)
Your gpu driver sends it.
can you get any more specific?
The gpu driver controls the hardware which opens data lines between the RAM and the GPU.
what's the hardware?
The computer hardware. The physical device.
do you know what the actual hardware is?
Depends on the device
for something like a mobile phone, the cpu, gpu, etc are integrated aka SoC.
In that case it's some unknown silicon that the data travels through.
Only the manufacturer knows and a few hackers.
For something like a PC, it goes through the motherboard.
so it'd be just some data bus?
PCI, AGP, or PCIe, etc.
ok thanks that actually clears up a lot for me
it's a bit more advanced than a normal bus
it acts a lot like networking
(because of the large number of required features added over time, e.g. more than one gpu)
ill have to look into it more, it's really hard to find anything tho if you don't know what to search for
at least for this sort of stuff
There is probably a discord and a subreddit for it if I had to guess.
How can I create a variable?
variable_name_goes_here = 'something'
have you named your file pygame.py?
Mmmm... ok do I need to type everything same?
no
ok
Yeah and this 'something' what do I need to do with it?
Set it to whatever you want it to be
Ok.
Yes, you can't name your python file in a way that conflicts with existing module names
👍
Sorry for the super late response, could I get an invite to that? I can't find a link online
In case I get banned for sending server invites, I'll just tell you where to find them
You can find it at #315249263103967242
or at the bottom of the homepage of https://www.panda3d.org
Thanks, much appreciated
no worries 🙂
Sending the invite here is fine 🙂 It's https://discord.gg/9XsucTT
does anyone know a super easy way to make a infinitly generated world, one that a idiot like myself would understand, if so DM me pls
@sonic belfry yes, spawn a copy of the world in 8 times around your current world, and when the player enters one of the surrounding copies, you position them back in the same position in the original copy
ok can someone help me with this?
split() returns a list of strings right
so x = line.split() should be able to be indexed like this: print(x[0])
so why does it give me an IndexError: list index out of range?
def GetScores(self):
scores = dict()
with open(self.directory + "/highscore.txt", "r") as score_file:
for line in score_file.readlines():
x = line.split()
print(x[0], x[2])
return scores
@quasi valley presumably there is a line that does not contain at least 3 elements
There might be an empty line at the end, or something
You could skip empty lines
ah
but my file just looks like this:
Apr-02-2021-00 - 450
Apr-06-2021-00 - 19770```
also it splits due to whitespaces
turns out one of my files that i didnt check had a messed up line lmao
had thought i checked them all xD
happens
yep
no wonder debugging is easy in python XD
Prob one of the best.
true
does anyone know why the images wont load even though I have them saved?
Are the images in a subfolder? If so use the directory of image including the sub folder
wym by that. They are saved in the same folder as the game
are the images in a subdirectory like images/racecar.png
or in the same dir as your game file
@deft locust
Same directory as my game file
Wait im using a web IDL
*Idle
hey im trying to make a egg game but its not detecting collison
hey can anyone help me to figure out why my bullet is not firing when i press Space bar
Hey @short wing!
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:
You code this? If you code this it's good
Love this
I have collision for the bottom edge, but I can't seem to get it for the top edge. Any ideas?
in the pygame buttons function include the spacebar
can u help me i dont understand plz
Yes I did but why? I think you are just bashing me. lol
btw I've completed the project. Thanks
Hehehe
@dawn quiver thanks anyway lol
did u used collide_rect().
Use 1 = instead of 2, two checks if those things are equal
Did you solve the space bar problem? I'm having the same issue
Nevermind, just used another keyboard and it worked
I am currently making a game called Hog under an archive of UC Berkeley's CS61A Summer of 2020 class. Can someone explain to me why 2 0
5
4 3
13
6 9
21
is the expected outcome of this
please
I think you need to call echo like echo()
so what this is is a test in which I need to unlock in order to proceed writing code for the Hog game. What one would do is roll the dice and it will cycle through make_test_dice(2, 3). always_rolls(1) rolls the dice (cycles through it) once. So 1 dice roll goes to 2. Another goes to 3. The above file shows some rules of the game that may apply. What I'm confused about is the relationship between total() and echo(). Every odd numbered line in the list of numbers I provided are Player 1 and 2's scores. The even numbered lines are the total after each turn I think.
hi i made a class but im having trouble implementing it into my main code
can someone explain this pls?
So i am making this rpg thing and i want to implement a fighting system. I want it to be based on the player's health, armor, strength, and his opponents health & strength. How do i do that?
Like how do i decide if the player missed his hit or no and how much health he lost and if the armor protected him
And all that math boring stuff
well, if you're thinking of it as "boring math stuff", copy the mechanics of some existing rpg or something
id start with trying to figure out the base dmg, how the prot will work, crits, etc, etc
after that start working on conditional randomness
But looking at some existing stuff could help where can i find it?
I've got a bit, it's not great but it's the basic concept
Can i have a look?
ya lemme find it
Wikis for RPGs usually say how the mechanics work
Aight ty
https://github.com/The1Divider/__insert_name__-rgp/blob/main/Game.py#L168
I really have to emphasize it's not great
Its alr i aint that professional of a programmer either lmao
Just the fact that u use the math module makes u better than me alr
😂
What are the directions for btw?
that one line took me + a friend like 6hrs to figure out
Is that like a 2d game on the console?
user would type in a direction -> player goes in that direction -> encounter logic is done ...
it was just a console game
I wouldn't even call it 2d
Like text based or 2d?
noice
Ok i am confuzed alr this is complex i am trying to make something simple 😅
if you look past the shitty signal handling it actually is pretty simple
I just need to know how to calculate the damage
And how to determine how much health is lost
dmg_done = base_dmg + crit * crit_chance - block * block_chance[optional], with: crit_chance, block_chance = random(0, total_chance) is in range
thats what I meant with this btw
I could just do
damage = random.randint(0, strength)
But that'd be boring wouldn't it? :joy:
you're also leaving almost all of it to chance
rpg doesn't stand for randomly played game 😄
Do i make critical hits? Like i aint making my rpg that complex
the beauty of this 'general formula' is that you can leave any part of it out and it'll still work for the most part
For me it'd be human fighting monsters so that eliminates blocking right?
Cuz monster r dumb
but different monsters might have different weaknesses?
it just adds a layer of complexity to the game so it's not just pressing the attack button over and over
even with the one I sent, the combat is literally just pressing '1', there's no point in blocking
Its text based to their aint even buttons
And also it'll be auto fighting i just want to tell the guy if he won or no
Player*
ah
I am making a discord bot if u haven't relized yet 😅
dmg_done = base_dmg + crit * crit_chance - block * block_chance[optional], with: crit_chance, block_chance = random(0, total_chance) is in range
The problem with this is that all this is variables
(also not python btw)
Like how do i determine the base damage or critical damge or chance
Yeah this all is math related ik
depends on the rest of the system, I cycled through weapon(s)/armour equiped and made the stats that way https://github.com/The1Divider/__insert_name__-rgp/blob/a92875960b9a5d9e817397073a14713db7768b85/InventorySystem.py#L486
but if you wanted just base stats then you'd probably want them based on player/enemy level
also just a massive heads up, signal processing when your game is solely text based gets complex very quickly
I fully refactored this project ~3 times to try to fix it and was working on a 4th before giving up
so ur project doesn't work?
last time I checked no
haha ya it just got really complex, trying to display inventories + properly type everything + dealing with i/o just got extremely convoluted
I think ill try to rewrite it but using arcade or some sort of gui over the summer
ping me in a couple hours if you're still around im working on a school project atm
just dm me when ya can
actually if you remove the "ThisShouldntShowUp" thingy it all works
Best of the worst sulotions!
better than givin up
it shouldn't
actually I don't think I pushed the most recent rework it's just on my other laptop
panda 3d vs. pyopengl
Hi guys, i need help on figuring out how to make a unity Slerp() function like, in python (im using Panda3d/ursina)
Yes I solved the problem. @bold tulip
Hey guys how do I make an object in pygame move around in ellipse? And I also want one more object to move in an arc shape, like the banana kick in football.
Im not really sure about the elipse but for the arc you are gonna need a parabola equation
anyone got some examples for games
Hello
I was working with pygame and pyopenGL
I am making an app and i need to blit some things which is Not possible with openGL
I have tried blitting onto another surface and then converting that surface to openGL textures but that didnt work
can anyone tell me a way to set a surface for openGL, such that i can use Pygame normally like i would in non openGL projects and for openGL part, I can blit on the surface and then blit that surface on the main surface
thanks in advance :)
some one explain me this pls
it says there is No such file
i know but how can i fix it?
is the image (spaceship_yellow.png) in Assets folder?
i dont use VS code so am not sure
but i think it is not in Assets
yes it is
weird isnt it?
got the error
wait
the main.py file is not in the PygameForBeginners folder, so there is no Assets folder in its directory
and what is supposed to get fixed?
because when i run the game
it opens the programm but its broken graphic
wait i am making a screenshot
ok
i was thinking about that too
is it working when opening in VScode?
wierd
no
not about the IDE
can u send the code ?
the part where you blit the image
Hey @dawn quiver!
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:
Hey @dawn quiver!
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:
Ah ok. Cool bro thanks. ❤️❤️❤️
ja ich habe es installiert
woher weißt du das ich deutsch kann haha
enes
das ist aber türkisch xD
egal
ich habs installiert aber das sagt immer was anderes
zeig mal den ganzen output
das bild ist aber schon noch am gleichen path oder
egal warte hab das code geloscht i habe noch ein spiel da sind glaube ich aber auch fehler drinne
can someone fix this?
@pale schooner can you fix this?
You either didn't install it, or you have multiple python installations and you installed to the wrong one
i have ursina installed
already
wait i chose the wrong interpreter
now it works
but its corrupted i think
@tranquil girder the game works but how do i leave it i think i forgot to add a panel
Hello, I'm making an online multiplayer Pong game using pygame and sockets. I have a client.py and server.py. The way I'm communicating between client and server is using pickles library. I'm sending and receiving player and ball objects continuously b/w client and server and server is keeping track of the positions of players and ball. I wanted to know that when I pickle an object and send it from server to client, it's actually sending a copy of the object to the client, right?
are you asking whether changing the object on the client will also change it on the server?
also be aware that this way of doing it allows the client and the server to run any code they want on each others' computers
Exactly yes. i need it for only one use case. I just need to change an attribute of the object in the client, and I want that affect to take place in server as well.
sorry for my poorly framed sentence. English is not my first language.
sure no problem
what? how?
pickle does not automatically synchronise changes to objects over the network
ok so, I'll need to send the object back to server??
yes, although there are much simpler and more efficient ways of doing this