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:
- Implement FrontEnd (Add Player, etc)
- Implement FrontEnd (Add Player, etc) ?
- Implement Player, Creatures
- Background and Wall Editing/Importing
- Shoot, Attack

View file

@ -8,6 +8,7 @@
<h1>JSDSH - Javascript Dungeonslayers Helper</h1>
<div id="game"></div>
<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>
</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

@ -1,6 +1,6 @@
{
Crafty.init(500,250, document.getElementById('game'));
Crafty.c(
"Wall", {
init: function() {
@ -46,13 +46,13 @@
}
);
/* Crafty.c(
"Creature", {
init: function() {
this.addComponent*/
/* Crafty.c(
"Creature", {
init: function() {
this.addComponent*/
Crafty.c(
"Player", {
"Creature", {
init: function() {
this.addComponent("Thing,Fourway,Draggable,Collision,WiredHitBox,Mouse,player");
},
@ -74,35 +74,31 @@
if(e.mouseButton === Crafty.mouseButtons.LEFT) {
this.old_pos["x"]=this.x;
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;
}
}
);
/* var fig=Crafty.e('Collision, 2D, Canvas, Color,Fourway,Draggable,WiredHitBox,Mouse,player')
.attr({x: 20, y: 20, w: 100, h: 100})
.color('#F00')
.fourway(4)
.collision()
.onHit("wall",function() {
this.stopDrag();
});*/
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})
.color('#F00')
.fourway(4)
.collision()
.onHit("wall",function() {
this.stopDrag();
});*/
var end_init= function() {
Crafty("Creature").each( function() {
this.disableControl();
});
};
}