Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Game
- type GameEngine
- type KeyEvent
- type KeyboardState
- type MIDIEvent
- type MIDIFile
- type MusicStream
- type Runtime
- type RuntimeConfig
- type SoundConfig
- type SoundPlayer
- type SoundSystem
- func (s *SoundSystem) Close()
- func (s *SoundSystem) MusicIsPlaying() bool
- func (s *SoundSystem) PauseMusic()
- func (s *SoundSystem) PlayMusic(data []byte, looping bool)
- func (s *SoundSystem) ResumeMusic()
- func (s *SoundSystem) SetMusicVolume(volume int)
- func (s *SoundSystem) SoundIsPlaying(channel int) bool
- func (s *SoundSystem) StartSound(id, channel, vol, sep int, data []byte) int
- func (s *SoundSystem) StopMusic()
- func (s *SoundSystem) StopSound(channel int)
Constants ¶
const ( KEY_RIGHTARROW = 0xae KEY_LEFTARROW = 0xac KEY_UPARROW = 0xad KEY_DOWNARROW = 0xaf KEY_STRAFE_L = 0xa0 KEY_STRAFE_R = 0xa1 KEY_USE = 0xa2 KEY_FIRE = 0xa3 KEY_ESCAPE = 27 KEY_ENTER = 13 KEY_TAB = 9 KEY_F1 = (0x80 + 0x3b) KEY_F2 = (0x80 + 0x3c) KEY_F3 = (0x80 + 0x3d) KEY_F4 = (0x80 + 0x3e) KEY_F5 = (0x80 + 0x3f) KEY_F6 = (0x80 + 0x40) KEY_F7 = (0x80 + 0x41) KEY_F8 = (0x80 + 0x42) KEY_F9 = (0x80 + 0x43) KEY_F10 = (0x80 + 0x44) KEY_F11 = (0x80 + 0x57) KEY_F12 = (0x80 + 0x58) KEY_BACKSPACE = 0x7f KEY_PAUSE = 0xff KEY_EQUALS = 0x3d KEY_MINUS = 0x2d KEY_RSHIFT = (0x80 + 0x36) KEY_RCTRL = (0x80 + 0x1d) KEY_RALT = (0x80 + 0x38) KEY_LALT = KEY_RALT KEY_CAPSLOCK = (0x80 + 0x3a) )
Doom key codes (from doomkeys.h)
const ( MIDINoteOff = 0x80 MIDINoteOn = 0x90 MIDIControlChange = 0xB0 MIDIProgramChange = 0xC0 )
MIDI event types
Variables ¶
var ( // ErrGameExit is returned when the game exits normally ErrGameExit = errors.New("game exit") // ErrMissingExports is returned when required WASM exports are missing ErrMissingExports = errors.New("missing required WASM exports") // ErrInvalidScreenDimensions is returned when screen dimensions are invalid ErrInvalidScreenDimensions = errors.New("invalid screen dimensions") // ErrNoScreenBuffer is returned when screen buffer pointer is not available ErrNoScreenBuffer = errors.New("no screen buffer pointer returned") // ErrReadScreenBuffer is returned when reading screen buffer fails ErrReadScreenBuffer = errors.New("failed to read screen buffer") // ErrMIDITooShort is returned when MIDI data is too short ErrMIDITooShort = errors.New("MIDI data too short") // ErrMIDIInvalidHeader is returned when MIDI header is invalid ErrMIDIInvalidHeader = errors.New("invalid MIDI header") // ErrNotMIDI is returned when data is not a MIDI file ErrNotMIDI = errors.New("not a MIDI file") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
WASMData []byte
IWADData []byte
IWADName string
SoundFontData []byte
Verbose bool
ExtraArgs []string
}
Config holds the configuration for a new game
type Game ¶
type Game struct {
// contains filtered or unexported fields
}
Game holds the WASM runtime and game state
func (*Game) FrameReady ¶
FrameReady returns true if a new frame is ready
func (*Game) GetScreenBuffer ¶
GetScreenBuffer returns the screen pixels as RGBA
func (*Game) ScreenHeight ¶
ScreenHeight returns the screen height
func (*Game) WindowTitle ¶
WindowTitle returns the current window title
type GameEngine ¶
type GameEngine interface {
// Tick runs one game frame
Tick() error
// GetScreenBuffer returns the screen pixels as RGBA
GetScreenBuffer() ([]byte, error)
// ScreenWidth returns the screen width
ScreenWidth() int
// ScreenHeight returns the screen height
ScreenHeight() int
// FrameReady returns true if a new frame is ready
FrameReady() bool
// WindowTitle returns the current window title
WindowTitle() string
// Close cleans up resources
Close() error
}
GameEngine defines the interface for a DOOM game engine
type KeyboardState ¶
type KeyboardState struct {
// contains filtered or unexported fields
}
KeyboardState tracks the state of all keys
func NewKeyboardState ¶
func NewKeyboardState() *KeyboardState
NewKeyboardState creates a new keyboard state tracker
func (*KeyboardState) GetEvent ¶
func (k *KeyboardState) GetEvent() *KeyEvent
GetEvent returns the next key event, or nil if none
func (*KeyboardState) HasEvents ¶
func (k *KeyboardState) HasEvents() bool
HasEvents returns true if there are pending events
func (*KeyboardState) Update ¶
func (k *KeyboardState) Update()
Update checks for key state changes and generates events
type MIDIEvent ¶
type MIDIEvent struct {
Time float64 // Time in seconds
Type int
Channel int
Key int
Velocity int
Program int
Controller int
Value int
}
MIDIEvent represents a MIDI event
type MusicStream ¶
type MusicStream struct {
// contains filtered or unexported fields
}
MusicStream implements io.Reader for SoundFont audio playback
func (*MusicStream) IsPlaying ¶
func (m *MusicStream) IsPlaying() bool
func (*MusicStream) SetPaused ¶
func (m *MusicStream) SetPaused(paused bool)
func (*MusicStream) SetVolume ¶
func (m *MusicStream) SetVolume(vol float64)
func (*MusicStream) Stop ¶
func (m *MusicStream) Stop()
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime manages the WASM runtime and module
func NewRuntime ¶
func NewRuntime(cfg RuntimeConfig, game *Game) (*Runtime, error)
NewRuntime creates a new WASM runtime with the DOOM module
func (*Runtime) ExportedFunction ¶
ExportedFunction returns an exported function by name
type RuntimeConfig ¶
type RuntimeConfig struct {
WASMData []byte
IWADData []byte
IWADName string
Args []string
Verbose bool
}
RuntimeConfig holds configuration for creating a runtime
type SoundConfig ¶
SoundConfig holds configuration for creating a sound system
type SoundPlayer ¶
type SoundPlayer interface {
// StartSound plays a sound effect
StartSound(id, channel, vol, sep int, data []byte) int
// StopSound stops a sound effect
StopSound(channel int)
// SoundIsPlaying returns true if a sound is playing
SoundIsPlaying(channel int) bool
// PlayMusic starts MIDI music playback
PlayMusic(data []byte, looping bool)
// StopMusic stops music playback
StopMusic()
// SetMusicVolume sets the music volume
SetMusicVolume(volume int)
// PauseMusic pauses music playback
PauseMusic()
// ResumeMusic resumes music playback
ResumeMusic()
// MusicIsPlaying returns true if music is playing
MusicIsPlaying() bool
// Close cleans up resources
Close()
}
SoundPlayer defines the interface for sound playback
type SoundSystem ¶
type SoundSystem struct {
// contains filtered or unexported fields
}
SoundSystem handles sound effects and music playback
func NewSoundSystem ¶
func NewSoundSystem(cfg SoundConfig) (*SoundSystem, error)
NewSoundSystem creates a new sound system
func NewSoundSystemFromData ¶
func NewSoundSystemFromData(soundFontData []byte, verbose bool) (*SoundSystem, error)
NewSoundSystemFromData creates a new sound system from embedded data (deprecated: use NewSoundSystem)
func (*SoundSystem) MusicIsPlaying ¶
func (s *SoundSystem) MusicIsPlaying() bool
func (*SoundSystem) PauseMusic ¶
func (s *SoundSystem) PauseMusic()
func (*SoundSystem) PlayMusic ¶
func (s *SoundSystem) PlayMusic(data []byte, looping bool)
PlayMusic starts MIDI music playback
func (*SoundSystem) ResumeMusic ¶
func (s *SoundSystem) ResumeMusic()
func (*SoundSystem) SetMusicVolume ¶
func (s *SoundSystem) SetMusicVolume(volume int)
func (*SoundSystem) SoundIsPlaying ¶
func (s *SoundSystem) SoundIsPlaying(channel int) bool
func (*SoundSystem) StartSound ¶
func (s *SoundSystem) StartSound(id, channel, vol, sep int, data []byte) int
StartSound plays a sound effect
func (*SoundSystem) StopMusic ¶
func (s *SoundSystem) StopMusic()
func (*SoundSystem) StopSound ¶
func (s *SoundSystem) StopSound(channel int)