thrungames

Getting started

Getting started with THRUNIUM is easy. Make a project folder with a 'index.html' file and a 'game.js' file. Just add a script tag with the link to the newest THRUNIUM file and a link to your 'game.js' file.

The newest version of THRUNIUM is 1.0.0 (See all versions).

You can see an example of the files below.

index.html

<!DOCTYPE html>
<html>
<body style="margin: 0; padding: 0;">
	<script src="https://cdn.thrungames.com/thrunium/1.0.0/thrunium.js"></script>
	<script src="game.js"></script>
</body>
</html>

game.js

var game = new THRUNIUM.Game(800, 800);

game.startState = 'game';
game.backgroundColor = '#eee';

game.states['game'] = function () {
	game.drawRect(100, 100, 100, 100);
	game.setFillColor('#000');
	game.fill();
}

game.init();

game.start();

Now you can add your game functionality in the function that is saved under game.states['game']. Inside the function there is some premade code. It draws a black rectangle at x: 100 and y: 100 with the width of 100px and a height of 100px. You can just replace this code with your own.

How to

A quick tutorial on how to use javascript.

console.log('Hello world!');       // print to the console

var test = 0;                      // init a variable
console.log(test);                 // print the variable
test++;                            // add 1 to test
console.log(test);                 // print the variable again

var arrayName = [];                // init an array
arrayName.push('test');            // add a string to the array
arrayName.push(10);                // add a number to the array
for (var i = 0; i < arrayName.length; i++) {
	conesole.log(arrayName[i]);    // print the variable at index i from arrayName
}

arrayName.splice(0, 1);            // remove the variable at index 0

Class

Making a class.

function Test(augument) {               // contructor auguments
	this.variable = "hello world";      // init variable for object
	this.variable2 = augument;          // init variable with an augument

	this.get_variable = function() {    // set a function for the object
		return this.variable;
	};
}

var test = new Test('my object');       // contruct a object with 'my object' as augument
console.log(test.get_variable());       // call the objects get_variable function and print the result

You can read about all the things that the Game class offers its documentation page.