wasm

package
v0.0.0-...-2ee3bae Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTime

func GetTime() time.Time

GetTime returns the current time (for compatibility with time.Time)

Types

type CameraController

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

CameraController handles camera input for head tracking

func NewCameraController

func NewCameraController() *CameraController

NewCameraController creates a new camera controller

func (*CameraController) GetPosition

func (c *CameraController) GetPosition() (float64, float64)

GetPosition returns the current head position

func (*CameraController) GetSensitivity

func (c *CameraController) GetSensitivity() float64

GetSensitivity returns the current sensitivity

func (*CameraController) Initialize

func (c *CameraController) Initialize() error

Initialize sets up the camera

func (*CameraController) IsEnabled

func (c *CameraController) IsEnabled() bool

IsEnabled returns whether camera is enabled

func (*CameraController) SetPositionCallback

func (c *CameraController) SetPositionCallback(callback func(x, y float64))

SetPositionCallback sets the callback for position updates

func (*CameraController) SetSensitivity

func (c *CameraController) SetSensitivity(sensitivity float64)

SetSensitivity sets the camera sensitivity

func (*CameraController) StartCalibration

func (c *CameraController) StartCalibration()

StartCalibration starts the calibration process

type InputState

type InputState struct {
	LeftPressed      bool
	RightPressed     bool
	UpPressed        bool
	DownPressed      bool
	FirePressed      bool
	FireJustPressed  bool
	PauseJustPressed bool
	EnterJustPressed bool
}

InputState represents the current input state

type JSBridge

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

JSBridge handles JavaScript interop for WASM

func NewJSBridge

func NewJSBridge() *JSBridge

NewJSBridge creates a new JavaScript bridge

func (*JSBridge) Cleanup

func (b *JSBridge) Cleanup()

Cleanup releases all resources

func (*JSBridge) ClearCanvas

func (b *JSBridge) ClearCanvas(color string)

ClearCanvas clears the entire canvas with the specified color

func (*JSBridge) DrawCircle

func (b *JSBridge) DrawCircle(x, y, radius float64, color string)

DrawCircle draws a filled circle

func (*JSBridge) DrawLine

func (b *JSBridge) DrawLine(x1, y1, x2, y2, lineWidth float64, color string)

DrawLine draws a line between two points

func (*JSBridge) DrawRect

func (b *JSBridge) DrawRect(x, y, width, height float64, color string)

DrawRect draws a filled rectangle

func (*JSBridge) DrawRectOutline

func (b *JSBridge) DrawRectOutline(x, y, width, height, lineWidth float64, color string)

DrawRectOutline draws a rectangle outline

func (*JSBridge) DrawText

func (b *JSBridge) DrawText(text string, x, y float64, font, color string)

DrawText draws text at the specified position

func (*JSBridge) DrawTextCentered

func (b *JSBridge) DrawTextCentered(text string, x, y float64, font, color string)

DrawTextCentered draws centered text

func (*JSBridge) GetCanvasSize

func (b *JSBridge) GetCanvasSize() (int, int)

GetCanvasSize returns the canvas dimensions

func (*JSBridge) GetContext

func (b *JSBridge) GetContext() js.Value

GetContext returns the canvas 2D context

func (*JSBridge) GetCurrentTime

func (b *JSBridge) GetCurrentTime() float64

GetCurrentTime returns the current time in milliseconds

func (*JSBridge) GetDevicePixelRatio

func (b *JSBridge) GetDevicePixelRatio() float64

GetDevicePixelRatio returns the device pixel ratio

func (*JSBridge) GetElementByID

func (b *JSBridge) GetElementByID(id string) js.Value

GetElementByID gets an element by its ID

func (*JSBridge) GetFPS

func (b *JSBridge) GetFPS(deltaTime float64) float64

GetFPS calculates and returns the current FPS

func (*JSBridge) GetInput

func (b *JSBridge) GetInput() (left, right, fire, fireJustPressed, pauseJustPressed bool)

GetInput returns the current input state

func (*JSBridge) GetInputState

func (b *JSBridge) GetInputState() InputState

GetInputState returns the current input state

func (*JSBridge) GetLocalStorage

func (b *JSBridge) GetLocalStorage(key string) string

GetLocalStorage gets a value from localStorage

func (*JSBridge) Initialize

func (b *JSBridge) Initialize(canvasID string) error

Initialize sets up the JavaScript bridge with canvas and event listeners

func (*JSBridge) IsKeyPressed

func (b *JSBridge) IsKeyPressed(key string) bool

IsKeyPressed checks if a specific key is currently pressed

func (*JSBridge) Log

func (b *JSBridge) Log(message string)

Log logs a message to the browser console

func (*JSBridge) LogError

func (b *JSBridge) LogError(message string)

LogError logs an error to the browser console

func (*JSBridge) PlaySound

func (b *JSBridge) PlaySound(soundID string)

PlaySound plays a sound effect (to be implemented with Web Audio API)

func (*JSBridge) SetCanvasSize

func (b *JSBridge) SetCanvasSize(width, height int)

SetCanvasSize sets the canvas size explicitly

func (*JSBridge) SetElementHTML

func (b *JSBridge) SetElementHTML(elementID, html string)

SetElementHTML sets the HTML content of an element

func (*JSBridge) SetElementText

func (b *JSBridge) SetElementText(elementID, text string)

SetElementText sets the text content of an element

func (*JSBridge) SetLocalStorage

func (b *JSBridge) SetLocalStorage(key, value string)

SetLocalStorage sets a value in localStorage

func (*JSBridge) SetTitle

func (b *JSBridge) SetTitle(title string)

SetTitle sets the document title

func (*JSBridge) ShowAlert

func (b *JSBridge) ShowAlert(message string)

ShowAlert shows an alert dialog

func (*JSBridge) StartAnimationLoop

func (b *JSBridge) StartAnimationLoop(callback func(float64))

StartAnimationLoop starts the animation loop using requestAnimationFrame

func (*JSBridge) UpdateInputState

func (b *JSBridge) UpdateInputState(state *InputState)

UpdateInputState updates the input state with proper "just pressed" detection

type Renderer

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

Renderer handles all game rendering to the canvas

func NewRenderer

func NewRenderer(bridge *JSBridge, screenWidth, screenHeight int) *Renderer

NewRenderer creates a new renderer

func (*Renderer) Clear

func (r *Renderer) Clear()

Clear clears the canvas

func (*Renderer) RenderExplosion

func (r *Renderer) RenderExplosion(x, y float64, frame int)

RenderExplosion renders an explosion effect

func (*Renderer) RenderGame

func (r *Renderer) RenderGame(state *game.GameState)

RenderGame renders the entire game state

func (*Renderer) SetContext

func (r *Renderer) SetContext(ctx js.Value)

SetContext sets the rendering context

Jump to

Keyboard shortcuts

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