-
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.
fixed some undefined game variables and added floor data.
- Loading branch information
Showing
89 changed files
with
3,078 additions
and
12 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
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,2 @@ | ||
title: ChromeRogue | ||
version: 0.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,11 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>{{ site.title }}</title> | ||
<script src="js/game.js" charset="utf-8"></script> | ||
<script src="js/main.js" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
</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,16 @@ | ||
# Chrome-Rogue | ||
|
||
## About | ||
A topdown roguelike game! This game is in active development. Come join us on freenode (irc) in #bbg! | ||
|
||
## Instructions | ||
|
||
### Install | ||
|
||
$git clone https://github.com/zachdyer/chrome-rogue.git | ||
$cd chrome-rogue | ||
$nemo . | ||
Open index.html | ||
|
||
### Demo | ||
To demo the game go to https://zachdyer.github.io/chrome-rogue/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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.
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.
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,18 @@ | ||
# Chrome-Rogue | ||
|
||
## About | ||
A topdown roguelike game! This game is in active development. Come join us on freenode (irc) in #bbg! | ||
|
||
## Instructions | ||
|
||
### Install | ||
|
||
$git clone https://github.com/zachdyer/chrome-rogue.git | ||
$cd chrome-rogue | ||
$nemo . | ||
Open index.html | ||
|
||
### Demo | ||
To demo the game go to https://zachdyer.github.io/chrome-rogue/ | ||
|
||
## License |
Binary file not shown.
Binary file not shown.
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.
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,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Roguelike JS</title> | ||
<script src="js/Game.js" charset="utf-8"></script> | ||
<script src="js/State.js" charset="utf-8"></script> | ||
<script src="js/Player.js" charset="utf-8"></script> | ||
<script src="js/Map.js" charset="utf-8"></script> | ||
<script src="js/Sprite.js" charset="utf-8"></script> | ||
<script src="js/TileSheet.js" charset="utf-8"></script> | ||
<script src="js/Enemy.js" charset="utf-8"></script> | ||
<script src="js/main.js" charset="utf-8"></script> | ||
</head> | ||
<body> | ||
</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,53 @@ | ||
function Enemy(map, player) { | ||
this.enemies = []; | ||
this.Rat = function(x, y) { | ||
this.x = x; | ||
this.y = y; | ||
this.startX = x; | ||
this.speed = 0.1; | ||
this.direction = "right"; | ||
}; | ||
this.generate = function(map) { | ||
//Place rats | ||
for(var i = 0; i < map.rooms.length; i++) { | ||
var room = map.rooms[i]; | ||
//2 out of 3 rooms get a filthy rat | ||
if(game.random(0, 100) > 25) { | ||
//This spawns a random rat in the room | ||
var x = game.random(room.x + 1, room.x + room.width); | ||
var y = game.random(room.y + 1, room.y + room.height); | ||
var rat = new this.Rat(x,y); | ||
this.enemies.push(rat); | ||
} | ||
} | ||
}; | ||
this.render = function() { | ||
var rat = new Sprite(game.assets.images[6], 4, 0); | ||
var scale = map.tileSize * map.scale; | ||
for(var i = 0; i < this.enemies.length; i++) { | ||
var enemy = this.enemies[i]; | ||
var drawX = Math.floor(scale * enemy.x - player.x * scale + window.innerWidth / 2 - map.tileSize / 2); | ||
var drawY = Math.floor(scale * enemy.y - player.y * scale + window.innerHeight / 2 - map.tileSize / 2); | ||
game.ctx.drawImage( | ||
rat, | ||
drawX, | ||
drawY, | ||
scale, | ||
scale | ||
); | ||
} | ||
}; | ||
this.update = function() { | ||
for(var i = 0; i < this.enemies.length; i++) { | ||
var enemy = this.enemies[i]; | ||
if(enemy.x - enemy.startX > 1 && enemy.direction == "right") { | ||
enemy.speed = -enemy.speed; | ||
enemy.direction = "left"; | ||
} else if(enemy.x - enemy.startX < -1 && enemy.direction == "left") { | ||
enemy.speed = Math.abs(enemy.speed); | ||
enemy.direction = "right"; | ||
} | ||
enemy.x += enemy.speed; | ||
} | ||
}; | ||
}; |
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,42 @@ | ||
function Filter(img, width, height) { | ||
var canvas = getCanvas(width, height); | ||
var pixels = getPixels(img); | ||
|
||
return canvas; | ||
|
||
var getPixels = function(img) { | ||
var c = this.getCanvas(img.width, img.height); | ||
var ctx = c.getContext('2d'); | ||
ctx.drawImage(img); | ||
return ctx.getImageData(0,0,c.width,c.height); | ||
}; | ||
|
||
var getCanvas = function(w,h) { | ||
var c = document.createElement('canvas'); | ||
c.width = w; | ||
c.height = h; | ||
return c; | ||
}; | ||
|
||
var filterImage = function(filter, image, var_args) { | ||
var args = [this.getPixels(image)]; | ||
for (var i=2; i<arguments.length; i++) { | ||
args.push(arguments[i]); | ||
} | ||
return filter.apply(null, args); | ||
}; | ||
|
||
var grayscale = function(pixels, args) { | ||
var d = pixels.data; | ||
for (var i=0; i<d.length; i+=4) { | ||
var r = d[i]; | ||
var g = d[i+1]; | ||
var b = d[i+2]; | ||
// CIE luminance for the RGB | ||
// The human eye is bad at seeing red and blue, so we de-emphasize them. | ||
var v = 0.2126*r + 0.7152*g + 0.0722*b; | ||
d[i] = d[i+1] = d[i+2] = v | ||
} | ||
return pixels; | ||
}; | ||
} |
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,151 @@ | ||
'use strict' | ||
|
||
function Game() { | ||
//self supports the use of "this" inside methods. | ||
var self = this; | ||
var loadingImg = new Image(); | ||
|
||
|
||
|
||
//Exporting the canvas and default settings | ||
this.canvas = document.createElement("canvas"); | ||
this.canvas.width = window.innerWidth; | ||
this.canvas.height = window.innerHeight; | ||
this.canvas.style.backgroundColor = "black"; | ||
this.canvas.style.cursor = "none"; | ||
this.ctx = this.canvas.getContext("2d"); | ||
this.ctx.imageSmoothingEnabled = false; | ||
|
||
//Arrays to store assets | ||
this.assets = { | ||
images: [], | ||
audio: [] | ||
}; | ||
|
||
//Game.load takes an array of assets such as scripts, images, and audio then loads them | ||
this.load = function(assets, callback) { | ||
var loadStart = Date.now(); | ||
var loadCount = 0; | ||
if(assets.length) { | ||
for(var i = 0; i < assets.length; i++) { | ||
if(assets[i].search(".png") != -1 || assets[i].search(".gif") != -1) { | ||
var image = new Image(); | ||
image.setAttribute("src", assets[i]); | ||
self.assets.images.push(image); | ||
image.onload = function() { | ||
loadCount++; | ||
//Handle loading image | ||
if(image.src.search("loading.gif") != -1) { | ||
document.body.style.background = "rgb(25, 31, 38)"; | ||
self.canvas.style.background = "rgb(25, 31, 38)"; | ||
loadingImg = image; | ||
loadingImg.style.margin = "0 auto"; | ||
loadingImg.style.display = "block"; | ||
document.body.appendChild(loadingImg); | ||
} | ||
if(loadCount === assets.length) finish(); | ||
}; | ||
} else if(assets[i].search(".mp3") != -1) { | ||
var audio = document.createElement("audio"); | ||
audio.setAttribute("type","audio/mpeg"); | ||
audio.setAttribute("src", assets[i]); | ||
audio.setAttribute("loop", "true"); | ||
self.assets.audio.push(audio); | ||
loadCount++; | ||
if(loadCount === assets.length) finish(); | ||
} | ||
} | ||
} | ||
var finish = function() { | ||
console.log("load time: ", Date.now() - loadStart, "ms"); | ||
//Styling body element | ||
document.body.style.margin = 0; | ||
document.body.style.overflow = "hidden"; | ||
loadingImg.style.display = "none"; | ||
document.body.appendChild(self.canvas); | ||
window.onload = callback; | ||
}; | ||
}; | ||
|
||
//readjust the canvas size on resize of the window | ||
window.onresize = function() { | ||
self.canvas.width = window.innerWidth; | ||
self.canvas.height = window.innerHeight; | ||
self.ctx.imageSmoothingEnabled = false; | ||
}; | ||
|
||
//Allows you to set the cursor type or turn it off | ||
this.cursor = function(bool, type) { | ||
if(bool) { | ||
document.body.style.cursor = type; | ||
} else { | ||
document.body.style.cursor = "none"; | ||
} | ||
}; | ||
|
||
// antialias allows you to toggle antialias of the canvas off and on | ||
this.antialias = function(bool) { | ||
return self.ctx.imageSmoothingEnabled = bool; | ||
}; | ||
|
||
//FPS | ||
//Game.fps is the games fps value that updates every second | ||
this.fps = 0; | ||
var fps = {}; | ||
fps.lastTime = 0; | ||
fps.timePerTick = 17; | ||
fps.lastUpdate = Date.now(); //This sets a time stamp every second to update the Game.fps | ||
fps.get = function(currentTime, lastTime) { | ||
var fps = 1000 / (currentTime - lastTime); | ||
return fps.toFixed(); | ||
}; | ||
fps.update = function() { | ||
var currentTime = Date.now(); | ||
if(currentTime - fps.lastUpdate >= 1000) { | ||
self.fps = ~~(1000 / (currentTime - fps.lastTime)); | ||
fps.lastUpdate = currentTime; | ||
} | ||
fps.timePerTick = currentTime - fps.lastTime; | ||
fps.lastTime = currentTime; | ||
}; | ||
|
||
// speedPerSecond will calculate the distance to | ||
// travel in a tick to equal the speed in one second | ||
this.speedPerSecond = function(speed) { | ||
var delta = fps.timePerTick / 1000; | ||
return speed * delta; | ||
}; | ||
|
||
//Message box | ||
this.messageBox = function(x, y, width, textArray) { | ||
var box = { | ||
x: x, | ||
y: y, | ||
width: width, | ||
height: textArray.length * 20 + 20, | ||
}; | ||
self.ctx.fillStyle = "rgba(0,0,0,0.8)"; | ||
self.ctx.fillRect(x, y, box.width, box.height); | ||
self.ctx.fillStyle = "white"; | ||
for(var i = 0; i < textArray.length; i++) { | ||
self.ctx.fillText(textArray[i], x + 20, (y + 20 * i) + 20); | ||
} | ||
}; | ||
|
||
this.random = function(min, max) { | ||
return ~~(Math.random() * (max - min)) + min; | ||
}; | ||
|
||
//The main game loop | ||
var clearScreen = function(){ | ||
self.ctx.clearRect(0, 0, self.canvas.width, self.canvas.height); | ||
}; | ||
this.loop = function (custom){ | ||
requestAnimationFrame(function(){ | ||
clearScreen(); | ||
custom(); | ||
fps.update(); | ||
self.loop(custom); | ||
}) | ||
}; | ||
} |
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,8 @@ | ||
function Item() { | ||
var material = ["wood","stone","copper", "iron","steel","diamond"]; | ||
|
||
this.name = null; | ||
this.material = null; | ||
this.type = null; | ||
|
||
} |
Oops, something went wrong.