Permalink
Browse files

Initial

  • Loading branch information...
phoboslab committed Jul 28, 2014
0 parents commit fecc02a0d3622165e4144d6258480d940190ee72
Showing with 4,926 additions and 0 deletions.
  1. +60 −0 index.html
  2. +3 −0 index.js
  3. +78 −0 lib/game/entities/debug-sectors.js
  4. +151 −0 lib/game/entities/enemy-blob.js
  5. +41 −0 lib/game/entities/grenade-pickup.js
  6. +45 −0 lib/game/entities/health-pickup.js
  7. +61 −0 lib/game/entities/particle.js
  8. +303 −0 lib/game/entities/player.js
  9. +23 −0 lib/game/entities/void.js
  10. +51 −0 lib/game/hud.js
  11. +262 −0 lib/game/levels/base1.js
  12. +332 −0 lib/game/main.js
  13. +58 −0 lib/game/title.js
  14. +123 −0 lib/game/weapons/base.js
  15. +213 −0 lib/game/weapons/grenade-launcher.js
  16. +42 −0 lib/plugins/mouse-delta.js
  17. +218 −0 lib/plugins/touch-button.js
  18. +110 −0 lib/plugins/touch-field.js
  19. +61 −0 lib/plugins/twopointfive/debug.js
  20. +181 −0 lib/plugins/twopointfive/entity.js
  21. +58 −0 lib/plugins/twopointfive/font.js
  22. +137 −0 lib/plugins/twopointfive/game.js
  23. +32 −0 lib/plugins/twopointfive/gl-matrix.js
  24. +108 −0 lib/plugins/twopointfive/hud.js
  25. +22 −0 lib/plugins/twopointfive/image.js
  26. +96 −0 lib/plugins/twopointfive/loader.js
  27. +12 −0 lib/plugins/twopointfive/namespace.js
  28. +35 −0 lib/plugins/twopointfive/renderer/ortho-camera.js
  29. +61 −0 lib/plugins/twopointfive/renderer/perspective-camera.js
  30. +65 −0 lib/plugins/twopointfive/renderer/program.js
  31. +181 −0 lib/plugins/twopointfive/renderer/quad.js
  32. +288 −0 lib/plugins/twopointfive/renderer/renderer.js
  33. +344 −0 lib/plugins/twopointfive/renderer/stereo-renderer.js
  34. +181 −0 lib/plugins/twopointfive/system.js
  35. +375 −0 lib/plugins/twopointfive/world/culled-sectors.js
  36. +60 −0 lib/plugins/twopointfive/world/light-map.js
  37. +83 −0 lib/plugins/twopointfive/world/map.js
  38. +133 −0 lib/plugins/twopointfive/world/tile.js
  39. +107 −0 lib/plugins/twopointfive/world/wall-map.js
  40. BIN media/blob-gib.png
  41. BIN media/blob-spawn.png
  42. BIN media/blob.png
  43. BIN media/explosion.png
  44. BIN media/fredoka-one.font.png
  45. BIN media/grenade-launcher.png
  46. BIN media/grenade-pickup.png
  47. BIN media/grenade.png
  48. BIN media/health-icon.png
  49. BIN media/health.png
  50. BIN media/hud-blood-low.png
  51. BIN media/loading-block.png
  52. BIN media/rotate.png
  53. BIN media/sounds/blob-gib.m4a
  54. BIN media/sounds/blob-gib.ogg
  55. BIN media/sounds/empty-click.m4a
  56. BIN media/sounds/empty-click.ogg
  57. BIN media/sounds/explosion.m4a
  58. BIN media/sounds/explosion.ogg
  59. BIN media/sounds/grenade-bounce.m4a
  60. BIN media/sounds/grenade-bounce.ogg
  61. BIN media/sounds/grenade-launcher.m4a
  62. BIN media/sounds/grenade-launcher.ogg
  63. BIN media/sounds/health-pickup.m4a
  64. BIN media/sounds/health-pickup.ogg
  65. BIN media/sounds/hurt1.m4a
  66. BIN media/sounds/hurt1.ogg
  67. BIN media/sounds/hurt2.m4a
  68. BIN media/sounds/hurt2.ogg
  69. BIN media/sounds/hurt3.m4a
  70. BIN media/sounds/hurt3.ogg
  71. BIN media/tiles/basic-tiles-64.png
  72. BIN media/tiles/lights-64.png
  73. BIN media/title.png
  74. +24 −0 readme.md
  75. +108 −0 styles.css
@@ -0,0 +1,60 @@
<!DOCTYPE html>
<html>
<head>
<title>TwoPointFive for Impact</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="viewport" content="width=device-width, minimal-ui, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="stylesheet" type="text/css" href="styles.css"/>
<script type="text/javascript" src="lib/impact/impact.js"></script>
<script type="text/javascript" src="lib/game/main.js"></script>
</head>
<body id="xibalba" class="desktop webgl">
<div class="panel desktop-only">
<h1>
Demo Game using the
<a href="http://github.com/phoboslab/twopointfive">TwoPointFive Plugin</a>
for
<a href="http://impactjs.com/">Impact</a>
</h1>
</div>
<div id="game" class="webgl-only">
<canvas id="canvas" class="landscape-only"></canvas>
<div id="rotate-to-play" class="mobile-only portrait-only">
<div><img src="media/rotate.png"/></div>
Rotate to Landscape to play!
</div>
<div class="panel desktop-only">
<div class="option">
<input type="checkbox" id="requestFullscreen"/>
<label for="requestFullscreen"><span></span>Fullscreen</label>
</div>
<div class="option">
<input type="checkbox" id="riftStereoMode"/>
<label for="riftStereoMode"><span></span>Oculus Rift Stereo Rendering</label>
– requires the <a href="https://github.com/phoboslab/OculusWeb/releases">OculusWeb Tracking Server</a>
</div>
</div>
</div>
<div class="no-webgl-only">
<div id="no-webgl-notice" class="panel">
<p>
Your browser does not support WebGL. Try
<a href="http://www.google.com/chrome">Chrome</a> or
<a href="http://www.mozilla.com/firefox/">Firefox</a>.
</p>
<p>
Mobile Safari has WebGL support in iOS 8
</p>
</div>
</div>
</body>
</html>
@@ -0,0 +1,3 @@
ejecta.include('lib/impact/impact.js');
ejecta.include('lib/game/main.js');
@@ -0,0 +1,78 @@
ig.module(
'game.entities.debug-sectors'
)
.requires(
'plugins.twopointfive.entity',
'plugins.twopointfive.world.culled-sectors'
)
.defines(function(){
// This Entity can be placed in weltmeister to visualize the sector boundaries
// in the level. It does not have any purpose in the game.
EntityDebugSectors = ig.Entity.extend({
type: ig.Entity.TYPE.NONE,
checkAgainst: ig.Entity.TYPE.NONE,
collides: ig.Entity.COLLIDES.NEVER,
size: {x: 16, y: 16},
sectorSize: 4,
_wmDrawBox: true,
_wmBoxColor: '#fff',
generate: function() {
var floorMap = null;
for( var i = 0; i < ig.editor.layers.length; i++ ) {
if( ig.editor.layers[i].name == 'floor' ) {
floorMap = ig.editor.layers[i];
break;
}
}
if( floorMap ) {
console
this.culledSectors = new tpf.CulledSectors( floorMap, [], this.sectorSize );
}
},
draw: function() {
if( !ig.global.wm ) { return; }
// Did the sector size change? Regenerate!
if( !this.culledSectors || this.culledSectors.sectorSize != this.sectorSize ) {
this.generate();
return;
}
// Draw all portals
for( var y in this.culledSectors.sectors ) {
for( var x in this.culledSectors.sectors[y] ) {
var s = this.culledSectors.sectors[y][x];
for( var i = 0; i < s.portals.length; i++ ) {
var p = s.portals[i];
this.drawLine('#f4f', p.x1, p.y1, p.x2, p.y2);
}
}
}
},
drawLine: function( color, sx, sy, dx, dy ) {
ig.system.context.strokeStyle = color;
ig.system.context.lineWidth = 1.0;
ig.system.context.beginPath();
ig.system.context.moveTo(
ig.system.getDrawPos(sx - ig.game.screen.x),
ig.system.getDrawPos(sy - ig.game.screen.y)
);
ig.system.context.lineTo(
ig.system.getDrawPos(dx - ig.game.screen.x),
ig.system.getDrawPos(dy - ig.game.screen.y)
);
ig.system.context.stroke();
ig.system.context.closePath();
}
});
});
@@ -0,0 +1,151 @@
ig.module(
'game.entities.enemy-blob'
)
.requires(
'plugins.twopointfive.entity',
'game.entities.particle'
)
.defines(function(){
EntityEnemyBlobSpawner = tpf.Entity.extend({
size: {x: 16, y: 16},
scale: 0.5,
dynamicLight: true,
_wmBoxColor: '#ff0000',
angle: 0,
animSheet: new ig.AnimationSheet( 'media/blob-spawn.png', 64, 128 ),
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 1, [0] );
this.addAnim( 'spawn', 0.05, [0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,14,15,16,17,18,19,20,21] );
},
update: function() {
if( this.currentAnim == this.anims.idle ) {
if( this.manhattenDistanceTo(ig.game.player) < 512 ) {
this.currentAnim = this.anims.spawn.rewind();
}
else {
return;
}
}
this.parent();
// Spawn anim finished? Spawn the Blob and kill the spawner.
if( this.currentAnim == this.anims.spawn && this.currentAnim.loopCount ) {
ig.game.spawnEntity(EntityEnemyBlob, this.pos.x, this.pos.y);
this.kill();
}
},
manhattenDistanceTo: function( other ) {
// This is a tiny bit faster than .distanceTo() and we don't need the precision
return Math.abs(other.pos.x - this.pos.x) + Math.abs(other.pos.y - this.pos.y);
}
});
EntityEnemyBlob = tpf.Entity.extend({
type: ig.Entity.TYPE.B,
checkAgainst: ig.Entity.TYPE.A,
collides: ig.Entity.COLLIDES.ACTIVE,
size: {x: 16, y: 16},
friction: {x: 100, y: 100},
scale: 0.5,
health: 10,
damage: 10,
dynamicLight: true,
_wmBoxColor: '#ff0000',
angle: 0,
speed: 80,
injump: false,
didHurtPlayer: false,
seenPlayer: false,
animSheet: new ig.AnimationSheet( 'media/blob.png', 64, 64 ),
init: function( x, y, settings ) {
this.parent( x, y, settings );
var crawFrameTime = 0.04 + Math.random() * 0.02;
this.addAnim( 'crawl', 0.04, [0,1,2,3,4,5,4,3,2,1] );
this.currentAnim.gotoRandomFrame();
this.hurtTimer = new ig.Timer();
},
update: function() {
this.angle = this.angleTo( ig.game.player );
this.vel.x = Math.cos(this.angle) * this.speed;
this.vel.y = Math.sin(this.angle) * this.speed;
if( ig.game.dead ) {
// Move away from the player if he's dead
this.vel.x *= -1;
this.vel.y *= -1;
}
this.parent();
},
kill: function() {
var cx = this.pos.x + this.size.x/2;
var cy = this.pos.y + this.size.y/2;
for( var i = 0; i < 20; i++ ) {
ig.game.spawnEntity( EntityEnemyBlobGib, cx, cy );
}
ig.game.blobKillCount++;
this.parent();
},
check: function( other ) {
if( this.hurtTimer.delta() < 0 ) {
// Player already hurt during this attack move?
return;
}
// Only hurt the player once a second
this.hurtTimer.set(1);
this.vel.x = -this.vel.x;
this.vel.y = -this.vel.y;
other.receiveDamage( this.damage, this );
}
});
EntityEnemyBlobGib = EntityParticle.extend({
vpos: 0,
scale: 0.5,
initialVel: {x:120, y: 120, z: 2.5},
friction: {x: 10, y: 10},
lifetime: 2,
animSheet: new ig.AnimationSheet( 'media/blob-gib.png', 16, 16 ),
init: function( x, y, settings ) {
this.addAnim( 'idle', 5, [0,1,2,3,4,5,6,7,8,9,10,11] );
this.parent( x, y, settings );
}
});
});
@@ -0,0 +1,41 @@
ig.module(
'game.entities.grenade-pickup'
)
.requires(
'plugins.twopointfive.entity',
'game.weapons.grenade-launcher'
)
.defines(function(){
EntityGrenadePickup = tpf.Entity.extend({
checkAgainst: ig.Entity.TYPE.A,
size: {x: 16, y: 16},
vpos: 0.5,
scale: 0.5,
amount: 8,
dynamicLight: true,
_wmBoxColor: '#55ff00',
animSheet: new ig.AnimationSheet( 'media/grenade-pickup.png', 32, 32 ),
pickupSound: new ig.Sound( 'media/sounds/health-pickup.*' ),
bounceTimer: null,
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 10, [0] );
},
update: function() {
this.parent();
},
check: function( other ) {
other.giveAmmo(WeaponGrenadeLauncher, this.amount);
this.pickupSound.play();
this.kill();
}
});
});
@@ -0,0 +1,45 @@
ig.module(
'game.entities.health-pickup'
)
.requires(
'plugins.twopointfive.entity'
)
.defines(function(){
EntityHealthPickup = tpf.Entity.extend({
checkAgainst: ig.Entity.TYPE.A,
size: {x: 16, y: 16},
vpos: 0.5,
scale: 0.5,
amount: 25,
gravityFactor: 0,
dynamicLight: true,
_wmBoxColor: '#55ff00',
animSheet: new ig.AnimationSheet( 'media/health.png', 32, 32 ),
pickupSound: new ig.Sound( 'media/sounds/health-pickup.*' ),
bounceTimer: null,
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.addAnim( 'idle', 10, [0] );
this.bounceTimer = new ig.Timer();
},
update: function() {
// Give the item an Arcade-like bounce animation
this.pos.z = (Math.cos(this.bounceTimer.delta()*3)+1) * 3;
this.parent();
},
check: function( other ) {
if( other.giveHealth(this.amount) ) {
this.pickupSound.play();
this.kill();
}
}
});
});
Oops, something went wrong.

0 comments on commit fecc02a

Please sign in to comment.