From e89b6d6890e21851a1d475c6d939a40ca798aa21 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 28 Dec 2016 11:05:46 +0900 Subject: [PATCH] Updated Tutorial:Your first game in Ebiten (markdown) --- Tutorial:Your-first-game-in-Ebiten.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Tutorial:Your-first-game-in-Ebiten.md b/Tutorial:Your-first-game-in-Ebiten.md index e9eba43..ec19173 100644 --- a/Tutorial:Your-first-game-in-Ebiten.md +++ b/Tutorial:Your-first-game-in-Ebiten.md @@ -4,7 +4,7 @@ ![](http://i.imgur.com/NPbjFJp.png) -And Ebiten is a cross-platform library, which means you can run Ebiten on these platforms: +Ebiten is a cross-platform library, which means you can run Ebiten on these platforms: * Desktop: Windows, Mac OS X, Linux * Mobile: Android, iOS @@ -17,7 +17,7 @@ There're already [some examples available on the website](https://hajimehoshi.gi Before we get started, you would need to `go get` the Ebiten package: ```bash -:; go get github.com/hajimehoshi/ebiten +:; go get github.com/hajimehoshi/ebiten/... ``` # Write your first game with Ebiten @@ -26,14 +26,14 @@ Once you got the Ebiten package, you can start to write your own game with Ebite ## Import Ebiten -We'll use Ebiten in our program, so the first thing is to `import` the Ebiten package which we `go get` before, so put this code at the top of your program. +We'll use Ebiten in our program, so the first thing is to `import` the Ebiten package which we `go get`-ed before, so put this code at the top of your program. ```go package main import ( "github.com/hajimehoshi/ebiten" - "github.com/hajimehoshi/ebiten/ebitenutil" + "github.com/hajimehoshi/ebiten/ebitenutil" // This is required to draw debug texts. ) ``` @@ -56,18 +56,20 @@ But hey! It's not done yet, because you'll need to tell Ebiten to run your `upda ## Initialize Ebiten -It's time to configure Ebiten through `ebiten.Run(update, width, height, scale, title)`. This tells which function to loop, what title of our game is, and the size of the window. +It's time to configure Ebiten through `ebiten.Run(update, width, height, scale, title)`. This tells which function to loop, the size of the window, and what title of our game is. -* `update` is the parameter that you would need to pass a function which will always be called at the each of the frame, and yes! We will pass our `update()` function though here. +* `update` is the parameter that you would need to pass a function which will always be called at the each of the frame. We will pass our `update()` function though here. * `width` and `height` are the width and the height of the game window. * `scale` is the value that will scale your game window, for example if you set it as `2` and draw a `16x16` canvas on the screen it'll be rendered as 32x32 (twice larger). * `title` is the title of the game window. -So what are we waiting for? Let's write the following code in your `main()` function! +Let's write the following code in your `main()` function! ```go func main() { - ebiten.Run(update, 320, 240, 2, "Hello world!") + if err := ebiten.Run(update, 320, 240, 2, "Hello world!"); err != nil { + panic(err) + } } ``` @@ -75,7 +77,7 @@ This will generate a 320x240 game window and it will be scaled twice larger (so # Review -Here's the fully example, it's short, isn't it? +Here's the fully example: ```go package main