Giter Club home page Giter Club logo

platformer-dsl's Introduction

What is Platformer DSL?

Platformer DSL is a project that I and three others completed for our CPSC 410 (Advanced Software Engineering) course. Our project was to create a DSL that would build a game level. It would allows users with a basic knowledge of programming to build a simple Mario-like platformer game. Players win the game when they reach a flag.

Features of the DSL include:

  • timed loops
  • dynamic game arena size
  • moving blocks
  • destroying blocks

The project was built using Python3 and the Arcade library.

Installation Instructions

  1. Install Python3
  2. Install the Arcade library by running pip3 install arcade in terminal
  3. Run git clone on the project repository
  4. In terminal, run cd Platformer-DSL

Usage

  1. Edit the config.txt file (following the EBNF) with desired input
  2. Run python3 main.py to see the input DSL get translated into a game

EBNF

        PROGRAM ::= CONFIGUREARENA? SETPLAYERPOS? (STATEMENT | LOOPSTATEMENT)+
 CONFIGUREARENA ::= "arena size" DIGITTUPLE
   SETPLAYERPOS ::= "put player at" DIGITTUPLE
     DIGITTUPLE ::= DIGIT "," DIGIT // e.g. xpos, ypos
      STATEMENT ::= MAKESTATEMENT | MODIFYSTATMENT
  MAKESTATEMENT ::= "make a" BLOCKTYPE "called" BLOCKNAME "at" DIGITTUPLE
MODIFYSTATEMENT ::= REMOVESTATEMENT | SETSTATEMENT | CHANGESTATEMENT | MOVESTATEMENT
REMOVESTATEMENT ::= "destroy" BLOCKNAME
   SETSTATEMENT ::= "set" FIELD "of" BLOCKNAME "to" DIGIT
CHANGESTATEMENT ::= "change" FIELD "of" BLOCKNAME "by" DIGIT
  MOVESTATEMENT ::= "move" BLOCKNAME DIR "by" DIGIT
  LOOPSTATEMENT ::= "do every" DIGIT TIME ":" (STATEMENT | WAITSTATEMENT)+ "end loop"
  WAITSTATEMENT ::= "wait" DIGIT TIME
           TIME ::= "ms"
      BLOCKTYPE ::= "block" | "goal"
      BLOCKNAME ::= STRING
            DIR ::= "up" | "down" | "left" | "right"
          FIELD ::= POSITION
       POSITION ::= "xpos" | "ypos"
          DIGIT ::= (-)?[0-9]+
        STRING ::= [A-Za-z0-9]+

Example DSL

DSL Preview

Game Preview

Game Preview

Code Authorship Acknowledgement

The tokenizer that we implemented was heavily based off the tokenizer that we have seen in class. A few points to consider, however, are:

  1. The tokenizer was written from scratch, since we had to translate into Python from Java.
  2. There were changes to the tokenize method to handle whitespaces in our language.
  3. Our project was quite substantial in that most of the time was spent on parsing, building the game, and implementing the loop functionality, all of which were original work.

platformer-dsl's People

Contributors

alexanderluong avatar ethanswcho avatar philmak avatar

Watchers

 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.