turboOcto

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2018 License: MIT Imports: 13 Imported by: 0

README

TurboOcto

TurboOcto is a game development library (and eventually game engine) for when you are in a crunch. If its a Gamejam, a Demoparty, rapid development or just toying around: TurboOcto is there for you.

Principles

The goal is to write an engine that comes packed with all the work done. Based on SDL2 it implements familiar concepts while adding loads of things that are missing in SDL:

  • Premade functions (Transitions, Animations, animated Sprites etc.)
  • Automatic scaler (With different scaling modes)
  • Savestate ecosystem
  • Optional error handling (#WorksForMe)
  • Premade assets for testing or even the finished game
  • Sane defaults

So when creatings a standard game you don't need to configure anything just code the game logic.

Roadmap

  1. Create a robust backend (<- This is where we are)
    • Complete layout of engine structure
    • The library is usable as-is
    • All code adheres to standards and is commentated
    • Full test coverage
    • Complete documentation
    • Tutorials
  2. Create a graphical helper program
    • Program can display different game states
    • Positioning via mouse
    • Object inspection
    • Object manipulation
    • Macros
    • Plugin for Atom????
  3. Magic
  4. Fully fledged graphical interface

Contributing

Currently the engine is only developed by me. If you have interest feel free to contact or just make pull requests. Join the Discord Server

Documentation

Index

Constants

View Source
const (
	USE_FRAME_COUNT = timerMode(iota)
	USE_TIME_PASSED
)
View Source
const (
	BLENDED = renderMethod(iota)
	SHADED
	SOLID
)

Variables

View Source
var (
	RELEASED  = buttonState{false, false}
	PRESSING  = buttonState{true, true}
	PRESSED   = buttonState{true, false}
	RELEASING = buttonState{false, true}
)
View Source
var (
	ConfigPath             string
	AllowFrameSkipping     bool
	DefaultSpriteTimerMode timerMode
	FramesVisibleOnLoad    bool
	ResourcePath           string
	SaveOnQuit             bool
	UpdateOnRefresh        bool
	Debug                  bool
)
View Source
var Buttons mouseButtons
View Source
var ExitRequested bool
View Source
var Keyboard keyboardState
View Source
var Mouse mouseState
View Source
var Scancodes scancodeLookup

Functions

func AddElement

func AddElement(element UniqueRenderable, z float64) error

Adds an element to the zSpace.

func ChangeLayer

func ChangeLayer(elem UniqueRenderable, z float64) error

func Clear

func Clear() error

func FillScreen

func FillScreen(r, g, b, a uint8) error

func Fullscreen

func Fullscreen() error

func LoadConf

func LoadConf(filePath string) error

func Quit

func Quit() error

func RemElement added in v0.2.0

func RemElement(element UniqueRenderable) (success bool)

func Render

func Render() []error

func SaveConf

func SaveConf() error

func SetDecoration

func SetDecoration(title string, iconPath string) error

func SetDefaultConf added in v0.1.1

func SetDefaultConf() error

func SetVirtualSize

func SetVirtualSize(size geo.Size) error

func SetWindowSize

func SetWindowSize(size geo.Size) error

func Update

func Update() error

func VSize

func VSize() (geo.Size, error)

func WindowSize

func WindowSize() (geo.Size, error)

func Windowed

func Windowed() error

Types

type Collection

type Collection struct {
	Renderables []Renderable
	*geo.Location
	// contains filtered or unexported fields
}

func EmptyCollection added in v0.1.1

func EmptyCollection() *Collection

func NewCollection added in v0.1.1

func NewCollection(renderables []Renderable) *Collection

func (*Collection) Add added in v0.1.1

func (c *Collection) Add(r Renderable)

func (*Collection) CollidesWith

func (c *Collection) CollidesWith(obj2 Collidable) (bool, error)

func (*Collection) ID added in v0.1.1

func (c *Collection) ID() uniqueID.ID

func (*Collection) MoveRel

func (c *Collection) MoveRel(v geo.Vec)

func (*Collection) MoveTo

func (c *Collection) MoveTo(p geo.Point)

func (*Collection) Remove added in v0.1.1

func (c *Collection) Remove(r UniqueRenderable)

type Collidable

type Collidable interface {
	CollidesWith(interface{}) (bool, error)
}

type Font

type Font struct {
	*ttf.Font
	Method     renderMethod
	ColorRed   uint8
	ColorGreen uint8
	ColorBlue  uint8
	ColorAlpha uint8
}

TODO: Add Size

func OpenFont

func OpenFont(file string, size int) (Font, error)

func (*Font) GlyphMetrics

func (f *Font) GlyphMetrics(char rune) (*GlyphMetrics, error)

func (*Font) RenderString

func (f *Font) RenderString(text string) (*Frame, error)

func (*Font) TextSize

func (f *Font) TextSize(text string) (geo.Size, error)

type Frame

type Frame struct {
	*geo.Rect
	*sdl.Texture

	Visible bool
	// contains filtered or unexported fields
}

func NewEmptyFrame

func NewEmptyFrame() (*Frame, error)

func NewFrame

func NewFrame(texture *sdl.Texture) (*Frame, error)

func (*Frame) ID

func (f *Frame) ID() uniqueID.ID

type GlyphMetrics

type GlyphMetrics ttf.GlyphMetrics

type Positioned

type Positioned interface {
	MoveTo(geo.Point)
	MoveRel(geo.Vec)
}

type Rect

type Rect struct {
	*geo.Rect
	// contains filtered or unexported fields
}

func NewRect

func NewRect(p geo.Point, s geo.Size) (*Rect, error)

func NewRectFromGeoRect

func NewRectFromGeoRect(r geo.Rect) (*Rect, error)

func (*Rect) HasMouseState

func (r *Rect) HasMouseState(which buttonPosition, state buttonState) bool

func (*Rect) IsClicked

func (r *Rect) IsClicked(which buttonPosition) bool

func (*Rect) SetConstraint

func (r *Rect) SetConstraint(constraint func(*Rect) error) error

type Renderable

type Renderable interface {
	// contains filtered or unexported methods
}

Finds usage also elsewhere

type Runlevel

type Runlevel int32
const PAUSED Runlevel = 2
const RUNNING Runlevel = 1
const STOPPED Runlevel = 0

type Sprite

type Sprite struct {
	Collection
	AllowFrameSkipping bool

	Delays     []int
	FrameIndex int

	TimerMode timerMode
	Visible   bool
	// contains filtered or unexported fields
}

Sprites should only be initialized with NewSprite or the LoadSprite[…] functions

func LoadAnimatedSpriteFromFile

func LoadAnimatedSpriteFromFile(filename string, rects []sdl.Rect, delays []int) (*Sprite, error)

func LoadAnimatedSpriteFromFiles

func LoadAnimatedSpriteFromFiles(fileNames []string, delays []int) (*Sprite, error)

func LoadAnimatedSpriteFromFrames

func LoadAnimatedSpriteFromFrames(frames []*Frame, delays []int) (*Sprite, error)

func LoadAnimatedSpriteFromTexture

func LoadAnimatedSpriteFromTexture(frame *Frame) (*Sprite, error)

func LoadSpriteFromFile

func LoadSpriteFromFile(filename string) (*Sprite, error)

func NewSprite

func NewSprite() (*Sprite, error)

func (*Sprite) ID

func (s *Sprite) ID() uniqueID.ID

func (*Sprite) Pause

func (s *Sprite) Pause() error

func (*Sprite) SetDelay

func (s *Sprite) SetDelay(time int) error

func (*Sprite) Start

func (s *Sprite) Start() error

func (*Sprite) Stop

func (s *Sprite) Stop() error

type UniqueRenderable

type UniqueRenderable interface {
	Renderable
	ID() uniqueID.ID
}

Jump to

Keyboard shortcuts

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