From 528c2cbff36c6c4ca359e602d448bdf3f8b6abb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Wed, 24 Sep 2014 15:44:00 +0200 Subject: [PATCH] First basic 'adventure', added creature --- src/adventure_01.js | 14 ++++++++--- src/jsds.js | 59 +++++++++++++++++---------------------------- src/jsds_crafty.js | 14 +++++++---- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/adventure_01.js b/src/adventure_01.js index 66faf8d..af74fee 100644 --- a/src/adventure_01.js +++ b/src/adventure_01.js @@ -7,7 +7,9 @@ //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 cur_sel; + var player={}; player["Gesina"]=(new Player({"pname":"Gesina", "cname":"Aknya", "class":"Zauberin", "level":0, "experience":0, "race":"Mensch", "size":2}, @@ -17,8 +19,14 @@ // 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'));*/ + + player["HobGob1"]=(new Beast({"pname":"HobGob1", "experience":71, "race":"Hobgoblin", "size":2}, + {"body":11, "agility":6, "spirit":3}, + {"strength":2,"hardness":3,"movement":0,"skill":3,"mind":2,"aura":0}, + {"x":90,"y":90,"w":30,"h":30,"col":"red"})); + + +/*.push(Crafty.e("Creature").creature("Hobgob1",100,100,30,30,'red'));*/ end_init(); } diff --git a/src/jsds.js b/src/jsds.js index d4b0aac..f388689 100644 --- a/src/jsds.js +++ b/src/jsds.js @@ -25,44 +25,29 @@ $('#output').html(this.info.cname+"
"+this.info.pname); }; - - function Creature(x,y,w,h,col) { - life - race + function Beast(info,attributes,properties,drawinfo){ // x,y,w,h,col) { + /* info: pname, experience, race, size + * attributes: body, agility, spirit + * properties: strength, hardness, movement, skill, mind, aura + * drawinfo: x,y,w,h,col + */ - size + this.info = {"pname": info["pname"]+"", "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}; - 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 + this.graphelement = Crafty.e("Creature").creature(this.info["pname"],drawinfo["x"],drawinfo["y"],drawinfo["w"], + drawinfo["h"],drawinfo["col"]); + }; + + Beast.prototype.printoutput = function() { + $('#output').empty(); + $('#output').html(this.info.race+"
"+this.info.pname); }; - -/* function Beast() { - experience - };*/ + + } diff --git a/src/jsds_crafty.js b/src/jsds_crafty.js index 79b93bd..1f662a6 100644 --- a/src/jsds_crafty.js +++ b/src/jsds_crafty.js @@ -70,12 +70,16 @@ if(e.mouseButton === Crafty.mouseButtons.LEFT) { this.old_pos["x"]=this.x; this.old_pos["y"]=this.y; + Crafty("Creature").each( function() { + this.disableControl(); + }); + cur_sel=player[this.id]; + cur_sel.printoutput(); + this.enableControl(); }; - Crafty("Creature").each( function() { - this.disableControl(); - }); - player[this.id].printoutput(); - this.enableControl(); +/* if(e.mouseButton === Crafty.mouseButtons.RIGHT) { + cur_sel.attack(player[this.id]); + };*/ }); return this;