Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions goverdrive/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
GOFILES=$(shell find . -name '*.go')
GOBINDIR=$(shell echo $(GOPATH) | awk -F: '{ print $$NF }')/bin

.PHONY: build clean save-deps restore-deps test

.DEFAULT_GOAL := all

ALL_EXAMPLES=mover drive sidetap zoneshapes
ALL_GAMES=chicken connect fourmation


ifdef GOBINDIR
clean:
rm -f $(ALL_EXAMPLES) $(ALL_GAMES)
endif


######################################################################
# TESTS
######################################################################

phystest:
go test -v -timeout 1m -race github.com/anki/goverdrive/phys/...

tracktest:
go test -v -timeout 1m -race github.com/anki/goverdrive/robo/track/...

robotest:
go test -v -timeout 1m -race github.com/anki/goverdrive/robo

test: phystest tracktest robotest


######################################################################
# EXAMPLES
######################################################################

mover: $(GOFILES)
go build github.com/anki/goverdrive/games/example/mover/

drive: $(GOFILES)
go build github.com/anki/goverdrive/games/example/drive/

sidetap: $(GOFILES)
go build github.com/anki/goverdrive/games/example/sidetap/

zoneshapes: $(GOFILES)
go build github.com/anki/goverdrive/games/example/zoneshapes/

examples: $(ALL_EXAMPLES)


######################################################################
# GAMES
######################################################################

chicken: $(GOFILES)
go build github.com/anki/goverdrive/games/gwenz/chicken/

connect: $(GOFILES)
go build github.com/anki/goverdrive/games/gwenz/connect/

fourmation: $(GOFILES)
go build github.com/anki/goverdrive/games/gwenz/fourmation/

103 changes: 103 additions & 0 deletions goverdrive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# goverdrive

A lightweight, standalone OverDrive simulator.

- Written in Go
- Designed to be a tool for Game Design on top of the OverDrive robotics platform
- Created by Gabriel Wenz (`gwenz@anki.com`)

![goverdrive Screenshot](doc/Screenshot.png)


## Features
- Any fixed-width track made up of arbitrary straight and curved road pieces
- Any number of vehicles
- Control driving speed, offset from road center, and driving direction of each vehicle
- Perfect knowledge of vehicle position and state at all times
- Collision detection
- Flexible vehicle lights geometry and control
- Programs compile in ~1 second and launch instantly
- Build working game prototypes with <500 lines of code

### Not Supported / Not Present
- Multi-loop tracks
- Fancy track pieces like Intersection and Jump Piece
- AI of any kind
- Path planning
- Default game logic, weapons, etc


## Requirements

- Go
- OpenGL development libraries. See the documentation for [Pixel](https://godoc.org/github.com/faiface/pixel).


## Installation Instructions

Background reading, for new Go developers:
[Go Code Organization](https://golang.org/doc/code.html#Organization)

1. Install Go
2. Setup the project work area and download source files

For example: `~/proj/go/goverdrive/`
```
$ cd ~/proj/go/
$ mkdir goverdrive
$ cp ~/Downloads/proj_setup.sh goverdrive/proj_setup.sh
$ chmod +x goverdrive/proj_setup.sh
$ cd goverdrive
$ ./proj_setup.sh
```

3. Build example programs
```
$ make examples
go build github.com/anki/goverdrive/games/example/mover/
go build github.com/anki/goverdrive/games/example/drive/
go build github.com/anki/goverdrive/games/example/sidetap/
go build github.com/anki/goverdrive/games/example/zoneshapes/
```

4. Run an example of your own configuration:
```
$ ./drive -h
Usage of ./drive:
-ins
Display instructions at the start of each game phase
-mb uint
Message board height, expressed as integer number of pixels. Can be 0. (default 200)
-t string
Track name or modular track string (default "Capsule")
-tmaxcofs float
Track max center offset, from road center
-twidth float
Track width, in Meters (default 0.2)
-v string
List of vehicles, using two-letter abberviations; eg "gs sk" for Groundshock and Skull (default "gs")
-w string
Window size, expressed as integer pixels WIDTHxHEIGHT (default "1200x850")
```
or this canned one:
```
$ ./drive -t loopback -v "gs th"
```


## Example Programs

See [games/example/](games/example/README.md)


## Enhancment Ideas

* Helper module: `gameutil/shapes/animation`. Examples to consider:
* Explosion
* Weapon
* Persistent "jet flame" from vehicle
* Rotating coins or mines
* Generalize user input in gameloop.RunGamePhase, eg use empty interface => enable batch-mode sims
* gameutil/vehtraj - track trajectory a vehicle; then view, analyze, write to file, etc
* Force-based robotics simulator

54 changes: 54 additions & 0 deletions goverdrive/doc/GameLoop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
This document presents a high-level view of the seqeuence of game and
simulation "ticks" or "updates" that make goverdrive go.

```
RunGameLoop(gamePhase) {
// No sim time passes in gamePhase.Start(). Game state can be
// initialized, and vehicles can be repositioned, eg to simulate a
// race lineup.
gamePhase.Start(rsys)

done = false
while !done {
// robo.System.Tick() updates the position and state of all vehicles,
// based on their current state and commands from the game phase.
// This is is the part of the program where sim time advances.
// Auxiliary robotics tasks, such as updating the vehicle lights and
// collision detection, also happen as part of the robotics simulation
// tick.
rsys.Tick()

// gamePhase.Update() may do any of the following:
// - Process user input
// - Issue new vehicle commands
// - Update the game state
// Update() returns all of the extra objects that need to visualized,
// such as game shapes, track regions, and message board text.
//
// Worth noting:
// - GamePhase.Update() may issue commands to vehicles, but it does
// NOT directly move or change the state of the vehicles. Vehicle
// movement and state updates are performed by the robotics
// simulator.
// - EXCEPTION: Vehicle.Reposition() DOES directly change the
// position of the vehicle.
done = gamePhase.Update(...)

// wait for remainder of real-time tick to finish

// Window.Update() draws the track, vehicles, and other game
// objects to the display. It also gathers new input (eg from
// the keyboard) for the next gaemPhase.Update().
Window.Update()

// Momentary Pause
while IsPressed(Backspace (ie delete) key) {
// no sim or game updates; only monitor key presses
}
}

// No sim time passes in gamePhase.Stop(). Final game state and ranking
// can be determined.
gamePhase.Stop(rsys)
}
```
Loading