Changeset b2d7893 in lost-haven for main/Creature.java


Ignore:
Timestamp:
Feb 20, 2021, 6:43:24 PM (4 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
master
Children:
4d8825f
Parents:
a49176d
Message:

Change all file paths to work from inside a JAR and update the makefile to correctly build the project

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/Creature.java

    ra49176d rb2d7893  
    354354        imgProj = LostHavenRPG.imgBow;
    355355      } else if (wType == ItemType.Spell) {
    356         imgProj[0] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    357         imgProj[1] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    358         imgProj[2] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    359         imgProj[3] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    360         imgProj[4] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    361         imgProj[5] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    362         imgProj[6] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
    363         imgProj[7] = ImageIO.read(cr.getClass().getResource("../images/" + cr.type.toString() + "/proj.png"));
     356        imgProj[0] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     357        imgProj[1] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     358        imgProj[2] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     359        imgProj[3] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     360        imgProj[4] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     361        imgProj[5] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     362        imgProj[6] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
     363        imgProj[7] = ImageIO.read(cr.getClass().getResource("/images/" + cr.type.toString() + "/proj.png"));
    364364      }
    365365      cr.model = cr.loadModel(cr.type.toString());
     
    391391    BufferedImage walkE = null;
    392392    BufferedImage walkW = null;
    393     boolean hasDeathAnim = (getClass().getResource("../images/" + folder + "/Death1.png") != null);
     393    boolean hasDeathAnim = (getClass().getResource("/images/" + folder + "/Death1.png") != null);
    394394    try {
    395       if (getClass().getResource("../images/" + folder + "/WalkN.png") != null) {
    396         walkN = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkN.png"));
     395      if (getClass().getResource("/images/" + folder + "/WalkN.png") != null) {
     396        walkN = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkN.png"));
    397397        anmWalkN.addFrame(walkN);
    398         walkS = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkS.png"));
     398        walkS = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkS.png"));
    399399        anmWalkS.addFrame(walkS);
    400         walkE = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkE.png"));
     400        walkE = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkE.png"));
    401401        anmWalkE.addFrame(walkE);
    402         walkW = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkW.png"));
     402        walkW = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkW.png"));
    403403        anmWalkW.addFrame(walkW);
    404       } else if (getClass().getResource("../images/" + folder + "/WalkN1.png") != null) {
    405         walkN = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkN1.png"));
     404      } else if (getClass().getResource("/images/" + folder + "/WalkN1.png") != null) {
     405        walkN = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkN1.png"));
    406406        anmWalkN.addFrame(walkN);
    407         anmWalkN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkN2.png")));
    408         walkS = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkS1.png"));
     407        anmWalkN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkN2.png")));
     408        walkS = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkS1.png"));
    409409        anmWalkS.addFrame(walkS);
    410         anmWalkS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkS2.png")));
    411         walkE = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkE1.png"));
     410        anmWalkS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkS2.png")));
     411        walkE = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkE1.png"));
    412412        anmWalkE.addFrame(walkE);
    413         anmWalkE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkE2.png")));
    414         walkW = ImageIO.read(getClass().getResource("../images/" + folder + "/WalkW1.png"));
     413        anmWalkE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkE2.png")));
     414        walkW = ImageIO.read(getClass().getResource("/images/" + folder + "/WalkW1.png"));
    415415        anmWalkW.addFrame(walkW);
    416         anmWalkW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkW2.png")));
     416        anmWalkW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkW2.png")));
    417417      } else {
    418418        noAnims = true;
    419         anmStandN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    420         anmStandS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    421         anmStandE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    422         anmStandW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    423         anmWalkN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    424         anmWalkN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    425         anmWalkS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    426         anmWalkS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    427         anmWalkE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    428         anmWalkE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    429         anmWalkW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    430         anmWalkW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    431         anmAttackN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    432         anmAttackS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    433         anmAttackE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
    434         anmAttackW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/" + folder + ".png")));
     419        anmStandN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     420        anmStandS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     421        anmStandE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     422        anmStandW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     423        anmWalkN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     424        anmWalkN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     425        anmWalkS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     426        anmWalkS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     427        anmWalkE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     428        anmWalkE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     429        anmWalkW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     430        anmWalkW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     431        anmAttackN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     432        anmAttackS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     433        anmAttackE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
     434        anmAttackW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/" + folder + ".png")));
    435435      }
    436436      if (!noAnims) {
    437437        BufferedImage standN, standS, standE, standW;
    438         if (getClass().getResource("../images/" + folder + "/StandN.png") == null) {
     438        if (getClass().getResource("/images/" + folder + "/StandN.png") == null) {
    439439          standN = walkN;
    440440          standS = walkS;
     
    442442          standW = walkW;
    443443        } else {
    444           standN = ImageIO.read(getClass().getResource("../images/" + folder + "/StandN.png"));
    445           standS = ImageIO.read(getClass().getResource("../images/" + folder + "/StandS.png"));
    446           standE = ImageIO.read(getClass().getResource("../images/" + folder + "/StandE.png"));
    447           standW = ImageIO.read(getClass().getResource("../images/" + folder + "/StandW.png"));
     444          standN = ImageIO.read(getClass().getResource("/images/" + folder + "/StandN.png"));
     445          standS = ImageIO.read(getClass().getResource("/images/" + folder + "/StandS.png"));
     446          standE = ImageIO.read(getClass().getResource("/images/" + folder + "/StandE.png"));
     447          standW = ImageIO.read(getClass().getResource("/images/" + folder + "/StandW.png"));
    448448          anmWalkN = new Animation("north", 0, 0, 40, 60, 150, true);
    449449          anmWalkS = new Animation("south", 0, 0, 40, 60, 150, true);
     
    452452          anmWalkN.addFrame(walkN);
    453453          anmWalkN.addFrame(standN);
    454           anmWalkN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkN2.png")));
     454          anmWalkN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkN2.png")));
    455455          anmWalkN.addFrame(standN);
    456456          anmWalkS.addFrame(walkS);
    457457          anmWalkS.addFrame(standS);
    458           anmWalkS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkS2.png")));
     458          anmWalkS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkS2.png")));
    459459          anmWalkS.addFrame(standS);
    460460          anmWalkE.addFrame(walkE);
    461461          anmWalkE.addFrame(standE);
    462           anmWalkE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkE2.png")));
     462          anmWalkE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkE2.png")));
    463463          anmWalkE.addFrame(standE);
    464464          anmWalkW.addFrame(walkW);
    465465          anmWalkW.addFrame(standW);
    466           anmWalkW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/WalkW2.png")));
     466          anmWalkW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/WalkW2.png")));
    467467          anmWalkW.addFrame(standW);
    468468        }
     
    471471        anmStandE.addFrame(standE);
    472472        anmStandW.addFrame(standW);
    473         if (getClass().getResource("../images/" + folder + "/AttackN.png") != null) {
    474           anmAttackN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackN.png")));
     473        if (getClass().getResource("/images/" + folder + "/AttackN.png") != null) {
     474          anmAttackN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackN.png")));
    475475          anmAttackN.addFrame(standN);
    476           anmAttackS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackS.png")));
     476          anmAttackS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackS.png")));
    477477          anmAttackS.addFrame(standS);
    478           anmAttackE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackE.png")));
     478          anmAttackE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackE.png")));
    479479          anmAttackE.addFrame(standE);
    480           anmAttackW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackW.png")));
     480          anmAttackW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackW.png")));
    481481          anmAttackW.addFrame(standW);
    482         } else if (getClass().getResource("../images/" + folder + "/AttackN1.png") != null) {
    483           anmAttackN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackN1.png")));
    484           anmAttackN.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackN2.png")));
    485           anmAttackS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackS1.png")));
    486           anmAttackS.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackS2.png")));
    487           anmAttackE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackE1.png")));
    488           anmAttackE.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackE2.png")));
    489           anmAttackW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackW1.png")));
    490           anmAttackW.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/AttackW2.png")));
     482        } else if (getClass().getResource("/images/" + folder + "/AttackN1.png") != null) {
     483          anmAttackN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackN1.png")));
     484          anmAttackN.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackN2.png")));
     485          anmAttackS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackS1.png")));
     486          anmAttackS.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackS2.png")));
     487          anmAttackE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackE1.png")));
     488          anmAttackE.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackE2.png")));
     489          anmAttackW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackW1.png")));
     490          anmAttackW.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/AttackW2.png")));
    491491        } else {
    492492          anmAttackN.addFrame(standN);
     
    496496        }
    497497        if (hasDeathAnim) {
    498           anmDeath.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/Death1.png")));
    499           anmDeath.addFrame(ImageIO.read(getClass().getResource("../images/" + folder + "/Death2.png")));
     498          anmDeath.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/Death1.png")));
     499          anmDeath.addFrame(ImageIO.read(getClass().getResource("/images/" + folder + "/Death2.png")));
    500500        }
    501501      }
Note: See TracChangeset for help on using the changeset viewer.