Browse Source

Add twin-stick shooter tutorial draft

master
Trevor Slocum 4 weeks ago
parent
commit
2cc61e6b37
  1. 7
      config.toml
  2. 130
      content/post/twin-stick-ebiten-tutorial.md

7
config.toml

@ -62,13 +62,8 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id
# Custom social links
[[Params.widgets.social.custom]]
title = "Self-hosted source code"
title = "Self-hosted Git repositories"
url = "https://code.rocketnine.space/tslocum"
icon = "svg/git.svg"
[[Params.widgets.social.custom]]
title = "GitLab"
url = "https://gitlab.com/tslocum"
icon = "svg/gitlab.svg"
[[Params.widgets.social.custom]]

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

@ -0,0 +1,130 @@
---
title: "How to create a twin-stick shooter with ebiten"
#date: 2019-11-26T01:42:18-07:00
categories: [tutorial]
draft: true
---
[![Donate](https://img.shields.io/liberapay/receives/rocketnine.space.svg?logo=liberapay)](https://liberapay.com/rocketnine.space)
[**Code for this tutorial is available here.**](https://code.rocketnine.space/tslocum/twin-stick-ebiten-tutorial/src/branch/master/)
```bash
go get code.rocketnine.space/tslocum/twin-stick-ebiten-tutorial/step-1 # Download and install
~/go/bin/step-1 # Run
```
### Introduction
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?
> 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?
> 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)
### Step 1: Create a new project
#### Initialize go.mod file
`go mod init my.awesome.site/twin-stick-shooter`
#### Install ebiten
`go get github.com/hajimehoshi/ebiten/v2`
#### Create main.go file
```go
package main
import (
"log"
"github.com/hajimehoshi/ebiten/v2"
)
func main() {
// Set window title.
ebiten.SetWindowTitle("Step 1 - Twin-stick shooter tutorial")
// Create a new game.
game := NewGame()
// Run the game.
err := ebiten.RunGame(game)
if err != nil {
log.Fatal(err)
}
}
```
#### Create game.go file
```go
package main
import "github.com/hajimehoshi/ebiten/v2"
// Game represents a twin-stick shooter game.
type Game struct {
}
// NewGame returns a new Game.
func NewGame() *Game {
return &Game{}
}
// 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.
func (g Game) Update() error {
return nil
}
// 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
#### Embed assets
#### Load assets
### Step 3: Create a level
#### Random dungeon generator
#### Add floor and wall sprites
#### Add prop sprites
### Step 4: Add entities
#### Add items
#### Add enemies
### Step 5: Add game mechanics
#### Add health and damage system
#### Add objective
Loading…
Cancel
Save