sdl

package
v0.0.0-...-39f28a0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CHUNK_SIZE = 4096
View Source
const H_MIN = 100
View Source
const SONG_PATH = "../assets/theme.ogg"
View Source
const W_MIN = 50

Variables

This section is empty.

Functions

func ClearSurface

func ClearSurface(surf *gosdl.Surface)

Clears the specified surface, by setting everything to the transparent color

func ColorMap

func ColorMap(color color.RGBA) uint32

func FillRect

func FillRect(surf *gosdl.Surface, rect gosdl.Rect, color color.RGBA)

Helper function for coloring rectangles in surfaces. Allows us to use ordinary colors from image/color without hasslej

func Init

func Init(xres, yres int, debug bool) (*EventMgr, *DisplayMgr)

Initializes SDL and starts everything related to it. This must be called before other managers are initialized, since they rely on the functionality here. Also listens for the quit event and exits if we attempt to close the window

func LookupColor

func LookupColor(tc lib.TileColor, p Palette) color.RGBA

func MakeGrid

func MakeGrid(w, h int) *gosdl.Surface

Creates a grid that is meant to be directly overlayed on top of a board, so it's more apparent how the tetrominos are layed out. This is a static component, so the surface is returned directly

func NewSurface

func NewSurface(w, h int) *gosdl.Surface

Helper function for creating surfaces

func Rect

func Rect(x, y, w, h int) gosdl.Rect

Helper function for quickly making rects

Types

type AudioMgr

type AudioMgr struct{}

func (*AudioMgr) Init

func (mgr *AudioMgr) Init()

Starts the mixer for SDL. We only need to deal with ogg files

func (*AudioMgr) Loop

func (mgr *AudioMgr) Loop(filepath string) error

type BoardComponent

type BoardComponent struct {
	// contains filtered or unexported fields
}

func NewBoardComponent

func NewBoardComponent(initBoard lib.Board, p Palette, w int, h int) *BoardComponent

func (*BoardComponent) Draw

func (bc *BoardComponent) Draw()

func (*BoardComponent) GetSurface

func (bc *BoardComponent) GetSurface() *gosdl.Surface

func (*BoardComponent) Update

func (bc *BoardComponent) Update(snap lib.GameSnapshot)

type Component

type Component interface {
	GetSurface() *gosdl.Surface
	Draw()
	Update(lib.GameSnapshot)
}

type DisplayMgr

type DisplayMgr struct {
	// contains filtered or unexported fields
}

func NewDisplayMgr

func NewDisplayMgr(name string, xres, yres int) *DisplayMgr

func (*DisplayMgr) Add

func (mgr *DisplayMgr) Add(comp Component)

func (*DisplayMgr) AddSurf

func (mgr *DisplayMgr) AddSurf(s *gosdl.Surface)

func (*DisplayMgr) CreateWindow

func (mgr *DisplayMgr) CreateWindow(xres, yres int)

func (*DisplayMgr) Render

func (mgr *DisplayMgr) Render(snapshots chan lib.GameSnapshot)

Renders visuals to the screen

type EventMgr

type EventMgr struct {
	C chan lib.Movement
}

func NewEventMgr

func NewEventMgr(inC chan gosdl.Event, debug bool) *EventMgr

type Palette

type Palette [7]color.RGBA

A palette must have exactly 7 colors

Jump to

Keyboard shortcuts

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