Browse Source

External dependencies added, and Gulp build process configured. That only cost me half a soul...

feature/coffeescript
Sven Slootweg 8 years ago
parent
commit
934859d92b
  1. 2
      .gitignore
  2. 13
      TODO.md
  3. 12508
      compiled/radium.js
  4. 6
      compiled/radium.min.js
  5. 9190
      external/jquery-2.1.1.js
  6. 12
      external/preloadjs-0.4.1.min.js
  7. 18
      external/soundjs-0.5.2.min.js
  8. 4
      gemswap.html
  9. 147
      gemswap/gemswap.js
  10. 1
      gemswap/gemswap.min.js
  11. 99
      gulpfile.js
  12. 19
      package.json

2
.gitignore

@ -0,0 +1,2 @@
/node_modules/
/npm-debug.log

13
TODO.md

@ -0,0 +1,13 @@
# TODO list
## Behavioural bugs
* Ensure that object association is not lost when a Timer is fired for an object.
## Visual bugs
* Make the first frame draw correctly, without requiring a `return true` from the onStep event.
## Ideas
None.

12508
compiled/radium.js
File diff suppressed because it is too large
View File

6
compiled/radium.min.js
File diff suppressed because it is too large
View File

9190
external/jquery-2.1.1.js
File diff suppressed because it is too large
View File

12
external/preloadjs-0.4.1.min.js
File diff suppressed because it is too large
View File

18
external/soundjs-0.5.2.min.js
File diff suppressed because it is too large
View File

4
gemswap.html

@ -2,7 +2,7 @@
<html>
<head>
<title>Gemswap</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> -->
<script src="compiled/radium.js"></script>
<script src="gemswap/gemswap.js"></script>
<link rel="stylesheet" href="gemswap/gemswap.css">
@ -11,4 +11,4 @@
<canvas id="gamecanvas"></canvas>
<div id="debug"></div>
</body>
</html>
</html>

147
gemswap/gemswap.js

@ -1,79 +1,76 @@
// Generated by CoffeeScript 1.7.1
(function() {
$(function() {
var engine, manager;
manager = new ResourceManager("gemswap/assets");
engine = new Engine(manager);
window.debug_engine = engine;
(function () {$(function() {
var engine, manager;
manager = new ResourceManager("gemswap/assets");
engine = new Engine(manager);
window.debug_engine = engine;
/*
* Configure pre-loading assets
manager.addImages([
"images/loading_screen.png"
], true)
*/
manager.addImages(["images/cursor.png", "images/diamond.png", "images/diamond_inverted.png", "images/diamond_shimmer.png", "images/yellow.png", "images/yellow_inverted.png", "images/yellow_shimmer.png", "images/blue.png", "images/blue_inverted.png", "images/blue_shimmer.png"]);
/*
* Configure pre-loading assets
manager.addImages([
"images/loading_screen.png"
], true)
*/
manager.addImages(["images/cursor.png", "images/diamond.png", "images/diamond_inverted.png", "images/diamond_shimmer.png", "images/yellow.png", "images/yellow_inverted.png", "images/yellow_shimmer.png", "images/blue.png", "images/blue_inverted.png", "images/blue_shimmer.png"]);
/*
manager.addSounds([
"sfx/match.wav"
"sfx/swap.wav"
])
*/
manager.prepare();
return manager.preload(null, function() {
var cursor, diamond, scene, x, y, _i, _j;
engine.addCanvas($("#gamecanvas"));
scene = engine.createScene("main");
engine.createSprite("cursor", "images/cursor.png");
engine.createSprite("diamond", "images/diamond.png");
engine.createSprite("diamond_inverted", "images/diamond_inverted.png");
engine.createSprite("diamond_shimmer", "images/diamond_shimmer.png");
engine.createSprite("yellow", "images/yellow.png");
engine.createSprite("yellow_inverted", "images/yellow_inverted.png");
engine.createSprite("yellow_shimmer", "images/yellow_shimmer.png");
engine.createSprite("blue", "images/blue.png");
engine.createSprite("blue_inverted", "images/blue_inverted.png");
engine.createSprite("blue_shimmer", "images/blue_shimmer.png");
cursor = engine.createObject("cursor");
cursor.sprite = engine.getSprite("cursor");
diamond = engine.createObject("diamond");
diamond.sprite = engine.getSprite("diamond");
diamond.draw_sprite = false;
diamond.onCreate = function() {
this.fade_value = 0;
this.shimmer_value = this.engine.ease.circInOut(0, 0.8, engine.random.number(200, 350), null, true, true);
return this.gem_type = this.engine.random.pick("diamond", "yellow", "blue");
};
diamond.onStep = function() {
return true;
};
diamond.onDraw = function() {
this.engine.getSprite(this.gem_type).draw(this.x, this.y);
this.engine.getSprite("" + this.gem_type + "_inverted").draw(this.x, this.y, {
alpha: this.fade_value
});
return this.engine.getSprite("" + this.gem_type + "_shimmer").draw(this.x - 14, this.y - 14, {
alpha: this.shimmer_value
});
};
diamond.onMouseOver = function() {
this.fade_value = this.engine.ease.quadInOut(0, 1, 10, this.engine.ease.bounceOut(1, 0, 35));
cursor = this.engine.getObject("cursor").getInstances()[0];
cursor.x = this.engine.ease.quadInOut(cursor.x, this.x - 9, 8);
return cursor.y = this.engine.ease.quadInOut(cursor.y, this.y - 9, 8);
};
for (x = _i = 10; _i <= 728; x = _i += 80) {
for (y = _j = 10; _j <= 550; y = _j += 80) {
scene.createInstance(diamond, x, y);
}
/*
manager.addSounds([
"sfx/match.wav"
"sfx/swap.wav"
])
*/
manager.prepare();
return manager.preload(null, function() {
var cursor, diamond, scene, x, y, _i, _j;
engine.addCanvas($("#gamecanvas"));
scene = engine.createScene("main");
engine.createSprite("cursor", "images/cursor.png");
engine.createSprite("diamond", "images/diamond.png");
engine.createSprite("diamond_inverted", "images/diamond_inverted.png");
engine.createSprite("diamond_shimmer", "images/diamond_shimmer.png");
engine.createSprite("yellow", "images/yellow.png");
engine.createSprite("yellow_inverted", "images/yellow_inverted.png");
engine.createSprite("yellow_shimmer", "images/yellow_shimmer.png");
engine.createSprite("blue", "images/blue.png");
engine.createSprite("blue_inverted", "images/blue_inverted.png");
engine.createSprite("blue_shimmer", "images/blue_shimmer.png");
cursor = engine.createObject("cursor");
cursor.sprite = engine.getSprite("cursor");
diamond = engine.createObject("diamond");
diamond.sprite = engine.getSprite("diamond");
diamond.draw_sprite = false;
diamond.onCreate = function() {
this.fade_value = 0;
this.shimmer_value = this.engine.ease.circInOut(0, 0.8, engine.random.number(200, 350), null, true, true);
return this.gem_type = this.engine.random.pick("diamond", "yellow", "blue");
};
diamond.onStep = function() {
return true;
};
diamond.onDraw = function() {
this.engine.getSprite(this.gem_type).draw(this.x, this.y);
this.engine.getSprite("" + this.gem_type + "_inverted").draw(this.x, this.y, {
alpha: this.fade_value
});
return this.engine.getSprite("" + this.gem_type + "_shimmer").draw(this.x - 14, this.y - 14, {
alpha: this.shimmer_value
});
};
diamond.onMouseOver = function() {
this.fade_value = this.engine.ease.quadInOut(0, 1, 10, this.engine.ease.bounceOut(1, 0, 35));
cursor = this.engine.getObject("cursor").getInstances()[0];
cursor.x = this.engine.ease.quadInOut(cursor.x, this.x - 9, 8);
return cursor.y = this.engine.ease.quadInOut(cursor.y, this.y - 9, 8);
};
for (x = _i = 10; _i <= 728; x = _i += 80) {
for (y = _j = 10; _j <= 550; y = _j += 80) {
scene.createInstance(diamond, x, y);
}
cursor.onStep = function() {
return $("#debug").html("Mouse coords: " + this.scene.mouse_x + " / " + this.scene.mouse_y + "<br>Frameskip: " + this.engine.frameskip);
};
scene.createInstance(cursor, 0, 0);
return engine.start();
});
}
cursor.onStep = function() {
return $("#debug").html("Mouse coords: " + this.scene.mouse_x + " / " + this.scene.mouse_y + "<br>Frameskip: " + this.engine.frameskip);
};
scene.createInstance(cursor, 0, 0);
return engine.start();
});
}).call(this);
});
})();

1
gemswap/gemswap.min.js

@ -0,0 +1 @@
(function(){$(function(){var e,i;return i=new ResourceManager("gemswap/assets"),e=new Engine(i),window.debug_engine=e,i.addImages(["images/cursor.png","images/diamond.png","images/diamond_inverted.png","images/diamond_shimmer.png","images/yellow.png","images/yellow_inverted.png","images/yellow_shimmer.png","images/blue.png","images/blue_inverted.png","images/blue_shimmer.png"]),i.prepare(),i.preload(null,function(){var i,n,t,r,a,s,m;for(e.addCanvas($("#gamecanvas")),t=e.createScene("main"),e.createSprite("cursor","images/cursor.png"),e.createSprite("diamond","images/diamond.png"),e.createSprite("diamond_inverted","images/diamond_inverted.png"),e.createSprite("diamond_shimmer","images/diamond_shimmer.png"),e.createSprite("yellow","images/yellow.png"),e.createSprite("yellow_inverted","images/yellow_inverted.png"),e.createSprite("yellow_shimmer","images/yellow_shimmer.png"),e.createSprite("blue","images/blue.png"),e.createSprite("blue_inverted","images/blue_inverted.png"),e.createSprite("blue_shimmer","images/blue_shimmer.png"),i=e.createObject("cursor"),i.sprite=e.getSprite("cursor"),n=e.createObject("diamond"),n.sprite=e.getSprite("diamond"),n.draw_sprite=!1,n.onCreate=function(){return this.fade_value=0,this.shimmer_value=this.engine.ease.circInOut(0,.8,e.random.number(200,350),null,!0,!0),this.gem_type=this.engine.random.pick("diamond","yellow","blue")},n.onStep=function(){return!0},n.onDraw=function(){return this.engine.getSprite(this.gem_type).draw(this.x,this.y),this.engine.getSprite(""+this.gem_type+"_inverted").draw(this.x,this.y,{alpha:this.fade_value}),this.engine.getSprite(""+this.gem_type+"_shimmer").draw(this.x-14,this.y-14,{alpha:this.shimmer_value})},n.onMouseOver=function(){return this.fade_value=this.engine.ease.quadInOut(0,1,10,this.engine.ease.bounceOut(1,0,35)),i=this.engine.getObject("cursor").getInstances()[0],i.x=this.engine.ease.quadInOut(i.x,this.x-9,8),i.y=this.engine.ease.quadInOut(i.y,this.y-9,8)},r=s=10;728>=s;r=s+=80)for(a=m=10;550>=m;a=m+=80)t.createInstance(n,r,a);return i.onStep=function(){return $("#debug").html("Mouse coords: "+this.scene.mouse_x+" / "+this.scene.mouse_y+"<br>Frameskip: "+this.engine.frameskip)},t.createInstance(i,0,0),e.start()})})}).call(this);

99
gulpfile.js

@ -0,0 +1,99 @@
var gulp = require('gulp');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var coffee = require('gulp-coffee');
var addsrc = require('gulp-add-src');
var cache = require('gulp-cached');
var remember = require('gulp-remember');
var header = require('gulp-header');
var footer = require('gulp-footer');
/* Engine build tasks */
engine = {
source: "radium/*.coffee",
external: ["external/jquery-2.1.1.js", "external/preloadjs-0.4.1.min.js", "external/soundjs-0.5.2.min.js"],
target: {
path: "compiled",
name: "radium.js",
minName: "radium.min.js"
}
}
gulp.task('dev-engine', function() {
return gulp.src(engine.source)
.pipe(cache("engine-coffee"))
.pipe(coffee({bare: true}).on('error', gutil.log)).on('data', gutil.log)
.pipe(remember("engine-coffee"))
.pipe(concat("radium.coffee.js"))
.pipe(header('(function () {'))
.pipe(footer('})();'))
.pipe(addsrc(engine.external))
.pipe(concat("radium.concat.js"))
.pipe(rename(engine.target.name))
.pipe(gulp.dest(engine.target.path));
});
gulp.task("prod-engine", ["dev-engine"], function(){
return gulp.src(engine.target.path + "/" + engine.target.name)
.pipe(uglify())
.pipe(rename(engine.target.minName))
.pipe(gulp.dest(engine.target.path));
});
/* Sample game build tasks */
gemswap = {
source: "gemswap/*.coffee",
external: "",
target: {
path: "gemswap",
name: "gemswap.js",
minName: "gemswap.min.js"
}
}
gulp.task('dev-gemswap', function() {
return gulp.src(gemswap.source)
.pipe(cache("gemswap-coffee"))
.pipe(coffee({bare: true}).on('error', gutil.log)).on('data', gutil.log)
.pipe(remember("gemswap-coffee"))
.pipe(concat("gemswap.coffee.js"))
.pipe(header('(function () {'))
.pipe(footer('})();'))
.pipe(addsrc(gemswap.external))
.pipe(concat("gemswap.concat.js"))
.pipe(rename(gemswap.target.name))
.pipe(gulp.dest(gemswap.target.path));
});
gulp.task("prod-gemswap", ["dev-gemswap"], function(){
return gulp.src(gemswap.target.path + "/" + gemswap.target.name)
.pipe(uglify())
.pipe(rename(gemswap.target.minName))
.pipe(gulp.dest(gemswap.target.path));
});
/* Watcher */
gulp.task('watch', function () {
targets = {
"gemswap": gemswap,
"engine": engine
}
for(name in targets)
{
var watcher = gulp.watch(targets[name].source, ['dev-' + name]);
watcher.on('change', function (event) {
if (event.type === 'deleted')
{
delete cache.caches[name + '-coffee'][event.path];
remember.forget(name + '-coffee', event.path);
}
});
}
});
gulp.task("dev", ["dev-engine", "dev-gemswap"]);
gulp.task("prod", ["prod-engine", "prod-gemswap"]);
gulp.task("default", ["prod"]);

19
package.json

@ -0,0 +1,19 @@
{
"name": "radium",
"description": "A game engine.",
"version": "0.0.1",
"devDependencies": {
"gulp": "3.6.x",
"gulp-add-src": "0.1.x",
"gulp-coffee": "1.4",
"gulp-concat": "2.2.x",
"gulp-rename": "1.2.x",
"gulp-uglify": "0.3.x",
"gulp-util": "2.2.x",
"gulp-cached": "0.0.x",
"gulp-remember": "0.2.x",
"gulp-header": "1.0.x",
"gulp-footer": "1.0.x",
"coffee-script": "1.7.x"
}
}
Loading…
Cancel
Save