mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
Updated Your first game in Ebiten! (markdown)
parent
e492b4db6a
commit
d7333bfa97
@ -1,6 +1,6 @@
|
|||||||
# What is Ebiten?
|
# What is Ebiten?
|
||||||
|
|
||||||
[Ebiten (海老天)](https://github.com/hajimehoshi/ebiten) is a 8-bit game library written in Golang, and you might wondering what is "海老天", Hmm.. it's actually shrimp of Tempura (≒ fried shrimp) in Japanese 🍤.
|
[Ebiten (海老天)](https://github.com/hajimehoshi/ebiten) is a 8-bit game library written in Go, and you might be wondering what is "海老天", Hmm.. it's actually shrimp of Tempura (≒ fried shrimp) in Japanese 🍤.
|
||||||
|
|
||||||
![](http://i.imgur.com/NPbjFJp.png)
|
![](http://i.imgur.com/NPbjFJp.png)
|
||||||
|
|
||||||
@ -8,13 +8,13 @@ And Ebiten is a cross-platform library, which means you can run Ebiten on these
|
|||||||
|
|
||||||
* Desktop: Windows, Mac OS X, Linux
|
* Desktop: Windows, Mac OS X, Linux
|
||||||
* Mobile: Android, iOS
|
* Mobile: Android, iOS
|
||||||
* Web browser: Chrome and Firefox (GopherJS)
|
* Web browser: Chrome and Firefox (powered by GopherJS)
|
||||||
|
|
||||||
There're already [some examples available on the website](https://hajimehoshi.github.io/ebiten/#examples), and you can also found the [documentation of Ebiten by clicking here](https://godoc.org/github.com/hajimehoshi/ebiten).
|
There're already [some examples available on the website](https://hajimehoshi.github.io/ebiten/#examples), and you can also found the [documentation of Ebiten by clicking here](https://godoc.org/github.com/hajimehoshi/ebiten).
|
||||||
|
|
||||||
# Get Ebiten package
|
# Get Ebiten package
|
||||||
|
|
||||||
Before we started, you would need to `go get` the Ebiten package:
|
Before we get started, you would need to `go get` the Ebiten package:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
:; go get github.com/hajimehoshi/ebiten
|
:; go get github.com/hajimehoshi/ebiten
|
||||||
@ -39,11 +39,11 @@ import (
|
|||||||
|
|
||||||
## Screen update and display
|
## Screen update and display
|
||||||
|
|
||||||
Anything in the game is **always being updating** (or refreshing), sometimes you can heard people talked about FPS, it means **frames per second**, we would have to **clean the previous screen** and **refresh the screen** each time **we move an element**, so **the element won't leave a long track** on the screen like a snake 🐍.
|
Anything in the game is **always being updating** (or refreshing). Sometimes you can hear people talking about FPS, which means **frames per second**. We would have to **clean the previous screen** and **refresh the screen** each time **we move an element**, so **the element won't leave a long track** on the screen like a snake 🐍.
|
||||||
|
|
||||||
If we want to display a text on the screen, **it will be disappeared before we see it**, Why? Because we didn't **keep it on the screen** to do this, we'll need to call a `update()` function **per frame**, then put our code inside of the function, so the text will keep on the screen.
|
If we want to display a text on the screen, **it will be disappeared before we see it**. Why? Because we don't **keep it on the screen** to do this, we'll need to call a `update()` function **per frame**, then put our code inside of the function, so the text will keep on the screen.
|
||||||
|
|
||||||
To display a text, we can use `ebitenutil.DebugPrint(image, text)`, which is a function for **displaying a debug information**, but we can use it to display a text also.
|
To display a text, we can use `ebitenutil.DebugPrint(image, text)`, which is a function for **displaying a debug information**, but we can also use it to display a text.
|
||||||
|
|
||||||
```go
|
```go
|
||||||
func update(screen *ebiten.Image) error {
|
func update(screen *ebiten.Image) error {
|
||||||
@ -59,7 +59,7 @@ But hey! It's not done yet, because **you'll need to tell Ebiten to run your `up
|
|||||||
|
|
||||||
## Initialize Ebiten
|
## Initialize Ebiten
|
||||||
|
|
||||||
It's time to configure Ebiten through `ebiten.Run(update, width, height, scale, title)`. This tells **what function to loop**, what title should our game be, 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**, what title of our game is, and the size of the window.
|
||||||
|
|
||||||
* `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**, and yes! **We will pass our `update()` function though here**.
|
||||||
* `width` and `height` are the **width** and the **height** of the game window.
|
* `width` and `height` are the **width** and the **height** of the game window.
|
||||||
|
Loading…
Reference in New Issue
Block a user