gorched

package module
v0.0.0-...-1babf2d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2023 License: MIT Imports: 6 Imported by: 0

README

Gorched

Run on Repl.it gorched

Gorched is terminal based game written in Go inspired by "The Mother of all games" Scorched Earth.

showcase

How the game looks like depends on your terminal !

Features

  • rendered in terminal
  • ASCII graphics (actually few unicode symbols were used)
  • procedurally generated world
  • terrain destruction
  • turn based multiplayer

Try online

You can try Gorched online on gorched.zladovan.repl.run.

Performance in online terminal can be worse than in real terminal !

Installation

General

Download archive for your platform from releases page and unpack it to some directory on your file system.

Linux

If you are using snap just run:

sudo snap install gorched
MacOS

If you are using homebrew just run:

brew install zladovan/tap/gorched
Windows

If you are using scoop run:

scoop bucket add zladovan https://github.com/zladovan/scoop-bucket
scoop install gorched

How to start

Just type gorched in terminal or run unpacked binary named gorched respectively gorched.exe.

How to play

Gorched currently has only one mode where two players are playing locally against each other. The goal is to find out correct angle and power to hit the enemy tank. Gameplay is turn based and each player has one attempt per turn. When some player hits the enemy he gains score and game continues in next round with different terrain.

Controls
  • ← → change angle of cannon
  • SPACE start loading (1st hit) and shoot (2nd hit)
  • Ctrl+C exit game
  • Ctrl+R restart current round
  • Ctrl+N start next round
  • S show score
  • A show player's attributes
  • H show help

When running from browser use just R / N instead of Ctrl+R / Ctrl+N

How to run from source code

Alternatively you can run Gorched from source code.

git clone https://github.com/zladovan/gorched.git
cd gorched
go run cmd/main.go

You need to have git and golang installed locally

Troubleshooting

When you see the question marks

When there are question marks instead some parts of the tank sprite it's probably because your terminal does not support unicode characters. Start game with --ascii-only flag and different sprite based only on ACSII characters will be used.

When you see weird colors

The exact colors used in the game depends on your terminal support and settings. So they can be a lot different as the colors in the showcase. When they are too weird or you see some big white areas start game with --low-color flag to use only basic 8 colors. Graphics would look simpler but it should be better.

Credits

Gorched is using termloop as game engine.

Procedural generation is based on OpenSimplex noise implemented in Go by opensimplex-go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controls

type Controls struct {
	// contains filtered or unexported fields
}

Controls holds data and logic for controlling game world.

func (*Controls) Draw

func (c *Controls) Draw(s *tl.Screen)

Draw does nothing now

func (*Controls) HideMessageBox

func (c *Controls) HideMessageBox()

HideMessageBox will hide any active message box

func (*Controls) MoveDown

func (c *Controls) MoveDown()

MoveDown decreases cannon's angle of active tank

func (*Controls) MoveFocus

func (c *Controls) MoveFocus()

MoveFocus moves focus to next component on currently opened form. If no form is opened ignore it.

func (*Controls) MoveUp

func (c *Controls) MoveUp()

MoveUp increase cannon's angle of active tank

func (*Controls) NextRound

func (c *Controls) NextRound()

NextRound will switch game to the next round

func (*Controls) PressButton

func (c *Controls) PressButton()

PressButton sends action event to currently opened form. If no form is opened ignore it.

func (*Controls) RestartRound

func (c *Controls) RestartRound()

RestartRound will restart current round

func (*Controls) Shoot

func (c *Controls) Shoot()

Shoot will start loading or shoot with active tank if it's already loading

func (*Controls) ShowAttributes

func (c *Controls) ShowAttributes()

ShowAttributes shows attributes dialog

func (*Controls) ShowInfo

func (c *Controls) ShowInfo()

ShowInfo shows main game information

func (*Controls) ShowScore

func (c *Controls) ShowScore()

ShowScore shows actual score board

func (*Controls) Tick

func (c *Controls) Tick(e tl.Event)

Tick handles all key events

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game holds information which is kept during whole session.

func NewGame

func NewGame(o GameOptions) *Game

NewGame creates new game object. Game is not started yet. You need to call Start().

func (*Game) Engine

func (g *Game) Engine() *tl.Game

Engine returns reference to underlying game engine

func (*Game) Hud

func (g *Game) Hud() *hud.HUD

Hud returns games HUD

func (*Game) InitialSeed

func (g *Game) InitialSeed() int64

InitialSeed returns seed used for the first level.

func (*Game) LastSeed

func (g *Game) LastSeed() int64

LastSeed returns seed used for the last (current active) level.

func (*Game) Players

func (g *Game) Players() core.Players

Players returns all players in the game

func (*Game) Start

func (g *Game) Start()

Start starts the game which means that game engine is started and first round is set up.

type GameOptions

type GameOptions struct {
	// Width of game world in number of console pixels (cells)
	Width int
	// Height of game world in number of console pixels (cells)
	Height int
	// PlayerCount is number of players which will be added to game
	PlayerCount int
	// Seed is number used as random seed and if it is reused it allows to play same game with same looking rounds
	Seed int64
	// Fps sets screen framerate
	Fps int
	// AsciiOnly identifies that only ASCII characters can be used for all graphics
	ASCIIOnly bool
	// LowColor identifies that only 8 colors can be used for all graphics
	LowColor bool
	// BrowserMode identifies that game was run in browser and some controls need to be modified to do not collide with usual browser shortcuts
	BrowserMode bool
	// Debug turns on debug mode if set to true
	Debug bool
}

GameOptions provide configuration needed for creating new game

type Round

type Round struct {
	// contains filtered or unexported fields
}

Round represents one round in the game. It is responsible for managing state of the round. It also provides functionality for transitions to next rounds. Use NewRound to create new instance. Add it to the termloop.Screen entities after creating. Call Restart to restart this round. Call Next to go to the next round.

func NewRound

func NewRound(game *Game) *Round

NewRound creates new round. Created round will be in Started state. It will add World as level after added to the screen.

func (*Round) ActivateNextTank

func (r *Round) ActivateNextTank()

ActivateNextTank moves turn to nearest tank which is alive.

func (*Round) ActiveTank

func (r *Round) ActiveTank() *entities.Tank

ActiveTank returns tank which is currently active / on turn.

func (*Round) Draw

func (r *Round) Draw(s *tl.Screen)

Draw is processing Round states

func (*Round) IsFinished

func (r *Round) IsFinished() bool

IsFinished returns true when round was already finished

func (*Round) IsPlayerOnTurn

func (r *Round) IsPlayerOnTurn() bool

IsPlayerOnTurn returns turn when some player is on turn now and he didn't made his move yet

func (*Round) IsTurnFinished

func (r *Round) IsTurnFinished() bool

IsTurnFinished returns true if there are no bullets and explosions in world

func (*Round) Next

func (r *Round) Next()

Next will go to the next round.

func (*Round) Number

func (r *Round) Number() int

Number returns number of this round starting with 1 for the first round

func (*Round) NumberOfTanksAlive

func (r *Round) NumberOfTanksAlive() int

NumberOfTanksAlive returns how many tanks is still alive (in game).

func (*Round) Restart

func (r *Round) Restart()

Restart will put state of this round to the same state as when it was started.

func (*Round) Tick

func (r *Round) Tick(e tl.Event)

Tick does nothing now

type RoundState

type RoundState uint8

RoundState represents state of the round

const (
	// Started round is state right after round was created / started / restarted
	Started RoundState = iota
	// PlayerOnTurn is state when some player is on turn but it has not done his move yet
	PlayerOnTurn
	// WaitForTurnFinish is state when some player did his move and we are waiting for all consequences of the move
	WaitForTurnFinish
	// Finished is state when round was finished which means there is only one or zero tanks alive
	Finished
)

Directories

Path Synopsis
Package debug provides access to debugging support.
Package debug provides access to debugging support.
Package demo contains support for playing scripted demos.
Package demo contains support for playing scripted demos.
hud
ui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL