mirror of
https://github.com/ysoftdevs/pf2016.git
synced 2026-01-11 14:30:51 +01:00
initial commit
This commit is contained in:
19
README.md
Normal file
19
README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
PF 2016 - Initial version
|
||||
|
||||
This is initial version of PF 2016.
|
||||
|
||||
Author: Juraj Michalek
|
||||
|
||||
Credits:
|
||||
|
||||
Kiwi.JS
|
||||
- HTML5 Game Framework - http://www.kiwijs.org/
|
||||
Graphic assets
|
||||
- Open souce game Enigma - http://www.nongnu.org/enigma/
|
||||
Image operations
|
||||
- GIMP - https://www.gimp.org/
|
||||
Map editor
|
||||
- Tiled - http://www.mapeditor.org/
|
||||
Coding
|
||||
- Visual Studio Code - https://code.visualstudio.com/
|
||||
- Cloud9 IDE - https://c9.io
|
||||
BIN
data/images/gfx64/marble_black.png
Normal file
BIN
data/images/gfx64/marble_black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
data/images/gfx64/tiles.png
Normal file
BIN
data/images/gfx64/tiles.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 144 KiB |
BIN
favicon.ico
Normal file
BIN
favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
160
index.html
Normal file
160
index.html
Normal file
@@ -0,0 +1,160 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PF 2016</title>
|
||||
<script src="js/kiwi-js-v1.4.0/kiwi.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
var state = new Kiwi.State('state');
|
||||
|
||||
state.preload = function() {
|
||||
this.addJSON('tilemap', 'tilemap.json');
|
||||
this.addSpriteSheet('base', './data/images/gfx64/tiles.png', 64, 64);
|
||||
this.addSpriteSheet('character', './data/images/gfx64/marble_black.png', 80, 80 );
|
||||
}
|
||||
|
||||
state.create = function() {
|
||||
|
||||
this.tilemap = new Kiwi.GameObjects.Tilemap.TileMap(this, 'tilemap', this.textures.base);
|
||||
|
||||
this.character = new Kiwi.GameObjects.Sprite(this, this.textures.character, 2*64, 64);
|
||||
this.character.box.hitbox = new Kiwi.Geom.Rectangle( 20, 20, 50, 50 );
|
||||
this.character.physics = this.character.components.add( new Kiwi.Components.ArcadePhysics( this.character, this.character.box ) );
|
||||
this.character.physics.acceleration.y = 0;
|
||||
this.character.physics.maxVelocity.y = 140;
|
||||
|
||||
this.character.animation.add('walking', [ 0, 1 ], 0.2, true);
|
||||
this.character.animation.add('idle', [ 2, 3, 4, 5 ], 0.2, false, false);
|
||||
|
||||
|
||||
this.addChild(this.tilemap.layers[0]);
|
||||
this.addChild(this.character);
|
||||
this.addChild(this.tilemap.layers[1]);
|
||||
|
||||
|
||||
|
||||
for(var i = 21; i < this.tilemap.tileTypes.length; i++) {
|
||||
this.tilemap.tileTypes[i].allowCollisions = Kiwi.Components.ArcadePhysics.ANY;
|
||||
}
|
||||
|
||||
this.keyboard = this.game.input.keyboard;
|
||||
|
||||
this.leftKey = this.keyboard.addKey(Kiwi.Input.Keycodes.LEFT, true);
|
||||
this.rightKey = this.keyboard.addKey(Kiwi.Input.Keycodes.RIGHT, true);
|
||||
//Prevent the down key from scrolling the page
|
||||
this.keyboard.addKey(Kiwi.Input.Keycodes.DOWN, true);
|
||||
|
||||
this.keyboard.onKeyDownOnce.add(this.keyDownOnce, this);
|
||||
this.keyboard.onKeyUp.add(this.keyUp, this);
|
||||
|
||||
this.character.input.onUp.add( this.activateScene, this );
|
||||
|
||||
|
||||
this.myButton = new Kiwi.HUD.Widget.Button( this.game, 'PRESS ME!', 260, 50 );
|
||||
this.game.huds.defaultHUD.addWidget( this.myButton );
|
||||
|
||||
this.myButton.style.color = 'white';
|
||||
this.myButton.style.fontSize = '2em';
|
||||
this.myButton.style.fontWeight = 'bold';
|
||||
this.myButton.style.padding = '0.5em 1em';
|
||||
this.myButton.style.backgroundColor = 'black';
|
||||
this.myButton.style.cursor = 'pointer';
|
||||
|
||||
this.myButton.input.onDown.add( this.buttonPressed, this );
|
||||
this.myButton.input.onUp.add( this.buttonReleased, this );
|
||||
|
||||
// this.myButton.input.onOver.add( this.buttonOver, this );
|
||||
// this.myButton.input.onOut.add( this.buttonOut, this );
|
||||
}
|
||||
|
||||
state.buttonPressed = function() {
|
||||
this.myButton.y = 55;
|
||||
}
|
||||
|
||||
state.buttonReleased = function() {
|
||||
this.myButton.y = 50;
|
||||
this.myButton.text = 'THANK YOU :)';
|
||||
this.character.physics.velocity.x = 0;
|
||||
this.character.physics.velocity.y = 0;
|
||||
}
|
||||
|
||||
state.activateScene = function () {
|
||||
this.character.physics.velocity.y = 40;
|
||||
}
|
||||
|
||||
state.update = function () {
|
||||
//Update all the gameobjects
|
||||
Kiwi.State.prototype.update.call(this);
|
||||
|
||||
//Update physics
|
||||
this.checkCollision();
|
||||
|
||||
this.updateCharacterMovement();
|
||||
this.updateCharacterAnimation();
|
||||
|
||||
// this.resetCharacter();
|
||||
}
|
||||
|
||||
state.updateCharacterAnimation = function () {
|
||||
|
||||
if(( this.character.physics.velocity.y != 0 ) || (this.character.physics.velocity.x != 0)) {
|
||||
this.character.animation.play('walking', false);
|
||||
} else {
|
||||
this.character.animation.play('idle', false);
|
||||
}
|
||||
}
|
||||
|
||||
//Resolve collisions between the character and the first layer.
|
||||
state.checkCollision = function () {
|
||||
this.tilemap.layers[1].physics.overlapsTiles( this.character, true );
|
||||
}
|
||||
|
||||
state.updateCharacterMovement = function () {
|
||||
|
||||
//Move the player/character
|
||||
if ( this.leftPressed ) {
|
||||
this.character.scaleX = -1;
|
||||
this.character.physics.velocity.x = -40;
|
||||
|
||||
} else if ( this.rightPressed ) {
|
||||
this.character.scaleX = 1;
|
||||
this.character.physics.velocity.x = 40;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//When the key is pressed
|
||||
state.keyDownOnce = function(keyCode, key) {
|
||||
if( keyCode === this.rightKey.keyCode ){
|
||||
this.rightPressed = true;
|
||||
}
|
||||
|
||||
if( keyCode === this.leftKey.keyCode ){
|
||||
this.leftPressed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//When the key is released
|
||||
state.keyUp = function(keyCode, key) {
|
||||
|
||||
if( keyCode === this.rightKey.keyCode ){
|
||||
this.rightPressed = false;
|
||||
}
|
||||
|
||||
if( keyCode === this.leftKey.keyCode ){
|
||||
this.leftPressed = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var game = new Kiwi.Game(null, 'PF 2016', state);
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
35179
js/kiwi-js-v1.4.0/kiwi.js
Normal file
35179
js/kiwi-js-v1.4.0/kiwi.js
Normal file
File diff suppressed because it is too large
Load Diff
11
js/kiwi-js-v1.4.0/kiwi.min.js
vendored
Normal file
11
js/kiwi-js-v1.4.0/kiwi.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
53
tilemap.json
Normal file
53
tilemap.json
Normal file
@@ -0,0 +1,53 @@
|
||||
{ "height":6,
|
||||
"layers":[
|
||||
{
|
||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"height":6,
|
||||
"name":"ground",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":18,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"data":[0, 51, 51, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 51, 51, 51, 51, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 51, 51, 51, 21, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 51, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||
"height":6,
|
||||
"name":"walls",
|
||||
"opacity":1,
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":18,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"nextobjectid":1,
|
||||
"orientation":"orthogonal",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"renderorder":"right-down",
|
||||
"tileheight":64,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"image":"data\/images\/gfx64\/tiles.png",
|
||||
"imageheight":400,
|
||||
"imagewidth":640,
|
||||
"margin":0,
|
||||
"name":"base",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"spacing":0,
|
||||
"tilecount":60,
|
||||
"tileheight":64,
|
||||
"tilewidth":64
|
||||
}],
|
||||
"tilewidth":64,
|
||||
"version":1,
|
||||
"width":18
|
||||
}
|
||||
Reference in New Issue
Block a user