Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Itembehavior #9

Merged
merged 13 commits into from
Apr 1, 2017
30 changes: 30 additions & 0 deletions assets/Keep (129)/Controls (182)/script.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Controls {

export let keyboard = {
jump: [ "W", "UP", "SPACE" ],
moveLeft: [ "A", "LEFT" ],
moveDown: [ "S", "DOWN" ],
moveRight: [ "D", "RIGHT" ],
swap: [ "Q", "SHIFT", "Z" ],
use: [ "E", "C", "RETURN" ],
};

let cbPressed = (acc, key) => acc || ( Sup.Input.wasKeyJustPressed(key) );
let cbHeld = (acc, key) => acc || Sup.Input.isKeyDown(key);

export function pressed( action:string ):boolean {
// let result = Sup.Input.wasKeyJustPressed( Controls.keyboard[action] );
let result = Controls.keyboard[action].reduce( cbPressed, false );
//Sup.log (result);
return result != undefined; // For some reason wasKeyJustPressed returns undefined instead of false
}

export function held( action:string ):boolean {
//let result = Sup.Input.isKeyDown( Controls.keyboard[action] );
let result = Controls.keyboard[action].reduce( cbHeld, false );
//Sup.log (result);
return result;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,35 @@
{
"id": "0",
"name": "Hero",
"children": [],
"children": [
{
"id": "1",
"name": "Equipment",
"children": [],
"components": [],
"position": {
"x": 1,
"y": 0,
"z": 0
},
"orientation": {
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"scale": {
"x": 1,
"y": 1,
"z": 1
},
"visible": true,
"layer": 0,
"prefab": {
"sceneAssetId": "153"
}
}
],
"components": [
{
"type": "SpriteRenderer",
Expand Down
Loading