resizing/aspect

(I already did searches for the last 1-2 hours but didnt find anything that helped me, so please dont be angry with me :slight_smile: )

Im currently working on a little game and ive got a little window resizing issue.

for an example:

i use a variable called norm_value_x and y calculated from the distance of the (static) camera node to 0,0,0. (tangens(20°)*distance to (0,0,0))

so if i have the camera at (0,-100,0) norm_value_x would be something like 33(divided by 50, so -50*norm value_x is the left side). this way i can place objects in a pseudogrid from -50 to +50.
(i didnt come up with anything better, so if there is, pls tell me)

as soon as the window is resized, (as far as i understood it) the camera settings are changed from 4:3 to whatever you drag the window to. now norm_value_x and y arent correct anymore and i can dump my whole idea.

so my questions: can you forbid window resizing somewhere in the game code?
or more important: is there a better solution than introducing those variables?

if there is a post with good enough answers pls just post a link and thanks for any help in advance!

There are several answers. The easiest might be to listen for the “aspectRatioChanged” event, and re-compute your grid when you hear it.

Another answer is to hard-code a specific aspect ratio in your Config.prc file, for instance:

aspect-ratio 1.333

Then Panda won’t auto-adjust the aspect ratio when the window is resized; instead, it will just stretch the contents accordingly.

A third answer is to actually disallow window resizing, by explicitly creating a window with the fixedSize property. This is a little more involved, since there’s not a config variable setting to do this automatically; and it’s also not very friendly to the user. So I don’t recommend this answer.

David

thx alot :slight_smile:
(there really should be a donation button for david :slight_smile: )