engine

package
v0.0.0-...-c712ff3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package engine contains bindings to SDL for rendering graphics. Support for audio, input, and networking will be added as needed. Integration with OpenGL contexts may also be added for 3D rendering.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrQuitting error = errors.New("quitting")
)

Functions

This section is empty.

Types

type Camera

type Camera interface {
	MoveTo(int32, int32)
	Position() (int32, int32)
	ShiftRect(*sdl.Rect) *sdl.Rect
	ShiftVectors([]int16, []int16) ([]int16, []int16)
}

func NewCamera

func NewCamera() Camera

type SDLEngine

type SDLEngine interface {
	Window() *sdl.Window
	Surface() *sdl.Surface
	Renderer() *sdl.Renderer
	Camera() Camera

	ProcessTextures(Spritesheet) error

	ClearScreen() error
	FillWindow(uint32) error
	Gradient(*sdl.Rect, uint32, uint32) error
	DrawRect(*sdl.Rect, uint32) error
	DrawIsometricRect(*sdl.Rect, uint32) error
	DrawLabel(string, *sdl.Rect, *ttf.Font) error
	DrawTexture(*sdl.Texture) error
	UpdateSurface() error

	Events() []sdl.Event

	PauseRendering(uint32)
	DestroyWindow()
}

SDLEngine is our interface to SDL2.

func NewSDLEngine

func NewSDLEngine(title string) (SDLEngine, error)

NewSDLEngine creates an SDL window, surface, and renderer with the given title. Implements and returns the SDLEngine interface.

type Scene

type Scene interface {
	Setup() error
	Main() error
	Teardown() error
}

Scene is a generic interface for types which interact with SDLEngine. They may resize the game window, make draw calls, interact with the event loop, and more.

type Spritesheet

type Spritesheet interface {
	Image() image.Image

	Width() int
	Height() int
	SpriteWidth() int
	SpriteHeight() int

	Sprites() []image.Image
	AddSprite(image.Image)

	LoadImage(string) error
	PopulateDimensions(string) error
	PopulateSprites()

	Textures() []*sdl.Texture
	CreateTexture(image.Image, *sdl.Renderer) (*sdl.Texture, error)
	AddTexture(*sdl.Texture)
	DestroyTextures()
}

Spritesheet is the interface for an image containing a grid of smaller images. Its interface allows us to carve up the image, and convert each one into an SDL texture.

Directories

Path Synopsis
Package input handles keyboard and mouse input with SDL.
Package input handles keyboard and mouse input with SDL.
Package menu provides various ways to draw a main menu and handle user input.
Package menu provides various ways to draw a main menu and handle user input.

Jump to

Keyboard shortcuts

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