Replies: 2 comments
-
| 
         Very cool idea, yes i would imagine that it would be really hard on the refresh rate.  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| 
         Maybe it helps if you change the order within the loop running in each animation frame to: 
 That way, the computation and (probably more relevant) ipc does not happen in between clearing and re-drawing.  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm practicing tauri + rust by implementing mini games and I want to keep as much of the game decisions as possible in rust and only use javascript to animate the game, however my implementation results in the ui flickering as the screen updates state. I'm first working on creating pong and I'm currently separating my game as follows
Frontend
requestAnimationFrameto try and control the fps and redraw the game scenesBackend
I'm sending the game variables to rust via tauri's invoke function and getting back the game state to update the ui for the next step. I've also implemented the game in pure solid.js as well and it runs smoothly. I understand that this is not ideal and expect it to run somewhat slower due to the additional communication overhead but the refresh rate is very noticable - I'd ideally like to offload the entire game loop to rust and only display the game animation in javascript but from my research, some considerable effort is required to get a game engine like bevy to handle the event loop and manage the ui or even a keyboard event listener (winit - I think tauri uses a fork of this somewhere) to play nicely with tauri and it also seems like overkill for my application.
I'm still a beginner to rust, does anyone have any suggestions for my implementation to improve the experience or what is the preferred approach to achieve what I'm trying to do?
I'm using a while loop with
requestAnimationFrameto avoid recursion, when I reduce the refresh rate lower than 9 or when I remove theif (delta < refresh)block, then the ball and paddle don't display on the screenindex.tsx
useGame.tsx
utility.ts
services.rs
game window for pure solid.js implementation (inside a tauri app)
solid-js-pong.mp4
game window for tauri implementation
tauri-pong.mp4
=====================================================================
Here is the output of my tauri info
=====================================================================
Beta Was this translation helpful? Give feedback.
All reactions