forked from codergautam/spicywar.io
-
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
0 parents
commit e720328
Showing
34 changed files
with
1,805 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,48 @@ | ||
<<<<<<< HEAD | ||
node_modules/ | ||
.env | ||
# Compiled source # | ||
################### | ||
.breakpoints | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.so | ||
out/ | ||
config.json | ||
dist/ | ||
# Packages # | ||
############ | ||
# it's better to unpack these files and commit the raw source | ||
# git has its own built in compression methods | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
|
||
|
||
# Logs and databases # | ||
###################### | ||
*.log | ||
*.sql | ||
*.sqlite | ||
|
||
# OS generated files # | ||
###################### | ||
.DS_Store | ||
.DS_Store? | ||
._* | ||
.Spotlight-V100 | ||
.Trashes | ||
ehthumbs.db | ||
Thumbs.db | ||
node_modules/ | ||
.env | ||
.DS_Store | ||
package-lock.json |
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 @@ | ||
web: node . |
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,175 @@ | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="icon" type="image/png" href="/assets/images/sword.png" /> | ||
|
||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="shortcut icon" type="image/jpg" href="favicon.png" /> | ||
<meta charset="utf-8"> | ||
<meta name="description" content="A fun multiplayer game where you fight with 2d swords! Play with friends or go solo, all in the comfort or your web browser."> | ||
<meta name="keywords" content="IOGAME, swordbattle, codergautam, swordiogame, swordio"> | ||
<meta name="author" content="CoderGautam"> | ||
<meta name="viewport" content="width=device-width"> | ||
|
||
<title>Waterwar.io</title> | ||
<style> | ||
|
||
.title { | ||
font-family: courier, cursive; | ||
font-size: 130px; | ||
} | ||
.container { | ||
position: absolute; | ||
margin: 0px; | ||
top: 0%; | ||
left: 50%; | ||
-moz-transform: translateX(-50%) translateY(-30%); | ||
-webkit-transform: translateX(-50%) translateY(-30%); | ||
transform: translateX(-50%) translateY(-20%); | ||
} | ||
|
||
|
||
|
||
|
||
.form { | ||
position: absolute; | ||
margin: 0px; | ||
top: 45%; | ||
left: 50%; | ||
-moz-transform: translateX(-50%) translateY(-60%); | ||
-webkit-transform: translateX(-50%) translateY(-60%); | ||
transform: translateX(-50%) translateY(10%); | ||
} | ||
|
||
.textbox { | ||
font-size: 27.5px; | ||
} | ||
|
||
.dropdown { | ||
position: absolute; | ||
margin: 0px; | ||
top: -.5%; | ||
left: 0%; | ||
-moz-transform: translateX(0%) translateY(5%); | ||
-webkit-transform: translateX(0%) translateY(5%); | ||
transform: translateX(0%) translateY(5%); | ||
} | ||
|
||
.button { | ||
|
||
font-size: 25px; | ||
position: absolute; | ||
margin: 0px; | ||
top: 60%; | ||
left: 50%; | ||
-moz-transform: translateX(-50%) translateY(-60%); | ||
-webkit-transform: translateX(-50%) translateY(-60%); | ||
transform: translateX(-50%) translateY(10%); | ||
transition-duration: 0.4s; | ||
background-color: #2e74e6; /* blue */ | ||
color: white; | ||
padding: 7.5px 16px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
border: 2px solid black; | ||
} | ||
|
||
.button:hover { | ||
background-color: #ffffff; | ||
color: #2e74e6; | ||
} | ||
|
||
@media screen and (max-height: 660px) { | ||
|
||
} | ||
|
||
@media screen and (max-height: 375px) { | ||
.button { | ||
top: 50%; | ||
} | ||
|
||
} | ||
|
||
@media screen and (max-height: 333px) { | ||
.button { | ||
top: 40%; | ||
} | ||
.title { | ||
top: 0% | ||
} | ||
|
||
} | ||
|
||
@media screen and (max-width: 1100px) { | ||
.title { | ||
font-size: 45px; | ||
} | ||
.textbox { | ||
font-size: 17.5px; | ||
} | ||
} | ||
@media screen and (max-width: 761px) { | ||
.title { | ||
font-size: 35px; | ||
} | ||
.textbox { | ||
font-size: 15px; | ||
} | ||
} | ||
@media screen and (max-width: 584px) { | ||
.title { | ||
font-size: 25px; | ||
} | ||
} | ||
@media screen and (max-width: 420px) { | ||
.title { | ||
font-size: 20px; | ||
} | ||
.textbox { | ||
font-size: 10px | ||
} | ||
} | ||
@media screen and (max-width: 320px) { | ||
.title { | ||
font-size: 12.5px; | ||
} | ||
.textbox { | ||
font-size: 10px; | ||
} | ||
} | ||
|
||
|
||
.title { | ||
color: rgb(0, 0, 0); | ||
animation-name: slide; | ||
animation-duration: 1s; | ||
} | ||
|
||
@keyframes slide { | ||
0% {top: -325px;} | ||
} | ||
.loggedin { | ||
cursor: not-allowed; | ||
background-color: lightgray; | ||
} | ||
.loggedin::selection { | ||
color: black; | ||
} | ||
</style> | ||
</head> | ||
<script src="script.js" type="eb309a5872f933ee98ec44f8-text/javascript"></script> | ||
<body> | ||
<div class='form' id='input-form'> | ||
<input id="box" autocomplete="off" class="textbox" name="name" STYLE="color: black; font-family: Verdana; font-weight: bold; background-color: white; border:3px solid #000000; " size="20" maxlength="16" value="" placeholder='Enter Name'></input> | ||
<br></br> | ||
<br></br> | ||
<button name="btn" class="button size">Play!</button> | ||
</div> | ||
<script src="/cdn-cgi/scripts/7d0fa10a/cloudflare-static/rocket-loader.min.js" data-cf-settings="eb309a5872f933ee98ec44f8-|49" defer=""></script><script defer src="https://static.cloudflareinsights.com/beacon.min.js/v652eace1692a40cfa3763df669d7439c1639079717194" integrity="sha512-Gi7xpJR8tSkrpF7aordPZQlW2DLtzUlZcumS8dMQjwDHEnw9I7ZLyiOj/6tZStRBGtGgN6ceN6cMH8z7etPGlw==" data-cf-beacon='{"rayId":"718e0d2e69552bf4","version":"2021.12.0","r":1,"token":"19808da52d6a413099d39b5c06310939","si":100}' crossorigin="anonymous"></script> | ||
</body> | ||
</div> | ||
<br> | ||
</html> |
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.
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 @@ | ||
const intersect = require("intersects"); | ||
module.exports = class Bridge { | ||
constructor(island1, island2, width) { | ||
this.island1 = island1; | ||
this.island2 = island2; | ||
this.width = width; | ||
this.length = Math.sqrt(Math.pow(this.island1.pos.x - this.island2.pos.x, 2) + Math.pow(this.island1.pos.y - this.island2.pos.y, 2)); | ||
|
||
// calculate angle | ||
this.angle = Math.atan2(island2.pos.y - island1.pos.y, island2.pos.x - island1.pos.x)+Math.PI/2; | ||
//to degrees | ||
console.log( this.angle * 180 / Math.PI); | ||
} | ||
getSendObject() { | ||
return { | ||
width: this.width, | ||
length: this.length, | ||
angle: this.angle, | ||
pos: this.getCorners()[2], | ||
corners: [this.getCorners()[2]], | ||
}; | ||
} | ||
getCorners(extraDiff = 1) { | ||
// find 4 corners of the bridge, make sure to use the angle and width | ||
var newWidth = this.width * extraDiff; | ||
var corners = []; | ||
corners.push({ | ||
x: this.island1.pos.x + Math.cos(this.angle) * newWidth, | ||
y: this.island1.pos.y + Math.sin(this.angle) * newWidth, | ||
}); | ||
corners.push({ | ||
x: this.island1.pos.x - Math.cos(this.angle) * newWidth, | ||
y: this.island1.pos.y - Math.sin(this.angle) * newWidth, | ||
}); | ||
corners.push({ | ||
x: this.island2.pos.x - Math.cos(this.angle) * newWidth, | ||
y: this.island2.pos.y - Math.sin(this.angle) * newWidth, | ||
}); | ||
corners.push({ | ||
x: this.island2.pos.x + Math.cos(this.angle) * newWidth, | ||
y: this.island2.pos.y + Math.sin(this.angle) * newWidth, | ||
}); | ||
return corners; | ||
} | ||
isIn(player) { | ||
// check if pos is in the bridge | ||
var corners = []; | ||
var u = this.getCorners() | ||
u.forEach(corner => { | ||
corners.push(corner.x); | ||
corners.push(corner.y); | ||
}); | ||
var center = player.getCenterPoint(); | ||
|
||
return intersect.pointPolygon(center.x, center.y, corners); | ||
} | ||
} |
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 @@ | ||
const idgen = require("../helpers/idgen"); | ||
const intersect = require("intersects"); | ||
const io = require("../helpers/io"); | ||
|
||
function getRandomInt(min, max) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
|
||
class Bullet { | ||
constructor(player, offset) { | ||
this.speed = player.speed / 2; | ||
this.angle = player.lookAngle; | ||
//cloning the object is necessary because the object is changed in the tick function | ||
this.pos = JSON.parse(JSON.stringify(player.pos)); | ||
this.pos.x += (Math.cos(this.angle) * this.speed * (50+offset)); | ||
this.pos.y += (Math.sin(this.angle) * this.speed * (50+offset)); | ||
this.createdAt = Date.now(); | ||
this.owner = player.id; | ||
this.roomId = player.roomId; | ||
this.id = idgen(); | ||
|
||
this.length = 10; | ||
io.getio().to(this.roomId).emit("addBullet", this.getSendObject()); | ||
} | ||
tick(tickDiff) { | ||
this.pos.x += Math.cos(this.angle) * this.speed * 50 * (tickDiff / 50); | ||
this.pos.y += Math.sin(this.angle) * this.speed * 50 * (tickDiff / 50); | ||
} | ||
collidingPlayer(entity) { | ||
if(entity.id == this.owner) return false; | ||
|
||
|
||
|
||
var corners = entity.getCorners(); | ||
var arr = []; | ||
corners.forEach(function(corner) { | ||
arr.push(corner.x); | ||
arr.push(corner.y); | ||
}); | ||
|
||
//check is inside corners | ||
|
||
|
||
return intersect.circlePolygon(this.pos.x, this.pos.y, this.length, arr); | ||
|
||
} | ||
collidingBullet(bullet) { | ||
return intersect.circleCircle(this.pos.x, this.pos.y, this.length, bullet.pos.x, bullet.pos.y, bullet.length); | ||
} | ||
getSendObject() { | ||
return { | ||
pos: this.pos, | ||
id: this.id, | ||
angle: this.angle, | ||
speed: this.speed, | ||
owner: this.owner, | ||
} | ||
} | ||
} | ||
|
||
module.exports = Bullet; |
Oops, something went wrong.