Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend the creep class in screeps

I am having a hard time trying to figure out how to extend the creep class to add my own functions in the new javascript mmo game, Screeps -> www.screeps.com

Has anyone figured this out yet ?

Thanks

like image 292
Ryan Avatar asked Jan 09 '23 09:01

Ryan


1 Answers

A bit of an old thread, and I am not sure if Screeps has changed since the initial query was posted, but here are my thoughts...

Why have a wrapper class?? why not extend the original / game provided Creep class ?

e.g.

Creep.prototype.myFunction = function(target){
         // my logic
       }

Make sure to check out the screeps inheritance structure.. (Google the screeps API and check out the 'Prototypes' section on the landing page)

This can save a lot of duplicate code, for example one declaration of an inherited function in the 'Structure' prototype may save a seperate declaration for each individual Structure sub class protocols.

Hope this helps.

like image 129
user7462201 Avatar answered Jan 24 '23 04:01

user7462201