core

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	MemoryBuffer Buffer
	// contains filtered or unexported fields
}

func CreateBitmap

func CreateBitmap(pixelsPerLine uint16, pixelMemory *[]uint32) *Bitmap

func CreateBitmapFromCompressed

func CreateBitmapFromCompressed(pixelsPerLine uint16, uncompressedLength int, compressedDate *[]uint32) *Bitmap

func (*Bitmap) Height

func (me *Bitmap) Height() uint16

func (*Bitmap) MakeEntity added in v0.3.0

func (me *Bitmap) MakeEntity() *BitmapEntity

func (*Bitmap) Width

func (me *Bitmap) Width() uint16

type BitmapEntity added in v0.3.0

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

func (*BitmapEntity) Alpha added in v0.3.0

func (me *BitmapEntity) Alpha(alpha byte, zeroIsInvisible bool) *BitmapEntity

func (*BitmapEntity) Clip added in v0.3.0

func (me *BitmapEntity) Clip(offsetX, offsetY, width, height uint16) *BitmapEntity

------------------------------------------------------------------------------ Setters ------------------------------------------------------------------------------

func (*BitmapEntity) CollisionLayers added in v0.3.0

func (me *BitmapEntity) CollisionLayers(layers CanvasCollisionLayers) *BitmapEntity

func (*BitmapEntity) H added in v0.3.0

func (b *BitmapEntity) H() uint16

func (*BitmapEntity) MoveBy added in v0.3.0

func (me *BitmapEntity) MoveBy(x, y int32) *BitmapEntity

func (*BitmapEntity) MoveTo added in v0.3.0

func (me *BitmapEntity) MoveTo(x, y int32) *BitmapEntity

func (*BitmapEntity) PPL added in v0.3.0

func (b *BitmapEntity) PPL() uint16

func (*BitmapEntity) Pixels added in v0.3.0

func (b *BitmapEntity) Pixels() int

func (*BitmapEntity) ToCanvas added in v0.3.0

func (b *BitmapEntity) ToCanvas(ca *Canvas) CanvasCollisionLayers

------------------------------------------------------------------------------ Actions ------------------------------------------------------------------------------

func (*BitmapEntity) UnclippedHeight added in v0.3.0

func (b *BitmapEntity) UnclippedHeight() uint16

func (*BitmapEntity) UnclippedWidth added in v0.3.0

func (b *BitmapEntity) UnclippedWidth() uint16

------------------------------------------------------------------------------ Getter ------------------------------------------------------------------------------ Internals

func (*BitmapEntity) W added in v0.3.0

func (b *BitmapEntity) W() uint16

func (*BitmapEntity) WH added in v0.3.0

func (b *BitmapEntity) WH() (uint16, uint16)

func (*BitmapEntity) X added in v0.3.0

func (b *BitmapEntity) X() int32

Display

func (*BitmapEntity) XY added in v0.3.0

func (b *BitmapEntity) XY() (int32, int32)

func (*BitmapEntity) Y added in v0.3.0

func (b *BitmapEntity) Y() int32

type BitmapFlag

type BitmapFlag uint32
const (
	BMP_OPAQUE BitmapFlag = 0x01000000 // Set on the Bitmap itself. A Pixel can either be drawn or not, their is no true Alpha channel

	// ColorChannels oBitmapFlag f a BMP
	BMP_CHANNEL_RED   BitmapFlag = 0x00ff0000
	BMP_CHANNEL_GREEN BitmapFlag = 0x0000ff00
	BMP_CHANNEL_BLUE  BitmapFlag = 0x000000ff
)

type Buffer

type Buffer struct {
	Memory       *[]uint32
	PixelPerLine uint16
}

type Canvas

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

func CreateCanvas

func CreateCanvas(e *Engine, width, height uint16) *Canvas

Constructors ==============================================================================

func (*Canvas) Blit

func (*Canvas) FillColorA

func (ec *Canvas) FillColorA(color uint32, alpha byte, layerReset CanvasCollisionLayers)

func (*Canvas) FillRGBA

func (ec *Canvas) FillRGBA(r, g, b, alpha byte, layerReset CanvasCollisionLayers)

Drawing Functions ==============================================================================

func (*Canvas) GetHeight

func (ca *Canvas) GetHeight() uint16

func (*Canvas) GetWidth

func (ca *Canvas) GetWidth() uint16

func (*Canvas) Run

func (ec *Canvas) Run()

Methods ==============================================================================

type CanvasBlitOpts added in v0.3.0

type CanvasBlitOpts struct {
	Bmp       *Bitmap               // What to blit
	X, Y      int32                 // Where to blit it on the screen
	Alpha     byte                  // how strong transparency is
	Alphazero bool                  // if true, an alpha value of 0 mean "draw nothing", otherwise 0 would mean ignore alpha
	Layers    CanvasCollisionLayers // What collision layers the drawn object occupies
	Clip      *types.Rect           // Clipping Rectangle to only draw a certain area of the bitmap
}

type CanvasCollisionLayers

type CanvasCollisionLayers uint32
const (
	// Collisiion Layers These layers are processed when a sprite is drawn
	// The Blit function will return a byte that contains all collision layers, that
	// already contained pixels, during drawing
	// [!NOTICE] regalrdless of BMP_TRANSPARENCY or BMP_FRONT this bits are always processed
	CANV_CL_1 CanvasCollisionLayers = 0x01000000
	CANV_CL_2 CanvasCollisionLayers = 0x02000000
	CANV_CL_3 CanvasCollisionLayers = 0x04000000
	CANV_CL_4 CanvasCollisionLayers = 0x08000000

	CANV_CL_NONE CanvasCollisionLayers = 0
	CANV_CL_ALL  CanvasCollisionLayers = CANV_CL_1 | CANV_CL_2 | CANV_CL_3 | CANV_CL_4
)

type CanvasFlag

type CanvasFlag uint32

type DefaultScene

type DefaultScene struct{}

func (DefaultScene) Draw

func (s DefaultScene) Draw(e *EngineState, ec *Canvas)

func (DefaultScene) Tick

func (s DefaultScene) Tick(e *EngineState) bool

func (DefaultScene) Unload

func (s DefaultScene) Unload(e *EngineState) *struct{}

type Drawable

type Drawable interface {
	Draw(e *EngineState, ec *Canvas)
}

type Engine

type Engine struct {
	Tick   *Tickable
	Draw   *Drawable
	Unload *Unloadable

	Run func(scene any)
	// contains filtered or unexported fields
}

func (*Engine) Canvas

func (e *Engine) Canvas() *Canvas

func (*Engine) Init

func (e *Engine) Init(s *EngineSetup)

func (*Engine) SwitchScene

func (e *Engine) SwitchScene(scene any)

type EngineSetup

type EngineSetup struct {
	WindowHeight, WindowWidth uint16
}

type EngineState added in v0.3.0

type EngineState struct {
	Mouse     io.MouseState
	Keyboard  io.KeyboardState
	DeltaTime float64
}

type Loadable

type Loadable interface {
	Load(e *EngineState, ec *Canvas)
}

type SceneDrawFunction

type SceneDrawFunction func(e *EngineState, pixelCount uint32, width, height, uint16, pixels *[]uint32)

type SceneLoadFunction

type SceneLoadFunction func(e *EngineState, ec *Canvas)

type SceneTickFunction

type SceneTickFunction func(e *EngineState) bool

type SceneUnloadFunction

type SceneUnloadFunction func(e *EngineState) *struct{}

type Tickable

type Tickable interface {
	Tick(e *EngineState) bool
}

type Unloadable

type Unloadable interface {
	Unload(e *EngineState) *struct{}
}

Jump to

Keyboard shortcuts

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