Giter VIP home page Giter VIP logo

dfjs's Introduction

dfjs

"Dwarf Fortress"-esqe JS Game framework

To-Do

Module skeleton

  1. Declare the object by name and as a function.
  2. Define any object related variables with this
  3. Define the object prototypes
  4. Instantiate the object and set as the exported module

Example:

// Create new object and load config if needed
var Map = function(config) {
  this.initialized = false;
};

// Initialize prototype
Map.prototype = {
  // Create new function
  init: function() {
    for (var x = 0; x <= 80 - 1; x++) {
      var row = [];
      for (var y = 0; y <= 45 - 1; y++) {
        row.push(-1);
      }
      Game.map.push(row);
    }
    this.initialized = true;
    console.log('Map initialized...');
  },
  // Create another function
  foobar: function(argument) {
    var result = argument.substring(0, 16);
    return result;
  }
};

// Instantiate and return Object.

// Alternatively you can just do this on
// the other side but it seems easier this way.

// If the Object/Module requires a config,
// you'll have instantiate it in whichever
// module or function has the config.

module.exports = new Map();

How to Build

I provide a fully compiled version of the game in the dist folder. Both plain and minified formats are in there.

Install NPM if you haven't already done so. NPM is a package manager that ships with Node.js. Then open up your console and navigate to the root folder of this project.

Run npm install once to install all the dependencies needed by this project. Next there are a few options:

Run grunt build to perform a new bundle build to the dist folder and a new node-webkit build to the build folder. This way Browserify will generate a bundle from every required script in the lib folder, this will also generate a minified file of the bundle. This is preferred when you are done developing and want to push your new changes, as this version doesn't include the debug map.

Run grunt dev to watch every module needed in the project for changes. Watchify will take care of rebuilding the bundle so the only thing you have to do is refresh your browser. No need to run grunt build everytime you make a change. This version includes a debug map so you are able to debug single files while the .js file included is still the bundle file.

Run grunt debug to let JSHint check the code for you, a tool that helps to detect errors and potential problems in your JavaScript code.

dfjs's People

Contributors

shanesteszyn avatar trevorstarick avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.