This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit: gulp scripts, VS2013 project, basic placeholders
- Loading branch information
0 parents
commit 371b2df
Showing
13 changed files
with
401 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.tscache | ||
node_modules | ||
tscommand*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) [year] [fullname] | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# KeyActionBinder | ||
|
||
KeyActionBinder tries to provide universal game input control for both keyboard and game controllers in JavaScript, independent of the game engine used, the browser, or the hardware platform it is running in. | ||
|
||
Under construction. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en"> | ||
<head> | ||
<title></title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
|
||
<!-- Own styles --> | ||
<style type="text/css"> | ||
body, document { | ||
padding: 0; | ||
margin: 0; | ||
font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif; | ||
font-size: 16px; | ||
overflow: hidden; | ||
} | ||
#videoContainer { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
</style> | ||
|
||
<!-- Key-Action-Binder library --> | ||
<script src="../build/key-action-binder.js"></script> | ||
|
||
<script> | ||
/** | ||
* Gets a query string parameter, to make it more dynamic | ||
**/ | ||
window.getQueryParameter = function(__name) { | ||
__name = __name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); | ||
var regexS = "[\\?&]" + __name + "=([^&#]*)"; | ||
var regex = new RegExp(regexS); | ||
var results = regex.exec(window.location.search); | ||
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); | ||
}; | ||
|
||
/** | ||
* Initialize everything | ||
**/ | ||
window.init = function(e) { | ||
console.log("OK"); | ||
|
||
// Create instance | ||
binder = new KeyActionBinder(); | ||
|
||
// Setup as many action bindings as you want | ||
binder.addKeyboardActionBinding("move-left", Keyboard.LEFT); | ||
binder.addKeyboardActionBinding("move-right", Keyboard.RIGHT); | ||
binder.addGamepadActionBinding("move-left", GamepadControls.DPAD_LEFT); | ||
binder.addGamepadActionBinding("move-right", GamepadControls.DPAD_RIGHT); | ||
|
||
/* | ||
function function gameLoop():void { | ||
// Evaluate actions | ||
if (binder.isActionActivated("move-left")) { | ||
// ... | ||
} else if (binder.isActionActivated("move-right")) { | ||
// ... | ||
} | ||
} | ||
*/ | ||
}; | ||
|
||
/** | ||
* Start | ||
**/ | ||
window.addEventListener("load", window.init); | ||
|
||
</script> | ||
|
||
</head> | ||
<body> | ||
<div id="messages">OK</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var gulp = require('gulp'); | ||
var ts = require('gulp-typescript'); | ||
var del = require('del'); | ||
var uglify = require("gulp-uglify"); | ||
var concat = require("gulp-concat"); | ||
var sourcemaps = require('gulp-sourcemaps'); | ||
|
||
gulp.task('clean', function (cb) { | ||
del(['build/**/*'], cb); | ||
}); | ||
|
||
gulp.task('build', function() { | ||
gulp.src('src/core/KeyActionBinder.ts') | ||
.pipe(sourcemaps.init()) | ||
.pipe(ts({ | ||
declarationFiles: true, | ||
noExternalResolve: false, | ||
removeComments: false, | ||
target: "es5", | ||
module: "amd", | ||
noImplicitAny: false, | ||
out: "key-action-binder.js", | ||
})) | ||
.pipe(sourcemaps.write()) | ||
.pipe(gulp.dest('build')); | ||
}); | ||
|
||
gulp.task('minify', function () { | ||
gulp.src('build/key-action-binder.js') | ||
.pipe(uglify()) | ||
.pipe(concat('key-action-binder.min.js')) | ||
.pipe(gulp.dest('build')); | ||
}); | ||
|
||
gulp.task('rebuild', ['clean', 'build', 'minify']); | ||
|
||
gulp.task('watch', ['rebuild'], function () { | ||
gulp.watch(['src/core/KeyActionBinder.ts'], ['rebuild']); | ||
}); | ||
|
||
gulp.task('default', ['watch']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "key-action-binder.ts", | ||
"version": "1.0.0", | ||
"description": "Key-Action-Binder", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/zeh/key-action-binder.ts.git" | ||
}, | ||
"author": "Zeh Fernando", | ||
"homepage": "https://github.com/zeh/key-action-binder.ts", | ||
"devDependencies": { | ||
"del": "^1.1.1", | ||
"gulp": "^3.8.11", | ||
"gulp-concat": "^2.5.2", | ||
"gulp-sourcemaps": "^1.5.1", | ||
"gulp-typescript": "^2.6.0", | ||
"gulp-uglify": "^1.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/// <reference path="./../libs/signals/SimpleSignal.ts" /> | ||
|
||
/** | ||
* Provides universal input control for game controllers and keyboard | ||
* More info: https://github.com/zeh/key-action-binder.ts | ||
* | ||
* @author zeh fernando | ||
*/ | ||
class KeyActionBinder { | ||
|
||
// Properties | ||
private _isRunning:boolean; | ||
private _maintainPlayerPositions: boolean; | ||
|
||
// Events | ||
private _onActionActivated:zehfernando.signals.SimpleSignal<(action:string) => void>; | ||
|
||
|
||
|
||
// ================================================================================================================ | ||
// CONSTRUCTOR ---------------------------------------------------------------------------------------------------- | ||
|
||
KeyActionBinder() { | ||
|
||
} | ||
|
||
|
||
// ================================================================================================================ | ||
// PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- | ||
|
||
// ================================================================================================================ | ||
// ACCESSOR INTERFACE --------------------------------------------------------------------------------------------- | ||
|
||
// ================================================================================================================ | ||
// PRIVATE INTERFACE ---------------------------------------------------------------------------------------------- | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module zehfernando.signals { | ||
|
||
/** | ||
* @author zeh fernando | ||
*/ | ||
export class SimpleSignal<F extends Function> { | ||
|
||
// Super-simple signals class inspired by Robert Penner's AS3Signals: | ||
// http://github.com/robertpenner/as3-signals | ||
|
||
// Properties | ||
private functions:Array<F> = []; | ||
|
||
// Temp variables | ||
private ifr:number; | ||
|
||
|
||
// ================================================================================================================ | ||
// CONSTRUCTOR ---------------------------------------------------------------------------------------------------- | ||
|
||
constructor() { | ||
this.functions = []; | ||
} | ||
|
||
|
||
// ================================================================================================================ | ||
// PUBLIC INTERFACE ----------------------------------------------------------------------------------------------- | ||
|
||
public add(func:F):boolean { | ||
if (this.functions.indexOf(func) == -1) { | ||
this.functions.push(func); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public remove(func:F):boolean { | ||
this.ifr = this.functions.indexOf(func); | ||
if (this.ifr > -1) { | ||
this.functions.splice(this.ifr, 1); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public removeAll():boolean { | ||
if (this.functions.length > 0) { | ||
this.functions.length = 0; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public dispatch(...args:any[]):void { | ||
var functionsDuplicate:Array<Function> = this.functions.concat(); | ||
for (var i:number = 0; i < functionsDuplicate.length; i++) { | ||
functionsDuplicate[i].apply(undefined, args); | ||
} | ||
} | ||
|
||
|
||
// ================================================================================================================ | ||
// ACCESSOR INTERFACE --------------------------------------------------------------------------------------------- | ||
|
||
public get numItems():number { | ||
return this.functions.length; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.suo |
Oops, something went wrong.