- server.zip
- Local.testsettings
- packages
- Fleck.0.8.2.1
- Fleck.0.8.2.1.nupkg
- lib
- net40
- Fleck.dll
- HttpClient.0.6.0
- HttpClient.0.6.0.nupkg
- lib
- 40
- JsonValue.0.6.0
- JsonValue.0.6.0.nupkg
- lib
- 40
- Newtonsoft.Json.4.0.5
- repositories.config
- SpaceShooterServer.sln
- SpaceShooterServer.vsmdi
- SpaceShooterServer
- Test
- bin
- Debug
- Release
- Fleck.dll
- Microsoft.Json.dll
- Microsoft.Json.xml
- Microsoft.Server.Common.dll
- SpaceShooterServer.exe
- Test.dll
- Local.testsettings
- obj
- Debug
- TempPE
- Release
- TempPE
- packages.config
- Properties
- SpaceShooterServer.vsmdi
- Test.csproj
- Test.csproj.user
- TraceAndTestImpact.testsettings
- UnitTests.cs
- TraceAndTestImpact.testsettings
- client.zip
|
var clamp = function(value, min, max) {
if(value > max)
return max;
else if(value < min)
return min;
return value;
};
var collisionQ2Q = function(sx, sy, sw, sh, dx, dy, dw, dh) {//Method to detect collisions for rectangle with rectangle
var sleft = sx - sw / 2,
dright = dx + dw / 2;
if(sleft > dright)
return false;
var sright = sx + sw / 2,
dleft = dx - dw / 2;
if(sright < dleft)
return false;
var sup = sy - sh / 2,
dbottom = dy + dh / 2;
if(sup > dbottom)
return false;
var sbottom = sy + sh / 2,
dup = dy - dh / 2;
if(sbottom < dup)
return false;
return true;
};
var collisionC2Q = function(sx, sy, sd, dx, dy, dw, dh) {//Method to detect collisions for circle with rectangle
var sradius = sd / 2;
var closestX = clamp(sx, dx - dw / 2, dx + dw / 2),
closestY = clamp(sy, dy - dh / 2, dy + dh / 2);
var distanceX = sx - closestX,
distanceY = sy - closestY;
var distanceSquared = (distanceX * distanceX) + (distanceY * distanceY);
return distanceSquared < (sradius * sradius);
};
var collisionC2C = function(sx, sy, sd, dx, dy, dd) {//Method to detect collisions for circle with circle
var sradius = sd / 2,
dradius = dd / 2;
var length = sradius + dradius,
distanceX = sx - dx,
distanceY = sy - dy;
var distanceSquared = (distanceX * distanceX) + (distanceY * distanceY);
return distanceSquared < (length * length);
};
var pbc = function(obj) {
var s = obj.size / 2;
if(obj.y + s < 0)
obj.y = c.canvas.height + s;
else if(obj.y - s > c.canvas.height)
obj.y = -s;
if(obj.x + s < 0)
obj.x = c.canvas.width + s;
else if(obj.x - s > c.canvas.width)
obj.x = -s;
};
var d2g = function(angle) { //Helper to calculate degree -> rad
return Math.PI / 180 * angle;
};
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Florian lives in Munich, Germany. He started his programming career with Perl. After programming C/C++ for some years he discovered his favorite programming language C#. He did work at Siemens as a programmer until he decided to study Physics.
During his studies he worked as an IT consultant for various companies. After graduating with a PhD in theoretical particle Physics he is working as a senior technical consultant in the field of home automation and IoT.
Florian has been giving lectures in C#, HTML5 with CSS3 and JavaScript, software design, and other topics. He is regularly giving talks at user groups, conferences, and companies. He is actively contributing to open-source projects. Florian is the maintainer of AngleSharp, a completely managed browser engine.