-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,192 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Untitled Document</title> | ||
|
||
<link href="style.css" rel="stylesheet" type="text/css"> | ||
</head> | ||
<body> | ||
<section class="page"> | ||
<canvas id="main_canvas" width="800" height="600" oncontextmenu="return false;"></canvas> | ||
</section> | ||
<section class="console"> | ||
</section> | ||
<footer>wallpaper taken from http://onlyhdwallpapers.com/</footer> | ||
<script language="JavaScript" src="../../../lib/jquery.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/easeljs-0.4.2.min.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/easeljs-colorfilter.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/class.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/script.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/map.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/unit.js" type="text/javascript"></script> | ||
<script language="JavaScript" src="js/bullet.js" type="text/javascript"></script> | ||
</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,57 @@ | ||
(function(window){ | ||
var bulletImg = new Image(); | ||
bulletImg.src = "images/bullet.png"; | ||
|
||
bulletCont = new Container(canvas); | ||
var BulletC = Class.extend({ | ||
init: function(shooter, trajectory, shooterId){ | ||
this.body = new Bitmap(bulletImg); | ||
this.body.x = shooter.x; | ||
this.body.y = shooter.y; | ||
this.body.rotation = trajectory; | ||
this.body.regX = 2; | ||
this.body.regY = 2; | ||
this.originX = shooter.x; | ||
this.originY = shooter.y; | ||
this.velocity = 4; | ||
this.trajectory = trajectory; | ||
this.status = "shooting"; | ||
|
||
bulletCont.addChild(this.body); | ||
this.shooter = shooter; | ||
this.shooterId = shooterId; | ||
this.body.parentId = bullets.push(this)-1; | ||
|
||
}, | ||
tick: function(){ | ||
var dx = this.velocity * Math.cos(this.trajectory * (Math.PI/180)); | ||
this.body.x += dx; | ||
var dy = this.velocity * Math.sin(this.trajectory * (Math.PI/180)); | ||
this.body.y += dy; | ||
if (distance(this.body.x,this.body.y,this.originX,this.originY)> 200){ | ||
this.destroy(); | ||
} | ||
bullet_collisionDetector(this); | ||
return true; | ||
}, | ||
destroy: function(){ | ||
bulletCont.removeChild(this.body); | ||
delete(bullets[this.body.parentId]); | ||
} | ||
}); | ||
function bullet_collisionDetector(bullet){ | ||
for(i in units){ | ||
var unit = units[i]; | ||
if(unit.name != bullet.shooterId && !unit.dead){ | ||
if (distance(unit.body.x,unit.body.y,bullet.body.x,bullet.body.y)<5){ | ||
// TODO: also check if owner is same as shooter's owner. | ||
bullet.destroy(); | ||
unit.health--; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
window.BulletC = BulletC; | ||
})(window); |
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,63 @@ | ||
/* Simple JavaScript Inheritance | ||
* By John Resig http://ejohn.org/ | ||
* MIT Licensed. | ||
*/ | ||
// Inspired by base2 and Prototype | ||
(function(){ | ||
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/; | ||
// The base Class implementation (does nothing) | ||
this.Class = function(){}; | ||
|
||
// Create a new Class that inherits from this class | ||
Class.extend = function(prop) { | ||
var _super = this.prototype; | ||
|
||
// Instantiate a base class (but only create the instance, | ||
// don't run the init constructor) | ||
initializing = true; | ||
var prototype = new this(); | ||
initializing = false; | ||
|
||
// Copy the properties over onto the new prototype | ||
for (var name in prop) { | ||
// Check if we're overwriting an existing function | ||
prototype[name] = typeof prop[name] == "function" && | ||
typeof _super[name] == "function" && fnTest.test(prop[name]) ? | ||
(function(name, fn){ | ||
return function() { | ||
var tmp = this._super; | ||
|
||
// Add a new ._super() method that is the same method | ||
// but on the super-class | ||
this._super = _super[name]; | ||
|
||
// The method only need to be bound temporarily, so we | ||
// remove it when we're done executing | ||
var ret = fn.apply(this, arguments); | ||
this._super = tmp; | ||
|
||
return ret; | ||
}; | ||
})(name, prop[name]) : | ||
prop[name]; | ||
} | ||
|
||
// The dummy class constructor | ||
function Class() { | ||
// All construction is actually done in the init method | ||
if ( !initializing && this.init ) | ||
this.init.apply(this, arguments); | ||
} | ||
|
||
// Populate our constructed prototype object | ||
Class.prototype = prototype; | ||
|
||
// Enforce the constructor to be what we expect | ||
Class.prototype.constructor = Class; | ||
|
||
// And make this class extendable | ||
Class.extend = arguments.callee; | ||
|
||
return Class; | ||
}; | ||
})(); |
Oops, something went wrong.