Documentation
Include TinyPlatforms.js script
<!-- Put this code inside <head> tag of your html file -->
<script src="tinyPlatforms.js"></script>
Initialize TinyPlatforms.js
var tinyPlatforms = new TinyPlatforms();
Create a platform
var platform = new Platform(x, y, width, height, isStatic);
tinyPlatforms.add(platform);
Update platforms
tinyPlatforms.run();
Render platforms
for (var i = 0; i < tinyPlatforms.platforms.length; i++) {
var p = tinyPlatforms.platforms[i];
rectangle(p.x, p.y, p.width, p.height, "red");
}
Add a player
var player = new Platform(100, 100, 50, 50, false);
tinyPlatforms.add(player);
var speed = 5;
if (getKey("a")) {
player.vx = -speed;
} else if (getKey("d")) {
player.vx = speed;
}
if (getKey("space") && player.isTouchingGround) {
player.vy = -6;
}