Browse Source

Update twin-stick tutorial

master
Trevor Slocum 2 months ago
parent
commit
e4d7c4b8eb
  1. 56
      content/post/twin-stick-ebiten-tutorial.md

56
content/post/twin-stick-ebiten-tutorial.md

@ -1,5 +1,5 @@
---
title: "How to create a twin-stick shooter with ebiten"
title: "How to create a twin-stick shooter game with Ebiten"
#date: 2019-11-26T01:42:18-07:00
categories: [tutorial]
draft: true
@ -16,21 +16,32 @@ go get code.rocketnine.space/tslocum/twin-stick-ebiten-tutorial/step-1 # Downloa
### Introduction
This tutorial explains how to create a basic twin-stick shooter video game using [ebiten](https://ebiten.org).
This tutorial explains how to create a basic twin-stick shooter video game using [Ebiten](https://ebiten.org).
**Note:** This tutorial is incomplete.
#### What is ebiten?
#### What are twin-stick shooter video games?
> Multidirectional shooters with one joystick for movement and one joystick for firing in any direction independent of movement are called twin-stick shooters.
>
>     -[Wikipedia](https://en.wikipedia.org/wiki/Shoot_'em_up)
#### What is Ebiten?
> Ebiten is an open source game library for the Go programming language. Ebiten's simple API allows you to quickly and easily develop 2D games that can be deployed across multiple platforms.
>
>     -[ebiten.org](https://ebiten.org)
#### What is a twin-stick shooter game?
#### Why use Ebiten instead of ____?
> Multidirectional shooters with one joystick for movement and one joystick for firing in any direction independent of movement are called twin-stick shooters.
>
>     -[Wikipedia](https://en.wikipedia.org/wiki/Shoot_'em_up)
Ebiten's design is simple: each component of the library is contained in its own package.
This requires developers to write a little extra code compared to "batteries included" type frameworks,
but Ebiten adheres to the deign principles of Go:
- Each package operates independently (packages are not tightly coupled)
- Each package provides a primitive (e.g. audio, image and vector) or utility (e.g. inpututil, )
-
### Step 1: Create a new project
@ -38,7 +49,7 @@ This tutorial explains how to create a basic twin-stick shooter video game using
`go mod init my.awesome.site/twin-stick-shooter`
#### Install ebiten
#### Install Ebiten
`go get github.com/hajimehoshi/ebiten/v2`
@ -84,30 +95,45 @@ func NewGame() *Game {
return &Game{}
}
// Layout is called by ebiten when the game starts, and every time the game state is updated.
// Layout is called by Ebiten when the game starts, and every time the game state is updated.
func (g Game) Layout(width, height int) (int, int) {
// Scale the size of the screen to support high-DPI displays.
s := ebiten.DeviceScaleFactor()
return int(s * float64(width)), int(s * float64(height))
}
// Update is called by ebiten to update the game state.
// Update is called by Ebiten to update the game state.
func (g Game) Update() error {
return nil
}
// Draw is called by ebiten to draw the game onto the screen.
// Draw is called by Ebiten to draw the game onto the screen.
func (g Game) Draw(screen *ebiten.Image) {
// We aren't drawing anything yet.
}
```
### Step 2: Embed and load assets
#### Find some assets
#### Audio assets
- bat sound
##### Find some assets
##### Embed assets
##### Load assets
#### Embed assets
#### Image assets
#### Load assets
##### Find some assets
##### Embed assets
##### Load assets
- display sprite
### Step 3: Create a level
@ -128,3 +154,5 @@ func (g Game) Draw(screen *ebiten.Image) {
#### Add health and damage system
#### Add objective
Bat Blaster

Loading…
Cancel
Save