Splitted JS

- Hopefully, ones able to reset the "script" Attribute.
This commit is contained in:
Oliver Rümpelein 2014-09-23 16:52:08 +02:00
parent 16a58b0fb2
commit 2f8f71eee7
4 changed files with 43 additions and 32 deletions

2
TODO
View file

@ -1,5 +1,5 @@
ToDo for JSDSH: ToDo for JSDSH:
- Implement FrontEnd (Add Player, etc) - Implement FrontEnd (Add Player, etc) ?
- Implement Player, Creatures - Implement Player, Creatures
- Background and Wall Editing/Importing - Background and Wall Editing/Importing
- Shoot, Attack - Shoot, Attack

View file

@ -8,6 +8,7 @@
<h1>JSDSH - Javascript Dungeonslayers Helper</h1> <h1>JSDSH - Javascript Dungeonslayers Helper</h1>
<div id="game"></div> <div id="game"></div>
<script type="text/javascript" src="lib/crafty.js"></script> <script type="text/javascript" src="lib/crafty.js"></script>
<script type="text/javascript" src="src/jsds.js"></script> <script type="text/javascript" src="src/jsds_crafty.js"></script>
<script type="text/javascript" src="src/adventure_01.js"></script>
</body> </body>
</html> </html>

14
src/adventure_01.js Normal file
View file

@ -0,0 +1,14 @@
{
var wall = [];
wall.push(Crafty.e("Wall").wall(240,0,10,250));
wall.push(Crafty.e("Wall").wall(0,240,240,10));
wall.push(Crafty.e("Wall").wall(0,0,10,240));
wall.push(Crafty.e("Wall").wall(10,0,230,10));
var player = [];
player.push(Crafty.e("Creature").player(40,40,40,40,'red'));
player.push(Crafty.e("Creature").player(100,100,30,30,'blue'));
end_init();
}

View file

@ -46,13 +46,13 @@
} }
); );
/* Crafty.c( /* Crafty.c(
"Creature", { "Creature", {
init: function() { init: function() {
this.addComponent*/ this.addComponent*/
Crafty.c( Crafty.c(
"Player", { "Creature", {
init: function() { init: function() {
this.addComponent("Thing,Fourway,Draggable,Collision,WiredHitBox,Mouse,player"); this.addComponent("Thing,Fourway,Draggable,Collision,WiredHitBox,Mouse,player");
}, },
@ -74,26 +74,18 @@
if(e.mouseButton === Crafty.mouseButtons.LEFT) { if(e.mouseButton === Crafty.mouseButtons.LEFT) {
this.old_pos["x"]=this.x; this.old_pos["x"]=this.x;
this.old_pos["y"]=this.y; this.old_pos["y"]=this.y;
console.log("New Pos saved: "+this.old_pos["x"]+' '+this.old_pos["y"]);
}; };
Crafty("Creature").each( function() {
this.disableControl();
});
this.enableControl();
}); });
return this; return this;
} }
} }
); );
/* var fig=Crafty.e('Collision, 2D, Canvas, Color,Fourway,Draggable,WiredHitBox,Mouse,player')
var wall = [];
wall.push(Crafty.e("Wall").wall(240,0,10,250));
wall.push(Crafty.e("Wall").wall(0,240,240,10));
wall.push(Crafty.e("Wall").wall(0,0,10,240));
wall.push(Crafty.e("Wall").wall(10,0,230,10));
var player = [];
player.push(Crafty.e("Player").player(40,40,40,40,'red'));
player.push(Crafty.e("Player").player(100,100,30,30,'blue'));
/* var fig=Crafty.e('Collision, 2D, Canvas, Color,Fourway,Draggable,WiredHitBox,Mouse,player')
.attr({x: 20, y: 20, w: 100, h: 100}) .attr({x: 20, y: 20, w: 100, h: 100})
.color('#F00') .color('#F00')
.fourway(4) .fourway(4)
@ -103,6 +95,10 @@
});*/ });*/
var end_init= function() {
Crafty("Creature").each( function() {
this.disableControl();
});
};
} }