Giter VIP home page Giter VIP logo

gamecs's Introduction

GameCS

Description

GameCs is a port of GameJs Framework to CoffeeScript.
GameJs is a JavaScript library for writing 2D games or other interactive graphic applications for the HTML Canvas http://gamejs.org.

Examples

You can check simple canvas gamecs examples online here and multi-canvas example here.
Examples are also available in the repository in the src/sc-examples/ and src/mc-examples directory.

http:// vs file://

Every example works in file:// except worker-require that uses WebWorker's ImportScript function which require http://

Usage

Download last version here
OR
compile it yourself by:

  1. cloning repository
  2. make && make install
  3. Get your minimized file from assets/js/gamecs.min.js

Dev

Start simple http server: make server (server available on http://localhost:8000)
Recompile on file change: make watch.

More Help

See the GameJs Website for more help or drop us an email in the Mailing List.
Irc channel #gamejs (on irc.freenode.net)

Unit Tests

Under refactoring

JsDoc

For now please use http://docs.gamejs.org/

TODO

  1. Multi-Canvas example development

  2. Solid implementation of the Entity-Component-System architecture

  3. Polygon collision detection (PNPoly)

  4. Polygon collision mask rotation

  5. Polygon mask graphic editor (as a gamecs example)

  6. Architecture refarctoring:
    Maybe rename the project as g-spot (g.).
    Separate whole project into smaller modules, my actual proposition is:

  • Audio:
    • mixer
    • sound
    • midi
  • 2d:
    • rect
    • circle
    • polygon (or pnpoly)
    • mask (when pnpoly is not precise enough)
    • collision
    • spriteSheet
    • Tilemap
  • Draw:
    • surface
    • surfaceArray
    • shape (formerly draw)
    • img
    • noise (simplex, Alea)
    • transform
  • Engines:
    • Particle
    • Physics
  • Text:
    • Font
  • Browser (or Web?):
    • Dom
    • XHttp (formerly http)
    • Input (formerly events)
    • Uri
  • Algorithm (maybe put algorithm in Utils)
    • Astar
    • MinMax (AlphaBeta pruning)
    • prng
  • Utils
    • Arrays
    • BinaryHeap
    • Base64
    • Geometry (formerly utils/math)
    • Matrix
    • Objects
    • Time
    • Vectors
  • Parser
    • xml

Refactoring could also include some:

  • Feature refatoring (if needed)
  • Write proper unit tests for each module

gamecs's People

Contributors

oberhamsi avatar jlfwong avatar danielgtaylor avatar sorki avatar dorisenthecat avatar domasx2 avatar gilbert avatar 4d47 avatar tnajdek avatar adriantoine avatar lvcivs avatar robi42 avatar troyjfarrell avatar

Watchers

 avatar  avatar James Cloos avatar

gamecs's Issues

Event manager: single global, multiple local or ... a mix ?

  • Require every object to extends Events class
  • Allow a great granularity: entity.trigger('collision')
  • Increase programming complexity by adding small event logic
  class Entity extends Events
  contextObj = new Entity()
  contextObj.on('test', fn)
  ContextObj.trigger('test', { stuff: 1, thing: obj})

VS

  • Only few event manager instance (one is enough I think)
  • Granularity require as much conditional block as cases (e.g. if or switch)
  • Add an additional dependancy all over the program
    -> require less ram
  • Need for more complex event name
  e = new Events()
  e.on('test', fn)
  contextObj = new Entity()
  e.trigger('test', contextObj, { stuff: 1, thing: obj})

Thinking Notes:
Those are two very different event manager, the first is more entity wise when the second is more applicatin wise.
Maybe we could combine both, ...
allowing us to get the great granularity, small ram usage, and having one common single object (reducing programming complexity):

  e = new Events()
  contextObj = new Entity()
  e.eventize(contextObj)
  contextObj.on('test', fn)
  ContextObj.trigger('test', { stuff: 1, thing: obj})

normalizing application

Last time I taught a friend how to make game with gamecs, he encoutered lots of guessing and remembering how the function were working.

For example the rect can be created from very various parameter:
new Rect(pos.x, pos.y, w, h)
new Rect([pos.x, pos.y], [w,h])
new Rect([pos.x, pos.y, w, h])
new Rect(rect)

WHEN Surface is:
new Surface(w, h)
new Surface([w, h])
new Surface(rect)

WHEN rect.blit is
rect.blit(src, [pos.x, pos.y] ...
rect.blit(src, rect ...

WHEN draw.rect is only
rect (surface, color, rect,

Further more when we want to access property
Rect has:
rect.x, rect.left
rect.pos, rect.topleft
rect.y, rect.top
rect.height
rect.width
rect.inflate(x, y)
union(rect)
clip(rect)

WHEN Surface has:
Surface.getSize

etc ...

optimising allocation

the most allocation in video game are made by entities (aka sprites).
generating pool of sprite and manging their lifespan with a boolean and a dedicated garbage collector could spare lots of resources.

System optimisation

In multiple canvas example, on each system we test on every entity if it has a relative components.
For example, the CollisionSystem tests if the property entity.components.Collidable exists before processing it.

We could generate cache by creating array for each component type.

InputEvent Stack vs State array

Working on a flash project I had some problems using an inputEvent Stack to get keyboard inputs.

What happened was sometime when I pressed a key and realease it, following event were triggered:
[keyDown, KeyDown, keyDown, keyUp, keyDown]
instead of:
[keyDown, KeyDown, keyDown, keyUp]

I had to use a state array/hash that seems to work like charm, example:
state[Keyboard.UP] = true (when keyDown)
state[Keyboard.UP] = false (when keyUp)

The state array solution sounds faster on paper, could be interesting to check it with benchmark.

Regroup animated and visible

Animated and visible both set an image property,
we just need in the update() of System.Rendering to check if the visible component is an animation by checking if the property animation exists.

Note: attribute size of Animated was used to cut spirteSheet, when attribute size of Visible forced the size of the final image. Renamed Animated's size into cutsize or anything else more appropriate.

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.