Git Product home page Git Product logo

mariocaml's Introduction

F# Fable port of MariOCaml from OCAML BuckleScript

Fable and Bucklescript are similar projects which both use OCAML (F# is based on OCAML) to compile to JavaScript. I ported the OCAML version to F# to compare the two approaches.

MariOCaml is a port of Mahsu's work to the excellent BuckleScript compiler, for the whole game it generates only 7K byte gzipped JS and takes 0.57s to build (including the start up time of npm).

MariOCaml is an HTML 5 canvas web-browser implementation of a well known platformer written exclusively in OCaml.

Gameplay preview

F# Fable 1.x BETA Build & Rollup

Windows, Max, Linux - requires .net Core Updated to use Fable with Paket

yarn install 
dotnet restore
dotnet fable npm-run rollup

Key Features

  • 2D Mario platformer that emulates the platformer mechanics of Super Mario Bros.
  • Web-based playable implementation with graphics (Ocaml transpiled to javascript).
  • Procedural level generator that randomly generates levels.

Description

MariOcaml is an OCaml implementation of Super Mario Bros. The game includes several basic enemies, blocks, and items, with particle support. The underlying system follows a director model, with the director maintaining state based on game objects and tiles, including Mario, items, and obstacles. The implementation of enemies and items is designed to be easily extensible. Furthermore, MariOcaml supports a game-over and game-win states, as well as score and coin counts, emulating several of the core mechanics of Mario.

The design follows a clean, modular, and extensible system to ensure that more features can easily be added. Levels are procedurally generated (pseudo-randomly), algorithmically creating an environment of textures and objects that are interactable. The procedural generation generally generates a playable map, but due to the nature of random generation, maps may not be the most aesthetically appealing. Additionally, the game is interactive and graphical using js_of_ocaml, which enables cross-compiliation of Ocaml to javascript, allowing MariOcaml to be run in any modern web browser.

The underlying procedural generation utilizes a grid system to generate objects, taking account parameters such as proximity and location. During game-play, the director maintains the game state, including the location and status of both items, enemies, and the character.

Modules

  • Director - The heart of the game, executes the main game loop and performs updates on the map, canvas, and objects. Also executes the side effectual collision detection.
  • Viewport - Represents a slice of the game map which is currently in view and rendered on the canvas.
  • Procedural Generator - Generates the game level in a game map to be played.
  • Actors - Represents the characters, items, and obstacles in the Mario game world.
  • Sprite - The visual representation of an object to be drawn on the canvas. Contains the ability to create sprites from a template configuration based on the type of actor.
  • Object - The abstract representation of a specific actor on the game map. Contains the ability to create objects from a template configuration based on the type of actor.
  • Particle - Represents a non-collidable visually oriented object on the map. This includes destruction and creation effects.
  • Draw - Contains methods which update the canvas.

Contributing

Pull requests fixing bugs, adding functionality, or improving organization are welcome!

Authors

MariOCaml was originally conceived for Cornell University's Fall 2015 CS3110 final project.

mariocaml's People

Contributors

bobzhang avatar chenglou avatar chenyukang avatar gasche avatar jonasrauber avatar liambui avatar mahsu avatar ncave avatar pmg103 avatar stweb avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.