Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm designing an RPG game in java and would like some help with my experience gain class for my characters. So far I only have

I'm designing an RPG game in java and would like some help with my experience gain class for my characters. So far I only have character classified as either Magic or Martial(warrior) and I need to implement an xp system that determines if they have leveled up or not. I started coding the outlook of my character xp class, which I have shown below but I would like some help with filling the gaps Right now I'm just using a simple level up in 1007 increments and simple attack and defense for my characters for my outline. Any help or different approaches to filling out my xp class would be appreciated.

public abstract class CharacterClass { // Manages level/xp protected int level; protected int currentXP; protected int perLevelHP; protected int perLevelAttack; protected int perLevelDefense;

public CharacterClass() { this.level = 1; this.currentXP = 0; }

protected int getLevel() { return level; }

protected int getCurrentXP() { return currentXP; }

protected boolean addXP(int xpGain) { // XP gain this.currentXP += xpGain; // Need a Level UP formula Level that uses a * 1007 = XP needed? per level // Level 1 need 1007 xp, level 2 needs 2014 xp ... etc if(this.currentXP >= this.level * 1007) { this.currentXP = 0; return true; //return true if character has leveled up }

return false; // A false means no level up } }

*******************************************************

public class MagicClass extends CharacterClass { public MagicClass() { this.perLevelAttack = 10; this.perLevelDefense = 5; this.perLevelHP = 5; } }

**************************************************************

public class MartialClass extends CharacterClass { public MartialClass() { this.perLevelAttack = 5; this.perLevelDefense = 10; this.perLevelHP = 10; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

Briefly describe the four types of costs in costs of quality (COQ).

Answered: 1 week ago

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago