Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / separate RENDER of LOGIC (they are not best friends) :)

Author
Message
Santiago3D
3
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 3rd Jun 2020 01:23
Hello, how are you ?, I'm here programming, accordingly.

I am now needing to separate my logic from my renders.

I do this, because I maintain a logic FPS at 60 fps, so the game always runs at the same speed.

but I run render only when I can, depending on what each render takes. but I avoid that it does not delay my game.

and the logical fps, can be as many as the pc wants.


in blitz, to give an example I did the following.





but in agk, i can't find how to update everything except the render.
if I use SYNC () it renders me and everything.


this is my main loop function
update_fps makes all calculation to decide if i render or i need to calculate logic




so, will be good to have an example of how is a correct loop with separate render and sync update objects, and logics
haliop_New
User Banned
Posted: 3rd Jun 2020 17:14
Please check the documentation of Sync()
You will see inside it the following :

Render()
Update2D()
Update3D()
Draw()
ClearScreen()
And Swap()
Etc,
All of these commands are automatically called by Sync()
But you can separate them in a fashion you would like.

I think there might be additional commands.

Give it a look
Santiago3D
3
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 3rd Jun 2020 20:17
Hello Haliop_New. thanks, but help no help to much...,I can assure you that I have read the help more than 20 times, of all the commands on the subject.
I am not an expert in the subject "CORE", I am testing, by force of trial and error, to find that my code works to have a constant speed of logic, and to regulate the renders of the game.

this function, it worked well for me in B3d, I am sure that if I understood better about CORE, buffers, and others, this would be easier for me.

I share a code, which I used in Blitz3D to make my games run fast on slow computers.
Not having limits in the main-loop, it was also very useful to measure the performance of the resources and handle the optimization of the game more efficiently.

Basically, what my program would do is.

Calculate logic at a constant frequency per second
Render whenever you can, without luring logic
and that the fps of the main loop have no limits.



this code works perfect, if someone know how to put correctly in place and orders this commands:
draw
render
swap
ender2dback
render
2dfront
cleardepthbuffer
update 2d
update3d
u hope don't forget any command...



Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 3rd Jun 2020 20:43
I think what your hinting at is a threaded application, which is not possible in AGK. The best you can do, I think, is set all your logic functions to be variable based on the render time, or FPS. So of you want a target of 60 fps, and the character moves forward 10 units.....if the fps is 45 then you multiply the forward movement by 1.25. That way your game logic will appear to be the same regardless of fps.
Santiago3D
3
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 3rd Jun 2020 20:51
Quote: "I think what your hinting at is a threaded application, which is not possible in AGK."

what this mean?, sorry, my english and technicals words are very poor.


i don't see why that is not posible, in blitz3D with directx7 perfectly works.
and AppGameKit have very much functions to control this issue, so, must be possible!, IT MUST BE!!! , im have a great logic faith about this.

this is realy simple, just i don't understand how works de AppGameKit functions.





Santiago3D
3
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 3rd Jun 2020 21:00 Edited at: 3rd Jun 2020 21:01
Quote: "if the fps is 45 then you multiply the forward movement by 1.25. "



I have used this method in the past, but I did not have good results.

mainly because it generates an ECO effect on the speeds, as with a latency, which is not a practical effect for simulation games.

In the post that discord shared with me today, it has the same approach.

Eejit share this in discord : post

not use all processing frames, relieve the whole system.

I use my function in my BLITZ3D games very successfully, on computers that render at 5 fps, but the game speed remains at 60fps.

This is a code, which by default, should be included in all engines.
Santiago3D
3
Years of Service
User Offline
Joined: 11th May 2020
Location: Argentina
Posted: 3rd Jun 2020 21:45
this we are discussing in Discord but i share here too.

i give a graphics example of one of my games



using the same code, but in blitz
1 system fps : 180337 (times my main loop repeats per seconds)
2 logic fps : 58 to calculate all physics and move, rotation, etcs.
3 RENDER, in this case, limited to 60, but vertical sync is off allways
4 GUI_UPDATE, i use all 2d interface on a screen image, and only update sometimes.
this if the renders is slower



9 fps of render, but logic keep runnin 60
and this is Tora Tora, old version in b3d, with the same code




the Renders FPS go fron 20 to 60 all the time, but you don't feel that because logic maintain stable
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 3rd Jun 2020 23:38
No, I dont think it is, unless you REALLY take control of the render pipeline. Let's take Frontier on the Amiga......it updated at as little as 1 fps.....but objects moved the same distance they would have if it were running at 60 fos.

I use the exact method described above and it works fine - from frames rates of 400 fps to 20 fps movement speeds etc can be scaled based on the frame time. This is also used for animation, particles etc.

The key is making as many functions as possible in your logic able to span multiple frames. For example, I wrote an A* pathfinding routine, then changed it to function over as many frames as was needed, but gave it a maximum amount of time for any one frame. Without this, when an enemy needed to pathfinder there was a pause, with it there was no pause but it just could take a few frames.
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 3rd Jun 2020 23:39
But if what you want, as I suspect, is to have screen updating happen asynchronisly to core code, I think youd have to go to tier 2.
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 4th Jun 2020 02:59
You can do this in T1.

I have functions that can work at any arbitrary frame rate.
For general games, i have a main loop working at max, which includes update/render.
I can a 60fps function which runs any other function which is happy at 60 fps (which is most control functions for the game).

Pretty much the only functions in the main loop are:

Timer updates
AGk Update
Render update
Input collection
Call my custom 60 (or whatever) function

Frame rate independent update is fine in AGK
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 4th Jun 2020 09:47
Years ago I started coding with AMOS, and within this it had AMAL. AMAL had the ability to run graphics code seperate to the main code, kind of like the first programmable shaders before they were thing. So you graphics ran in another process, and were completely unaffected by other code. I've never used Blitz, but I think that's what Santiago3D is looking for. So in your example, your custom 60 function is timing at the same time as the render.
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 4th Jun 2020 13:59 Edited at: 4th Jun 2020 14:04
Quote: "So of you want a target of 60 fps, and the character moves forward 10 units.....if the fps is 45 then you multiply the forward movement by 1.25."

Wouldn't 1.33 or even 1.34 be closer than 1.25?

We would need to add one third of the 45 (15) to get to the 60 target, right?



@ Santiago3D
Do you make your own models or buy them?

I only ask because they look very nice.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Santman
12
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 4th Jun 2020 18:46
Conjured, you're probably right- that was off my head. In code I do it is an actual floating point sum as the frame time varies, but i used it as an example.

Login to post a reply

Server time is: 2024-04-25 11:53:10
Your offset time is: 2024-04-25 11:53:10