#game-development

1 messages ยท Page 49 of 1

dawn quiver
#

so, i know this isnt exactly python, but im making a game in unity and i have two terrain generating scripts, one generates a bunch on tiles underneath a parent, and the other determines how many parents to place in the world. I want to generate caves, but if i put it in the parent class, the caves might get cut off since those parents are just one chunk of the whole, and if i put it in the parent-placing class, it would be harder to access/destroy the cubes that make up the parent classes in order to generate caves. With you guys having a coder's mindset, i was wondering if i could help get some insight on where to add my terrain generation process.

potent ice
#

@fierce wraith Just saying there is a huge difference between feeding the previous buffer back to the compute shader and always feeding it with the original buffer. If you can get away with always feeding the original values, do that.

#

it may also be that these inaccuracies are not a big problem at all

#

.. if you are doing "transform feedback" type compute shader

#

@fierce wraith I see in the code that you are are swapping the buffers. Could you instead calculate the planet position from the original position? That should be a lot more accurate because feeding back the calculated values should definitely keep enhancing inaccuracies per frame.

#

You would experience the same issue doing these calculations on the CPU

#

So yes. Like you said.. the value will drift when you calculate them using feedback

#

Instead pass in a time uniform and move them from the original position every frame.

#

.. or live with the inaccuracies

fierce wraith
#

i figured it out! @potent ice

potent ice
#

woot?

fierce wraith
#

this is me hardcoding a value into the velocity vector by just always setting it to a dvec3(1):

(0.0, 1.0, 1.0)
(1.0, 0.0, 0.0)```
it starts one number to late into the velocity vector
and then writes the last one into the force vector
#

its messing up by padding the vectors

#

for some reason it thinks the velocity vector starts 4 numbers in

#

and then it just sets the next 3 numbers

#

but the last one is in the force vector

#

see how the 1 slips into the next line

#

does this have something to do with the std430 layout?

layout(std430, binding=1) buffer planets_out
{
    Planet planets[];
} Out;```
potent ice
#

ah. I see. You'll probably still get some inaccuracies, but I guess this just greatly enhanced it

fierce wraith
#

yeah..

#

any ideas on how to fix it?

potent ice
#

It it even a problem?

fierce wraith
#

well yeah its writing into the wrong vector

potent ice
#

pushed your code?

fierce wraith
#

yup just now

potent ice
#

Ahh. It's the std430 alignment rules I guess

fierce wraith
#

yeah but how would i fix that?

potent ice
#

I think that is the best explanation I have found

fierce wraith
#

yeah but then i should be fine right?

#

my largest size is 3*8

#

so why does the padding already mess up on the second dvec3?

potent ice
#

That is in the second Planet entry?

fierce wraith
#

yeah its
dvec3
dvec3
dvec3
float
vec4

potent ice
#

So your structure is 108 bytes

fierce wraith
#

hm i dont think so

#

(3*8*3)+(4)+(4*4)

#

92

potent ice
#

er yep 92 ๐Ÿ˜„

#

Then the structure aligns at 96 bytes. (4 * 24)

#

So I guess each entry gets offset by 4 bytes?

fierce wraith
#
struct Planet
{
    dvec3 pos;   // 3*8 bytes
    dvec3 vel;   // 3*8 bytes
    dvec3 frc;   // 3*8 bytes
    float mass;  // 1*4 bytes
    vec4 col;    // 4*4 bytes
};               // = 92 bytes
#

hm dont really get all this alignment and offset stuff.

potent ice
#

It just means you have to add a 4 byte padding per entry in the array

fierce wraith
#

but how can i add padding?

potent ice
#

You have control over the struct.pack

fierce wraith
#

yeah but how do i add padding in the struct

#

im not getting something

potent ice
#

just 4 bytes with anything like a dummy float or something

fierce wraith
#

but writing to the buffer for the first time works fine

#

just outputting in the compute shader is broken

#

i think

#

or is just my reading broken

#

because it aligns for me

potent ice
#

I'm not sure if it applies to both the input and output bufffer, but I would assume so

fierce wraith
#

hmm ok ill have to figure it out tomorrow its way to late here ๐Ÿ™‚

#

but thanks for the help!

potent ice
#

Your are on the right track at least. Sadly I don't have the hardware to test any of this at the moment

#

Worst case just make everything a double in your struct so it always aligns perfectly ๐Ÿ˜„

#
struct Planet
{
    double px, py, pz;
    double vx, vy, xy, vz;
    double fx, fy, fz;
    double mass;
    double r, g, b, a;
};
#

The structure will have an 8 byte alignment this way and all entries fits perfectly

#

This is actually good for me as well because I have not messed with compute shaders in a long time.

fierce wraith
#

Hm but the fragment shader doesnt like doubles!

#

For the color atleast

#

But yeah that seems like the easiest way to do it

potent ice
#

Why do you need to pass the color in the compute shader?

fierce wraith
#

I don't, I guess I could have a extra buffer... never thought of that

potent ice
#

yup. much better

fierce wraith
#

I always forget you can bind multiple buffers

potent ice
#

I guess you can also have multiple in/out ssbos in the compute shader

#

A good tip I guess is also to greatly scale down what you are doing making a very minimal example just with a position and a velocity

#

See if you can render that first and expand later

#

I'm guessing you are using a compute shader here because it would be harder to interact with data for the other planets with transform feedback.

fierce wraith
#

Yeah

#

Well it all worked fine on a small scale with floats

#

But I wanted to simulate our solar system and floats just cant keep up with that...

potent ice
#

I guess you were just lucky with the alignment initially ๐Ÿ™‚

fierce wraith
#

Yup hahah

#

Well it was all vec4 initially

#

And mass was the w of velocity

potent ice
#

What is a good way to pack the data

fierce wraith
#

Hm?

#

Anyways I should really get to bed... its 2am!

potent ice
#

yup yup nn!

inner hamlet
#

Hi guys, I'm using a demo file messing around with the pygame module but no idea how to implement either a scroll or click and drag to move the camera around ๐Ÿ˜

#

all i have atm but cant navigate around it ๐Ÿ˜ is there an easy way to do it?

#

ps it's isometric not a 2d hill

#

128px blocks 29x49

#

map size

potent ice
#

Do you know how to read mouse coordinates or mouse position delta?

#

Break your problem down into smaller ones and attack one at a time.

fierce wraith
#

@potent ice for binding the vao, can i still use '3f8' even if my struct has 3 seperate doubles not a vector?

potent ice
#

I don't see why not.

fierce wraith
#

well maybe dvec3 has some extra info in it

#

and not just three doubles next to each other in mem

#

ill just try it ๐Ÿ™‚

potent ice
#

It should not as far as I know. The only padding you get in ssbo is between the planet entries (I think)

#

Unless some datatypes expand. The std spec is fairly clear on these things. I have not read it recently. Look it up ๐Ÿ™‚

fierce wraith
#

so because the struct is only doubles now the alignment should be correct right?

struct Planet
{
    double px, py, pz;
    double vx, vy, vz;
    double fx, fy, fz;
    double mass;
};```
#

and i can just have this at the beginning of the main func to get my vecs back:
dvec3 p = dvec3(in_planet.px, in_planet.py, in_planet.pz);

potent ice
#

I think so yes. Each Planet instance should have an 8 byte alignment

#

What you had before was planet, 4 bytes, planet, 4 bytes ...

fierce wraith
#

it works!!!

potent ice
#

Yay!

#

So it was just byte alignmemt issue between blocks as suspected.

fierce wraith
#

yup! it finally works haha

potent ice
#

A lot of fun when you can access all data instead of being limited to proccessing separate incoming chunks of data like in vertex shader

#

Calculating gravity I guess?

fierce wraith
#

yup.

potent ice
#

Oh. Fun!

fierce wraith
#

well it almost works ๐Ÿ˜‰

potent ice
#

I did that with transform feedback and 250k points (hard to display more on a screen), but that was simple with a single point of gravity. Your version sounds more fun.

fierce wraith
#

yeah but it gets pretty slow pretty fast haha its O(n**2) after all

potent ice
#

How many planets?

fierce wraith
#

i can get it down to O(n*(n-1)/2) but not that far yet haha

#

before it gets slow?

potent ice
#

I'm thinking you can get away with around 64k

fierce wraith
#

yeah

#

maybe 250k if i try hard haha

potent ice
#

You can even download planet textures from nasa

fierce wraith
#

that would look pretty cool!

#

but i dont even have them emitting spheres yet

#

just points

potent ice
#

It maps on a geometry.sphere

#

Easy

#

You can get som ideas here. Even has the milky way map

fierce wraith
#

oooo

#

thanks!

potent ice
#

Looks more like a black hole

fierce wraith
#

yup haha

#

just gotta go look up all the correct velocities for the planets hehe

#

ok i think the main bottleneck is just displaying it to the screen

#

i need more speeed

#

do i just wrap the compute shader in a loop?

#

i think the python function call to run the compute shader is taking pretty long

fierce wraith
#

can i somehow tell the compute shader to do this?

for _ in range(1000):
  self.calculate_force.run(group_x=self.NUM_GROUP)
  # swap buffers
  self._swap_buffers()
  # run the compute shader
  self.move_planets.run(group_x=self.NUM_GROUP)
  # swap buffers
  self._swap_buffers()```
#

because i think its the python overhead that is taking up most of the time

#

ideally i would run the two compute shaders 8_640_000 times per second inorder to simulate 10 days in one second with a dt of .1 seconds

#

but that seems kinda crazy

fierce wraith
#

ok @potent ice im gonna try to render out a gif over a few hours of runtime, do i just render to a fbo and then save that to a image?

#

ahh was it simple frame buffer or just frame buffer?

potent ice
#

I think you can use the screenshot module and dump directly from the window

#

window.fbo I think?

fierce wraith
#

you mean moderngl_window.screenshot?

potent ice
#

yes

fierce wraith
#

AttributeError: module 'moderngl_window' has no attribute 'screenshot'

#

ah

#

yup works ๐Ÿ™‚

potent ice
#

Forgot to make api docs for that. Fixing. It Easy enough to look at the source.

fierce wraith
#

yeah it was the first result anyways ๐Ÿ™‚

#

how would i set the SCREENSHOT_PATH setting?

fierce wraith
#

haha

potent ice
#

Just to be clear, I only do that to Leterax.

fierce wraith
#

and im fine with that haha

#

i must be doing something wrong, the gpu is only running at 50% utilization...

#

well im gonna take a picture every 12 hours of simulated time

#

so every 40 real seconds

potent ice
#

You can disable vsync and use the frame counter as time to greatly speed it up

#

You can base it on 30fps even

fierce wraith
#

yeah i have vsync disabled.

#

2.1kfps

potent ice
#

ok, so 70 x speed with 30fps as a base

#

I think you could also make it faster by running multiple iteration of the cumpute shader per frame.

fierce wraith
#

i tried that with a simple for loop but it wasnt any faster

potent ice
#

ah ok ๐Ÿ˜ฆ

fierce wraith
#

hmm running slower than expected, about 1/4 of the way done after 1.5 hours.. i was expecting one hour

fierce wraith
potent ice
#

Will the final gif anim take 1 year to watch?

fierce wraith
#

yes! hahah

#

its speed up by a lot ๐Ÿ˜‰

#

since CULL_FACE is enabled, shouldnt it be invisible from the inside

potent ice
#

Read again : self.ctx.disable(moderngl.DEPTH_TEST | moderngl.CULL_FACE)

#

The real resources are defined in dependencies.py by the way.

#

The code fetch resources by the label defined in that module

fierce wraith
#

haha disable!

humble pewter
#

So I've never made anything with Renpy before

green galleon
#

I haven't either

humble pewter
#

So im not sure it will know which text editor to associate with the files

green galleon
#

it says the "associated one"

#

on Windows, you can associate applications to file extensions

#

you can check that if you right click on an file > Open with...

#

if I recall correctly

#

then you can check a box to make an association

night swan
#

what module should I use for video game development

humble pewter
#

Wing personal isn't there

green galleon
#

if it's not on the list, you'll have to select the executable file manually

humble pewter
#

Ok idk how to do that

green galleon
#

if you give me a second, I'll start up a Windows VM I never use

humble pewter
#

Epic thx

#

Now renpy wont open

#

it said to uninstall it and reinstall it

#

But that isn't working

green galleon
#

(you need to check "Always use the selected program to open this kind of file")

#

remember you need to do that with a RenPy file

humble pewter
#

thank you

green galleon
#

not an executable

humble pewter
#

But now it wont open

green galleon
#

I feel you associated the RenPy binary file

humble pewter
#

Ok but it wont open now

#

How do I get it to open

green galleon
#

you had to do that with a .rpy file (which you'll have to create yourself)

humble pewter
green galleon
#

mmm I don't know if it's the same issue

#

but you'll have to undo the association

humble pewter
#

How

#

It wont open

green galleon
#

I don't know, lemme replicate it

#

I'll do the same thing, I have nothing to lose in the VM

#

no, there's no "open with" for exe files

humble pewter
#

Ok?

green galleon
#

that screenshot probably means you just moved the file?

humble pewter
#

No

#

I mean

#

I did

#

But then I deleted it

#

It's now where it was before

#

I moved it again

#

Back to where it was when I first moved it

green galleon
#

oh, it's a compressed 7z

humble pewter
#

It still wont open

#

Wassat mean

green galleon
#

this is not a Windows installer per se

#

it's like a .zip

#

so do the following

humble pewter
#

It worked last time

#

It opened last time

#

It did what it was supposed to do

green galleon
#

yes, you probably just unzipped it somewhere and deleted something thinking you were deleting the installer

#

that's what I think

humble pewter
#

What does unzip mean

green galleon
#

because the default path to extract RenPy is the one the .exe is (so you didn't install anything, you just extracted it to Downloads/)

#

unzip means uncompress a zip

#

like

#

just think of that .exe you downloaded as a file that contains files

#

download the latest version for you (the green button, SDK 7z.exe)

humble pewter
#

I already did

#

Twice

green galleon
#

then open it, but change the path

humble pewter
#

What

#

What path

#

It gives me no option for a path

green galleon
#

that thing

#

(ye, John Lennon is my name in the VM)

humble pewter
#

Which file do I click on

#

there are a lot of files

green galleon
#

you need to select a folder, actually, where you want to have all the RenPy files

#

for example

#

you could choose something like C:\Users\Whatever your name in Windows is\Desktop\RenPy

humble pewter
#

Where

#

Which folder

#

There are lots of folders

green galleon
#

well, this is more like a Windows thing

#

if you go to C:\Users you can find yourself, right?

humble pewter
#

What

#

Where's that

green galleon
#

do the following

#

try Windows + R

#

it will open the Run app

humble pewter
#

That just took me to favorites

green galleon
#

huh?

#

I am... quite sure Windows + R still opens Run

humble pewter
#

Oh it does

green galleon
humble pewter
#

It took me to that

green galleon
#

type C: and press enter

#

just to know, is what you see after that familiar to you?

humble pewter
#

No

#

It just took me to local disc

green galleon
#

Yes, that's what I wanted

#

but you know what it is, right?

humble pewter
#

Not really

#

There's nothing about renpy here

green galleon
#

I know

#

I kinda wanted to show you what you're doing

#

if you don't want to, I can make the process faster

#

but you could learn a few things on browsing the typical Windows tree of directories

humble pewter
#

Nah you can show me

green galleon
#

I don't plan to go too deep, it's quite basic anyway

#

alright, do you see a Users folder there?

humble pewter
#

Yes

green galleon
#

double click on it

#

you should see a bunch (or at least one) folder inside of it

#

and one of those folders should have your username as its name

humble pewter
#

Oh no

#

There are lots of users folders

green galleon
#

this is mine on my VM, for example

#

how many? it's not unusual to have a few

#

although it would be weird if you found like 30

humble pewter
#

There are a whole lot

green galleon
#

can you find yourself there?

humble pewter
#

Like 8

#

I think so

green galleon
#

double click on the one you think it's you

humble pewter
#

I found appdata

green galleon
#

appdata is not really relevant

humble pewter
#

F

green galleon
#

let's try a different thing

#

are you used to cmd or PowerShell?

humble pewter
#

Idk

green galleon
#

try Windows + R

#

then type in cmd and press Enter

humble pewter
#

It opened up command prompt

green galleon
#

yes

humble pewter
#

Ig thats what im used to

green galleon
#

you see that C:\Users\John Lennon?

humble pewter
#

yes

green galleon
#

John Lennon is my username on the VM

#

and C:\Users\John Lennon is the directory for my user account

#

so you should see something similar, with your name

humble pewter
#

Yeah I do

green galleon
#

alright, then you can go with the file explorer there

#

did you know that's where your Desktop is?

humble pewter
#

No

green galleon
#

okay, your desktop is just another folder

#

now you know

humble pewter
#

Kewl

green galleon
#

this is something you could do from the RenPy 7z, but let's do it from here

#

I want you to go to your Desktop (if you want to learn a bit, I want you to do it from the file explorer)

#

so basically going to C:\Users\whatever your name is

#

then \Desktop

humble pewter
#

How do i do that

green galleon
#

first, open your file explorer

humble pewter
#

Alright

green galleon
#

you're probably using Windows 10 - I don't remember which one is

#

from there, go to C:\

humble pewter
#

Im actually using windows xp

#

This computer is very old

green galleon
#

ah, that makes things a lot easier

#

just go to My Computer

humble pewter
#

Ok I thought that would make things harder lol

#

Alright

green galleon
#

I just happen to have more experience with XP than with 10

humble pewter
#

Yayyy

green galleon
#

that doesn't mean I remember everything, but still

#

so you see the C:\ disk, right?

#

in My Computer

humble pewter
#

No

green galleon
#

or My PC, whatever its name is

humble pewter
#

I saw one called just computer

#

Is that correct?

green galleon
#

do you think you can share a screenshot?

humble pewter
#

Sure

#

No i cant

#

It wont let me

green galleon
#

dang it

humble pewter
#

The snipping tool wont work when the windows bar is up

green galleon
#

I'll rely on Google Images

#

this is My Computer

#

you have something like that, right?

humble pewter
#

It does not look like that lol

green galleon
#

are you sure you're on XP?

humble pewter
#

Yes

#

This is what it looks like

green galleon
#

that's not XP

humble pewter
#

What

#

What is it

#

My dad told me its xp

green galleon
#

looks like Windows 7 to me

humble pewter
#

Huh ok

green galleon
#

okay, you do have C:, I can see it from here

#

it's that one

humble pewter
#

Ohhh

#

Ok

green galleon
#

just double click on it

#

then go to Users

#

then your username

humble pewter
#

There are 5 users folders

humble pewter
#

Yeah

green galleon
#

you can know which folder is yours with that

humble pewter
#

No they all just say users

green galleon
#

can you share another screenshot?

humble pewter
#

Ok hold on

green galleon
#

if you want to share the entire screenshot, you don't need to use the snippet tool at all if I recall correctly

humble pewter
#

How do I take a screenshot with windows 7

green galleon
#

you just need to press Prt Scr

#

there will be no visual feedback

#

but you can do Ctrl + V here afterwards

humble pewter
#

What does that mean

green galleon
#

ah, I see

#

you didn't went to a specific directory

#

to looked up "User"

humble pewter
#

But I did?

green galleon
humble pewter
#

I went to local disc?

green galleon
#

that's not to go to folders

#

it's for searching things

#

so what you see there are a list of results

#

things named "users"

humble pewter
green galleon
#

yes, it says those are results

humble pewter
#

Yeah and?

green galleon
#

let me record a short video

humble pewter
#

Ok

green galleon
#

I forgot to record the cursor...

humble pewter
#

F

green galleon
#

that starts from My Computer

#

so you can see everything I'm clicking on

#

does that clear things up on how to get there?

humble pewter
#

No

#

There are still 5 users folders

green galleon
#

but they can't have the same name

#

what you showed before is the search tool

humble pewter
#

But they do

green galleon
#

but I don't have to search anything

#

you just need to click on thigs, you don't need to write anywhere, anything

humble pewter
#

But I do

green galleon
#

scroll down

humble pewter
#

My dad has a lot of things on his computer and it's very hard to navigate

#

Ah ok

#

Found one

green galleon
#

that's the one

humble pewter
#

Clicked on my username

green galleon
#

well done

humble pewter
#

Thanks lol

green galleon
#

see a bunch of folders there?

#

Downloads, Documents, Desktop

#

that's all yours

humble pewter
#

There's too many

green galleon
#

yes

#

don't worry

#

feel free to learn from this, as long as you don't break your dad's PC

#

I want you to go to the Desktop folder (which is exactly that, your desktop)

humble pewter
#

Ok

green galleon
#

I see it right in the middle

#

so, there's no much point in doing this from here - but I felt it was necessary

#

browsing files shouldn't be intimidating, you need to get a bit used to it

#

I want you to make a new folder in Desktop

#

name it RenPy

humble pewter
#

Alright

#

What now

green galleon
#

now we can go back to the 7z file

humble pewter
#

Where's that

green galleon
#

it should be in your Downloads folder

#

which, since we're at it, it's in C:\Users\JC\Downloads

humble pewter
#

Alright

#

It's not there

green galleon
#

alright, then go to Chromium (I suppose) and press Ctrl + J

#

if you didn't delete it, it should be on that list

#

it's the renpy-7.3.5-sdk.7z.exe file

humble pewter
#

Where's chromium

green galleon
#

maybe you don't use Chromium?

#

what do you use to surf the web? Firefox?

#

ah, Chrome, right

#

I meant Chrome

humble pewter
#

Ah ok

#

It's trying to extract or something

green galleon
#

No, don't press accept

humble pewter
#

Ok

green galleon
#

I mean, don't press "Extract"

#

you need to change the path

#

do you know what a path is?

humble pewter
#

It's where something goes right

green galleon
#

yes

humble pewter
#

Make it go to RenPy?

green galleon
#

yes

#

you can use

#

this button

humble pewter
#

Alright done

#

It's extracting

green galleon
#

to explore your existing folders

#

alright, while it's working, go to your Desktop (you don't need to use the explorer if you don't want to, that was just to make you understand what you were doing)

humble pewter
#

It's done

green galleon
#

and then check the RenPy folder there

#

if everything went well, you should find files there

humble pewter
#

It works!

#

Thank you!

green galleon
#

nice!

#

you can delete that renpy 7z.exe file now

#

don't delete anything on that RenPy folder on your desktop

humble pewter
#

Now to figure out how to make a game with it

green galleon
#

well I'm running out of time now, but you should have everything set up

#

I can help you with the editor thingie

humble pewter
#

Can I move the renpy folder to anothe folder?

green galleon
#

yes, you can move the folder itself to anywhere else

humble pewter
#

Epic thx

#

I have to go too

#

I'll ping you when I get back ok?

green galleon
#

sure

humble pewter
#

Bai

green galleon
#

(but I might not be here, just ask)

humble pewter
#

Oh no

#

Ok nvm

restive wagon
#

Do you think it would be better for me to run Unity on a Windows PC with only 4GB RAM or on Linux with 8GB ram? Can you still develop multi-platform games on Linux?

iron galleon
#

4gb of ram wouldn't be enough

#

8gb of ram on linux should be ok on ubuntu and centos

green galleon
#

I used Unity for around 3 or 4 months, on Linux, and 8 GB was enough but very close to the limit at times. Depends on what you're working on. On the other hand, I used a Unity build in Archlinux and worked a bit like poop sometimes (but Arch is not "supported" anyway)

#

still, Unity doesn't use Python, but C#, be aware of that

restive wagon
#

Is Unity on Linux fine for creating games for Windows, Linux, iOS and Android?

green galleon
#

I did export to Linux and Android, didn't bother to check the other two. I didn't have any issues with it. It was a VR game (but as I mentioned before, the general performance of Unity on Arch wasn't always great while editing - maybe it's much better on Ubuntu.)

#

If you need help with Unity, you should probably ask in the off topic channels. I don't think people here expect to use Unity.

fierce wraith
#

@potent ice is there a option for moderngl to not clear the screen between calls to the render method? i tried just not calling the clear method but the screen then just goes black. its because im only actually rendering every n'th simulation step because well i dont need to render at 2.6kfps.

restive wagon
#

Thank you for your help

potent ice
#

That is moderngl-window specific. When running a WindowConfig we do the most common draw loop for you that includes clearing. There are examples with custom usage in the example directory.

fierce wraith
#

oh ok. its not that important, im rendering to a gif anyways and i can just check the most recent screenshot ๐Ÿ™‚

potent ice
#

If you ever need it, it's not hard to change. Fairly boilerplate stuff

fierce wraith
#

while i have you here, any fun things i could simulate now?

#

just our planets is pretty boring because i cant really use/show the power of the gpu with 9 bodies ๐Ÿ˜‰

humble pewter
#

Hey um

#

I'm tryna use renpy

#

And I'm trying to make the character's text color change

#

But nothing I do works

#

Im following the instructions

#

But nothing works

#

I also can't get Agnes to talk instead of Elena

#

I also can't get that period to go away

#

This is what my code looks like, simplified

define e = Character("Elena")
    a "Hello player!"```
#

Oh!

#

Nevermind?

#

I fixed it?

#

Somehow?

#

Ah ok I see what I did

summer pond
#

I've been working with pygame and I need a solution to a problem with a car simulation I've been making
so
I need to find a way to rotate a rectangle as if it were driving
like you press the left key and it rotates counter clockwise
and I know there's no default support for this, but I'm wondering if anyone has any good work arounds

#

I don't wanna send my code in this channel cuz it's a lot, but if anyone with experience can DM me for some help, I'd greatly appreciate it

foggy python
#

Are you talking about just an image or also a hitbox used for physics?

#

If itโ€™s just an image, you can do pygame.transform.rotate()

#

Otherwise, youโ€™ll probably need to make your own system.

#

or use the per-pixel collisions and write a weird physics system

summer pond
#

also a hibox used for "physics" I just need to check whether two elements overlap

#

is there really no good work around?

foggy python
#

you can do per-pixel collisions with masks

#

If youโ€™re just looking for the overlap

#

Iโ€™ve never used it tho tbh

#

thereโ€™s plenty of tutorials on it

summer pond
#

do u put the mask over an image?

foggy python
#

I think you use Mask.overlap for collisions

#

Iโ€™m just reading the docs tho

summer pond
#

ok thx

foggy python
#

Keep in mind, if you want actual physics and not just overlap checks, youโ€™ll need to write that yourself

summer pond
#

I just need overlap and rudimentary movement with translations

potent ice
#

@fierce wraith Draw textured spheres with instancing at the planet positions.

#

One draw call

frozen knoll
#

@summer pond If you want easy rotation of the car and hitbox, Arcade supports it by just changing the angle attribute of the sprite. But that doesn't help you if you are committed to PyGame.

summer pond
#

how hard would it be to convert from pygame to arcade

frozen knoll
#

Really depends on how far you've gotten, and how it is written. You can take a look at the sample code to get an idea: http://arcade.academy

summer pond
#

I'm looking at it now, and tbh it looks a lot better

frozen knoll
#

I taught with PyGame for many years, and things like rotation, scaling, were always a headache for students. So I tried to create a higher-performing library that made common operations easier for students.

summer pond
#

oh you made it???

#

That's awesome

frozen knoll
#

Well, there are a lot of other people that contributed.

foggy python
#

I kinda get rotation, but what was wrong with scaling?

frozen knoll
#

Scaling graphics in PyGame was never as easy as it could be. Creating a sprite and just passing in a scaling number is way easier. Transparency wasn't done automatically. Generating hitboxes based on the transparency in the image wasn't done automatically. The curved primitive drawing functions produced a moire pattern. You can't rotate an ellipse. You were expected to make your own event loop. It didn't use OpenGL for drawing in a batch. And at the time I started Arcade no one was updating PyGame and you couldn't even do a pip install.

#

Anyway, after 10 years of teaching PyGame and one book written, the list of frustrations got long enough I started a different library.

#

(Don't get me wrong, I still like pygame and I'm glad development started again with it.)

potent ice
#

Yup. They have managed to shape up things slowly in pygame2.

#

But you have to install the latest dev release from pip

#

There are certainly advantages with pygame. It's basically software rendering, so it can run on almost anything. The amount of platforms sdl/sdl2 based games can run on is insane.

#

.. but on modern PCs linux/win/osx you have powerful gpus that can do the job much faster. Even integrated intel and amd is awesome nowdays.

#

You can of course also combine pygame rendering and opengl, but that might be for more advanced users. You upload the pygame surface to a texture in opengl and do the remaining work with shaders. Lighting, postprocessing etc.

#

I actually love that combo ๐Ÿ™‚

#

Also, considering even lower budget PCs from 5 years ago have GL 3.3+ support.. they have access to really powerful functionality that can move expensive operations from python code into shaders.

#

.. that runs in microseconds.

#

What library to use really depends on what you are making and what platforms you want to cover. It's not always an easy choice.

#

Scaling and rotating would definitely be superior in GL based libraries unless you want the authentic 8bit style.

#

simply because you have better interpolation support and mipmaps.. and msaa.. and anisotropic filtering.

#

BUT. Drawing a cirlce in GL is not as simple as in pygame.

#

But I guess Arcade probably have support of that. I know Wasabi2D has it

grand imp
#

has anyone made a tool that compiles python or something python-like to shaders?

#

the past times i've looked at GLSL, there were different versions that had frustratingly different ways of doing things

frozen knoll
#

Even just drawing a line more than one pixel wide requires drawing two triangles. Circles take a bit of work!

potent ice
#

@grand imp Use #version 330 or higher and things should be pretty consistent. (OpenGL 3.3+)

grand imp
#

huh, ok

#

ty

potent ice
#

It get's confusing with version 120. It works with the fixed pipeline automatically sending in the old fixed pipeline matrix stuff + lots of other material and lighting stuff.

#

@frozen knoll You can use geometry shader to do lines and draw circle with fragment shader, but I guess that can be a challenge to batch draw with other geometry ๐Ÿ™‚

humble pewter
#

Ok so Im using renpy

#

And I want the player to input their name

#

Is is any different with renpy than with python?

humble pewter
#

Ok it is

#

But it says this is wrong

#

name = renpy.input("Hello! Welcome to Mythical Creature Dating Sim! What is your name?", default="Your name", allow=abcdefghijklmnopqrstuvwxyz?!, exclude=None, length=None, pixel_width=None)

#

Now my code looks like this

#
    name = renpy.input("Hello! Welcome to Mythical Creature Dating Sim! What is your name?", default="Your name", allow=abcdefghijklmnopqrstuvwxyz?!, exclude=None, length=None, with_none=None pixel_width=None)```
#

But it still doesn't work

#

What do I do

minor mortar
#

the allow part doesn't look like a valid string

humble pewter
#

Alright I'll try getting rid of it

#

Still says it's wrong

humble pewter
#

Can someone pls help

foggy python
#

wrong how

humble pewter
#

Idk it just says its wrong

#

I cant debug bc im using wing personal

#

I just have to run the game and see what it tells me is wrong

foggy python
#

@humble pewter
with_none=None pixel_width=None)

#

you're missing a comma there

humble pewter
#

Still says its wrong

#

@foggy python

foggy python
#

well I can't help if you don't have the error message

#

I also don't know anything about renpy lol

humble pewter
#

Aw man ๐Ÿ˜ฆ

#

Can someone else pls help?

minor mortar
#

isn't wing able to tell you about syntax errors

humble pewter
#

Yes

#

But im using renpy, not python

#

It's not build for renpy

minor mortar
#

renpy is a python library/engine, so renpy is python

#

you shouldn't ignore python syntax errors

scarlet whale
#

hi

#

i need help with a small little code

#

for pygame

#

can anyone help?

#

its pretty urgent

#

its due tomorrow

foggy python
#

I should be able to.

#

I'ma go do something for 30-45 mins then I'll be back for a couple minutes before I go to sleep.

humble pewter
#

Welp I just debugged it and it said my very first line of code is wrong

#

But renpy didn't

potent ice
#

You should share the exact error message

fierce wraith
#

@potent ice that with the instanced rendering sounds very smart! sadly i dont have that much time rn, maybe ill get around to it next week or on the weekend

potent ice
#

Turn off the heating in your room!

fierce wraith
#

exactly! its perfect haha

weary elbow
#

@humble pewter
When using Ren'Py, the error message should be displayed in the window in which you launch your game?
Like this (I assume this is the error message you got):

#

In which case, yes, the problem was the lack of quotation marks around the allow argument!

#

This should work:
$ name = renpy.input("Hello! Welcome to Mythical Creature Dating Sim! What is your name?", default="Your name", allow="abcdefghijklmnopqrstuvwxyz?!", exclude=None, length=None, pixel_width=None)

humble pewter
#

Oh there should be quotation marks?

weary elbow
#

The dollar sign at the beginning is used to insert a one-line Python statement

#

Yup, since it's a string, as someone mentioned before!

humble pewter
#

So if I put a dollar sign, I can use it exactly like python?

potent ice
#

@minor mortar also pointed this out earlier: "the allow part doesn't look like a valid string"

humble pewter
#

Ahhhh so that's what he meant

weary elbow
#

Yup, that was the only problem AFAIK ahaha

#

As for the dollar sign, yes

humble pewter
#

Kewl

#

Thank you!

weary elbow
#

But you shouldn't use a lot of actual Python in Ren'Py
Most of the time, using Ren'Py script (the Python-like language used for simple actions like dialogues, displaying sprites, etc) should be enough!
Use Python when you need to set variables or access specific functions like renpy.input like you did

#

No problem!

humble pewter
#

Huh

#

Still says its wrong

weary elbow
#

Could you screenshot what you got as I did earlier?

humble pewter
#

Sure

weary elbow
#

Are you sure you put a dollar sign at the beginning of the line ?

humble pewter
#

But this is a renpy input right? And not a python input?

weary elbow
#

The dollar sign allows you to put "real" Python inside a Ren'Py script file (.rpy file)

humble pewter
#

Ok but this isn't real python right

weary elbow
#

It is!

humble pewter
#

Huh ok

#

I'll try that

#

It worked!

#

Wait

#

Now I can't type anything in it

#

Oh!

#

Yes I can! Nevermind!

weary elbow
#

Ah, great!

Also scrolling back up, I see that you had tried using a python: block to put this line and that should work too!
But you have to use a lowercase "p" letter in python or it won't work.
Otherwise, using the dollar sign in front of a single line as you just did is good as well.
The documentation explains both usages here: https://www.renpy.org/doc/html/python.html

humble pewter
#

Thank you ๐Ÿ™‚

humble pewter
#

Ok I have a question about renpy

#

Im making a menu right

#

What do I do if I want the color of the text in the menu to change

potent ice
#

I have no idea. Never used it.. but the docs are there ๐Ÿ™‚

humble pewter
#

Thank you ๐Ÿ™‚

#

Ok I couldn't find anything about menus

#

I found something about menu arguments in another page

#

And I was like "Oh, so this is how you change the color"

#

But either it's not or I'm doing something wrong

#

menu (color="#f7bf69"):

#

This is what it looks like

#

My code I mean

mortal bridge
humble pewter
#

can someone pls help

humble pewter
#

Pls

compact wasp
#

hi guys, anyone who can explain me a few things on pygame and backgrounds please

humble pewter
#

I was pinged?

weary elbow
#

I don't recall the exact way to do right now, but for Ren'Py-centric questions like this one, you might have better luck asking in the official Ren'Py Discord server

humble pewter
#

There's a discord server for that?

weary elbow
#

There is!

#

I can't paste the invite link apparently, but there's a link online:

humble pewter
#

Epic

weary elbow
#

in "how do I keep in touchโ€

ember glade
weary elbow
#

Oh thank you, that's the one!

ember glade
#

Sorry, we scrub invites by default since bots and people like to spam them

humble pewter
#

Thank you ๐Ÿ™‚

weary elbow
#

no problem, figured as much

ember glade
#

And is that the official on for them?

weary elbow
#

Yup, it's the right one

ember glade
#

Okay cool. I'll look into whitelisting it

compact wasp
#

@ember glade im stuck with the my code. i try to have the bouncy ball clean. at the moment it leaves a trail behind it and i cant find how to fix it. im stuck

ember glade
#

Sorry for the late reply, had to answer a lot of questions for a co-worker that was having computer security concerns

compact wasp
#

@ember glade thank you very much!!! no problem at all. i will give it a good study and if i have more questions, which i cannot answer by myself, i will come back

compact wasp
#

this is what my code returns ๐Ÿ˜ฆ

dusty heron
#

looks great ๐Ÿ‘

compact wasp
#

it shouldnt leave that trail behind

#

i dont know how to fix it

fierce wraith
#

You probably are forgetting to clear the screen

compact wasp
#

i think i found it. im not sure if its the optimised way to do it

#

i included the blit of the background picture after the blit of the ball

#

now it works but is it the optimal way to do it, or the computer has to process the bg picture continuously?

potent ice
#

I guess you would draw the background, draw the ball, then flip.

#

flip is like starting with a new blank surface

#

In your code above the first frame will only contain the ball. Then the next frame will contain the background and the ball. It's a weird setup.

#

Make it simple. Draw everything you need, then flip ๐Ÿ™‚

#

You can also think of flip as making what you just rendered visible in the window.

#

It's normally the last thing you do in a draw loop

#
window.blit(bg, (0, 0))
window.blit(ball, ballrect)
pygame.display.flip()
#

That way the background will also not render on top of the ball removing it from the screen

#

Unless pygame has some magical rules for overwriting pixels, but I doubt that

#

@compact wasp

compact wasp
#

@potent ice i just tried it and the ball moves really laggish!

potent ice
#

I think you have to use pygame.time.Clock to syncronize

#

Possibly something like this ```python
clock = pygame.time.Clock()
FPS = 30

while 1:
# draw stuff
pygame.display.flip()
clock.tick(FPS)

compact wasp
#

oh ok let me try

#

yup it works

potent ice
#

Awesome ๐Ÿ™‚

compact wasp
#

i used clock.tick(fps) within the main menu loop

#

i guess its not need it right?

potent ice
#

Just in the draw loop

#

after flip

compact wasp
#

i also changed it to 45 fps and the ball runs smoother

potent ice
#

yeah whatever you can get away with works.

compact wasp
#

the higher the fps rate the better the gpu has to be right?

#

well in this case there arent any limitations of course

potent ice
#

Well. pygame uses SDL so it's really software rendering

ember glade
#

^ so it would be a CPU limitation in this case

compact wasp
#

oh yes sure! cpu

#

is there any way i can use gpu sources instead of cpu?

ember glade
#

To my knowledge, not currently in pygame

#

I believe the next major update is going to add OpenGL, but I might be misremembering

potent ice
#

That depends on the platform implementation of SDL2.

foggy python
#

It uses the GPU for some stuff

ember glade
#

Oh does it? Wasn't aware

foggy python
#

but it canโ€™t use a lot of GPUs

#

Yeah, with my GTX 1060, I can see it using the GPU

ember glade
#

Also it should be noted that there are other libraries such as arcade that are quite well suited for 2D game creation and would give you more power

#

I'm not suggesting you abandon your current course, but just know you have options

foggy python
#

Iโ€™m not sure entirely what for, but my FPS is way higher than my laptop that doesnโ€™t use its integrated GPU

ember glade
#

Is it an APU?

#

The ones that have the graphics and CPU combined will offload tasks to each other, which might explain that

foggy python
#

Isnโ€™t APU amd?

potent ice
#

The advantage of pygame is the potential platforms you could support, but the drawback is performance. (Depending on what you want to do)

foggy python
#

Intel calls it integrated graphics iirc

potent ice
#

Yeah APU is AMD marketing speech ๐Ÿ™‚

foggy python
#

I use Pygame for simplicity and control over things like the game loop

ember glade
#

Ah right, my mistake

#

Forgot it was marketing hype

foggy python
#

Also because its Python

#

Anyways, unlike normally Pygame, Pygame uses pretty much any GPU afaik.

#

And there are options to use it for even more tasks iirc.

compact wasp
#

@ember glade im not abandoning my course. i guess as a newbie, any course is a good course for the basics and the more in depth i go, then i see limitations and probably switch to other languages, but for the time being i need to learn the basics. my next task is going to be the documentation you sent me yesterday, which is about the player control. my next task will be the ball to be controlled by the user and not just move up and down within a while loop

ember glade
#

Good, I'm glad to hear it. Keep at it, you're doing well

potent ice
#

@compact wasp Keep doing what you are doing. Pygame is a great intro to graphics.

compact wasp
#

thanks ๐Ÿ™‚

potent ice
#

Throw a newbie at GL 3.3 core and ask them to draw a circle is not a good idea. Pygame makes things simple and easy

ember glade
#

Of course

potent ice
#

and you can combine it with GL stuff later. No problem.

ember glade
#

I think arcade does a solid job at abstracting that complication stuff out, though.

#

Might be worth poking around after you finish this one in pygame

potent ice
#

Agreed.

#

At least if your goal is to use your 1060 ๐Ÿ˜„

#

Every library has their advantaged and disadvantages. In the long run it's important to chose the right one based on that.

ember glade
#

Absolutely

#

"Right tool, right job"

potent ice
#

Things like resolution scaling in pygame is a bit of a bummer compared to GL based libraries, but if that is not important.. then it's not a problem!

jovial fable
#

oh source code of VVVVV will be released for 10y anniversary of the game

kind moat
#

hello, I'm trying to convert a pong clone made in python 3.7 with pygame to exe using pyinstaller or auto-py-to-exe, both options don't work

#

I tried executing the exe through cmd and got the following output:

#
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "pong.py", line 67, in <module>
  File "site-packages\pygame\pkgdata.py", line 50, in getResource
  File "site-packages\pkg_resources\__init__.py", line 1134, in resource_exists
  File "site-packages\pkg_resources\__init__.py", line 1404, in has_resource
  File "site-packages\pkg_resources\__init__.py", line 1473, in _has
NotImplementedError: Can't perform this operation for unregistered loader type
[15692] Failed to execute script pong```
#

I also don't have any extra files I'd need to add to it, it's just the one script

potent ice
#

There are some posts on reddit and other places about this. You might also want to look into using the pygame2-dev packages. 2.0.0.dev6 is surprisingly nice with so many bug fixes.

#

1.9.6 has a lot of issues.

#

But it might be ok if this is win only. No idea.

summer pond
#

I've been having a lot of problems with lag using the python arcade library

potent ice
#

How many lines are you drawing here?

#

There should be a way to batch draw them instead of loop-drawing single lines

#

Similar to batches in pyglet I guess..

#

@summer pond

summer pond
#

There is, but anywhere from 30 to 100

#

In pygame I can draw upwards of 200 with no problem, but more than 3 or so with the code as it is now causes problems

potent ice
#

Maybe create as issue in the arcade project to get some pointers?

#

@frozen knoll should know more about this

frozen knoll
#

Right, draw them as a batch if you can. Look at the ShapeElementLists demos.

potent ice
#

@frozen knoll Just committed support for resizing buffers in moderngl so it's a lot easier to make pyglet style batch support etc. buffer.orphan(new_byte_size). Might actually batches in moderngl-window. It's a great thing.

#

I'm going to have a deeper look at Arcade. Probably a lot that can be learned from it. Wasabi2D also have a lot of neat things worth looking at.

summer pond
#

@frozen knoll Do you know if there's any way to make the points rotate with the sprite when using player_sprite.points after rotating the sprite by a certain angle?

#

or alternatively get a list of points on the border of player.sprite that rotate with it

#

I know I've been in this chat a lot for help, but I really appreciate it. Game dev is not my strong suite at all lol

real prawn
#

What game engines support python?

late sorrel
#

pygame

#

not really a game engine but you know

real prawn
#

No I kinda don't
I'm not that experienced with python

untold lodge
#

@real prawn check the pins for some info on that.

mighty rose
#

@real prawn The primary frameworks I am aware of (that one can use to make games) for Python: Arcade, Kivy and Kivent, Pygame, Cocos2D-Python, RenPy. I'm sure there are others I am missing!

potent ice
#

You also have unreal engine and blender game engine

#

and Panda3D

#

It really depends on what abstraction level you want to be in.

#

Low level rendering calls vs. managing higher level info were the rendering part is handled for you

#

It would be useful to come up with a complete list grouping them by category.

#

RenPy and Arcade are probably closer to a game engine than for example pyglet.

#

The same way you can say that moderngl is not a game engine, but a graphics library.. while Wasabi2D is a 2D game engine based on moderngl.

frozen knoll
#

@summer pond If you change the angle, the points should auto-rotate with the sprite. You shouldn't have to do anything.

#

Arcade will also try to guess the points based on transparency, so you many not have to even specify the points.

summer pond
#

@frozen knoll It seems like they don't... just player_sprite.points right?

frozen knoll
#

Don't rotate, or don't auto-guess points?

real prawn
#

@spinningD20#4376 which would you say is the best?

frozen knoll
#

@summer pond - Oh weird, you are right. Something does seem off. I'm researching.

fierce wraith
#

@potent ice how does instanced rendering work? And how does it work with moderngl?

real prawn
#

@mighty rose which would you say is the best?

mighty rose
#

@real prawn It depends ๐Ÿ˜‰ what do you want to build, and why? do you care about mobile? All important questions!

foggy python
#

I was messing around with different outlining methods. (I still have a few more I want to try.) The one on the left uses pygame.draw.polygon() with a width of 3 using the outline given from pygame.mask.Mask.outline() and it runs at about 80fps when I render 300 of them on top of each other. The issue with this one is that pygame.draw.polygon() doesn't actually make a perfect outline. The one on the right creates surface containing the edge pixels using the data from pygame.mask.Mask.outline() to use .set_at() on the surface. The surface with that outline is then blitted one pixel in each direction so the border edge line shows as an outline. This one runs at 60fps with 300 of them on top of each other, but makes a perfect outline.

#

so I'm tryin the same thing in Pygame 2.

#

they now run at the same framerate but both are 60fps

#

which means that the first method somehow got an fps drop from Pygame 2

#

using Mask.to_surface() on Pygame 2 and blitting in the 4 directions gets about 67fps

#

Pygame 2 with Mask.to_surface() seems to be the superior method because it works when there's holes in the image unlike the methods that use Mask.outline().

#

I might do a video on this. lol

frozen knoll
#

@summer pond I put out a 2.2.3b1 version of Arcade which should correctly rotate and scale hitboxes with the sprites if you want to take a look at it.

real prawn
#

@mighty rose I would wanna create PC games
Can they all not create games for mobile or PC?

frozen knoll
#

Python doesn't have much of a mobile presence. If your immediate goal is to create marketable games, I'd look at something like Unity.

#

If you want build your skills up with a language that is easier to get into, Python is good for that.

mighty rose
#

@frozen knoll Do you mean marketable mobile games, or any game? If any, I'd be interested in hearing your reasoning.

#

@real prawn yes, they all can create desktop games. The intention of my questions were to figure out what your goals were. If you're interested in using something to get your feet wet, and don't care about mobile, then the easiest to learn would be between cocos2d and arcade. If you're eventually looking to learn how games work under the hood, then perhaps pyglet or kivy will almost force you to do so, as they don't have much in the way of conveniences and "solving common problems for you".

If you aren't interested in learning the lower-level stuff under the hood, specifically using python, or to better learn programming in general, then I would recommend something like Unity or Godot.

foggy python
summer pond
#

@frozen knoll you're literally the best human alive. Thanks so much!

mortal bridge
#

that it doesn't have much market presence doesn't mean it's not a possible tool for that, it's just not one that the market recognize to be useful, but it might be for good or bad reasons. Only one example of a good game done with it should be enough to demonstrate it's a possible path.

#

i believe the boardz game made with kivent is example enough that it's possible to do games with python on android.

#

also it's been quite a few years i didn't work on that, but my pygame smash-bros-like project ran on a platform much less powerful than any phone that went out in the last 5ย years (and not flagship ones, even lower spec ones i'm sure, as i developped that on an eeepc 701 back then)

frozen knoll
#

You can easily create a mobile game on Unity or similar environment. As Python doesn't run natively on mobile devices, and there's not a good way (yet) to get an installable game running Python under iOS or Android, you'd spend way too much time solving that problem as opposed to writing a game.

real prawn
#

@mighty rose I thought Unity only supported C#
And I'm a beginner, but I want to leard how games work and eventually create them

potent ice
#

@foggy python what is the normal way to scale up pygame surfaces? Let's say I have a 4k screen and want to scale a game window 3500x2000 or similar.

mortal bridge
#

@frozen knoll uh, python does run natively on android/ios, the kivy project has made that happen quite a few years ago, and kivy is used by a lot of people to build android apps fully in python

#

maybe i misunderstand what you mean, but i don't see how it's any different from using unity

untold lodge
#

when you say natively, that seems to indicate that they'll be running in Java

mortal bridge
#

but that's not what unity does, right?

untold lodge
#

I'm unsure exactly how Unity solves that under the hood. it does claim to create native apps.

mortal bridge
#

or unreal engine or whatever, these are c# and c++ framework, they have their runtime compiled or compile to native arm code and run there, not as java, but directly in the system, in that sense, kivy apps, running in cpython runtime built for arm, running in android through the ndk, is totally on the same level imho

untold lodge
#

I think that's probably a reasonable claim.

#

so unity's C# compiles to .NET bytecode, and the android app has a .NET bytecode interpreter in native code.

#

so yeah, I think that sounds more or less analogous to what you guys are doing

mortal bridge
#

and it's certainly possible to build/run pygame and arcade library games as well, as long as someone write the bootstrap and any required recipe to build them in p4a (i think that's more or less done for pygame, though not many people use that, and it's probably not too hard to do so for arcade, if people want it to happen)

untold lodge
#

yes. but what paul said about spending more time trying to get it running on mobile than doing actual game development does probably apply to most non-Kivy frameworks as of today, even though maybe that doesn't need to be the case.

mortal bridge
#

yeah, it's not known if it's trivial or not until somebody try

untold lodge
#

before i knew about kivy and when I did a deep dive down the rabbit hole of writing an app for android with Python, the research I did left me thinking it was probably hopeless. this was many years ago though

#

all the relevant tools seemed like they weren't really mature enough.

mortal bridge
#

there has always been a struggle to have tools that works without flaws, and buildozer/kivy-ios has suffered from that, both platforms like to move things regularly, and make it harder to maintain, and there are enough system differences that for some people it basically work, and for others it's just a painful process of finding what's wrong, these tend to be (understandably) a bit more vocal about their experiences than the former.

#

Things have improved, but i don't think we can claim it's flawless yet.

frozen knoll
#

BeeWare has done work trying on mobile, but getting Python to run well on both iOS and Android without some 3rd party Python app just isn't there yet. I really don't feel like Kivy's there yet. Too many hoops and flaws in my opinion. (Yes, your opinion may vary.) Unity (and other engines like it) makes cross-compiling pretty easy. But there's a TON of back-end things they do to make that happen.

mighty rose
#

@frozen knoll I'm biased towards kivy, but, it really isn't bad to deploy a game onto android or ios. I've created an apk of my game in testing for various android friends and it was no issue, and I have used Kivy for production sales applications, the challenges were minimal there too. I guess I would also need to know how it can improve specifically, if it is lacking for general development. In the context of an approachable game framework, sure I agree with what you've said.

frozen knoll
#

Interesting, last I played around with Kivy (which has been a while) Android was highly frustrating and I never got it to work.

#

Thanks for the updated info.

mighty rose
#

To be clear, I wasn't trying to minimize your opinion or anything, just looking for specifics and seeking to understand your perspective. Everything has room to improve and nothing is perfect, I'm not saying Kivy is. I am pretty passionate about Kivy and have my own opinions about how it could improve, as well.

#

I've been playing with the idea of making something similar to arcade's api for kivy. I still don't know enough about it from a performance perspective, I have a lot to learn, but I believe that discoverability (both in using it and people coming to know about it) is among Kivy's largest weaknesses. The only other I can think of is native platform widgets. Would love to hear feedback from others and try to find solutions on how to improve the framework (kivy)!

mortal bridge
#

I respect the work done by FreakBoy, but i would love for him to respect ours a little more, it's easy to say you are unconvinced by something, until you try to do better and see that yeah, it's just not that simple, kivy is used by a lot of people to build apps, it's not perfect, sure, but it works for a lot of things, and while there are a few hoops to jump through, it's possible to do about anything with it. to my knowledge, no real world app has been developped with BeeWare, the technology he built is impressive for sure, but the goal he set for himself, is in my opinion impossible to achieve, no matter how good you are, and it would have been better to try to cooperate with us more instead of dismissing our work for years on end.
anyway, time to sleep for me.

foggy python
#

@potent ice I believe that Pygame 2 has some new stuff that allows fullscreen scaling with really good performance, but in normal Pygame, you can force stuff to scale by making it fullscreen. If the base resolution is low, the scaled version looks blurry because of how it gets scaled. To fix this, you need to increase the base resolution. Since I do pixel art, I normally render everything at the base resolution for that pixel art and use pygame.transform.scale() to scale and I blit it onto the main surface that gets rendered.

potent ice
#

Ok. So I think they way I am doing it now is acceptable. I render to offscreen surface and copy the the surface into an OpenGL texture. Then I can scale that using nearest interpolation in any way I want.

#

Then I can also to postprocessing in OpenGL if needed

#

(Assuming target platforms are win10, linux, osx)

foggy python
#

just do whatever works. lol

potent ice
#

Yeah, but I will try pygame.transform.scale() now ๐Ÿ™‚

#

2.0.0-dev6 is pretty nice.

potent ice
frozen knoll
#

Nice!

potent ice
#

A geometry shader destroys the dead geometry and we know how many died so we can emit new ones. Can be done with shader or writing data directly from python

#

Was requeted by Daniel Pope who wanted better control over particles in Wasabi2D ๐Ÿ™‚

#

Also it's 3.3 core. No fancy GL needed.

#

Can do more fanciness in 4+, but I don't want to exclude all those people with 5+ year old integrated gpus

frozen knoll
#

I'm hoping to get Arcade to a better performance level by moving some of the sprites via GPU instead of CPU. I'm going to need to learn more about shaders first.

potent ice
#

ah yup. Huge potential there. You can always poke me if you need any input on that

lost needle
#

I'm honestly interested, could you accelerate 4096x4096 square tiles via shaders and storing position as 12-bit half-colors in coordinates of a pixel buffer?

frozen knoll
#

I probably will. I want to get info to the GPU without using Numpy to create the memory block too.

#

@lost needle I use shaders to store sprites in a tiled grid with Arcade. I've had over 400,000 sprites with no problem.

potent ice
#

@lost needle I would believe so, yes

#

There is so much potential with opengl 3.3 core and python. It's an area that hasn't been properly explored. opengl 3.3 is the new opengl 2.1 considering everyone and their mother has at least an integrated gpu supporting it

fierce wraith
#

But compute shaders are even more awesome!!

#

Ive been using them for everything haha

potent ice
#

Yes they are, but then you exclude a lot of integrated GPUs ๐Ÿ™‚

#

Integrated gpus in the last 2-3 years have them I think. At least AMD Vega supports 4.5 now

fierce wraith
#

Do that many people still have that old hardware?

potent ice
#

Yup

fierce wraith
#

Especially the kind of people that would try out my projects

potent ice
#

Any more info about it other than the link?

sweet elbow
#

@dawn quiver that is very much an ad. please read our rules

potent ice
#

@fierce wraith About the instancing. I am making an example in a bit

fierce wraith
#

Oh awesome! I know moderngl has an example where it renders a bunch of rotating triangles but Id love a modernglmodern window example :)

potent ice
#

Yeah. VAO wrapper variant

fierce wraith
#

Yup!

frozen knoll
#

Anyone played around with shadertoy? That looks like a decent way to learn.

potent ice
#

Yup

fierce wraith
#

Yup. Its awesome to test if one part of the shader works

#

But most of the time my bugs are not in the shader code, just because they tend to be pretty simple for me :)

potent ice
#

You learn a lot about GLSL playing with shadertoy, but you don't learn much about the GL pipeline (other shader types like vertex, geometry and tessellation). You definitely learn how to take advantage of the fragment shader.

#

Still, it's a nice tool for learning, but very focused on fragment shader.

#

It's just an application that can render shadertoy projects and support automatic reloading. I could not use shadertoy on the train, so I made this one ๐Ÿ™‚

frozen knoll
#

Ah yes! Thanks for sharing your shadertoy project.

round obsidian
#

+1 on all this!

frozen knoll
#

Arcade 2.2.3 is out. Supports hitboxes scaling and rotating with the sprite. Internally imports are done in a more proper Python fashion.

potent ice
#

It's all about the /i suffix in the buffer format. Data will be passed per instance instead of per vertex

frozen knoll
#

Where is programs/cube_simple_instanced.glsl

potent ice
#

examples/resources

#

I should probably make that more obvious. hmmm

frozen knoll
#

Not to be dumb, but I don't see that directory:

potent ice
#

oh, the examples I posted is in moderngl-window, not moderngl

frozen knoll
#

Thanks, I should have seen that.

potent ice
#

It's sunday, you'll get a pass ๐Ÿ˜„

frozen knoll
#

I need a fast buffer to pass data back and forth between sprite objects and the graphics card. Right now I build one using Numpy when it changes. That's not very efficient.

#

I tried just pulling the data from the numpy array, but that turned out to be slower. Doing get/set on numpy was slower than using regular variables in Python and rebuilding the array later.

#

I'm not sure the fastest buffering solution. I've tried doing things in C, but that is a headache and makes distribution difficult.

potent ice
#

Have you thought about using transform feedaback for some things?

frozen knoll
#

I'm not sure how that would help?

#

Right now data goes one-way

potent ice
#

What data do you need to update on the gpu?

frozen knoll
#

Python objects -> Numpy -> Buffer for GPU

#

Position of the sprites

#

Position, angle, size, sub texture coordinates, and color.

potent ice
#

Ok, so those positions are set by the user in python then?

frozen knoll
#

Yes.

potent ice
#

Interleaved buffer?

frozen knoll
#

Yes

#

buffer_type = np.dtype([('position', '2f4'), ('angle', 'f4'), ('size', '2f4'), ('sub_tex_coords', '4f4'), ('color', '4B')])

#

Building that buffer is a big bottleneck for me.

#

Keeping the buffer, and updating it live is, oddly, even slower.

potent ice
#

Where is the actual sprite geometry?

#

I'm guessing the data you describe above is per sprite instance?

frozen knoll
#

Right. Position and size cover the geometry.

#

The full building of the buffer is here:

#

There's just got to be a better way to do it.

#

And I'd love to get the position to be updated on the GPU, and then fed back to the Python objects if that would speed things up.

potent ice
#

How often is that method called?

#

oh and do you have any test for profiling performance of sprite rendering? I remember you posted some nice graphs for collision, so I would guess you have something for this as well? ๐Ÿ™‚

#

Not graphs, but at least some small example stressing the sprite system

fierce wraith
#

@potent ice so right now I have this:

self.render_vao.buffer(self.buffer1, '3f8 3f8 3f8 1f8', ['in_position', 'in_velocity', 'in_force', 'in_mass']) self.render_vao.buffer(self.color_buffer, '4f', ['in_color'])

The only thing used in the shader to render them is the position and the color

#

I dont quite unterstand how the data is passed per instance

potent ice
#

You map the buffer with a format using a /i suffix

#

I guess you could just pass in the buffer above. You just need to pad it in the format string 3f8 7x8/i

#

sphere.buffer(self.buffer1, '3f8 7x8/i', ['planet_pos']) maybe

#

Then a new in dvec3 planet_pos is passed in per planet you render. Add that to the in_position in the vertex shader to make the position offset

fierce wraith
#

Ah

potent ice
#

Then you render the planets with sphere.render(prog, instances=num_planets)

#

Just don't lie about the number of planets. That's a bad idea ๐Ÿ˜„

fierce wraith
#

Hahaha

#

Pluto isnt a planet! ;)

frozen knoll
potent ice
#

ah right. I found the sprite stress tests as well

potent ice
#

hmm yep, so when you reach 6000 sprites the per instance data reaches 240k bytes.

#

Think I see several small things that can be improved as a start

#

I'll see if I can find some time to experiment more. Been poking around to understand things.

#

The particle stress test thingy is perfect!

potent ice
#

@frozen knoll I still don't know where you actually move the sprites.

frozen knoll
#

There's a separate sprite class. If any of those sprites move, it rebuilds the data.

potent ice
#

@frozen knoll I think potentially the movement vectors can be used to transform the buffer on the gpu, but that will of course increase the instanced data 8 more bytes. Then something needs to be done to optimize the full buffer updates.

#

That would only apply to the dynamic sprite lists

#

hmm yeah I think there is a lot we can do here!

#

and your opengl wrappers kind of looks like moderngl light, so they were easy to understand ๐Ÿ™‚

#

It could actually be beneficial to separate the instanced data into several buffers. If we somehow can know what data is "dirty" it can be optimized more... but time will show

frozen knoll
#

Right, that makes sense. That would reduce the amount of data put together. I'll give that a try.

potent ice
#

@frozen knoll I'd try to implement a transform(target_buffer) method in the VAO class

#

Then you probably end up with 2 buffers in the sprite list you can transform between

#

like pouring vertex data between buckets with a transform filter applying the movement vectors to the position

#

You can probably use moderngl as a reference.

#

What I still don't understand is what exactly triggers a full rebuild

potent ice
#

Some other small things that helps is consuming generator data with (numpy arrray) fromiter(generator, dtype count=n) to avoid building lists in memory first.

#

@frozen knoll Also I see you are using tobytes() in some places. numpy arrays can be passed with ctypes void_p directly because they support the buffer protocol.

#

Fixing up a lot of those small things quickly adds up

potent ice
#

I'd store the buffers in the spritelist as well and reuse them.

#

There is also some interesting concept with destroying geometry using the geometry shader in transform feedbacks. That can definitely be taken advantage of in some way.

#

During a transform you can discard instances and get a count back of how many instances was emitted

#

so the output buffer can contain less elements than the input buffer

#

That's a very efficient way to prune a list on the gpu. Since you know the number of primitives emitted during the process you can use this information for various other things.

frozen knoll
#

Hey, thanks for the feedback. I'll parse through it tomorrow.

hidden juniper
#

What combination of languages are best for game development? Preferably something on an indie scale for starters.