pub struct WebPlatform { /* private fields */ }Expand description
The main web platform struct exposed to JavaScript via wasm-bindgen.
This handles the game loop, input processing, and render command generation. All computation happens in Rust; JavaScript only forwards events and draws.
Implementations§
Source§impl WebPlatform
impl WebPlatform
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Creates a new WebPlatform with default configuration.
Sourcepub fn set_canvas_offset(&mut self, x: f32, y: f32)
pub fn set_canvas_offset(&mut self, x: f32, y: f32)
Sets the canvas offset from viewport origin.
Sourcepub fn resize(&mut self, width: u32, height: u32)
pub fn resize(&mut self, width: u32, height: u32)
Handles canvas resize.
§Arguments
width- New canvas width in pixelsheight- New canvas height in pixels
Sourcepub fn get_config(&self) -> String
pub fn get_config(&self) -> String
Returns the current configuration as JSON.
Sourcepub fn reset_timer(&mut self)
pub fn reset_timer(&mut self)
Resets the timer (useful when tab becomes visible again).
Sourcepub fn get_ai_model(&self) -> String
pub fn get_ai_model(&self) -> String
Returns the AI model as JSON string for download.
Sourcepub fn get_ai_info(&self) -> String
pub fn get_ai_info(&self) -> String
Returns AI model metadata and current state as JSON.
Sourcepub fn set_ai_difficulty(&mut self, level: u8)
pub fn set_ai_difficulty(&mut self, level: u8)
Sets the AI difficulty level (0-9).
Sourcepub fn get_ai_difficulty(&self) -> u8
pub fn get_ai_difficulty(&self) -> u8
Gets the current AI difficulty level.
Sourcepub fn set_game_mode(&mut self, mode: &str)
pub fn set_game_mode(&mut self, mode: &str)
Sets the game mode (“demo”, “1p”, “2p”).
Sourcepub fn get_game_mode(&self) -> String
pub fn get_game_mode(&self) -> String
Gets the current game mode as string.
Source§impl WebPlatform
impl WebPlatform
Sourcepub fn new_for_test(config: WebConfig) -> Self
pub fn new_for_test(config: WebConfig) -> Self
Creates a platform without wasm-bindgen (for testing).
Sourcepub const fn input(&self) -> &InputState
pub const fn input(&self) -> &InputState
Returns a reference to the input state (for testing).
Sourcepub fn input_mut(&mut self) -> &mut InputState
pub fn input_mut(&mut self) -> &mut InputState
Returns a mutable reference to the input state (for testing).
Sourcepub const fn timer(&self) -> &FrameTimer
pub const fn timer(&self) -> &FrameTimer
Returns a reference to the frame timer (for testing).
Sourcepub const fn tracer(&self) -> &GameTracer
pub const fn tracer(&self) -> &GameTracer
Returns a reference to the game tracer (for testing).
Trait Implementations§
Source§impl From<WebPlatform> for JsValue
impl From<WebPlatform> for JsValue
Source§fn from(value: WebPlatform) -> Self
fn from(value: WebPlatform) -> Self
Source§impl FromWasmAbi for WebPlatform
impl FromWasmAbi for WebPlatform
Source§impl IntoWasmAbi for WebPlatform
impl IntoWasmAbi for WebPlatform
Source§impl LongRefFromWasmAbi for WebPlatform
impl LongRefFromWasmAbi for WebPlatform
Source§impl OptionFromWasmAbi for WebPlatform
impl OptionFromWasmAbi for WebPlatform
Source§impl OptionIntoWasmAbi for WebPlatform
impl OptionIntoWasmAbi for WebPlatform
Source§impl RefFromWasmAbi for WebPlatform
impl RefFromWasmAbi for WebPlatform
Source§type Anchor = RcRef<WebPlatform>
type Anchor = RcRef<WebPlatform>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for WebPlatform
impl RefMutFromWasmAbi for WebPlatform
Source§impl TryFromJsValue for WebPlatform
impl TryFromJsValue for WebPlatform
Source§impl VectorFromWasmAbi for WebPlatform
impl VectorFromWasmAbi for WebPlatform
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[WebPlatform]>
Source§impl VectorIntoWasmAbi for WebPlatform
impl VectorIntoWasmAbi for WebPlatform
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[WebPlatform]>) -> Self::Abi
Source§impl WasmDescribeVector for WebPlatform
impl WasmDescribeVector for WebPlatform
impl SupportsConstructor for WebPlatform
impl SupportsInstanceProperty for WebPlatform
impl SupportsStaticProperty for WebPlatform
Auto Trait Implementations§
impl Freeze for WebPlatform
impl !RefUnwindSafe for WebPlatform
impl Send for WebPlatform
impl !Sync for WebPlatform
impl Unpin for WebPlatform
impl !UnwindSafe for WebPlatform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.