Adding (add-hook! quit-hook abort-game) worked flawlessly, thanks. Can I do anything to help Chickadee to recognize my monitor refresh rate?
On 04.09.2018 21:22, Thompson, David wrote: > Hello Zelphir, > > First, thanks for trying Chickadee! > > On Tue, Sep 4, 2018 at 2:34 PM, Zelphir Kaltstahl > <[email protected]> wrote: >> On my system Chickadee seems to build fine with the usual configure, >> make, make install. However I want to mention something, which might >> indicate a problem. >> >> When I run the example code: >> >> ~~~~~ >> (use-modules (chickadee) >> (chickadee math vector) >> (chickadee render sprite) >> (chickadee render texture)) >> >> (define sprite #f) >> >> (define (load) >> (set! sprite (load-image "logo.png"))) >> >> (define (draw alpha) >> (draw-sprite sprite (vec2 256.0 176.0))) >> >> (add-hook! load-hook load) >> (add-hook! draw-hook draw) >> >> (run-game) >> ~~~~~ > (Just a heads up: Chickadee 0.3.0 will be released soon and it will > remove the add-hook! stuff. It's an easy change, but be sure to refer > to the updated example code when 0.3.0 is released!) > >> It works and the sprite is rendered, however, one core is used to 100%. >> I guess the game loop is rendering the sprite over and over again in a >> non-updated position. > Correct, the game loop doesn't stop because you're not moving > anything. Chickadee's game loop renders frames as often as possible. > If 100% of one CPU core is being used, the likely culprit is that > Chickadee was unable to sync it's drawing with the monitor's refresh > rate, which could cause it to pause a bit after rendering each frame. > Perhaps I could automatically factor in a small usleep call when vsync > is unavailable in order to avoid this situation. > >> Another thing is, that I cannot click the close button of the window >> that renders the sprite. I guess because I do not handle the closing >> event in this example code. I need to close it by C-c C-c in my Eshell. > Yes, that's exactly why. The quit hook is run when the close button > is pressed, but you haven't added anything to handle that hook. If > you eval (add-hook! quit-hook abort-game) then the game will close > when you click the window's close button. > >> Aside from that it seems to work fine. I would like to see development >> in 2D game engines for Guile. I imagine minimalistic libraries / game >> engines and Guile to be a powerful combination! I always wanted to make >> a game (like probably most people in CS :D). Maybe with Guile and >> Chickadee or similar I can grab some new motivation. So far I have not >> tried to build anything complex with Chickadee, but maybe it is already >> possible. I think it would be cool to have a page listing projects using >> Chickadee, even if those projects are not done or only proofs of concepts. > I don't know of anyone that has built anything particularly complex > with Chickadee, but if anyone has that is reading this please let me > know! > > I call Chickadee a "game toolkit" rather than an "engine" because it's > simply a collection of handy building blocks that you need to piece > together on your own, whereas an engine has already made major > architecture decisions for you. It's more like building your own > furniture than assembling something from IKEA. It's a lot easier to > make a collection of essential game utilities that almost every game > developer needs than it is to design an entire engine, so that's why > Chickadee is what it is. I mentioned elsewhere in this thread that > I'm working on a somewhat minimal game engine built on top of > Chickadee called Starling (sticking with the bird theme) that I think > will help people go from nothing to playable game in much less time. > However, you may not like the abstractions I chose for Starling, but > Chickadee's building blocks will always be there to assemble however > you wish. > > - Dave
