[程式] 四小时学会建置简易PC/Web/Android游戏

楼主: cnoize (泥巴星球Server)   2019-07-25 11:54:24
ebiten 套件原作者是日本人。
少量游戏作品可在 wiki 中找到:
https://github.com/hajimehoshi/ebiten/wiki/Works
很多使用范例可以学习:
https://github.com/hajimehoshi/ebiten/tree/master/examples
0.
前人写的中文教学:
https://yami.io/tag/ebiten/
在 Golang 透过 Ebiten(炸虾)来制作 8-Bit 游戏!
1.
安装 git
https://gitforwindows.org/
2.
安装 GO
https://golang.org/
3.
安装 Android Studio
https://developer.android.com/studio
我是装在 c:\and
装好后 Configure -> SDK -> SDK tools
找到 NDK 勾选它, 选 apply
SDK 我是装在 c:\andsdk
NDK 在 c:\andsdk\ndk-bundle
set ANDROID_NDK_HOME=c:\andsdk\ndk-bundle
或原始目录
set ANDROID_NDK_HOME= \
C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle
4.
安装 gomobile
https://godoc.org/golang.org/x/mobile/cmd/gomobile
go get golang.org/x/mobile/cmd/gomobile
gomobile init
5.
依照上面的中文说明取得 ebiten
set ANDROID_NDK_HOME=c:\andsdk\ndk-bundle
gomobile build -tags=example \
-target=android github.com/hajimehoshi/ebiten/examples/2048
得到 go2048.apk
安装雷电可使用:
https://imgur.com/QbC1uhd
https://github.com/hajimehoshi/ebiten/wiki/Android
https://github.com/hajimehoshi/ebiten/wiki/iOS
https://github.com/hajimehoshi/ebiten/wiki/Mobile
6.
WWW
https://github.com/hajimehoshi/ebiten/wiki/GopherJS
go get github.com/gopherjs/gopherjs
gopherjs 不能用 -tags=example,原作者有设定 example 和系统分开
所以要 copy
cd work
xcopy /s C:\Users\username\go\src\github.com\hajimehoshi\ebiten\examples\2048
set GOOS=linux
gopherjs build -o 2048.js main.go
notepad 2048.htm
<!DOCTYPE html>
<script src="2048.js"></script>
https://www.rejetto.com/hfs/
hfs.exe 2048.htm 2048.js
hfs 会有网址
可用 chrome 开启:
https://imgur.com/w5for3v
7.
PC 原版
go run -tags=example github.com/hajimehoshi/ebiten/examples/2048
https://imgur.com/zhfWiL4
作者: wangm4a1 (水兵)   2019-07-25 13:12:00
作者: lanpadick (懒又如何趴又如何)   2019-07-25 18:32:00
push
作者: justatree (justatree)   2019-07-25 20:17:00
作者: aton602 (南方堂果)   2019-07-25 21:42:00
作者: NX9999 (台中走钟张勋杰)   2019-07-26 01:56:00
感谢,来试试看XD

Links booklink

Contact Us: admin [ a t ] ucptt.com