Creature-objects are now clickable and reveal information.

This commit is contained in:
Oliver Rümpelein 2014-09-24 15:16:10 +02:00
parent 009ae449df
commit 8ee25d51cf
4 changed files with 84 additions and 4 deletions

View file

@ -9,9 +9,11 @@
<div id="game"></div>
<button id="load">Load</button>
<div id="output"></div>
<script type="text/javascript" src="lib/crafty.js"></script>
<script type="text/javascript" src="lib/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="src/jsds_crafty.js"></script>
<script type="text/javascript" src="src/jsds.js"></script>
<script type="text/javascript" src="src/base_ui.js"></script>
<!-- <script type="text/javascript" src="" id="adv"></script>-->
</body>

View file

@ -8,9 +8,17 @@
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'));
var player={};
player["Gesina"]=(new Player({"pname":"Gesina", "cname":"Aknya", "class":"Zauberin", "level":0, "experience":0,
"race":"Mensch", "size":2},
{"body":6, "agility":6, "spirit":8},
{"strength":0,"hardness":2,"movement":0,"skill":3,"mind":3,"aura":3},
{"x":40,"y":40,"w":40,"h":40,"col":"blue"}));
// player.push(Crafty.e("Creature").player(40,40,40,40,'red'));
/* var beasts = [];
beasts.push(Crafty.e("Creature").creature("Hobgob1",100,100,30,30,'red'));*/
end_init();
}

68
src/jsds.js Normal file
View file

@ -0,0 +1,68 @@
{
function Player(info,attributes,properties,drawinfo){ // x,y,w,h,col) {
/* info: pname, cname,class, level, experience, race, size
* attributes: body, agility, spirit
* properties: strength, hardness, movement, skill, mind, aura
* drawinfo: x,y,w,h,col
*/
// player.push(Crafty.e("Creature").player(x,y,w,h,col);
this.info = {"pname": info["pname"]+"", "cname": info["cname"]+"", "class": info["class"]+"",
"level": info["level"]*1, "experience": info["experience"]*1, "race":info["race"]+"",
"size":info["size"]*1};
this.attributes = {"body": attributes["body"]*1, "agility": attributes["agility"]*1,
"spirit": attributes["spirit"]*1};
this.properties = {"strength": properties["strength"]*1 , "hardness": info["hardness"]*1,
"movement": info["movement"]*1, "skill": properties["skill"]*1,
"mind": properties["mind"]*1, "aura": properties["aura"]*1};
this.graphelement = Crafty.e("Creature").creature(this.info["pname"],drawinfo["x"],drawinfo["y"],drawinfo["w"],
drawinfo["h"],drawinfo["col"]);
};
Player.prototype.printoutput = function() {
$('#output').empty();
$('#output').html(this.info.cname+"<br>"+this.info.pname);
};
function Creature(x,y,w,h,col) {
life
race
size
body
agility
spirit
strength
hardness
movement
skill
mind
aura
life_base
def_base
ini
walk
melee
shoot
chanting
shot_chant
bweapon
barmor
bchant
x
y
w
h
color
};
/* function Beast() {
experience
};*/
}

View file

@ -46,7 +46,8 @@
init: function() {
this.addComponent("Thing,Fourway,Draggable,Collision,WiredHitBox,Mouse,creature,coll");
},
player: function(x,y,w,h,col) {
creature: function(id,x,y,w,h,col) {
this.id=id || "";
this.h = h || 40;
this.w = w || 40;
this.thing(x,y,w,h,col)
@ -73,6 +74,7 @@
Crafty("Creature").each( function() {
this.disableControl();
});
player[this.id].printoutput();
this.enableControl();
});