#game-development
1 messages ยท Page 92 of 1
it will be longer
but
if they're at a point in the code, i want them to be able to come back without restarting
@exotic laurel
sorry i gotta go now!
kk
hi, can someone help me please? What is meant by callable? (using ursina engine)
a function is callable for example
an instance of a class like you're using here is not
but i cant use class there... then what to do?
whats is block? and what are you trying to do?
I just called him block its slime cube entity
I try to do when you pressed k it will disappear
so you want to do block.visible = False?
what does "there is no class" mean?
block.visible = False is how you should do it
no problem there
oh its working now thx
And I have another problem, I want that when you press k it will lower the heart slime and it does not lower why?
-=
also, held_keys is for checking if you're holding a key, not if you pressed it
that's what the input function is for
oh ok thx
I tried it already, I just want that if the amount of slime hearts = 3 then every time i press k it will remove 1 heart
it stay 2
slime_health = 3
if held_keys['k']:
slime_health -= 1
first click: 2
Second click: 2
Third click: 2
... 2```
@tranquil girder
use def input(key) instead of update
also, you're setting the health to 3 every time the function gets called, so it will never go below 2
Then what to change
the structure
what do you mean?
try rewriting it to make sure you get the logic correct
hi i know im in the wrong chat asking for help but the available help channel said cool down and i don't know how to delete the help channel i was using (because that's what it said to do)
you should set the hp to 3 earlier,
when you create the slime for example
oh right thx i will try
i want to have a line between the projectile (its a circle) and my mouse
one end of the line is at the ball
but the other end doesn't follow my mouse
its stuck at a random point
show code for your Projectile class
@teal ember
what graphics library are u using to render @dawn quiver
that seems like a pretty good minecraft clone
Show the code
@dawn quiver ^^
i am working on a text base game and i was wondering if its possible to delete the text in the shell before it prints the next part
because the longer it goes on the messier the shell looks
Ok 5 mins I'm showing
i even need optimization cause i want to make the world 10000 x 10000 or infinite
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:
from random import randint
from ursina import *
from ursina.prefabs.first_person_controller import FirstPersonController
from perlin_noise import PerlinNoise
app = Ursina()
grass_texture = load_texture('Minecraft-in-Python-main/assets/grass_block.png')
stone_texture = load_texture('Minecraft-in-Python-main/assets/stone_block.png')
brick_texture = load_texture('Minecraft-in-Python-main/assets/brick_block.png')
dirt_texture = load_texture('Minecraft-in-Python-main/assets/dirt_block.png')
sky_texture = load_texture('Minecraft-in-Python-main/assets/skybox.png')
arm_texture = load_texture('Minecraft-in-Python-main/assets/arm_texture.png')
block_pick = 1
noise = PerlinNoise(octaves=1, seed=randint(1,18446744073709551616))
xpix, ypix = 100, 100
pic = [[noise([i/xpix, j/ypix]) for j in range(xpix)] for i in range(ypix)]
window.fps_counter.enabled = True
window.exit_button.visible = False
window.fullscreen = True
def update():
global block_pick
if held_keys['left mouse'] or held_keys['right mouse']:
hand.active()
else:
hand.passive()
if held_keys['1']: block_pick = 1
if held_keys['2']: block_pick = 2
if held_keys['3']: block_pick = 3
if held_keys['4']: block_pick = 4
class Voxel(Button):
def init(self,position=(0,0,1),texture=grass_texture):
super().init(
parent=scene,
position=position,
model='assets/block',
origin_y=0.5,
texture=texture,
color=color.color(0 ,0 ,random.uniform(0.9 ,1)),
scale=0.5,
)
def input(self, key):
if self.hovered:
if key == 'left mouse down':
if block_pick == 1:
voxel = Voxel(position=self.position + mouse.normal, texture=grass_texture)
if block_pick == 2:
voxel = Voxel(position=self.position + mouse.normal, texture=stone_texture)
if block_pick == 3:
voxel = Voxel(position=self.position + mouse.normal, texture=brick_texture)
if block_pick == 4:
voxel = Voxel(position=self.position + mouse.normal, texture=dirt_texture)
if key == 'right mouse down':
destroy(self)
class Hand(Entity):
def init(self):
super().init(
parent=camera.ui,
model='arm.obj',
texture=arm_texture,
scale=0.2,
rotation=Vec3(150 ,-10 ,0),
position=Vec2(0.7,-0.6),
)
def active(self):
self.position = Vec2(0.6, -0.5)
def passive(self):
self.position = Vec2(0.7, -0.6)
for z in range(20):
for x in range(20):
y = noise([x/8,z/8])
y =math.floor(y * 7.5)
voxel = Voxel(position=(x, y, z))
for z in range(20):
for x in range(20):
y = noise([x / 8, z / 8])
y = math.floor(y * 7.5)
voxel = Voxel(texture=dirt_texture ,position=(x ,(-1) + y ,z))
player = FirstPersonController()
Sky(texture = sky_texture,shader = False)
hand = Hand()
pivot = Entity()
PointLight(parent = camera, color = color.white, position = (0, 10, -1.5))
AmbientLight(color = color.rgba(100, 100, 100, 0.1))
app.run()
dumb question but how does one make an actual game in python
Like where do I start
For example graphics
@dawn quiver yo'd use a library designed for it, such as Pygame or Arcade
the library handles windowing, graphics, keyboard or controller input, sound, etc.
so you need to update the mouse position every frame, right now you set the mouse position at the start only, so add this in your draw_line function, self.line[1] = pygame.mouse.get_pos()
wow this is weird
many people say that Python isn't fast enough, I dont understand what that means
to make AAA games of course
well, games often update at 60 fps meaning that the code needs to finish be able to update the game state 60 times every second and for very complex games like 3d shooters this is very computationally expensive and python is one of the slower languages which is why the very low-level languages like C++ is used
oh, thanks a lot ๐
Hey, I couldn't use the midbottom function in my program .... Using it still places my rect object on the bottom left
Can someone plz help me out...
Does K_LCTRL / K_RCTRL work? If not how about K_LSUPER and K_RSUPER they are supposed to be window keys but worth a try, pygame doesnt seem to have an exact binding to mac specific command
Ohh, meta keys
That's good!
have you tried printing the coords out and matching them? Also check if you're moving them elsewhere
show code
dawn, whats performance like?
like a chess board "list"?
How can I print the co-ordinates?
Can someone explain to me when I should be using sprite.Group and sprite.GroupSingle?
It is PyGame? https://www.pygame.org/docs/ref/sprite.html
Yes it is
So if we want to control a single sprite we use sprite.Group
And if we want to control many of them we use sprite.GroupSingle?
Read the link
It is obviously you did not.
And perhabs English is not your first language as well.
What Python libraries do I need to develop a 3D game?
i figured out how to generate under it if gives 40 frame 20 x 6 x 20 terrain no mesh
ursina
dawn, no mesh, so you're really drawing al those blocks completly?
yes
ig
how do i put a messsshhhhhhhhh
thats my doubt
i want infinite generation
plz help
Well as far as I know game development, for infinite generation you should use perlin noise, just generate the map around the player based on his coordinates and the perlin noise map
The mesh probably heavily depends on the lib you're using, but I have no game development experience in Python, so on that end can't really help you further
I just updated my game (made entirely in Python) on itch.io for the first time in a LONG time. https://xtaloid.itch.io/xtaloid
Smooth. What libraries are using for this game? Just curious. Not that it matters ๐
ah. It's pyglet. I snooped in files
Pyglet, and a little bit of C by way of Cython @potent ice
ah I thought I saw some of that, but wasn't sure if that was part of the packaging
yup, that was my core lib
you need a 3 d engine like blender or unreal
ok
any website for free images
Over 5,000 blades of shaded and interactive grass running at over 60fps in Pygame.
Hey @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
@manic zinc achha baba what bout gaming
i think you need 3.8
i made minecraft
๐ญ
Appreciate if someone could help
haha the creativity in modern age of mobile phones
Use pastebin.com or similar websites instead
you might be mixing tabs and spaces? also why dont you use f strings instead of the .format thing
Pygame, how do i check if a mouse click is inside a circle?
i found this "distance formula" on SO but idk why or how it works and wanted to check if there's an easier way?
pygame.display.update(); scr.fill((200, 200, 255))
pygame.draw.circle(scr, (0, 0, 0), (400, 300), 100)
x = pygame.mouse.get_pos()[0]
y = pygame.mouse.get_pos()[1]
sqx = (x - 400)**2
sqy = (y - 300)**2
if math.sqrt(sqx + sqy) < 100:
print 'inside'
Gracias
Pythagorean theorem
btw you can do just
x, y = pygame.mouse.get_pos()
if it returns a tuple of length 2
ah ok
what's the third argument here for
the **2?
in pygame.draw.circle(scr, (0, 0, 0), (400, 300), 100)
where do i download pygame from, https://www.pygame.org/download.shtml or the github
@dawn quiver pip install pygame
no, in cmd, not python
i dont know but my frined told me that you cant have spaces and indents only one? i have no idea sorry if it doesnt help u can also highlight to see spaces
Watt
@distant lotus That's off-topic, and not something you should be asking for here.
New build of my game (written in Python, natch)
https://xtaloid.itch.io/xtaloid/devlog/282868/new-build-wcolorblindness-options
while (hitwall != True & distance2Wall < main.maxDepth):
-----------------------
if (testX < 0.0 | testX >= float(main.mapW) | testY < 0.0 | testY >= float(main.mapH)):
These 2 lines pop up the following error:
TypeError: unsupported operand type(s) for |: 'float' and 'float'
I am not too sure what's going on here, not used to working with Python.
insane
if 0 > testX >= float(main.mapW) or 0 > testY >= float(main.mapH):
I recommend you learn basic boolean operators in Python again.
that is a great idea. what is wrong with me
I can only assume your while expression should have been:
while not hitwall and distance2Wall < main.maxDepth:
yep, yep
Hey guys i need help this game im making its pretty much bo1 zombies but top down pixel art form i got zombie to work but i need to add a.i to them like to avoid walls and stuff and i was wondering what would be the best way to come at this
im making my first clicker game
i don'tknow how well it would work as you have quite a few entities path finding at once, and i really am not sure if a* is fast enough
ya i was thinking about doign this but with how many entities there will be i didnt think that would be the was way
Well bo solved it somehow
so there must be an algorithm you can implement
also you could try it, your game does not seem very graphically intensive so maybe it'll work
thats true ive still got alot to do
yeah, you could try using it as a temporary solution while you work on whatever else you need to add
update #1, all button layouts and keybinds are done
also added an money counter, but currently it's just $0
how to make something infinite, like prestiges in an game ๐
every prestige gives one score_prestige and an 1.2x money multiplier
try implementing something like this perhaps
prestige_value = 1
money = 0
# whenever player prestiges or w/e the trigger isincrement presitges
# let's say you kill an enemy so reward is money rite
money += (1+0.2*presitge_value) * enemy value
for w/e reason nothing seems to be drawn
i cheked using this to try triggering the damn thing to draw
screen = pygame.display.set_mode((screenW, screenH))
pygame.draw.line(screen, (100, 0, 0), (100, 0), (100, 10), 20)
nada.
ty
Python programmers when sees Anaconda programmers : 
Anyone can help me ? @round pawn @dawn quiver @dawn quiver
im not really a good python programmer
still intermediate level
No I am beggener
Can you suggest me from where and which software and window I need to install for coading?@round pawn
!resources @spark cargo
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
ohh
i can answer that
I recommend VSvode and Sublime Text for python (Thats what I prefer)
or if u want an IDE
use pycharm
maybe
i use jetbrqims
jetbrains
dont use it
too complicated
when i get to pc ill send
https://www.jetbrains.com/pycharm/ might as well bite the bullet, get the community edition it's free
what you actually need is the know how
Giraffe Academy is rebranding! I've decided to re-focus the brand of this channel to highlight myself as a developer and teacher! The newly minted Mike Dane channel will have all the same content, with more to come in the future!
Source Code - http://www.mikedane.com/programming-languages/python/
This video is one in a series of videos where w...
try follwing along to this
Hey, its python a good language for game development?
yes
hey so i'm basically trying to send direct keyboard input into a specific window ( Rage multiplayer) i'm completely lost and would appreciate any help
i want to get input thru even when the window is out of focus
don't spam .....
can i see some projects some of you guys have done?
@radiant sage This is a game I'm working on now in Python https://xtaloid.itch.io/xtaloid
damn that looks sick, is there a github? i can only see the download
I don't have source code available for this on GitHub, but it's all Python with a smidge of Cython (C)
mkay
nah
only reason why im working on a game in python is because i have that assigned
idk why anybody would actually choose to use python for games
@round obsidian i actuallly would like an explanation if you could, why are you writing a game in python
@slate briar if you're looking to become a game programmer i'd go with c++ if you wanna work in games, or maybe you could try unity using c# or godot with gdscript.
python for games seems like a waste of time imo, though it is better than nothing, if that's the only language you can bare to learn now program in python and learn other languages later
@dawn quiver because I know Python, and it's easy to work with, and I'm getting very good results
what's your specific objection to Python?
slow and not used in the industry
not so good for games
obviously if it works for you then it works for you
unless its 2d game then its fine
Python is plenty fast enough for the game I'm writing
that's true
but if anybody asked me what language they should learn for games, i would never list python
my game runs at 60FPS, and I use maybe 0.06% of that time in the game logic and draw operations combined
You won't be making AAA 3D games in Python, for sure, but you can certainly write good decently performant 2D games
python is great for machine learning or so i've heard, im a begginer pretty much
but the whole "Python's too slow" thing can be rebutted by doing some simple performance profiling
then why do apps that have to run fast not use it
i don't get it
it has it's uses it's a great language
because many people do not know how to use Python well?
that's ridiculous cmon
I'm only reporting what I've seen, many people don't know the wealth of tools available in the language's ecosystem for performant applications
it's like saying assembly would be great for modern programming, you just have to be good at it
e.g., the most performance intensive part of my game, I wrote in Cython (which compiles to a C module), with a speedup of 500x for that part of the code
but I run into folks all the time who don't know anything about even performance profiling
I won't belabor the point, though - I'm using it, it works fine for this, at some point I'm most likely going to learn C# and Unity too, but for now I'm quite happy
so far I seem to have it :D
but one of the nice things about Python is how closely you can integrate stuff written in C
hey guys how can i like connect or call python game menu script in my game script ?
like all this .py files one is having loading screen one have menu one have main game in it
you import them
and if things need to be instantiated in a specific order, you do that too
oke thanks ๐
Arcade 2.6.0.dev5 is out as a pre-release. (You'll have to specify the version when pip-installing, or you'll get 2.5.7.) If you want to try out the new (or old) features, we'd love your feedback. Release notes: https://api.arcade.academy/en/development/development/release_notes.html
hey, I made that :)
?
i made it its a simple gun with bullets firing i made that using a yotube tutorial ๐
well, it's identical to the test scene for the first person controller
yeah
cuz i wanted to look it like 3d haha
i am actually looking how to load blender 3d models if possible or .obj files bc its not loading in it
you just have to write the name of it
like how can you tell ?
holy shit are you the developer of the ursina engine ?
yes x)
you should put your model in the same folder as your script or in a folder below too. that's easy to forget
๐ btw the engine is ๐ฅ not gonna lie
i just saw your comment on github i might try to triangulate it first
aye bro it is working but the texture of objects is not there only white color
What does this symbol over the vector mean?
how do i get caod 2 work
There are better ways to ask someone for more information
thats the joke
You seem to be the only one laughing
idk man i'll figure it out somehow, my shitty ray tracing engine ain't workin
Ah, apologies, I thought you were responding to Snake's question
Thought it was mocking
oh i have no idea what he wants
not here to mock random people who are better than me at this langauge
No no all good, my fault for misunderstanding. Been a rough week
oh really
watcha up to
@dawn quiver Are you trolling or is this serious?
wdym
my code doesn't work for reasons i will find out
Hey all!
I am back
with a vengeance
https://www.youtube.com/watch?v=5MA2_gernow
Polished GFX - Wrectified Mission system
check this out
really like the effect that phases in the ground
HAHAHA
im fuckin
IT
it was in loop
a bit of my code was in a loop and that's what caused the errors
clock.tick(clock,60)
using pygame.time.Clock I'm trying to set a framerate for my game, however the ide flags this as a warning saying :
Expected type 'Clock', got 'Type[Clock]' instead
if somebody could dm me what teh fuck is wrong with my shit i'd appriciate it or just ping me
Performant grass in Pygame:
https://cdn.discordapp.com/attachments/554140571787067393/875612395681222666/vid_0.mp4
Good
can i get this
Iโll release it to patrons soon and Iโll post it on GitHub in ~6 months or so.
how do you read
Hey !
I want to make a multiplayer fps with python.
Networking is ok, but can someone help me finding the right lib ?
If i could use some blender objects to do it, it can be nice x))
And, pls ping to respond, thx
https://www.youtube.com/watch?v=__mZO-53PPM&t=1240s will this work with ursina ?
A tutorial on how to save and load files in pygame using the json module. The approach shown here would work in pretty much any python code and could generally be used to create and load data.
Timetamps:
0:00 - Intro
0:50 - saving information and json
8:46 - creating the clicker game
19:50 - json part of the game
hi what libraries do I usually use when I'm developing a text-based game
No one, simply create classes
Well, if it doesnt, use pickle.load and pickle.dump
ok
If u need an explication of how to use, ask x)
thats absolutely amazing
It's a conventional sign
Omg how is this so good! I find pygame so sooo hard to use
hey guys does anyone know a good method to make games using python, ive already tried pygame and turtle library but still they dont seem so good...
@stray gazelle Have you tried Arcade?
many are there 1-pygame 2-arcade 3-ursina 4-panda3d 5-godot 6-pyglet but pygame , ursina , arcade are best among all these
what kind of game
what do you want to do
if you want to just write your own shit
Hello ๐
My name is Samuel
I'm Amy from Brazil, then sorry by the mistakes of portuguese
I would like to know if I can create a game in Python on my cell phone??
I use the Replit website
does anyone want to test my custom built text adventure game framework? https://github.com/y3493r/pyadventure
il sure try arcade... is it a library?
oh and
im actually trying to make something like
pubg
or gta
i mean
not exactly like that but something with good graphics
i can do the code, the algorithm, im good with algorithms but im not able to find a good graphic library or platform for making a game with as good graphics as pubg or fortnite or gta
i found platforms for graphics development but they work on c++....... i could not find for python
anyone know any good github shaders?
okay, do you know on what line of code the error is?
okay well
the error says that "module object is not callable"
makes sense, right? modules aren't meant to be called
and what if I told you that pygame.display is a module
do you see the problem then?
is there a reason not to pickle over using a json? seems like a lot less of a hassle than [un]packing state into a json
@last moon Pickle has no security, but then again neither does JSON
JSON is more broadly interchangeable, Pickle is specific to Python
by 'no security' do you mean encryption?
the real problem with pickle is that you can get arbitrary code execution if a malicious pickle file is loaded
and also yeah its less useful as an interchange format
@severe saffron that's pretty much it: a pickle file can contain anything
arbitrary code execution = no security
pycharm is a good IDE to make games with pygame?
@wide tree any good Python IDE will do.
ok thanks
but then again neither does JSON
since when does decoding JSON can execute arbitrary code?
point
well, more like, JSON has no native mechanisms for, for instance, checksumming or signing data
but your point is still taken
ive been trying to play ur games from github(the links) but im not sure how to even play it lmao
woah, i thought normal GUI alterations would be clumpsy for a bot like that but those are pretty good results
has anyone made a minecraft clone in ursina with mesh if u have pls dm me i need help
Pretty good tutorial https://youtu.be/DHSRaVeQxIk, also explains minor urisna basics, hope it helps
A basic tutorial on how to create Minecraft in Python by using the Ursina Game Engine. This also includes a general introduction to the engine itself.
Timestamps:
0:00 - Intro
1:24 - The basics of Ursina
15:49 - Creating Minecraft style blocks
35:25 - Creating a sky, a hand and adding sounds
Project files are available here:
https://github.co...
there is no mesh
AH right okay
have u made ?
nope
Python in Java
Where should i store photo to load it in pygame?
@magic pelican yeah
no
!warn 376588652790284288 Please do not promote your YouTube content here, especially if it breaks the game's EULA
:incoming_envelope: :ok_hand: applied warning to @edgy night.
Also @dawn quiver this isn't the right channel for posting minecraft screenshot, feel free to share it in off-topic!
i asked @olive grotto he only told me to post here
no i did not misunderstood him and yes he said it
but i did not want to blame him as he was using the word "maybe"
In Brazil we call that "Treta"
People can also be wrong. That is the shocking truth ๐
can anyone help with an enemy call in pygame
@bleak reef This is very useful to read : https://pythondiscord.com/pages/guides/pydis-guides/asking-good-questions/
A guide for how to ask good questions in our community.
lol
does anyone know how to make an enemy class where i can also spawn in a bunch of enemys? also while having a "ai" system to attack?
um, create a class for the enemy, have methods and attributes inside it with the ai thing done in it, and i guess use a for loop to spawn in a bunch of enemies, or if you also want to randomize spawn locations just use the random module and get a random location for spawning the enemy every time the loop runs.
There is something wrong with my game. I was trying to make a tic tac toe game but when I was testing the top left button, I found out that the button isn't displaying the X or O. Can anyone help me please?
Here is the code. https://paste.pythondiscord.com/putopetife.yaml (Also this is pygame)
Also "win" is the pygame window and "run" is the bool value for game loop.
hello
so im getting this error even tho i installed the right mudoles
Exception has occurred: SystemExit
1
File "D:\Android app\android.py", line 2, in <module>
from kivy.uix.textinput import TextInput```
@frozen knoll do you have any experience working with the new shader module in Pyglet 2? I ran into an issue that might either be a bug or my own inexperience.
I've worked with the shadertoy in arcade, i think it might be built on top of that.
@frozen knoll
I'm trying to work with the new shader module but I'm having trouble with a shader that has the following uniform: uniform vec4 palette[7];
When I try to set its value using the program object, it doesn't recognize a uniform by the name palette, only palette[0] (with a length of 4). Any idea what I am doing wrong?
@round obsidian Can you show your shader?
Remember that glsl compilers are really loves to optimize your uniforms
If determines that you only use the first 4 entries in that array it will make it length 4
The best thing to do is setting the palette data as a tuple ```glsl
uniform float values[10];
```py
program["values"] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
An alternative solution is storing the palette vales in a texture and reading them using texelFetch
@potent ice how would the latter approach work?
#version 330
in vec4 vertex_colors;
in vec3 texture_coords;
out vec4 final_colors;
uniform sampler2D sprite_texture;
uniform vec4 palette[7];
void main()
{
vec4 c = texture(sprite_texture, texture_coords.xy) * vertex_colors;
final_colors = c;
}
I'm just trying to read in the value to see if it works, I haven't done anything with palette yet. I think the problem is in Pyglet's shader module?
I just now tried using the uniform float values[10] approach, and I get this error
File "D:\Dev\Robotron 2021\.env\lib\site-packages\pyglet\graphics\shader.py", line 153, in setter_func
c_array[0] = value
TypeError: must be real number, not list
Found uniform: palette[0], type: 5126, size: 7, location: 0, length: 1, count: 1
I think the problem is the shader module doesn't know how to deal with uniforms that are arrays
e.g., an array of vec4s or floats
You can only assign values to a uniform in one go
assigning all values in a big tuple is the simplest
right, I'mt rying to do that, and it's erroring out
I'm assigning all the values as a tuple, and it rejects it
self.program["palette[0]"] = the_tuple
and again it generates this error
File "D:\Dev\Robotron 2021\.env\lib\site-packages\pyglet\graphics\shader.py", line 153, in setter_func
c_array[0] = value
TypeError: must be real number, not list
self.program["palette"]
File "D:\Dev\Robotron 2021\.env\lib\site-packages\pyglet\graphics\shader.py", line 336, in __setitem__
raise Exception("Uniform with the name `{0}` was not found.".format(key))
Exception: Uniform with the name `palette` was not found.
from debug:
Found uniform: palette[0], type: 5126, size: 28, location: 0, length: 1, count: 1
oh. It's pyglet
Yeah, that's been my suspicion
I thougth you were using our gl 3.3 wrapper in arcade
no, sorry if that wasn't clear earlier
Ask in pyglet discord ๐
@round obsidian you can use arcade.gl with pyglet if you need to. Just create an arcade.gl.Context instance and you are good to go. It's at least a much more complete api to gl 3.3 (considering you are using 3.3 shaders)
pyglet and arcade's gl wrapper will probably slowly melt together over time anyway
I found a workaround that should get me most of the way home for what I'm doing, actually
HI
hi
from pyglet.window.key import X
from pyleap import*
from pyleap.shape import sprite
window.set_size(800,400)
monkey = "https://cdn.leaplearner.education/i/1ea273.png"
mk = Sprite(monkey,170,100,100,100)
mk.flip()
mons = "https://cdn.leaplearner.education/i/5926f1.png"
mn = Sprite(mons,700,100,100,100)
#mk.flip()
r1 = Rectangle(200,90,50,20,"gold")
r2 = Rectangle(250,90,100,20,"brown")
r3 = Rectangle(350,90,50,20,"gold")
r4 = Rectangle(630,70,25,50,"green")
r5 = Rectangle(630,120,25,50,"pink")
r6 = Rectangle(630,170,25,50,"black")
def draw(dt):
#window.show_axis()
window.clear()
r1.x=r1.x+1
r2.x=r2.x+1
r3.x=r3.x+1
r1.draw()
r2.draw()
r3.draw()
r4.draw()
r5.draw()
r6.draw()
mk.draw()
mn.draw()
#Text(str(r1.x),700,300,20,"red").draw()
# if r3.x>=620:
# mn.x=mn.x+1
# if r1.x<=465:
# mk.x=mk.x+1
if r4.x>=515:
r4.x=r4.x-1
if r5.x>=515:
r5.x=r5.x-1
if r6.x>=515:
r6.x=r6.x-1
if mn.x>=585:
mn.x=mn.x-1
if r4.x>=515:
r4.x=r4.x+1
repeat(draw)
run()
r4 obj is not moving
i have a blender model of a house if i try to open it in ursina it is not
can anyone tell how to open my model ?
I'm trying to move my camera in gta5 using python, but it doesnt work
i tried:
import pyautogui
while True:
pyautogui.moveTo(0,100,)
Some im using something like this to makethe window open
How do i make words print onto the window?
Becuase using print will only print the words into the terrminal
import turtle as t
import os
import time
win = t.Screen() # creating a window
win.title("Test") # Giving name to the game.
win.bgcolor('black') # providing color to the HomeScreen
win.setup(width=800,height=800) # Size of the game panel
win.tracer(0) # which speed up's the
while True:
win.update()```
how do i create a 3d model for ursina
go to blender, make your model, export as obj
Does anyone have any good references for learning how to make multiplayer games with python?
All I've been able to find are old, outdated tutorials that no longer seem to work properly
@limpid gate Here's a recent Pygame project that supports multiplayer and which might be useful as a codebase to examine
A multiplayer (sockets) shooting game made with python and pygame: Client: (https://repl.it/@trotemus/Multiplayer-Game-Client) Server: (https://repl.it/@trotemus/Multiplayer-Game-Server) - GitHub -...
Ill take a look thank you!
Anotehr nifty example
Some im using something like this to makethe window open
How do i make words print onto the window?
Becuase using print will only print the words into the terrminal
import turtle as t
import os
import time
win = t.Screen() # creating a window
win.title("Test") # Giving name to the game.
win.bgcolor('black') # providing color to the HomeScreen
win.setup(width=800,height=800) # Size of the game panel
win.tracer(0) # which speed up's the
while True:
win.update()
can anybody help trying to make the pic move using get_rect but the code doesnt make the image move
Player_rect = Player.get_rect(topright = (200, 300))
screen.blit(background_image, center)
Player_rect.left += 1
screen.blit(Player, Player_rect)
pygame.display.flip()
pygame.display.update()```
go to a help channel
nobody will see this channel that can help
go to avalable help channels and type
then when you solve it do !close so someone else can use the channel
ok
Hey @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @icy inlet!
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 @icy inlet!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @icy inlet!
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:
Please help me. I made a camera that follows the character, but when the character collides with a wall and holds two keys, the character moves in the opposite direction.
main.py
https://paste.pythondiscord.com/jalapemuqe.properties
Please
when i use this code, the line isnt drawing for som reason
import pygame
from pygame.locals import (
K_UP,
K_DOWN,
K_LEFT,
K_RIGHT,
K_ESCAPE,
KEYDOWN,
QUIT,
)
pygame.init()
SCREEN_WIDTH = 1440
SCREEN_HEIGHT = 900
circle_coords = [0, 0]
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
surface = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT))
running = True
while running:
pygame.draw.line(surface=surface, color=(255, 255, 255), start_pos=(720, 0), end_pos=(720, 900), width=3)
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False```
ok nvm i fixed the problem
Honestly I would just recommend setting up your own game loop with tick and render functions, that can supply a delta time parameter
There are lots of good tutorials for game loops online
hi
pip install -U pip
how is it a fps and a 2d game lol
pip install --upgrade pip
Uhmm
Just trying to experiment stuff
But it look abad
can somebody help me with a game?
i basically got the code from here https://www.youtube.com/watch?v=XGf2GcyHPhc
Learn Python in this full tutorial course for beginners. This course takes a project-based approach. We have collected five great Python game tutorials together so you can learn Python while building five games. If you learn best by doing, this is the course for you.
๐ฅ Learn Python syntax in our other Python course: https://www.youtube.com/wat...
:incoming_envelope: :ok_hand: applied mute to @wide smelt until <t:1629304668:f> (9 minutes and 59 seconds) (reason: newlines rule: sent 137 newlines in 10s).
!unmute 447671182028963841
:incoming_envelope: :ok_hand: pardoned infraction mute for @wide smelt.
!paste <- use this
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
this is the code
it produces some bugs
wait
i added a few lines of code at the bottom, so it doesn't go beyond the screen
when i move the paddles, the ball speeds up for some reason
and there is a bug with sound
can someone figure out whats wrong?
someone?
It seems the bug happens when colliding with the bottom and top of the paddle, maybe the original code is bugged already
anyways you should not be using turtle for these things, is a bad example imo
import pygame
from pygame.locals import (
K_UP,
K_DOWN,
K_LEFT,
K_RIGHT,
K_ESCAPE,
KEYDOWN,
QUIT,
)
pygame.init()
SCREEN_WIDTH = 1440
SCREEN_HEIGHT = 900
circle_coords = [0, 0]
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
surface = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT))
running = True
while running:
pygame.draw.line(surface=surface, color=(255, 255, 255), start_pos=(720, 0), end_pos=(720, 900), width=3)
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
running = False
import turtle
#setting up the screen
wn = turtle.Screen()
wn.title("PingPong")
wn.bgcolor("Black")
wn.setup(height=600, width=800)
wn.tracer = 0
#paddle A
paddle_a = turtle.Turtle()
paddle_a.speed(0)
paddle_a.shape("square")
paddle_a.color("white")
paddle_a.shapesize(stretch_wid=5, stretch_len=1)
paddle_a.penup()
paddle_a.goto(-350, 0)
#Paddle B
paddle_b = turtle.Turtle()
paddle_b.speed(0)
paddle_b.shape("square")
paddle_b.color("white")
paddle_b.shapesize(stretch_wid=5, stretch_len=1)
paddle_b.penup()
paddle_b.goto(350, 0)
#Ball
ball = turtle.Turtle()
ball.speed(0)
ball.shape("square")
ball.color("white")
ball.shapesize(stretch_wid=1, stretch_len=1)
ball.penup()
ball.goto(0, 0)
#defining functions
def paddle_a_up():
y = paddle_a.ycor
y += 20
paddle_a.sety(y)
#keyboard binding
wn.listen
wn.onkeypress(paddle_a_up, "w")
#Main Game Loop
while True:
wn.update()
help me
its not moving
when
i click w
I would really suggest using pygame rather than turtle
look i am also a pygame kinda person
but i was learning
anyways
class Tile(pygame.sprite.Sprite):
def init(self, image, x, y, spritesheet):
pygame.sprite.Sprite.init(self)
self.image = spritesheet.parse_sprite(image)
hey so why I'm getting error here that
AttributeError: 'pygame.Surface' object has no attribute 'parse_sprite' ?
Because 'pygame.Surface' object has no attribute 'parse_sprite'
That parameter spritesheet is not what you think it is. Dynamic typing for the win.
The error is probably in the calling code
the calling is map = Tilemap('room1udrl.csv', spritesheet) where spritesheet is loaded image
what is colour key in pygame , how to avoid pygame to add black backgroung to my transparent png
btw I am trying to use a spritesheet
Still hard to say. Anyways, to fix this you must be sure that the variable spritesheet is of a type that contains the method parse_sprite, a class something like pygame.Spritesheet, i'm not very familiar with pygame. The calling code im talking about should be some_tile.init(some_image, 20, 50, spritesheet).
New build of my game written in Python w/Pyglet https://xtaloid.itch.io/xtaloid/devlog/285199/new-build-new-game-features
nice!
https://github.com/AxhrafY/My-laggy-platform-game
any idea why my game keeps freezing?
i want to learn this
What the method parse_sprite does in pygame?
Where did you get that code, did you write it yourself?
No I got it from there https://youtu.be/37phHwLtaFg
In this video, we'll discuss tilemaps. We'll learn how we can create them using Tiled, as well as how we can parse them into pygame.
Code can be found on my github: https://github.com/ChristianD37/YoutubeTutorials/tree/master/Tilemap
Download tiled: https://www.mapeditor.org/
Join my discord: https://discord.gg/qu8a7DfK2X
My video on sprite ...
I see, well take a look at https://github.com/ChristianD37/YoutubeTutorials/tree/master/Tilemap
That the code he is using, you can see that parse_sprite comes from a custom class, nothing to do with pygame
that variable is defined here spritesheet = Spritesheet('spritesheet.png') on main.py, try to follow from there, i don't have time to check that rn
Ok thanks
I need help controlling mouse movements in a game with python. Pyautogui dosent work for mouse moments. I looked into it further and because the game uses directx, it wants its inputs in a specific way (idk). Sentdex made an ai that plays gta 5 and his code is at https://github.com/Sentdex/pygta5/blob/master/Tutorial Codes/Part 1-7/directkeys.py. But is only shows how to send key presses not mouse movements. Im lost and i dont know what to do
nice
hello i am a beginner in ursina, can you help me to get click position(world position)
Hey @idle hemlock!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Hey @idle hemlock!
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:
hello i am new to python and i have a problem with my game code i used https://realpython.com/pygame-a-primer/ for the base and pngs
when i touch a enemy i sometimes lose health and sometimes dont and i just cant find out why pls help.
here is the code https://paste.pythondiscord.com/kacaquguvo.rb
pls help ๐ฆ
mouse.world_position will get the mouse position in 3d, but keep in mind it will only hit things with a collider
Can u help me to get the hit position in raycast, too
it's the same, raycast() returns a HitInfo of which you can get .world_point
Thanks
I am trying to make a multiplayer pygame game and creating a loading screen while the client is connecting to the server.
from network import NetworkConnection # My custom network connection class
def connecting(screen):
screen.fill((200, 200, 200))
width, height = screen.get_size()
font = pygame.font.Font('client\\fonts\\basic.TTF', 50)
text = font.render('Connecting to Server...', 1, (150, 150, 150))
screen.blit(text, (width/2-text.get_width()/2, height/2-text.get_height()/2))
pygame.display.update()
def main():
# Initialization
pygame.init()
pygame.mixer.init()
pygame.font.init()
# Screen
width, height = 800, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption('Game')
# Clock
clock = pygame.time.Clock()
# Network connection
network = NetworkConnection()
connected = False
while not connected:
connecting(screen)
connected = network.connect() # Returns False if the connection fails
# Main Loop
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
return
if __name__ == '__main__':
main()```
I just get the pygame window not responding, and I can't figure out why. I've never done something like this before so if there is a better/standard way to do a loading screen like this I would love to know that too.
pygame.display.update()
Should be called once per frame at the end of the frame.
An introduction to various concepts, charts and diagrams invovled in effective software design and development.
It is in connecting()
"Should be called once per frame at the end of the frame."
The main loop contains no such call.
The main loop is never reached
Until a connection is successful, the loop above the main one continues
The main loop should always be reached and everything should happen in it.
Would it not make more sense to connect to a server before the main loop?
Because you only want one connection
No
Unless I guess I could add a variable or otherwise only establish a connection if one doesnt already exist
But it seemed to make more sense to create it once, then enter the game loop
Everything in a game happens in the game loop.
Ok
Because it's where you draw and get input. Any error that happens before it will not give any information to the user.
The only stuff that happens outside of the game loop is bare minimum initialization (like pygame.init, making the window).
Enough so that you can get input and show output.
Yeah that makes sense
So now I've got ``` network = NetworkConnection()
connected = False
# Main Loop
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
return
if not connected:
connecting(window)
connected = network.connect()
continue```
You don't need the continue, but yes.
the display update should happen below
it's get input, process, show ouput.
connecting should only connect
not draw anything
# Initialization
pygame.init()
pygame.mixer.init()
pygame.font.init()
# Window
width, height = 800, 600
window = pygame.display.set_mode((width, height))
pygame.display.set_caption('Card Game')
# Clock
clock = pygame.time.Clock()
# Network connection
network = NetworkConnection()
connected = False
# Main Loop
while True:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
return
if not connected:
connecting(window)
connected = network.connect()
pygame.display.update()```
connecting draws the screen
window.fill((200, 200, 200))
width, height = window.get_size()
font = pygame.font.Font('client\\fonts\\basic.TTF', 50)
text = font.render('Connecting to Server...', 1, (150, 150, 150))
window.blit(text, (width/2-text.get_width()/2, height/2-text.get_height()/2))```
Yes
To do this, create a Scene class, which has a update function and a draw function.
Scenes can transition to other scenes by by playing some transition animations and then switching the current Scene to a new Scene.
Inside their update methods they do whatever happens in that scene and also check to see if the transition conditions to other Scenes have been met (and then invoke their transition function if they are met).
Shrink wrap smart project in py over frames + sample noise where not shrink wrapping
I made a new math :3
With this system you can have Scenes such as main menu, options, starting-game, main-game, paused.
I'll try to do that thanks
What I do is have Scene have update, draw, on_enter, on_exit, and transition functions.
Given Scene A and Scene B. Scene A might decide in its update function that it wants to transition to B. So it calls its own transition function which calls its own on_exit function and B's on_enter function. It then sets the current scene to Scene B.
An example Scene would be SMainMenu which inherits from Scene.
In update it checks if the buttons where pressed and draws them in draw too. Which are the transition conditions.
The current scene's update and draw are called in the main loop
Do you create just a generic Scene class and then create MenuScene, GameScene, etc. classes that inherit from it, or have menu_scene, game_scene simply be instances of Scene?
Also how do you do buttons?
yes, but how big is UPBGE?
Inherit. Buttons are GameObjects.
1 gig @round obsidian
you can use python in BPY (the viewport) and in the ge (bpy and bge) and we also have geonodes and eevee shaders and modifiers and lots of other candy that all work in game
including openXR
the published game .exe I think is quite a bit smaller though
Does anyone know how to check for collision with one thing hitting a wall and reversing back in turtle module
so UPBGE has native support for publishing to an .exe? @cold storm
I got this from a tutorial but even the way he explains it doesn't make sense```py
import turtle as t
ball = 0
gravity = 0.1
while(True):
ball -= gravity
t.sety(t.ycor() + ball)
if(t.ycor() <= -1000):
ball *= -1
t.done()```
yeah it's a included addon
it has bullet physics, sdl2 controllers, openXr was just added
we are also gradually transitioning to vulkan
which should open up mobile ports
right now though it works on
Windows
Linux
Linux arm64
Mac arm64
Mac (no well)
should work on steamOS I assume
after vulkan we should be able to port to android, reaching iphones may still require a https://webassembly.org/ port
Do you have the buttons as part of the scene class. I.e. is it something like
def __init__(self):
self.buttons = [Button(x=200, y=200, width=100, height=50, color=(255, 0, 0)]
...```
All game state is stored in the GameState class, Scenes and GameObjects hold a reference to that GameState so they can access anything in the game at any time.
GameState for example, contains the current Scene and a list of GameObjects.
I mean do you have the buttons stored by scene or all together. It makes sense to me to put them all together so you can execute a "click" method in the main loop
The scene and the Button (GameObjects) are all in the GameState which is an object created once and can be accessed from anywhere, game loop, inside a scene, inside a GameObject (e.g. Button).
You can also have the buttons just be in the Scene as you wrote, it's up to you. Try it and if you end up trying to do something that does not seem to fit in the system, redesign it.
As long as you have some kind of structure (e.g. Scenes), it will make designing the game a much more organized process.
Python is ok language to make games?
Btw for a multiplayer game your scenes would probably go something like InitScene -> MainMenuScene -> (maybe OptionsScene) -> Loading/Connection/GameStart Scene -> GameScene -> ...
@limpid gate
Try making a single player game with the scene system first to get used to it.
@normal silo How do you avoid circular imports if the GameState holds a list of Buttons, but each Button also needs a reference to the GameState?
Do you have an projects you'd be willing to share to show how you implement this structure?
You don't, they just import each other.
Do you hold a dictionary of scenes in the GameState as well?
If you want to store it that way, sure. It can be stored in many ways, your choice.
Im just trying to figure out how to store buttons
Right now I have Scenes which store a list of buttons
The purpose of GameState is that it's all in one place, Scene and GameObjects just have access to that data, but they don't own it (it does not die with them when they leave).
But Button instantiation requires passing in a scene (the scene to transition to)
You don't have to make Button's constructor take a Scene, there absolutely nothing stopping you from just setting it later and having it None by default in which case clicking the button does nothing.
So I needed to have access to a list of scenes, so Im not instantiating the same scene in multiple button instantiations
How would you set it, if not at initialization?
Where in the code structure though?
Anywhere you want.
Also I don't see the issue here anyhow. If you have Scene as a constructor argument.
self.buttons = [Button(self), ...] in the scene's init
But if you want the scene to transition to
Since Scene has a reference to GameState which contains a list of all Scenes, in the init you can just do game_state.whatever
self.buttons = [Button(game_state.scene_a), ...]
I suppose my confusion is just the overall structure of how you code. Should the GameState or Scene be what holds Buttons? Does GameState hold a list of all the scenes, or does it only hold current_scene, to which buttons can assign different Scenes?
Ok
Everything else, just manipulates the game state.
So GameState holds buttons directly, they are not attributes of the individual Scene
Yes. But you could have them be in the scenes, since the scenes are part of the game state the game state holds all buttons still then
It's just flat structure vs heirarchical.
I prefer flat, it's simple.
I think that is the distinction I have been meaning to ask without knowing the term for it
Flat allows easier access from everything to everything else which is very convenient since you don't know what may need access to what else down the line when coming up with a game design.
But flat also means that you now have this "god object" which holds everything, which if you are working on a team would potentially create a mess (in that case you want to balance it being too flat and a mess vs too heirarchical and hard to make quick changes).
Yeah
I definitely intuitively prefer hierarchical structure, but it seems to be causing me more headache than its worth
Another tip which you may notice down the line is that really everything can be a GameObject, including Scenes themselves resulting in the entire game being unified under one system .
Hierarchical seems nice at first, but for things like games which have lots and lots of interdependent systems, every heirarchical solution ends up trying to be flat anyhow, even if you are trying to turn a blind eye to it.
Or as it's called in OOP, cross cutting concerns.
And games are all cross-cutting concerns.
Many game engines are realizing this and switching to solutions such as ECS which allow this flatness.
(But you don't need an entire ECS almost always, just keep it simple like the solution I gave)
It really depends on the game to be honest. You can make pretty neat gamecode without an ecs
If you're working in a team and/or potentially will have a fairly complex game.. that is a completely different situation
@normal silo Hey so I was wondering if I could ask you some questions again. Do you keep everything in the same file? I have GameState and Scene classes in seperate files, and this naturally gives a circular import error when I do something like:
class GameState:
def __init__(self, window):
self.window = window
self.current_scene = MenuScene(self)```and
```class MenuScene:
def __init__(self, game_state):
self.game_state = game_state
self.window = self.game_state.window```
Use import scenes, not from scenes import MenuScene
This is some python specific jank you need to figure out.
Ah ok thanks
Iโve been working with Python for about a year but still feel like a newbie sometimes
Thanks for your help / advice
seems you need to call it image, not img
hey so I'm confused, I have this line in pygame:
spritesheet = pygame.image.load('tileset1.png').convert_alpha()
and I get the error: FileNotFoundError: No such file or directory.
where this file tileset1.png is in the same dir. What is the problem?
tileset1.png and tileset.png is not the same
it is
ok I got it
what was it?
I had to move this all one dir up and then worked
A pong clone : https://youtu.be/kbAIiOqKdqY
Footage of me testing my pong code with my bro
I'm not sure if this is too much game related but it's tkinter.
So basically I wanna make a thing where you can enter text into a thing with tkinter
then press a button that will save it to a variable called text
how could I do that?
i think u can do it easily by using PyQt
Anyone wanna work for me? for a upcoming good planned roblox game coming soon? i need Scripters which is like coding but not really like python. ill be paying 30 percent to people who have been working for along time and 20 for new people. Which is like robux being paid to you. DM me if your instrested. * and you can exchange it into money btw the robux *
what happens when you got 4 scripters?
and how can you guarantee that you won't screw over everyone?
@dawn quiver If you use an Entry widget, you can use its .get() method to get its content at any time.
Help please!
Here's the code:
from ursina.prefabs.first_person_controller import FirstPersonController
class Voxel(Button):
def __init__(self, posotion = (0,0,0)):
super().__init__(
parent = scene,
position = position,
model = 'cube',
origin_y = 0.5,
texture = 'white_cube',
color = color.white,
highlight_color = color.lime)
app = Ursina()
for z in range(8):
for x in range(8):
voxel = Voxel(position = (x,0,z))
player = FirstPersonController()
app.run()```
When I start I get:
```Known pipe types:
glxGraphicsPipe
(4 aux display modules not yet loaded.)
size; LVector2f(1280, 720)
render mode: default
:pnmimage:png(warning): iCCP: known incorrect sRGB profile
Traceback (most recent call last):
File "/home/meliorator1333/PycharmProjects/MyWorld/Scripts/main.py", line 19, in <module>
voxel = Voxel(position = (x,0,z))
TypeError: __init__() got an unexpected keyword argument 'position'
Process finished with exit code 1```
What do I need to do?
By answering you can @mention me in the answer.
def __init__(self, posotion = (0,0,0)): you made a typo
@dawn quiver change "posotion" to "position"
thank you I figured it out now I'm just trying to make a version of it with kivy
thank you I figured it out now I'm just trying to make a version of it with kivy
noice
can someone help me with pyinstaller i just cant convert my file
I am starting a GIT project on a multiplayer base 2d shooter game
Anyone interested to join the project can dm me
In pygame what is the best way to go to another scene? Just another while loop in the while and breaking it or does pygame have a feature for that?
I would have all your scenes in a list and just store the one you're currently on. Like if you had a theoretical Scene object (just however you're storing the actual data for a scene):
tutorial = Scene(...)
level_1 = Scene(...)
scene = [tutorial, level_1]
current_scene = 0
while True:
# game loop stuff
...
# or however you'd play out the scenes
scene[current_scene].render()
Wouldn't that just be the same..?
It'd be better than starting a completely new game loop, especially if it's nested.
Depends on what your game does. Some example data could be a background image, entity positions, title, etc. Pretty much anything that would be going on on the screen could be included in Scene.
I'm going to make chess
Chess probably wouldn't need scenes tbh. There isn't like a massive change in the game from one move to the next, so it'd probably be easier to just move piece objects in a single scene.
True but i was thinking about making a menu so i can combine projects
So i can click on chess for example then go to that game and go back.
guys is my game good ?
how much you rate it ?
does it need anything else?
https://github.com/Karam-Sabbagh/Avoid-it
and what my next project should be
Is this any good? This is just for starting ofc but i want a nice base to start on -> https://paste.pythondiscord.com/itiyeherow.rb
One thing I'd say is that you could move the constants Colors and Fonts outside of Main, and structure them as a namespace. Something like:
class Colors:
WHITE = (255, 255, 255)
DARK_GREY = (80, 80, 80)
...
```By doing this, you don't have to construct an instance of `Colors` every time you want to access them, you can just do `Colors.WHITE`. (It also means you don't have to nest class definitions).
Is it less readable this way?
I think it would lead to less readability down the road. Examples uses with both:
colors = Colors()
screen.fill(black)
```vs
```py
screen.fill(Colors.BLACK)
```It also fits the usage for classes better, imo. The values in `Colors` shouldn't ever change, so there's not much of a point in defining them as instance variables.
I defined the colors in my init so for me it's just self.colors.white
I can always move them so i think i will let it be for now.
Thanks for the tip trough i will def consider it.
hOw to convert python made pygame to browser game
For what i've read it takes less time to rewrite the entire game in javascript than to convert pygame to browser.
hm can someone here perhaps help me understand bitmasks? im doing layering for my physics engine but i cannot wrap my head around the concept
i understand how bitmasks work in binary
it makes perfect sense there
but i dont know how to do the whole modulus/division thing to do binary operations and check bits and stuff given a base 10 number
like 1010 would be 10 in base 10, but how do i get the values of each bit out of the number 10
besides literally converting it to binary
hacker lol
wdym? You don't have to convert to binary, to do bit masks and other bitwise operations
@stuck stone yeah! thats what i mean. i dont get how to do bitwise operations when something is in base 10
def bitmask_overlap(mask1: int, mask2: int) -> bool:
# returns true if mask1 and mask2 both contain an element
layer_1 = mask1
layer_2 = mask2
while layer_1 > 0 and layer_2 > 0:
layer_1, has_bit_1 = divmod(layer_1, 2)
layer_2, has_bit_2 = divmod(layer_2, 2)
if has_bit_1 and has_bit_2:
return True
return False```
thats my current method, which is basically converting to binary bc i do the whole thing where i divide it by 2 over and over
so i cant go straight to a specific bit which makes me kinda :(
have to loop through
@late yew
mask1 & mask2?
yeah, it's valid
so basically there's not a special "base 2" type. If you use the correct operators, any number/integer will be interpreted in base 2
Is there a python library that's easly able to make mobile games other than kivy 
Nope
this is not the channel to try to get people to work for you for free, in a language that's not python, with only a hope of earning the completely useless currency robux
ok
but it isnt for free they do get paid they can exchange it into money but ill stop
even though ur not even a mod in here

@olive parcel do you know pybox2d ?
No, I do not
oh sorry for the ping
@tawny monolith why not ask the maintainers? https://github.com/pybox2d/pybox2d
there's also examples in that repo, if you need them
I know
but I am having some problems installing it
open an issue with them, see what they say
@tawny monolith It also looks like there's a pipwin installer that may help
pip install pipwin
pipwin install pybox2d
they says download Msys and finally do in Msys python setup.py build and Msys telling me that there is no command called python
that way you don't have to build from source, you can use a precompiled binary
oh ok thanks
Hello everyone I have a problem, I created a small python script for minecraft but when I click on the minecraft window it is as if the bot stops. The typing action does not work in the games but on my desktop it works perfectly
๐
like 95% powered by python
I use c for things like reinstance Physics mesh and recalculate normals
Hey @cold storm!
It looks like you tried to attach file type(s) that we do not allow (.blend). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.
Feel free to ask in #community-meta if you think this is a mistake.
@round obsidian its not working help me please its giving me this error ```C:\WINDOWS\system32>pipwin install pybox2d
Package pybox2d not found
Try pipwin refresh
Help :(
@tawny monolith sorry, I had to run off to deal with some stuff.
@tawny monolith try pipwin install box2d
Hecker*
hello i am new to python and i have a problem with my game. code i used https://realpython.com/pygame-a-primer/ for the base and pngs.
when i touch a enemy i sometimes lose health and sometimes don't and i just cant find out why pls help.
here is the code https://paste.pythondiscord.com/kacaquguvo.rb
PyGame: A Primer on Game Programming in Python โ Real Python
hello
any pygame people online
i need some help
#client file.
import pygame
width = 500
height = 500
win = pygame.display.set_mode((width, height))
pygame.display.set_caption("Client")
clientNumber = 0
class Player():
def init(self, x, y, width, height, color):
self.x = x
self.y = y
self.width = width
self.height = height
self.color = color
self.rect = (x,y,width, height)
self.vel = 3
def draw(self, win):
pygame.draw.rect(win, self.color, self.rect)
def move(self):
pygame.keys.get_pressed()
keys = pygame.keys.get_pressed()
if keys(pygame.K_LEFT):
self.x -= self.vel
if keys(pygame.K_RIGHT):
self.x += self.vel
if keys(pygame.K_UP):
self.y -= self.vel
if keys(pygame.K_DOWN):
self.y += self.vel
self.rect(self.x, self.y, self.width, self.height)
def redrawWindow(win,player):
win.fill (255, 255, 255)
player.draw(win)
pygame.display.update()
def main():
run = True
p = Player(50,50,100,100(0,255,0))
clock = pygame.time.clock()
while run:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
p.move()
redrawWindow(win, p)
main()
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.
import pygame
width = 500
height = 500
win = pygame.display.set_mode((width, height))
pygame.display.set_caption("Client")
clientNumber = 0
class Player():
def __init__(self, x, y, width, height, color):
self.x = x
self.y = y
self.width = width
self.height = height
self.color = color
self.rect = (x,y,width, height)
self.vel = 3
def draw(self, win):
pygame.draw.rect(win, self.color, self.rect)
def move(self):
pygame.keys.get_pressed()
keys = pygame.keys.get_pressed()
if keys(pygame.K_LEFT):
self.x -= self.vel
if keys(pygame.K_RIGHT):
self.x += self.vel
if keys(pygame.K_UP):
self.y -= self.vel
if keys(pygame.K_DOWN):
self.y += self.vel
self.rect(self.x, self.y, self.width, self.height)
def redrawWindow(win,player):
win.fill (255, 255, 255)
player.draw(win)
pygame.display.update()
def main():
run = True
p = Player(50,50,100,100(0,255,0))
clock = pygame.time.clock()
while run:
clock.tick(60)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
p.move()
redrawWindow(win, p)
main()```
ok man just help me fix it
Oh ok thanks I will try it later
Yeah haha
Let me see
can you tell me whats the error ? And were it is ?
@small flint .
You should remove self.rect(self.x,,,) from the move function because thats not how you move a rect you should doself.rect.move(self.x, self.y) and you can put this in the draw function
???
it fixed
And you can call the move function inside the draw function(before you draw)
So you can just call the draw function instead of calling the draw function and the move function
Yeah but you can fix some things to make your code easier
ok
@round obsidianthanks you verrrry much,
I've spended an lot of time trying to do this and here you go 2 lines of command and it have been installed, thank you it worked
I've tried to download wsys , c++ and swig and I couldn't do it
but now with some commands in cmd it worked
guys what do you think about my game ?
https://github.com/Karam-Sabbagh/Avoid-it
is it good ?
yes it is amazing
oh really
thank you
its kinda simple
It needed some math
like sin and cos
where I still didn't learn in school
๐
oh I forgot something
the screen size :L
well I don't care
who play it must know some programming
(to change the size)
hey do you guys know about variable inheiritance? im trying to figure out how to make a configurable class which is defined and then instantiated inside a function
like specifically a "GameObject", which when instantiated, takes in parent classes as additional arguments
so that way i can make a gameobject that inheirits from physics object class but not my sprite class, so it has a hitbox but doesnt get drawn, etc
ive never done this before but id like for the object to just not have variables, as opposed to just not using the physics related variables if its static
@stuck stone i think?? im not sure if thats what i meant because i dont really understand whats going on
double underscores scare me
ive used if __name__ == __main__ but fuck me if i know what it means
wait is that unrelated?
No ahahaha, it's just something I put in all my programs
I can explain it to you, if you want
that would be nice
thank you for also showing me the inheiritance thing
but yes i would like to know what the hell the double underscores are
Well, there are a few double underscore variables. Usually it's just variables that are defined by default. Probably got the weird name so no one accidentally uses them without being aware they exist
ah okey
i understand __init__
thats like the one function thats already defined for the base python object
Is pygame library, cross platform?
Also can I make my own game engine inside it?
Oh yeah
You technically can change your VS Code background with extensions
but it breaks the installation
PyCharm
ok
Out of the Fog - Wrectified unified streamer
Unknown Forces Game Studio
Ca, USA
If you're using pygame you can use yourRectangleName.center = pygame.Vector2(x_coord, y_coord) (or just use an array it works too)
Anyone online to help me
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pydis.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
you can use this to paste your code
And what issues do you have with the code?
its not animating
anyone available?
i tried to make a game by whenever i enter the player's choice, the if code is skipped for the player and only the cpu moved
Hey guys. What's a good import for working with 3D models? I'm trying pymesh but i'm not having much luck getting it to even install properly.
Windows 10. And I believe latest python
;-; all i'm trying to do is display a 3D model I downloaded off the internet using python
why does this need to be so complicated
At least I've found several ways of not how to do it
pyglet I believe also lets you import and show 3D models in common formats
and it's pure Python, no binary deps
side note, when people try to do something and say "why is this so complicated" one of the answers I find myself reaching for is "because until now the complexity of this was concealed from you"
I guess this is why people dont bother making their own game engines lol
yes :D
people are unaware of how much complexity is inside many common pieces of software
we had a discussion in another channel with someone who wanted to make their own web browser in Python, from scratch, and didn't seem to realize just how massive an undertaking that is
browsers are essentially little OSes at this point
Browsers are starting to actually advertise as an OS lol
Does anyone with basic python knowledge feel generous today? I'm in my last year of high school, making an arcade game and I need help with getting an image of my healthbar in the right hand corner. I've got the png photos and everything. There is currently functional text that changes every time I lose a life but I don't know how to replace the number in text with its equivalent image. If anyone wants to save me from my simple problems, it'd be appreciated. I have tried other things, this is just my last resort because I take an online class, I don't know anyone in my class that well and my problem is too specific for google because i'm not using the same plugins and software. Sorry for the long message lol
what in the actual hell. highschool and learning this stuff?
boy. Back in my day all we were taught about computers is how to turn them on.
That does make me feel better lol
I aint even kidding. The most advanced computer type class we had was learning to use the microsoft programs lol
Granted this was over 15 years ago
Maybe not 15. idk. my concept of time has warped since I stopped counting
@undone pilot what library are you using?
Me? hell na. I can't even get python to function properly. I would if I knew how tho.
I am using the arcade library and os
@undone pilot @Paul Craven#0050 maintains the Arcade library and he hangs out here, so try pinging him with that question. Note that you can also use a font to render text rather than static images, so that might be easier
maybe instead of 3d models I'll do some arcade 2d models and games
Maybe that'll be easier to do xD
So right now it says "health: 5" and when you hit an enemy, it says "health: 4" so I need to replace that text for the image of the corresponding health bar
Can't you just create a box there and resize it based on the % of health remaining?
I already have a set image that I designed
How are you currently displaying stuff on screen? why cant you just use the same methods and change the position/image?
because I don't know what the command is to replace it with an image
Draw our health on the screen, scrolling it with the viewport
health_text = f"Health: {self.health}"
arcade.draw_text(health_text, 1400 + self.view_left, 10 + self.view_bottom,
arcade.csscolor.BLACK, 18)
That code displays the health as it changes as TEXT but I need to put an image instead of text lol
The small things are always the most painful
I've made a sprites
I'm kind of new to this and we're using a software called Pycharm and a software called Tiled. Tiled is like a map design software that means I have to do less code if i use it smartly
Can you create a new sprite for the healthbar and simply draw it where the health_text is? and then layer the health text over the sprite?
That is what I have been trying to do for the past 5 hours, yes
But there are all kinds of errors
I'm still confused as to how you can create other sprites and display them but you can't simply copy and paste the exact same code and simply change what sprite it's loading?
That's what i've been trying to do but they're different in subtle ways
The only other similar sprite I have is my main character sprite
The health bar should move along with the viewport screen, the player does but not in the same way
the game window
Are you using this website? https://api.arcade.academy/en/latest/examples/index.html#sprites
yup
What's that?
a whole bunch of 'em
Wait. this tiled program. why arent u using that to display your gui?
I'll have a play around with what's there.
And because if I used that, it wouldn't move with my screen
Thanks for that link btw
Yeah, I'm vaguely familiar, I've created my own map and collectibles etc
Yes, but the layers are bound to their spacial position it seems. By that I mean, they don't move with the screen, they stay still
Ah parallax scrolling, see i'm learning all these terms

