Splitted JS
- Hopefully, ones able to reset the "script" Attribute.
This commit is contained in:
parent
16a58b0fb2
commit
2f8f71eee7
4 changed files with 43 additions and 32 deletions
2
TODO
2
TODO
|
@ -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
|
||||||
|
|
|
@ -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
14
src/adventure_01.js
Normal 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();
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
Crafty.init(500,250, document.getElementById('game'));
|
Crafty.init(500,250, document.getElementById('game'));
|
||||||
|
|
||||||
Crafty.c(
|
Crafty.c(
|
||||||
"Wall", {
|
"Wall", {
|
||||||
init: function() {
|
init: function() {
|
||||||
|
@ -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,35 +74,31 @@
|
||||||
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')
|
||||||
|
.attr({x: 20, y: 20, w: 100, h: 100})
|
||||||
|
.color('#F00')
|
||||||
|
.fourway(4)
|
||||||
|
.collision()
|
||||||
|
.onHit("wall",function() {
|
||||||
|
this.stopDrag();
|
||||||
|
|
||||||
|
});*/
|
||||||
|
|
||||||
var wall = [];
|
var end_init= function() {
|
||||||
|
Crafty("Creature").each( function() {
|
||||||
wall.push(Crafty.e("Wall").wall(240,0,10,250));
|
this.disableControl();
|
||||||
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();
|
|
||||||
|
|
||||||
});*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue