EngoEngine / engo

Engo is an open-source 2D game engine written in Go.
https://engoengine.github.io
MIT License
1.76k stars 136 forks source link

Mint Linux/Ubuntu setup error #198

Closed F483 closed 8 years ago

F483 commented 8 years ago

I'm new to go (learning by making a game with engo) so it may be a misunderstanding on my part.

$ sudo apt-get install libopenal-dev libglu1-mesa-dev freeglut3-dev mesa-common-dev xorg-dev libgl1-mesa-dev golang gccgo-go
$ go get -u engo.io/engo
# github.com/go-gl/mathgl/mgl32
../go/src/github.com/go-gl/mathgl/mgl32/mempool.go:12: undefined: sync.Pool
../go/src/github.com/go-gl/mathgl/mgl32/mempool.go:29: undefined: sync.Pool
../go/src/github.com/go-gl/mathgl/mgl32/mempool.go:41: undefined: sync.Pool
# github.com/luxengine/math
../go/src/github.com/luxengine/math/sqrt_amd64.s:6 6a: No such file or directory: textflag.h
# golang.org/x/mobile/internal/mobileinit
../go/src/golang.org/x/mobile/internal/mobileinit/ctx_android.go:8:17: fatal error: jni.h: No such file or directory
 #include <jni.h>
                 ^
compilation terminated.
otraore commented 8 years ago

@F483 What go version are you running? I know that apt-get uses an older version of go so that might be the issue.

F483 commented 8 years ago
$ go version
go version go1.2.1 linux/amd64
otraore commented 8 years ago

That's why @F483 Follow these instructions: https://www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-14-04

I'll put them here just in case: But first make sure you uninstall go1.2.1 by running

sudo apt-get uninstall golang && sudo apt-get uninstall gccgo

sudo apt-get update
sudo apt-get -y upgrade
sudo curl -O https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
sudo tar -xvf go1.6.linux-amd64.tar.gz
sudo mv go /usr/local
sudo nano ~/.profile
export PATH=$PATH:/usr/local/go/bin
` ``
After that just set your GOPATH environmental variable (Where all your Go code will live) example: ~/Go or ~/Documents/Go or ~/GoCode all up to you. Let me know how it goes.
F483 commented 8 years ago

Thanks that seemed to work.

otraore commented 8 years ago

Alright glad that you've got that fixed! @F483

F483 commented 8 years ago

I now get the following though when I try to run the Getting Started example.

$ go run main.go
main.go:6:2: cannot find package "github.com/engoengine/ecs" in any of:
    /usr/local/go/src/github.com/engoengine/ecs (from $GOROOT)
    /home/f483/dev/go/src/github.com/engoengine/ecs (from $GOPATH)
main.go:7:2: cannot find package "github.com/engoengine/engo" in any of:
    /usr/local/go/src/github.com/engoengine/engo (from $GOROOT)
    /home/f483/dev/go/src/github.com/engoengine/engo (from $GOPATH)
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/f483/dev/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
otraore commented 8 years ago

@F483 Easy fix, the getting started needs to be fixed: change your imports to engo.io/engo and engo.io/ecs respectively. I'd recommend you look at the site for tutoraisl (engo.io)

Edit: updated the wiki

F483 commented 8 years ago

I replaced it with this and get the following error.

$ go run main.go 
# command-line-arguments
./main.go:34: cannot use myGame literal (type *myGame) as type engo.Scene in argument to engo.Run:
    *myGame does not implement engo.Scene (missing Exit method)
otraore commented 8 years ago

@F483 Just add:

func (*myGame) Exit() {}

Sorry about this, this is a recent change and not every example has been updated.

F483 commented 8 years ago

No problem, glad to help find the documentation errors.

Now it works but I cant close the window (via button or ctrl-c). It keeps printing the following output:

2016/04/14 14:17:31 Warning: default close action set to false, please make sure you manually handle this

I had to kill the process :/

otraore commented 8 years ago

@F483 May I see your source code?

F483 commented 8 years ago
$ cat main.go 
package main

import (
    "engo.io/ecs"
    "engo.io/engo"
)

type myGame struct{}

// Type uniquely defines your game type
func (*myGame) Type() string { return "myGame" }

// Preload is called before loading any assets from the disk,
// to allow you to register / queue them
func (*myGame) Preload() {}

// Setup is called before the main loop starts. It allows you
// to add entities and systems to your Scene.
func (*myGame) Setup(*ecs.World) {}

// Show is called whenever the other Scene becomes inactive,
// and this one becomes the active one
func (*myGame) Show() {}

// Hide is called when an other Scene becomes active
func (*myGame) Hide() {}

func (*myGame) Exit() {}

func main() {
    opts := engo.RunOptions{
        Title:  "Hello World",
        Width:  400,
        Height: 400,
    }
    engo.Run(opts, &myGame{})
}
otraore commented 8 years ago

@F483 I know the issue, I'm on it right now.

otraore commented 8 years ago

@F483 In the meantime add this to your Exit() function:

engo.Exit()

I am in process of sending in a pull request to fix that issue.

F483 commented 8 years ago

Thanks!

otraore commented 8 years ago

@F483 Would you mind joining the gitter chat, I'd like to talk to you beyond this PR. (https://gitter.im/EngoEngine/engo)

otraore commented 8 years ago

Update: with https://github.com/EngoEngine/engo/pull/199 you don't need to manually exit the engine anymore unless you set the default close action to false. so @F483 run the following to update to the latest version:

go get -u engo.io/engo