Crate fallingrust

Source
Expand description

This is the main entry point for our WebAssembly-based falling sand simulation. In Rust, the lib.rs file serves as the primary file for libraries.

Modules§

  • cells 🔒
    Defines the different types of cells/particles in our simulation This file defines the different types of cells (particles) in our falling sand simulation and their properties like density, temperature behavior, and special characteristics.
  • input 🔒
    Handles user inputs like mouse clicks and movements This file handles user input for the simulation, like mouse clicks and movements. It keeps track of mouse state and which cell type the user has selected.
  • simulator 🔒
    Contains the core simulation logic This file contains the core simulation logic for our falling sand game. It defines how different cell types behave and interact with each other.
  • space 🔒
    Manages the grid where all our cells live This file defines the simulation space (grid) that contains all the cells. It manages the 2D grid layout and provides methods to access and manipulate cells.
  • timer 🔒
    Provides timing functionality for the simulation This file provides timing functionality for the simulation. It measures elapsed time and helps maintain a consistent frame rate.
  • ui 🔒
    Handles the user interface elements This file handles the user interface for our simulation. It connects our Rust code to the browser’s DOM and handles rendering and user input.
  • world 🔒
    Represents the entire game world state This file defines the World struct, which brings together all the components of our simulation: the space (grid), input handling, and simulation logic.

Macros§

  • This macro provides a convenient way to print debug messages to the browser console Macros in Rust are a way to define reusable code patterns

Constants§

Statics§

  • Height of each cell in pixels when rendered
  • Width of each cell in pixels when rendered
  • Controls how often the simulation updates (in milliseconds)
  • Height of the simulation space in cells
  • Width of the simulation space in cells

Functions§

  • alert 🔒
    Allows our Rust code to trigger browser alerts
  • log 🔒
    Allows our Rust code to write messages to the browser’s console The js_namespace attribute specifies which JavaScript object the function belongs to
  • A helper function that provides a random number generator This calls JavaScript’s Math.random() function to get a random float between 0 and 1
  • This is the main entry point function that will be called from JavaScript when our application starts