🎮
Blade Games
  • Blade Games Whitepaper
    • Blade Games
  • BLADE GAMES OVERVIEW
    • Who We Are
    • Key Partnerships
    • Our Team
  • Dune Factory
    • Gameplay, Play-and-Mine
      • Dune Factory Gameplay Guide
      • Play-and-Mine (Please Wait For New Season)
      • Resources
      • Monster Compendium
    • Private Test (Finished)
      • Must-knows
      • Invite Codes
    • Dune Factory Public Test
  • AI Agents in Blade Games
    • Blade Games AI Agent Overview
    • Our Design Framework
    • How AI Agents Drive Revenue in the Ecosystem
    • Blade Games AI Agent Use Cases
    • Blade Games AI Agent Plan
    • Games Ecosystem That You Can Play
  • ZKUNITY - GAME ENGINE
    • ZKUnity Guide
      • zkWASM
      • ZKUnity
      • Architecture
      • MVC Programming Pattern
      • Demo - a roguelike card game
        • Prerequisites
        • How to run
        • How to play
        • Dir Structure
        • Guide for the backend code
        • Guide for the frontend code
        • ZK Proof
  • Tokenomics
    • Token Utility
    • Token Distribution/Allocation
    • Treasury Wallets Disclosure
  • Important
    • Roadmap
    • Feedback
    • Investors
    • Official Links
Powered by GitBook
On this page
  1. ZKUNITY - GAME ENGINE
  2. ZKUnity Guide

MVC Programming Pattern

PreviousArchitectureNextDemo - a roguelike card game

Last updated 1 year ago

Using MVC for FOC Game in ZKWASM

Brief of MVC

The Model-View-Controller (MVC) pattern, while traditionally associated with web and enterprise application development, can also be applied to game development, albeit with some adaptations. Here’s how the MVC components might be interpreted in the context of game development:

Model: In game development, the Model represents the game’s data and logic. This includes the game state (like the score, level, and player stats), game objects, and the rules that govern the game world. The Model is responsible for managing the data and the state of the game, and it typically doesn’t have any knowledge about how this data will be presented or displayed.

View: The View in game development is concerned with presenting the game state to the player. This involves rendering the game graphics, playing sounds, and displaying UI elements like scores, health bars, and menus. The View observes the Model and updates the visual and auditory representations of the game world to the player. In many game engines, this might be encapsulated within the rendering engine and the UI system.

Controller The Controller interprets user input from keyboards, mice, gamepads, or other input devices, and translates it into actions within the game. For instance, when a player presses a button to make the character jump, the Controller would handle this input and communicate the action to the Model. The Controller in a game acts as a mediator between the input devices and the game logic.

Applying MVC in Game Development has considerable benefits:

  1. Separation of Concerns: MVC can help in organizing code and separating the game logic from the user interface, which can make the development process more manageable and the code more maintainable.

  2. Flexibility: MVC can allow different views to be created for the same model. This can be useful in games that offer multiple perspectives or need to support various display modes.

  3. ZK friendly: By separating game logic from presentation, the model is the only part needs to be trustlessly executed. By putting the model into ZKWASM, the core game mechanics are naturally proved as the game runs.