adityaravishankar / command-and-conquer

Command & Conquer in HTML5/Javascript
776 stars 169 forks source link

use a database for unit & building parameters. #40

Open jovoud opened 12 years ago

jovoud commented 12 years ago

Shouldn't it be easier to create a unitManager and buildingManager object that create the units and buildings using db files? In the sourcecode you have lot of this: [code] 'tiberium-silo':{ name:'tiberium-silo', label:'Tiberium Silo', powerIn:10, cost:150, sight:2, hitPoints:150, imagesToLoad:[ {name:'build',count:20},{name:"healthy",count:5}, {name:"damaged",count:5},{name:"ultra-damaged",count:1}], gridShape: [[1,1]]
}, 'hand-of-nod':{ name:'hand-of-nod', label:'Hand of Nod', powerIn:20, cost:300, sight:3, hitPoints:400, imagesToLoad:[ {name:'build',count:20},{name:"healthy",count:1}, {name:"damaged",count:1},{name:"ultra-damaged",count:1}], gridShape: [[0,0], [1,1], [1,1]]
},
[/code] It's not that hard to create a manager which builds these object using xml files or some other kind of file or db. Makes it easier to add units and change values + if people later on want to create mods based on this game, it's much easier.

jakemac53 commented 12 years ago

This could be part of the level editor which is also planned I believe. In order to really support this there would need to be a lot of restructuring of the code though to make all objects a bit more generic. Right now vehicles/infantry/etc all are completely their own objects and don't inherit from a base object. As well the draw functions need to be standardized and their needs to be a way to support special objects that aren't just a single sprite with that (like tanks which have swiveling turrets).

I think the best way to start down this path would be to make a generic "sprite" class that all the other objects build on top of. It would include all the basic draw functions and such, and then we could just a provide a standard way of overriding those when necessary.

adityaravishankar commented 12 years ago

True...

And that should be the eventual destination... But writing it in JS for the first couple of objects in each category is the simplest way to design the objects....

Once the design gets stable, and we are ready to extend to all units/buildings is when the transition needs to happen....

This is just a reasonable intermediate stepping stone :)

jovoud commented 12 years ago

sound good :). As far for the level editor.. I think first the conventions of the map and the generics of sprites needs to be taken care of. Else if they change afterwards, all the maps created for that version are useless...

jakemac53 commented 12 years ago

totally agree, I think really a major restructuring of the code and objects is in order... and then we can work on a level editor/unit builder once the standard is in place.

jovoud commented 12 years ago

units: http://xhp.xwis.net/isu_data.html