
ZPanic0
Hands-on Rust: Does Flappy Dragon need to crush a core?
I am finding that when I run the completed Flappy Dragon project, one of my cpu cores is pinned. It seems like we are running the simulation just as fast as a single thread can muster. Does Rust have the tools to reduce or avoid this? It seems like a lot of our “ticks” may not be meaningful relative to the previous one.
Most Liked

herbert
Thanks for the report. This was a tricky one when I was setting up the chapter; I wanted to include timing, as a teaching vehicle for tackling that side of things. I also wanted to keep it simple - avoid overloading the reader too much with the introductory game.
You can greatly reduce the amount of CPU usage by adding .with_fps_cap(30.0)
to the builder call in main()
. That adds CPU sleep time in between frames.
I’ll do a bit of testing/playing around and see what the impact would be on the book as a whole to include this in by default.
Popular Prag Prog topics







Modern Front-End Development for Rails - application does not start after run bin/setup (page xviii)

Modern front-end development for Rails, second edition - Struggling to get the first chapter to work


Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /zig
- /scala
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /ubuntu
- /revery
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim