perspectivefungo

package module
v0.0.0-...-fa155da Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

perspectivefungo

https://perspective.fun

Perspective is a casual puzzle game in which players navigate a 3-dimensional maze controlling only their orientation and gravity.

  • Swipe to rotate maze.
  • Tap to activate gravity.

Generate Puzzle

go run ./cmd/generator -size 11 -moves 7 -blocks 8 -portals 2 puzzle.json

Play Puzzle

go run ./cmd/glfwplayer puzzle.json

Build Web Player

tinygo build -o ./cmd/server/assets/static/player.wasm ./cmd/wasmplayer

Run Web Server

go run ./cmd/server

Navigate to localhost

Documentation

Index

Constants

View Source
const (
	ACCELERATION = 98.1
	INCREMENT    = 0.02
)
View Source
const (
	BAD  = -1
	GOOD = 1
)

Variables

View Source
var (
	BackgroundColor = mgl32.Vec4{1, 1, 1, 1}
	GameLostColor   = mgl32.Vec4{0.9, 0, 0, 1}
	GameWonColor    = mgl32.Vec4{0.9, 0.9, 0, 1}
	RetryColor      = mgl32.Vec4{0.9, 0, 0, 1}
	ShareColor      = mgl32.Vec4{0, 0.8, 0, 1}
	BlockColor      = mgl32.Vec4{0.5, 0.5, 0.5, 1}
	GoalColor       = mgl32.Vec4{0, 0.8, 0, 0.9}
	PlayerColor     = mgl32.Vec4{1, 1, 0, 1}
	PortalColors    = []mgl32.Vec4{
		mgl32.Vec4{0, 0, 0.8, 0.9},
		mgl32.Vec4{0.27, 0, 0.8, 0.9},
		mgl32.Vec4{0.54, 0, 0.8, 0.9},
	}
)
View Source
var Block []byte
View Source
var Eight []byte
View Source
var Five []byte
View Source
var Four []byte
View Source
var FragmentShader string
View Source
var GameOver []byte
View Source
var Goal []byte
View Source
var Nine []byte
View Source
var One []byte
View Source
var Player []byte
View Source
var Point []byte
View Source
var Portal []byte
View Source
var Retry []byte
View Source
var Seconds []byte
View Source
var Seven []byte
View Source
var Share []byte
View Source
var Six []byte
View Source
var Start []byte
View Source
var Three []byte
View Source
var Two []byte
View Source
var VertexShader string
View Source
var Zero []byte

Functions

func Abs

func Abs(a int) uint

func GenerateLocation

func GenerateLocation(occupied map[string]bool, size uint) []int

func Key

func Key(x, y, z int) string

func LoadAssets

func LoadAssets(d Driver) error

func LoadOFFMesh

func LoadOFFMesh(d Driver, id string, data []byte, smooth bool) error

func NewCameraEye

func NewCameraEye() mgl32.Vec3

func NewCameraLookAt

func NewCameraLookAt() mgl32.Vec3

func NewCameraUp

func NewCameraUp() mgl32.Vec3

func NewLight

func NewLight() mgl32.Vec3

func NewModel

func NewModel() mgl32.Mat4

func NewProjection

func NewProjection(width, height float32) mgl32.Mat4

func RandomLocation

func RandomLocation(size uint) int

func Score

func Score(puzzle *Puzzle) (uint, uint)

func ScoreDirection

func ScoreDirection(size uint, player, goal []int, blocks map[string]bool, portals map[string][]int, direction []int, tested map[string]int, visited map[string]bool, portaled bool) int

func ScoreDirections

func ScoreDirections(size uint, player, goal []int, blocks map[string]bool, portals map[string][]int, tested map[string]int, visited map[string]bool, portaled bool) (int, []int)

Types

type Animation

type Animation interface {
	Tick() bool // Return true if animation has completed
}

func NewGameOverAnimation

func NewGameOverAnimation(model *mgl32.Mat4) Animation

func NewRotateToAxisAnimation

func NewRotateToAxisAnimation(rotation *mgl32.Mat4, cameraEye, cameraUp mgl32.Vec3) Animation

type Driver

type Driver interface {
	Init(Game) error
	Loop(float64) error
	AddMesh(string, int32, []float32, []float32) error
	DrawMesh(string) error
	Now() float64
	SetProjection(*mgl32.Mat4)
	SetCamera(*mgl32.Mat4)
	SetModel(*mgl32.Mat4)
	SetLight(*mgl32.Vec3)
	SetColor(*mgl32.Vec4)
}

type Game

type Game interface {
	Init(Driver) error
	Resize(float32, float32)
	Reset()
	Start()
	Loop(Driver) error
	Rotate(float32, float32)
	RotateToAxis()
	ReleaseBall()
	Animating() bool
	Solution() *Solution
	GameOver(bool)
	HasGameStarted() bool
	HasGameEnded() bool
}

func NewGame

func NewGame(puzzle *Puzzle) Game

type Puzzle

type Puzzle struct {
	Size    uint  `json:"size"`
	Player  []int `json:"player"`
	Goal    []int `json:"goal"`
	Blocks  []int `json:"blocks"`
	Portals []int `json:"portals"`
}

func Generate

func Generate(size, blocks, portals uint) (*Puzzle, error)

type ReleaseBallAnimation

type ReleaseBallAnimation interface {
	Animation
	Progress(float64) bool
}

func NewReleaseBallAnimation

func NewReleaseBallAnimation(size uint, rotation mgl32.Mat4, player *[3]float32, goal [3]float32, blocks, portals [][3]float32) ReleaseBallAnimation

type Snapshot

type Snapshot struct {
	Time     time.Time
	Position [3]float32
}

type Solution

type Solution struct {
	Start, End time.Time
	Progress   []*Snapshot
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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