gamvas

Description

Basic functions for handling the gamvas environment: http://gamvas.com

Gamvas is a HTML5 game development framework/engine that simplifies the task of developing games.  It keeps the developer away from the boring tasks and allows you to concentrate on the gameplay instead of spending weeks coding just to get you a useful base framework for your game.

The framework uses upper case words for classes, lowercase words for static functions.  For example, see gamvas.State vs gamvas.state

While the use of static functions won’t win Gamvas a award in object oriented software design, it will in certain situations improve performance and reduce necessary amount of source code and therfor further speed up your development process.

At the moment Gamvas is more like a framework for developing games with the HTML5 canvas element and you’ll need quite a bit of JavaScript knowledge to use it, although i hope that the documentation and examples make it even possible for JavaScript beginners to get their dream game to life.

Gamvas is planned to evolve into a full game engine though with native graphical editors on Linux, Mac OSX and Windows.  I want to make this system as useful as it can get for the developers, so future features depend on the requirements.  Feel free to contact me with feature requests at h.nosp@m.i@93-intera.nosp@m.ctive.com

Summary
gamvasBasic functions for handling the gamvas environment: http://gamvas.com
Variables
baseURLThe place there the gamvas scripts live Will be filled on startup
Functions
startStarts the gamvas system
getCanvasPositionGet the position in DOM of the current canvas
getCanvasDimensionGet the width and height of the canvas
getCanvasGet the canvas element
getContext2DGet the 2D context object of the canvas
isSetTests if a variable is set
hasMultiTouchTest if device supports multi touch operations
hasFullScreenTest if real fullscreen more is supported
isFullScreenTest if we are currently running in real fullscreen mode
setFullScreenSet real fullscreen mode, if available

Variables

baseURL

baseURL: ''

The place there the gamvas scripts live Will be filled on startup

Functions

start

start: function(canvasid,
usePhysics,
doSleep)

Description

Starts the gamvas system

Parameters

canvasIDThe id of the canvas element to start gamvas on
usePhysicsUse physics (requires box2dweb JavaScript)
doSleepIf using physics, allow objects to ‘fall asleep’ when not active anymore

Example

A typical gamvas start, add a onload handler that adds your main game state and starts gamvas on the canvas with id “myCanvas” and enables physics support

gamvas.event.addOnLoad(function() {
   gamvas.state.addState(myState);
   gamvas.start('myCanvas', true);
});

getCanvasPosition

getCanvasPosition: function()

Description

Get the position in DOM of the current canvas

Returns

gamvas.Vector2D

See

gamvas.dom.getPosition

getCanvasDimension

getCanvasDimension: function()

Description

Get the width and height of the canvas

Returns

Object {w, h} with with and height of the canvas

Example

var d = gamvas.getCanvasDimension();
alert('canvas has a width of '+d.w+' pixels');

getCanvas

getCanvas: function()

Description

Get the canvas element

Returns

Canvas DOM element

getContext2D

getContext2D: function()

Description

Get the 2D context object of the canvas

Returns

The 2D context of the canvas

See

http://dev.w3.org/html5/2dcontext/

isSet

isSet: function(v)

Description

Tests if a variable is set

Parameters

vthe variable

Returns

true or false

Example

var el = document.getElementById('myelement');
if (!gamvas.isSet(el)) {
    alert('myelement not found');
}

hasMultiTouch

hasMultiTouch: function()

Test if device supports multi touch operations

Returns

true or false

hasFullScreen

hasFullScreen: function()

Test if real fullscreen more is supported

Returns

true or false

isFullScreen

isFullScreen: function()

Test if we are currently running in real fullscreen mode

Returns

true or false

setFullScreen

setFullScreen: function(yesno)

Set real fullscreen mode, if available

Description

Real fullscreen mode as of early 2012 is not yet supported by many browsers, you should ensure to only show fullscreen switches on browsers that support it.  See gamvas.hasFullScreen

Parameters

yesnoA boolean, true to enter real full screen mode, false to leave
baseURL: ''
The place there the gamvas scripts live Will be filled on startup
start: function(canvasid,
usePhysics,
doSleep)
Starts the gamvas system
getCanvasPosition: function()
Get the position in DOM of the current canvas
getCanvasDimension: function()
Get the width and height of the canvas
getCanvas: function()
Get the canvas element
getContext2D: function()
Get the 2D context object of the canvas
isSet: function(v)
Tests if a variable is set
hasMultiTouch: function()
Test if device supports multi touch operations
hasFullScreen: function()
Test if real fullscreen more is supported
isFullScreen: function()
Test if we are currently running in real fullscreen mode
setFullScreen: function(yesno)
Set real fullscreen mode, if available
Game state class, overwrite for own states
Helper functions for state management
A 2D vector class
getPosition: function(el)
Gets the position of a DOM element
Close