Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Advice for my new project (text rpg)
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Aziz




PostPosted: Mon Jul 31, 2006 7:12 pm   Post subject: Advice for my new project (text rpg)

Anyone who's been frequenting this forum can guess I'm working on an rpg-like game. Well, I'm starting with the classes, mostly. This is basically going to be my help thread (so I don't spam the forum Razz).

My first question is about classes. Say I have a class like Element or Sword. Now, I'm going to have pre-made elements and swords in the game, like Air or Earth and Longsword or Saber. So would it be a bad a idea, in your opinion, to create new classes, like AirElement, EarthElement, Longsword or Saber, and have the constructor call super()? For example, say Sword's constructor required a name, description, cost, and damage value, Longsword() would call super("Longsword", "A sword with a long blade.", 50, 14); Or simply create a new Sword? I was thinking this approach for pre-defined weapons, to be added in shops, etc. But it would be a lot. Not actually a technical problem, but more an effeciency problem. Thanks a lot Smile
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Mon Jul 31, 2006 8:12 pm   Post subject: (No subject)

Alternatively, you may wish to define a set of behaviors which characterize a sword. This would be an interface. Then weapons can freely imp-lement this interface.

Just a possibility.
Aziz




PostPosted: Tue Aug 01, 2006 11:36 am   Post subject: (No subject)

I was thinking about that, but a Sword would have fields and methods. Like int damage;. Perhaps I would just specify a getDamage() method in the Sword interface, and this would force the implementing class to do something with it? And say interface Sword extends interface Weaopon. Would "new LongSword() instanceof Weapon" work?
wtd




PostPosted: Tue Aug 01, 2006 12:37 pm   Post subject: (No subject)

You should not have public fields, and yes, that would work.
Aziz




PostPosted: Tue Aug 01, 2006 3:43 pm   Post subject: (No subject)

Okay, thank you wtd. I'm going to take your advice into mind while working on the project Smile I'm creating a bunch of classes first, and then going to work on a text-based battle engine, and from there on. Graphics last, I've got a book Game Programming for Teens for VB6 and it shouldn't be too hard to port the graphics to java.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: