2048

    A MoonBit implementation of the 2048 game on browser.

    js
    game
    2048
    browser
    Download zip
    Author
    Version
    0.1.1
    License
    Apache-2.0
    Last updated
    8 hours ago
    Downloads
    26

    #sennenki/2048

    ActuatorMetadata

    pub(all) struct ActuatorMetadata {
    score : Int
    best_score : Int
    terminated : Bool
    over : Bool
    won : Bool
    keep_playing : Bool
    }

    Any

    #external
    pub type Any

    Any::from

    fn[T] Any::from(obj : T) -> Any

    Any::to

    fn[T] Any::to(self : Any) -> T

    Any::undefined

    fn Any::undefined() -> Any

    Event

    #external
    pub type Event

    Event::prevent_default

    fn Event::prevent_default(self : Event) -> Unit

    GameManager

    type GameManager

    GameManager::new

    fn GameManager::new(size : Int, criteria : Int) -> GameManager

    GameState

    pub(all) struct GameState {
    grid : Grid
    score : Int
    over : Bool
    won : Bool
    keep_playing : Bool
    } derive(ToJson,
    FromJson
    )

    Grid

    Grid::available_cells

    fn Grid::available_cells(self : Grid) -> Iter[Position]

    Grid::cell_available

    fn Grid::cell_available(self : Grid, pos : Position) -> Bool

    Grid::cell_content

    fn Grid::cell_content(self : Grid, pos : Position) -> Tile?

    Grid::cell_occupied

    fn Grid::cell_occupied(self : Grid, pos : Position) -> Bool

    Grid::cells_available

    fn Grid::cells_available(self : Grid) -> Bool

    Grid::copy

    fn Grid::copy(grid : Grid) -> Grid

    Grid::each_cell

    fn Grid::each_cell(self : Grid) -> Iter[Tile?]

    Grid::insert_tile

    fn Grid::insert_tile(self : Grid, tile : Tile) -> Unit

    Grid::new

    fn Grid::new(size : Int) -> Grid

    Grid::random_available_cell

    fn Grid::random_available_cell(self : Grid) -> Position?

    Grid::remove_tile

    fn Grid::remove_tile(self : Grid, pos : Position) -> Unit

    Grid::within_bounds

    fn Grid::within_bounds(self : Grid, pos : Position) -> Bool

    HtmlActuator

    type HtmlActuator

    HtmlActuator::actuate

    fn HtmlActuator::actuate(self : HtmlActuator, grid : Grid, metadata : ActuatorMetadata) -> Unit

    HtmlActuator::add_tile

    fn HtmlActuator::add_tile(self : HtmlActuator, tile : Tile, ephemeral : Bool) -> Unit

    HtmlActuator::continue_game

    fn HtmlActuator::continue_game(self : HtmlActuator) -> Unit

    HtmlActuator::new

    HtmlActuator::prompt_restart

    fn HtmlActuator::prompt_restart(self : HtmlActuator) -> Unit

    HtmlActuator::prompt_undo

    fn HtmlActuator::prompt_undo(self : HtmlActuator) -> Unit

    KeyboardInputManager

    type KeyboardInputManager

    KeyboardInputManager::emit

    fn KeyboardInputManager::emit(self : KeyboardInputManager, event : String, data? : Any) -> Unit

    KeyboardInputManager::listen

    fn KeyboardInputManager::listen(self : KeyboardInputManager) -> Unit

    KeyboardInputManager::new

    KeyboardInputManager::on

    fn KeyboardInputManager::on(self : KeyboardInputManager, event : String, callback : (Any) -> Unit) -> Unit

    LocalStorageManager

    type LocalStorageManager

    LocalStorageManager::clear_game_state

    fn LocalStorageManager::clear_game_state(self : LocalStorageManager) -> Unit

    LocalStorageManager::get_best_score

    fn LocalStorageManager::get_best_score(self : LocalStorageManager) -> Int

    LocalStorageManager::get_game_state

    fn LocalStorageManager::get_game_state(self : LocalStorageManager) -> GameState?

    LocalStorageManager::get_length_of_game_states_stack

    fn LocalStorageManager::get_length_of_game_states_stack(self : LocalStorageManager) -> Int

    LocalStorageManager::new

    LocalStorageManager::pop_game_state

    fn LocalStorageManager::pop_game_state(self : LocalStorageManager) -> GameState?

    LocalStorageManager::push_game_state

    fn LocalStorageManager::push_game_state(self : LocalStorageManager, state : GameState) -> Unit

    LocalStorageManager::set_best_score

    fn LocalStorageManager::set_best_score(self : LocalStorageManager, score : Int) -> Unit

    LocalStorageManager::set_game_state

    fn LocalStorageManager::set_game_state(self : LocalStorageManager, game_state : GameState) -> Unit

    Nullable

    #external
    pub type Nullable[T]

    Nullable::is_null

    fn[T] Nullable::is_null(self : Nullable[T]) -> Bool

    Nullable::to_option

    fn[T] Nullable::to_option(self : Nullable[T]) -> T?

    Nullable::unwrap

    fn[T] Nullable::unwrap(self : Nullable[T]) -> T

    Position

    pub struct Position {
    x : Int
    y : Int
    } derive(Eq, ToJson,
    FromJson
    )

    Position::new

    fn Position::new(x : Int, y : Int) -> Position

    Tile

    pub struct Tile {
    pos : Position
    value : Int
    previous_pos : Position?
    merged_from : Array[Tile]?
    }

    impl ToJson for Tile

    Tile::clear_merge

    fn Tile::clear_merge(self : Tile) -> Unit

    Tile::new

    fn Tile::new(pos : Position, value : Int, merged_from? : Array[Tile]) -> Tile

    Tile::save_position

    fn Tile::save_position(self : Tile) -> Unit

    Tile::serialize

    fn Tile::serialize(self : Tile) -> Json

    Tile::update_position

    fn Tile::update_position(self : Tile, pos : Position) -> Unit

    i18n

    fn i18n(key : String) -> String

    init_i18n_messages

    fn init_i18n_messages() -> Unit

    install_night_mode_handler

    fn install_night_mode_handler() -> Unit

    start_game

    fn start_game(size : Int, criteria : Int) -> Unit

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io