Permalink
Browse files

global refactor

  • Loading branch information...
1 parent f9d1a73 commit c14ed4e26f22c99a98fc0f2c74a4626455d50b51 @hugeen committed Nov 18, 2012
@@ -5,7 +5,12 @@ define([
], function(Backbone, Skill, skillsData) {
var Skills = Backbone.Collection.extend({
- model: Skill
+ model: Skill,
+ playerSkills: function() {
+ return this.filter(function(model) {
+ return model.get("player");
+ });
+ }
});
return new Skills(skillsData);
View
@@ -1,22 +1,16 @@
define([
'backbone',
- 'crafty'
-], function(Backbone, Crafty) {
+ 'crafty',
+ 'game/keyboard'
+], function(Backbone, Crafty, keyboard) {
var Skill = Backbone.Model.extend({
- defaults: {},
- addEntity: function() {
-
- return Crafty.e("Skill").skill({
- cooldown: 0.5
- }).bind("SkillTriggered", function() {
- console.log("skill triggered")
- //AttackEntity.create(player);
- });
-
+ defaults: {
+ player: false,
+ cast: function() {}
},
- fire: function() {
-
+ keybind: function() {
+ return keyboard.keybinds.AZERTY[this.get("name")];
}
});
@@ -7,6 +7,12 @@ html, body {
body {
background: url("../images/pinstriped_suit.png") repeat scroll left top transparent;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: none;
+ -ms-user-select: none;
+ user-select: none;
}
.title_font { font-family: 'Finger Paint', cursive; }
@@ -5,20 +5,15 @@ define([
Crafty.c("Attack", {
init : function() {
this.addComponent("Bullet, axe, Collision");
-
this.speed = 15;
this.attack = function(from, to) {
-
this.origin("center");
-
this.bind("EnterFrame", function() {
this.rotation += 15;
});
-
this.fire(from, to, this.speed);
-
- }
+ };
}
});
View
@@ -5,7 +5,6 @@ define([
return {
create: function(type, line) {
-
var monster = Crafty.e("NonPlayableCharacter, "+type);
monster.moveToLine(line);
return monster;
View
@@ -4,26 +4,33 @@ define([
"burst",
"game/entities/player",
"game/entities/monster",
- "game/entities/attack",
'game/keyboard',
'collections/skills',
'text!templates/game_ui/skills.html',
'text!templates/game_ui/skill.html',
- 'game/mouse'
-], function($, Crafty, Burst, PlayerEntity, MonsterEntity, AttackEntity, keyboard, skills, _skills, _skill, mouse) {
+ 'game/mouse',
+ 'mouseTrap'
+], function($, Crafty, Burst, PlayerEntity, MonsterEntity, keyboard, skills, _skills, _skill, mouse, Mousetrap) {
return {
name: "level",
init: function(options) {
$("#wrapper").append(_.template(_skills));
-
+
+ var player = PlayerEntity.create();
+
skills.each(function(skill) {
- var keybind = keyboard.keybinds.AZERTY[skill.get("name")]
-
- /*Mousetrap.bind(keybind, function() {
- console.log(skill.get("name"));
- });*/
+ var keybind = skill.keybind();
+ Mousetrap.bind(keybind, function() {
+ skill.get("cast")({
+ x: player.x,
+ y: player.y
+ }, {
+ x: mouse.position.relative.x,
+ y: mouse.position.relative.y
+ });
+ });
var compiledTemplate = _.template(_skill, {
key: keybind,
@@ -34,7 +41,7 @@ define([
});
- var player = PlayerEntity.create();
+
//var monster = MonsterEntity.create("Octocat", 1);
//var monster = MonsterEntity.create("Octocat", 3);
View
@@ -1,28 +1,39 @@
define(function() {
-
+
return [{
name: "Shield",
+ player: true,
backgroundPosition: "0 0"
}, {
name: "Attack",
+ player: true,
+ cast: function(from, to) {
+ Crafty.e("Attack").attack(from, to);
+ },
backgroundPosition: "-53px 0"
}, {
name: "Blow",
+ player: true,
backgroundPosition: "-106px 0"
}, {
name: "Stone",
+ player: true,
backgroundPosition: "-159px 0"
}, {
name: "Root",
+ player: true,
backgroundPosition: "-212px 0"
}, {
name: "Frost",
+ player: true,
backgroundPosition: "-265px 0"
}, {
name: "Hast",
+ player: true,
backgroundPosition: "-318px 0"
}, {
name: "Life",
+ player: true,
backgroundPosition: "-371px 0"
}];

0 comments on commit c14ed4e

Please sign in to comment.