Skip to content

Commit

Permalink
reposition and resize grid, creature code needs more work
Browse files Browse the repository at this point in the history
  • Loading branch information
calebj0seph committed May 22, 2012
1 parent 8212735 commit 05f664c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions combat/Arena.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function Arena() {
Arena.prototype.init = function() {
var _this = this;
// Generate Renderers
this.tilesRenderer = new CanvasRenderer($("#tiles")[0], 18);
this.arenaRenderer = new CanvasRenderer($("#arena")[0], 18);
this.tilesRenderer = new CanvasRenderer($("#tiles")[0], 17);
this.arenaRenderer = new CanvasRenderer($("#arena")[0], 17);
this.tilesRenderer.resizeToWindow();
this.arenaRenderer.resizeToWindow();

Expand Down
10 changes: 5 additions & 5 deletions combat/TileMap.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function TileMap(columns, rows) {
// Scale of TileMap
this.tilesSize = new Vector2D(1.0, 0.7);
this.tilesSize = new Vector2D(1.0, 0.75);
// Location of TileMap
this.tilesTranslation = new Vector2D(0.3, 4.1);
this.tilesTranslation = new Vector2D(0.25, 3.5);

this.columns = columns || 2;
this.rows = rows || 2;
Expand All @@ -27,7 +27,7 @@ TileMap.prototype.draw = function(renderer) {
for (var y=0; y < this.rows; ++y) {
for (var x=0; x < this.columns; ++x) {
renderer.save();
var offset = new Vector2D(y % 2 == 0 ? this.tilesSize.x : this.tilesSize.x * 0.5, 0);
var offset = new Vector2D(y % 2 == 0 ? this.tilesSize.x * 0.5 : 0, 0);
var translate = new Vector2D(offset.x + x * this.tileSeparation.x, offset.y + y * this.tileSeparation.y);
renderer.translate(translate);

Expand All @@ -45,7 +45,7 @@ TileMap.prototype.getTilePosition = function(tile) {
var columnWidth = (this.tilesSize.x*this.tileSeparation.x);
var tileIndex2D = this.getTileIndex2D(tile);
var position = new Vector2D(tileIndex2D.x * columnWidth, tileIndex2D.y * rowHeight);
var offsetX = tileIndex2D.y % 2 == 0 ? columnWidth : columnWidth/2;
var offsetX = tileIndex2D.y % 2 == 0 ? columnWidth * 0.5 : 0;
position.x = position.x + offsetX;
position = position.add(this.tilesTranslation);
position = position.multiply(this.tilesSize);
Expand Down Expand Up @@ -142,7 +142,7 @@ TileMap.prototype.getActiveTile = function(renderer, mouse) {

var translatedMouse = mouse.substract(this.tilesTranslation);
var activeRow = Math.floor(translatedMouse.y / rowHeight) % this.rows;
var offsetX = activeRow % 2 == 0 ? columnWidth : columnWidth/2;
var offsetX = activeRow % 2 == 0 ? columnWidth * 0.5 : 0;
var activeColumn = Math.floor((translatedMouse.x-offsetX) / columnWidth) % this.columns;

// ignore if past the offset
Expand Down

0 comments on commit 05f664c

Please sign in to comment.