Giter VIP home page Giter VIP logo

flappy-gopher's Introduction

Flappy Gopher

Flappy Gopher is a clone of the famous Flappy Bird game developed in Go with bindings for SDL2.

Recordings

You can learn more about the game and how it was implemented watching the three episodes dedicated to it.

Installation

You need to install first SDL2 and the SDL2 bindings for Go. To do so follow the instructions here. It is quite easy to install on basically any platform.

You will also need to install pkg-config.

After that you should be able to simply run:

go get github.com/campoy/flappy-gopher

And run the binary generated in $GOPATH/bin.

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.

Disclaimer

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

flappy-gopher's People

Contributors

campoy 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  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  avatar  avatar

flappy-gopher's Issues

Failed loading libpng16-16.dll

I have successful install https://github.com/veandco/go-sdl2
and pass its test: cd go/src/github.com/veandco/go-sdl2/examples/events and run go run events.go

The sample project need adjust imports to below per latest go-sdl2:
"github.com/veandco/go-sdl2/ttf"
"github.com/veandco/go-sdl2/img"

And then I try build and run your sample, I encounter below issue:
could not create scene: could not load background image res/imgs/background.png : Failed loading libpng16-16.dll: 找不到指定的程序。

And I find the dll does in my SDL folder.
Anyway, I try copy that dll to same sample folder and run again to avoid issue, however, the issue still happen.

Btw, I am sure the background image existing.

I use Win10 64 bit, Go 1.9.2.

I try test SDL again, and find texture sample success load bmp file.
But the texture_png sample failed. So should be SDL go binding itself failed.

go-sdl2 not rendering in goroutines on Ubuntu

I think I found an issue (hopefully it is not just my machines). I am running Ubuntu 17.04 64 bit. The title renders properly but the scene never renders when called inside of a goroutine. Adding runtime.LockOSThread() didn't help. I think I found the proper solution. This is from the go-sdl2 FAQ

Recent update added a call queue system where you can put thread-sensitive code and have it called synchronously on the same OS thread. See the render_queue or render_goroutines examples to see how it works.

Following the render_goroutines example I was able to get it to work. I'm not sure if it is the best way to do it.

bug in `go-sdl v0.3.0` stops compilation on macos

hi francesc,

love your youtube series and all the cool golang related discussions. Thanks for making that all available. Trying to follow along with flappy-gopher tutorial and just downloaded and installed your repo for reference... #covid19 plan: implement a version of this with custom-made artwork 😄

on macos (i am on high sierra at the moment), the go-sdl version has a small bug. simply updating that dependency to v0.3.1 makes everything work:

require github.com/veandco/go-sdl2 v0.3.0

-d

for reference, error message is this:

# github.com/veandco/go-sdl2/sdl
../../../../pkg/mod/github.com/veandco/[email protected]/sdl/hints.go:86:50: could not determine kind of name for C.SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH

optimize pipes update func

I just watched the videos after 4 years of their release and they are great !!

In your pipes update function, instead of checking all your pipes to see if they are offscreen, you can just check the first element in your pipes array. Since you are appending to it in the back and your pipes start at 800, only your first pipe can be out of screen.

so your function should be:

func (ps *pipes) update() {
	ps.mu.Lock()
	defer ps.mu.Unlock()

	for _, p := range ps.pipes {
		p.mu.Lock()
		p.x -= ps.speed
		p.mu.Unlock()
	}
	if ps.pipes[0].x-ps.pipes[0].w < 0 {
			ps.pipes=ps.pipes[1:]
        }
	
}

That saves you assigning to pipes for every run and your off screen check only runs O(1) instead of O(n).

Compatibility issue with veandco/go-sdl2

Seems like the go-sdl library is under heavy reconstruction, using gopkg.in/veandco/go-sdl2.v0 as suggested is not enough to make this work right out of the box: the code there calls on github.com/veandco/go-sdl2.

Get errors such as this when following the steps in here:

./bird.go:45:34: cannot use r (type *"gopkg.in/veandco/go-sdl2.v0/sdl".Renderer) as type *"github.com/veandco/go-sdl2/sdl".Renderer in argument to img.LoadTexture

Happy to try fixing it, any suggestions?

How do you package that kind of application for release ?

Hie @campoy ,

I really enjoy your video serie JustForFunc. I started golang a few weeks ago and I made a video game, using sdl2 go bindings (like your flappy-gopher) : topheman/gopher-ball.

I'm on a Mac, it works, no problem. But how do you build then package this kind of go application so that you could distribute a binary to friends that don't have go, neither sdl2 intalled ?

You would have to ensure:

  • embedding the assets (might differ according to the platform - like on Mac OS X .app files have some specific folder structure)
  • statically linking the c++ library sdl2 (might need the version of the other platform while compiling cross platform ?) - installed mine with HomeBrew
  • compiling cross platform

While searching, I've come accross go-bindata. Is that the way, isn't there some builtin way to do that (Build flag ? Makefile ?) - it only manage assets (not sdl2 lib).

It's not clear how you should do it and you don't find often repos that go all the way to publishing.

Again, thanks a lot for your videos,

If you have any info about this matter (or if you could point me to some resources that I missed), please do,

Tophe

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.