Skip to content

Commit

Permalink
fixed some undefined game variables and added floor data.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachio committed Mar 19, 2017
1 parent eead2e3 commit c5eb06e
Show file tree
Hide file tree
Showing 89 changed files with 3,078 additions and 12 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ A topdown roguelike game! This game is in active development. Come join us on

### Demo
To demo the game go to https://zachdyer.github.io/chrome-rogue/

## License
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: ChromeRogue
version: 0.1.0
11 changes: 11 additions & 0 deletions _layouts/default.html
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>
16 changes: 16 additions & 0 deletions _site/README.md
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 added _site/assets/audio/beep.mp3
Binary file not shown.
Binary file added _site/assets/audio/caverns.mp3
Binary file not shown.
Binary file added _site/assets/audio/chest.mp3
Binary file not shown.
Binary file added _site/assets/audio/dungeon.mp3
Binary file not shown.
Binary file added _site/assets/audio/grunt.mp3
Binary file not shown.
Binary file added _site/assets/audio/hit.mp3
Binary file not shown.
Binary file added _site/assets/audio/little_miss_sunshine.mp3
Binary file not shown.
Binary file added _site/assets/audio/potion.mp3
Binary file not shown.
Binary file added _site/assets/audio/scream.mp3
Binary file not shown.
Binary file added _site/assets/audio/skill-up.mp3
Binary file not shown.
Binary file added _site/assets/audio/step.mp3
Binary file not shown.
Binary file added _site/assets/audio/steps.mp3
Binary file not shown.
Binary file added _site/assets/audio/swing.mp3
Binary file not shown.
Binary file added _site/assets/images/TileA4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/blood-down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/blood-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/blood-right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/blood-splatter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/character-face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/characterDown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/chest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/deadrat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/door.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/dungeontileset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/rat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/assets/images/sword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions _site/backup/README.md
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 added _site/backup/assets/audio/dungeon.mp3
Binary file not shown.
Binary file not shown.
Binary file added _site/backup/assets/audio/steps.mp3
Binary file not shown.
Binary file added _site/backup/assets/images/TileA4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/backup/assets/images/character-face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/backup/assets/images/characterDown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/backup/assets/images/chest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/backup/assets/images/dungeontileset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/backup/assets/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _site/backup/assets/images/rat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions _site/backup/index.html
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>
53 changes: 53 additions & 0 deletions _site/backup/js/Enemy.js
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;
}
};
};
42 changes: 42 additions & 0 deletions _site/backup/js/Filter.js
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;
};
}
151 changes: 151 additions & 0 deletions _site/backup/js/Game.js
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);
})
};
}
8 changes: 8 additions & 0 deletions _site/backup/js/Item.js
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;

}
Loading

0 comments on commit c5eb06e

Please sign in to comment.