Skip to content

jtbonhomme/asteboids

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to asteboids 👋

Version Documentation Maintenance License: MIT GoDoc: jtbonhomme/asteboids coverage

This repository is a simple port of the original Atari 1979's game in Go, with boids (autonomous agents).

A little bit of history

Asteroids is a arcade game released in 1979 by Atari, Inc. The player controls a single spaceship in an asteroid field. The object of the game is to shoot and destroy the asteroids, while not colliding with either. The game becomes harder as the number of asteroids increases.

This repository is a simple port of the original game play in Go, while replacing asteroids with boids (autonomous agents).

Demo

Build

$ make build

Will create an asteboids binary executable file.

Run

$ make run

Run with debug information

$ make debug

Run in a browser with Web Assembly

$ make wasm

This feature is broken since integration with segmentio/conf (see: #14)

Keyboard control

  • key up: startship move forward
  • key left: startship rotate counter clockwise
  • key right: startship rotate clockwise
  • space: startship shot
  • enter: game restart
  • s: takes a screenshot (file is stored as screenshot_<date><time>.png)
  • d: dumps internal game state (file is stored as asteboids_<date><time>.dump)
  • cmd+q: exit

Makefile targets

help                 Show this help.
lint                 Execute Golangci-lint on the repo.
test                 Go test the repo.
run                  Run the main program.
debug                Run the main program.
pprof                Run the main program with profiling.
clean                Build the main program.
build                Build the main program.
wasm                 Build for WASM distribution.
badge                Generate a coverage badge.
cover                Measure the test coverage.
login                Log in to docker hub registry.
build-docker         Build docker images.

Options

By default, Asteboids will read from a configurable file defined by the -config-file command line argument, then load values present in the environment, and finally load the program arguments.

CLI

Passing configuration via the program arguments:

$ go run cmd/asteboids/main.go -debug

Environment variables

Passing configuration via the environment variables:

$ MAIN_BOIDS=100 go run cmd/asteboids/main.go

Configuration File

Passing configuration via a configuration file:

$ go run cmd/asteboids/main.go -config-file ./custom_config.yml

Default configuration is located in the file config.yml

Option List

  • debug
  • optim
  • asteroids
  • boids
  • screenWidth
  • screenHeight
  • scoreTimeUnit
  • autoGenerateAsteroidsRatio
  • visionRadius
  • maxTPS
  • mute

Flocking

In his book Nature Of Code, Daniel Shiffman reminds us the three rules of flocking:

  1. Separation (also known as “avoidance”): Steer to avoid colliding with your neighbors.
  2. Alignment (also known as “copy”): Steer in the same direction as your neighbors.
  3. Cohesion (also known as “center”): Steer towards the center of your neighbors (stay with the group).

The boids in Asteboids implement these 3 rules.

Resources

Fonts

Some fonts in this repository are copyright (c) Jakob Fischer at www.pizzadude.dk, all rights reserved. Do not distribute without the author's permission. Use these font for non-commercial use only! If you plan to use them for commercial purposes, contact the author before doing so! For more original fonts take a look at www.pizzadude.dk

Author

👤 jtbonhomme@gmail.com

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 jtbonhomme@gmail.com.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator