Skip to content

Commit

Permalink
Reorganize game images
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Mar 31, 2012
1 parent 5acd2ab commit bcfcc51
Show file tree
Hide file tree
Showing 60 changed files with 111 additions and 102 deletions.
3 changes: 1 addition & 2 deletions app/javascripts/game/image.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ define 'game.Image', ->
assignable,
simpleDrawable,

init: (@name, @width, @height) ->
path = @name
init: (@name, path, @width, @height) ->
unless /\.[^.]+$/.test(path)
path += ".gif"
unless /^\//.test(path)
Expand Down
102 changes: 54 additions & 48 deletions app/javascripts/game/image_collection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ define 'game.imageCollection', ->
numImages = 0
numLoaded = 0

add = (name, width, height) ->
img = images[name] = Image.create(name, width, height)
add = (name, path, width, height) ->
img = images[name] = Image.create(name, path, width, height)
img.onLoad -> numLoaded++
numImages++

addTile = (name, width, height) ->
add(name, "game/tiles/#{name}", width, height)

addObject = (name, width, height) ->
add(name, "game/objects/#{name}", width, height)

get = (name) ->
images[name] or throw new Error "Couldn't find image #{name}!"

Expand All @@ -27,53 +33,53 @@ define 'game.imageCollection', ->

#---

add '8stone', 32, 32
add 'dirt1', 16, 16
add 'dirt2', 16, 16
add 'dirt3', 16, 16
add 'entrance_skull', 32, 16
add 'flower', 16, 48
add 'grass_dirt_edge01', 16, 16
add 'grass_dirt_edge02', 16, 16
add 'grass_dirt_edge03', 16, 16
add 'grass_dirt_edge04', 16, 16
add 'grass_dirt_edge05', 16, 16
add 'grass_dirt_edge06', 16, 16
add 'grass_dirt_edge07', 16, 16
add 'grass_dirt_edge08', 16, 16
add 'grass_dirt_edge09', 16, 16
add 'grass_dirt_edge10', 16, 16
add 'grass_dirt_edge11', 16, 16
add 'grass_dirt_edge12', 16, 16
add 'grass_dirt_edge13', 16, 16
add 'grass_dirt_edge14', 16, 16
add 'grass1', 16, 16
add 'grass2', 16, 16
add 'hill_e', 48, 32
add 'hill_n', 32, 32
add 'hill_ne1', 16, 32
add 'hill_ne2', 32, 16
add 'hill_nw1', 16, 32
add 'hill_nw2', 32, 16
add 'hill_s', 32, 80
add 'hill_se1', 16, 80
add 'hill_se2', 16, 64
add 'hill_se3', 16, 64
add 'hill_se4', 16, 32
add 'hill_sw1', 16, 80
add 'hill_sw2', 16, 64
add 'hill_sw3', 16, 64
add 'hill_sw4', 16, 32
add 'hill_w', 48, 16
add 'links_door_closed', 32, 32
add 'links_house', 208, 200
add 'post1', 16, 32
add 'post2', 16, 32
add 'post3', 16, 32
add 'rock1', 16, 16
add 'rock2', 16, 16
addTile '8stone', 32, 32
addTile 'dirt1', 16, 16
addTile 'dirt2', 16, 16
addTile 'dirt3', 16, 16
addTile 'entrance_skull', 32, 16
addTile 'flower', 16, 48
addTile 'grass_dirt_edge01', 16, 16
addTile 'grass_dirt_edge02', 16, 16
addTile 'grass_dirt_edge03', 16, 16
addTile 'grass_dirt_edge04', 16, 16
addTile 'grass_dirt_edge05', 16, 16
addTile 'grass_dirt_edge06', 16, 16
addTile 'grass_dirt_edge07', 16, 16
addTile 'grass_dirt_edge08', 16, 16
addTile 'grass_dirt_edge09', 16, 16
addTile 'grass_dirt_edge10', 16, 16
addTile 'grass_dirt_edge11', 16, 16
addTile 'grass_dirt_edge12', 16, 16
addTile 'grass_dirt_edge13', 16, 16
addTile 'grass_dirt_edge14', 16, 16
addTile 'grass1', 16, 16
addTile 'grass2', 16, 16
addTile 'hill_e', 48, 32
addTile 'hill_n', 32, 32
addTile 'hill_ne1', 16, 32
addTile 'hill_ne2', 32, 16
addTile 'hill_nw1', 16, 32
addTile 'hill_nw2', 32, 16
addTile 'hill_s', 32, 80
addTile 'hill_se1', 16, 80
addTile 'hill_se2', 16, 64
addTile 'hill_se3', 16, 64
addTile 'hill_se4', 16, 32
addTile 'hill_sw1', 16, 80
addTile 'hill_sw2', 16, 64
addTile 'hill_sw3', 16, 64
addTile 'hill_sw4', 16, 32
addTile 'hill_w', 48, 16
addTile 'links_door_closed', 32, 32
addTile 'links_house', 208, 200
addTile 'post1', 16, 32
addTile 'post2', 16, 32
addTile 'post3', 16, 32
addTile 'rock1', 16, 16
addTile 'rock2', 16, 16

add 'link2x', 34, 1440
addObject 'link2x', 34, 1440

#---

Expand Down
Binary file removed public/images/enemy1.gif
Binary file not shown.
Binary file removed public/images/enemy2x.gif
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file removed public/images/link-sprite-sheet.png
Diff not rendered.
Binary file removed public/images/link.gif
Diff not rendered.
Binary file removed public/images/map.png
Diff not rendered.
Binary file removed public/images/map25.png
Diff not rendered.
Binary file removed public/images/map2x.png
Diff not rendered.
Binary file removed public/images/mask.gif
Diff not rendered.
Binary file removed public/images/player.gif
Diff not rendered.
4 changes: 1 addition & 3 deletions public/javascripts/app/game/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
meta = require('meta');
_ref = require('roles'), assignable = _ref.assignable, simpleDrawable = _ref.simpleDrawable;
Image = meta.def(assignable, simpleDrawable, {
init: function(name, width, height) {
var path;
init: function(name, path, width, height) {
this.name = name;
this.width = width;
this.height = height;
path = this.name;
if (!/\.[^.]+$/.test(path)) path += ".gif";
if (!/^\//.test(path)) path = require('common').resolveImagePath(path);
this.path = path;
Expand Down
104 changes: 55 additions & 49 deletions public/javascripts/app/game/image_collection.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
(function() {

define('game.imageCollection', function() {
var Image, add, each, get, images, isLoaded, load, meta, numImages, numLoaded;
var Image, add, addObject, addTile, each, get, images, isLoaded, load, meta, numImages, numLoaded;
meta = require('meta');
Image = require('game.Image');
images = {};
numImages = 0;
numLoaded = 0;
add = function(name, width, height) {
add = function(name, path, width, height) {
var img;
img = images[name] = Image.create(name, width, height);
img = images[name] = Image.create(name, path, width, height);
img.onLoad(function() {
return numLoaded++;
});
return numImages++;
};
addTile = function(name, width, height) {
return add(name, "game/tiles/" + name, width, height);
};
addObject = function(name, width, height) {
return add(name, "game/objects/" + name, width, height);
};
get = function(name) {
return images[name] || (function() {
throw new Error("Couldn't find image " + name + "!");
Expand All @@ -39,52 +45,52 @@
return fn(images[name]);
});
};
add('8stone', 32, 32);
add('dirt1', 16, 16);
add('dirt2', 16, 16);
add('dirt3', 16, 16);
add('entrance_skull', 32, 16);
add('flower', 16, 48);
add('grass_dirt_edge01', 16, 16);
add('grass_dirt_edge02', 16, 16);
add('grass_dirt_edge03', 16, 16);
add('grass_dirt_edge04', 16, 16);
add('grass_dirt_edge05', 16, 16);
add('grass_dirt_edge06', 16, 16);
add('grass_dirt_edge07', 16, 16);
add('grass_dirt_edge08', 16, 16);
add('grass_dirt_edge09', 16, 16);
add('grass_dirt_edge10', 16, 16);
add('grass_dirt_edge11', 16, 16);
add('grass_dirt_edge12', 16, 16);
add('grass_dirt_edge13', 16, 16);
add('grass_dirt_edge14', 16, 16);
add('grass1', 16, 16);
add('grass2', 16, 16);
add('hill_e', 48, 32);
add('hill_n', 32, 32);
add('hill_ne1', 16, 32);
add('hill_ne2', 32, 16);
add('hill_nw1', 16, 32);
add('hill_nw2', 32, 16);
add('hill_s', 32, 80);
add('hill_se1', 16, 80);
add('hill_se2', 16, 64);
add('hill_se3', 16, 64);
add('hill_se4', 16, 32);
add('hill_sw1', 16, 80);
add('hill_sw2', 16, 64);
add('hill_sw3', 16, 64);
add('hill_sw4', 16, 32);
add('hill_w', 48, 16);
add('links_door_closed', 32, 32);
add('links_house', 208, 200);
add('post1', 16, 32);
add('post2', 16, 32);
add('post3', 16, 32);
add('rock1', 16, 16);
add('rock2', 16, 16);
add('link2x', 34, 1440);
addTile('8stone', 32, 32);
addTile('dirt1', 16, 16);
addTile('dirt2', 16, 16);
addTile('dirt3', 16, 16);
addTile('entrance_skull', 32, 16);
addTile('flower', 16, 48);
addTile('grass_dirt_edge01', 16, 16);
addTile('grass_dirt_edge02', 16, 16);
addTile('grass_dirt_edge03', 16, 16);
addTile('grass_dirt_edge04', 16, 16);
addTile('grass_dirt_edge05', 16, 16);
addTile('grass_dirt_edge06', 16, 16);
addTile('grass_dirt_edge07', 16, 16);
addTile('grass_dirt_edge08', 16, 16);
addTile('grass_dirt_edge09', 16, 16);
addTile('grass_dirt_edge10', 16, 16);
addTile('grass_dirt_edge11', 16, 16);
addTile('grass_dirt_edge12', 16, 16);
addTile('grass_dirt_edge13', 16, 16);
addTile('grass_dirt_edge14', 16, 16);
addTile('grass1', 16, 16);
addTile('grass2', 16, 16);
addTile('hill_e', 48, 32);
addTile('hill_n', 32, 32);
addTile('hill_ne1', 16, 32);
addTile('hill_ne2', 32, 16);
addTile('hill_nw1', 16, 32);
addTile('hill_nw2', 32, 16);
addTile('hill_s', 32, 80);
addTile('hill_se1', 16, 80);
addTile('hill_se2', 16, 64);
addTile('hill_se3', 16, 64);
addTile('hill_se4', 16, 32);
addTile('hill_sw1', 16, 80);
addTile('hill_sw2', 16, 64);
addTile('hill_sw3', 16, 64);
addTile('hill_sw4', 16, 32);
addTile('hill_w', 48, 16);
addTile('links_door_closed', 32, 32);
addTile('links_house', 208, 200);
addTile('post1', 16, 32);
addTile('post2', 16, 32);
addTile('post3', 16, 32);
addTile('rock1', 16, 16);
addTile('rock2', 16, 16);
addObject('link2x', 34, 1440);
return {
get: get,
load: load,
Expand Down

0 comments on commit bcfcc51

Please sign in to comment.