Giter Site home page Giter Site logo

flappy-rust's Introduction

Flappy Rust

Flappy Rust is a mostly complete clone of Flappy Gopher which is a clone of the famous Flappy Bird game developed in Rust with bindings for SDL2.

Flappy Rust

This repo was built significantly faster by referencing Francesc Campoy's version originally based in Go: https://github.com/campoy/flappy-gopher

Why did you write a clone of a clone?

Because I'm home all day after being layed off (along with 70% of the company) on Monday 4/3/2017 and decided to write some code in Rust since it's been on my TODO list AND because I need an outlet for my negative energy.

Features

  • Music soundtrack
  • The game can be paused by pressing P
  • The bird bounces when jumping based on his vertical gravity and speed.
  • Particle effects with additive blending
  • All new background graphics.
  • Work begun to add parallax scrolling.

Thoughts on the Go version vs the Rust version

  • This version's collision detection is complete and has particle effects.
  • Also, I cheated a bit (due to lazy-ness) and simplifed the Scene object and event loop.
  • I also pulled this version off in a single OS thread, no need to add mutexes like Francesc's version.
  • The Go version needs it's main goroutine pinned to an OS thread because Go's runtime is allowed to move goroutines to different threads. If this wasn't done then you'd have the SDL2 event-loop trying to mutate state while Go's runtime mutates state on a competing thread. For more information watch Francesc's video series called Just for Func where he mentions why this is important: https://www.youtube.com/channel/UC_BzFbxG2za3bp5NRRRXJSw
  • By sticking to one thread, the Rust version needs no synchronization and furthermore, I can guarantee the full correctness of the application thanks to Rust's super advanced compiler. This means, even if I introduced more threads to; for example, generate the pipes similar to Francesc's version...the compiler will absolutely stop me from having data-races by refusing to compile. This means I get to sleep better at night than Francesc.
  • I didn't go out of my way to optimize anything yet and I'm vaguely familiar with SDL2 since most of my work back in the day was with SDL1.
  • Also, before anyone starts complaining about the code...I hacked on this in a fit of rage over a few hours...it was just for fun.
  • Shoutout to Francesc Campoy https://twitter.com/francesc?lang=en a developer advocate on the Go team. Check out his video series Just for Func if you love Go.

Installation

Please reference the rust-sdl2 crate which has installation instructions for SDL2 based on your platform: https://github.com/AngryLawyer/rust-sdl2

Additionally, you'll need the following addtional dependencies:

sdl2_ttf sdl2_image sdl2_mixer sdl2_gfx

On OSX:

brew install sdl2_mixer --with-flac --with-fluid-synth --with-libmikmod
--with-libmodplug --with-libvorbis --with-smpeg2

Running

cargo run #Inside the flappy-rust repo.

Images, fonts, and licenses

All the images used in this game are CC0 and obtained from Clipart. You can find atlernative birds in there, so you can mod the game!

The fonts are copied from https://github.com/deano2390/OpenFlappyBird.

This project is licensed under Apache v2 license. Read more in the LICENSE file.

flappy-rust's People

Contributors

deckarep avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

flappy-rust's Issues

/usr/bin/ld: cannot find -lSDL2_image and the like

Arch linux, sdl2 is installed, the "-dev" is installed automatically with sdl2. but:

error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "/home/alex/tmp/flappy-rust/target/debug/deps/flappy_rust-24495436fb6b58aa.0.o" "-o" "/home/alex/tmp/flappy-rust/target/debug/deps/flappy_rust-24495436fb6b58aa" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/home/alex/tmp/flappy-rust/target/debug/deps" "-L" "/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/home/alex/tmp/flappy-rust/target/debug/deps/libsdl2-3b347601ec96a2c3.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/liblazy_static-3b17cb290f94de07.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libc_vec-be496150d8557b7a.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libnum-1dc0cc712369fa49.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libnum_iter-e3d53b72a44dd492.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libnum_integer-bbbfaf8dce75e1b6.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libbitflags-65ddff5d2b91509e.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/librand-c9d9fbdab2355ee4.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libnum_traits-69f4129d46397118.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/libsdl2_sys-ee994632e6c1cf31.rlib" "/home/alex/tmp/flappy-rust/target/debug/deps/liblibc-5dc7b85e748840b4.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-59ddb13a3f650112.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-767b332f5908b01d.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-f398b0d5b9a21c21.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librand-6b4d3f27209030d8.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections-3af8bfb25c05686b.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f1fb18790492c3aa.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-6bc0b2bf6ca2be30.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-ca857c642bda864a.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_unicode-77fac022534befb6.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-9d5fb400d5bdba42.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-9e459e24d06424e8.rlib" "-l" "SDL2_ttf" "-l" "SDL2_image" "-l" "SDL2_mixer" "-l" "SDL2_gfx" "-l" "SDL2" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util"
  = note: /usr/bin/ld: cannot find -lSDL2_ttf
          /usr/bin/ld: cannot find -lSDL2_image
          /usr/bin/ld: cannot find -lSDL2_mixer
          /usr/bin/ld: cannot find -lSDL2_gfx
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `flappy-rust`.

Caused by:
  process didn't exit successfully: `rustc --crate-name flappy_rust src/main.rs --crate-type bin --emit=dep-info,link -ebuginfo=2 -C metadata=24495436fb6b58aa -C extra-filename=495436fb6b58aa --out-dir /home/alex/tmp/flappy-rust/targetbug/deps -L dependency=/home/alex/tmp/flappy-rust/target/dg/deps --extern sdl2=/home/alex/tmp/flappy-rust/target/debdeps/libsdl2-3b347601ec96a2c3.rlib --extern rand=/home/alemp/flappy-rust/target/debug/deps/librand-c9d9fbdab2355ee4.b` (exit code: 101)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.