id
stringlengths
36
36
text
stringlengths
1
1.25M
a070fa49-a6c2-42f1-9dfb-c87b8be4b5fe
public static void main(String[] args) throws NativeHookException { Duo.initialize(); Ranged.initialize(); GlobalScreen.registerNativeHook(); GlobalScreen.getInstance().addNativeKeyListener(new UI()); UI.initializeUI(); }
030ca1a7-5a0d-4bd8-a032-d449a4a1382d
@Override public void run() { try { while (true) { if (!Monitor.flag) { FightLogic.supporting(ReadScreen.getRole()); } else { synchronized (Monitor.setState) { Monitor.setState.wait(); } } } } catch (Throwable t) {t.printStackTrace();} }
2f3ac415-effd-4c6e-8239-efbea553167b
@Override public void run() { try { while (true) { if (!Monitor.flag) { FightLogic.healing(ReadScreen.getRole()); } else { synchronized (Monitor.setState) { Monitor.setState.wait(); } } } } catch (Throwable t) {t.printStackTrace();} }
518c5b46-9809-478e-9353-67f15c0f88e6
@Override public void run() { try { int firstPoint = 1; int lastPoint = 0; while (true) { if (!Monitor.flag) { while (!ReadScreen.targetPresence() & !Monitor.flag) { Select.nextFoe(); if (ReadScreen.targetPresence()) { break; } Movement.turnLeft(300, 200); if (UI.decision.equals("y")) { Monitor.iterator++; if (Monitor.iterator > 10) { break; } } else {/*NOP*/} } if (UI.decision.equals("y")) { if (Monitor.iterator >= 10 & firstPoint == 1) { CheckMiniMap.go(UI.firstDirection, UI.steps * 1000); lastPoint = 1; firstPoint = 0; Monitor.iterator = 0; } else if (Monitor.iterator >= 10 & lastPoint == 1) { CheckMiniMap.go(UI.secondDirection, UI.steps * 1000); lastPoint = 0; firstPoint = 1; Monitor.iterator = 0; } } if (Monitor.flag) { synchronized (Monitor.setState) { Monitor.setState.wait(); } } FightLogic.preparing(ReadScreen.getRole()); FightLogic.skillRotation(ReadScreen.getRole()); } else { synchronized (Monitor.setState) { Monitor.setState.wait(); } } } } catch (Throwable t) {t.printStackTrace();} }
517ceba5-838b-4ba8-88d3-40f65a3420a2
private static boolean checkOrange(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); return hsbBuffer[0] < maxOrange & hsbBuffer[0] > minOrange; }
1059a47e-64ce-4c9a-9a75-9fffaea3ae81
private static boolean checkRed(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); return hsbBuffer[0] < maxRed | hsbBuffer[0] > minRed; }
5b2d41f7-f8fb-4f4a-927e-d0486a545c07
public static boolean isLookingNorth() { return checkOrange(ReadScreen.getRobot().getPixelColor(x, y)) && checkRed(ReadScreen.getRobot().getPixelColor(x, y + 3)); //111 94 1808, 94 1808, 97 }
f38458ed-2fcd-4ba3-8541-0c9400cb0c07
public static boolean isLookingSouth() { return checkOrange(ReadScreen.getRobot().getPixelColor(x + 1, y + 21)) && checkRed(ReadScreen.getRobot().getPixelColor(x + 1, y + 18)); //112 115 112 112 }
526a6d35-a67b-4b5d-bba7-8c23bc835b10
public static boolean isLookingWest() { return checkOrange(ReadScreen.getRobot().getPixelColor(x - 10, y + 11)) && checkRed(ReadScreen.getRobot().getPixelColor(x - 7, y + 11)); //101 105 104 105 }
39a977b1-60a4-4eff-b154-f2b6399620b3
public static boolean isLookingEast() { return checkOrange(ReadScreen.getRobot().getPixelColor(x + 11, y + 10)) && checkRed(ReadScreen.getRobot().getPixelColor(x + 8, y + 10)); //122 104 119 104 }
6625fe7e-d356-46e4-ba4f-0905032a7965
public static boolean isLookingNorthEast() { return checkOrange(ReadScreen.getRobot().getPixelColor(x + 8, y + 3)) && checkRed(ReadScreen.getRobot().getPixelColor(x + 6, y + 5)); //119 97 }
66f44c7d-d9d9-41e8-ab5c-60b076f5ecff
public static boolean isLookingNorthWest() { return checkOrange(ReadScreen.getRobot().getPixelColor(x - 7, y + 3)) && checkRed(ReadScreen.getRobot().getPixelColor(x - 5, y + 5)); }
9a26f9d8-2c97-4c86-a8d9-bb936e6e065f
public static boolean isLookingSouthEast() { return checkOrange(ReadScreen.getRobot().getPixelColor(x + 8, y + 18)) && checkRed(ReadScreen.getRobot().getPixelColor(x + 6, y + 16)); }
faf30083-e7e4-45f8-9969-2e18d10fdcda
public static boolean isLookingSouthWest() { return checkOrange(ReadScreen.getRobot().getPixelColor(x - 7, y + 18)) && checkRed(ReadScreen.getRobot().getPixelColor(x - 5, y + 16)); }
c06a03bb-4e21-4b48-91b1-279f8a4cc541
public static void go(String direction, int duration) throws AWTException { switch (direction) { case "north": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingNorth()) { Movement.goForward(duration, 50); break; } } break; case "south": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingSouth()) { Movement.goForward(duration, 50); break; } } break; case "west": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingWest()) { Movement.goForward(duration, 50); break; } } break; case "east": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingEast()) { Movement.goForward(duration, 50); break; } } break; case "northeast": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingNorthEast()) { Movement.goForward(duration, 50); break; } } break; case "northwest": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingNorthWest()) { Movement.goForward(duration, 50); break; } } break; case "southeast": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingSouthEast()) { Movement.goForward(duration, 50); break; } } break; case "southwest": while (!Monitor.flag) { Movement.turnRight(20, 10); if (isLookingSouthWest()) { Movement.goForward(duration, 50); break; } } break; } }
cff65f55-44d1-4cda-a309-badb94075858
public static Robot getRobot() { if (robot == null) { synchronized (ReadScreen.class) { if (robot == null) { try { robot = new Robot(); } catch (AWTException e) { e.printStackTrace(); } } } } return robot; }
3cf43087-0c89-4822-b0ea-238dfa791963
public static boolean targetPresence() { return getRobot().getPixelColor(1, 0).equals(Color.green); }
21f9db59-df9a-4215-a73e-b02950d1f58e
public static boolean isInCombat() { return getRobot().getPixelColor(2, 0).equals(Color.green); }
b7685856-d080-4efd-a490-9f25e6a8259a
public static boolean lowMorale() { return getRobot().getPixelColor(3, 0).equals(Color.green); }
8a1c84c4-bd99-484d-81c1-d23cbb4123d9
public static boolean petPresence() { return getRobot().getPixelColor(4, 0).equals(Color.green); }
f9e787af-e7a4-4503-b9f4-f25795ecc705
public static boolean targetReachable() { return !getRobot().getPixelColor(5, 0).equals(Color.green); }
a0cab119-6b25-4bb2-93ae-2d56949f3f28
public static String getRole() { String role = null; if (getRobot().getPixelColor(0, 0).equals(Color.red)) { role = "melee"; } else if (getRobot().getPixelColor(0, 0).equals(Color.blue)) { role = "duo"; } else if (getRobot().getPixelColor(0, 0).equals(Color.green)) { role = "ranged"; } else { role = "unidentified"; } return role; }
564be7be-dd71-48c5-b4a6-6122f2ef451f
private static boolean checkGreen(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); if (hsbBuffer[0] < maxGreen & hsbBuffer[0] > minGreen) { return true; } else { return false; } }
4b202fc2-069b-4eac-a9d8-0e548b2b5c01
private static boolean checkRed(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); if (hsbBuffer[0] < maxRed & hsbBuffer[0] > minRed) { return true; } else { return false; } }
1b923c32-effc-44d2-a8ff-9adf3c95a806
public static boolean petHere(){ return ReadScreen.getRobot().getPixelColor(552, 765).equals(petHere); }
e583281e-c2fe-40d1-a34a-0351764592fa
public static boolean lowMorale(){ return !checkGreen(ReadScreen.getRobot().getPixelColor(/*500, 540*/650, 850)); }
5b794bd0-3cce-454c-9efb-140c00c33ed6
public static boolean lowPetHealth(){ return !ReadScreen.getRobot().getPixelColor(645, 768).equals(lowPetHealth); }
36bcae77-5543-4119-9d80-45e3e16f2224
public static boolean targetPresence(){ return checkRed(ReadScreen.getRobot().getPixelColor(/*890, 540*/1245, 852)) || ReadScreen.getRobot().getPixelColor(1245, 852).equals(targetPresenceYellow); }
d731ab6e-04d4-456e-b400-c7565953aed2
private static boolean checkBlack(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); if (hsbBuffer[2] < maxBlack & hsbBuffer[2] > minBlack) { return true; } else { return false; } }
4fccf885-af81-4d0d-ad51-6f09e28a2109
private static boolean checkRed(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); if (hsbBuffer[0] < maxRed | hsbBuffer[0] > minRed) { return true; } else { return false; } }
4c91f842-66c4-4aa9-b9be-9aa942296bb8
private static boolean checkBlue(Color c) { RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hsbBuffer); if (hsbBuffer[0] < maxBlue & hsbBuffer[0] > minBlue) { return true; } else { return false; } }
81724c41-18c4-4e12-a8b4-42b4e3b1f517
public static boolean inCombat(){ return !checkBlue(ReadScreen.getRobot().getPixelColor(/*494, 715*/765, 1020)); }
0d89337e-8a31-4f33-afa4-7923b4c4fe57
public static boolean targetTooFar(){ return checkBlack(ReadScreen.getRobot().getPixelColor(/*544, 723*/821, 1035)) & checkRed(ReadScreen.getRobot().getPixelColor(/*545, 724*/822, 1036)) & checkRed(ReadScreen.getRobot().getPixelColor(/*546, 725*/823, 1037)) & checkBlack(ReadScreen.getRobot().getPixelColor(/*547, 726*/824, 1038)); }
132fd65d-1774-4bd5-bc81-ae519217bb79
public static void skillRotation(String role) { switch (role) { case "duo": while (ReadScreen.isInCombat()) { for (Duo skill : Duo.listOfActions) { skill.use(); shuffle(Duo.listOfActions); if (!ReadScreen.isInCombat() || Monitor.flag) { break; } } } break; case "ranged": while (!Monitor.flag && !ReadScreen.isInCombat() && ReadScreen.targetPresence()) { Ranged.skill_1.use(); if (!ReadScreen.targetReachable()) { Select.undo(); Movement.turnLeft(500, 400); break; } } while (ReadScreen.isInCombat()) { if(!ReadScreen.targetReachable()){ Select.undo(); Select.nearestFoe(); } for (Ranged skill : Ranged.listOfActions) { skill.use(); shuffle(Ranged.listOfActions); if (!ReadScreen.isInCombat() || Monitor.flag) { break; } } } break; } }
eca79f08-ade8-493f-b5a7-9fcb2257bc36
public static void healing(String role) { switch (role) { case "duo": if (ReadScreen.lowMorale()) { Duo.skill_0.use(); //Heal self } break; case "ranged": if (ReadScreen.lowMorale()) { Ranged.skill_0.use(); } break; } }
84a56749-70da-4896-b072-184c56a7757a
public static void supporting(String role) { switch (role) { case "duo": if (!ReadScreen.petPresence()) { Duo.skill_minus.use(); //Summon a pet } break; case "ranged": {/*NOP*/} //Don't know what to do here break; } }
82d34c8f-3c40-409d-827b-9575b68857a0
public static void preparing(String role) { switch (role) { case "duo": if (ReadScreen.targetPresence()) { Duo.skill_equals.use(); //Command pet to attack } break; case "ranged": {/*NOP*/} //Haven't pet break; } }
b835a8f6-9954-4bb4-9e20-a0224dd398ae
public static void goForward(int movementDuration, int waitAfter) { GameAction.getRobot().keyPress(KeyEvent.VK_W); GameAction.getRobot().delay(movementDuration); GameAction.getRobot().keyRelease(KeyEvent.VK_W); GameAction.getRobot().delay(waitAfter); }
b0f9bd7b-f138-428f-ab53-48f6407aa71a
public static void goBackward(int movementDuration, int waitAfter) { GameAction.getRobot().keyPress(KeyEvent.VK_S); GameAction.getRobot().delay(movementDuration); GameAction.getRobot().keyRelease(KeyEvent.VK_S); GameAction.getRobot().delay(waitAfter); }
f437efe7-ca5f-4bdc-8a54-5df0c360c8fe
public static void turnLeft(int movementDuration, int waitAfter) { GameAction.getRobot().keyPress(KeyEvent.VK_A); GameAction.getRobot().delay(movementDuration); GameAction.getRobot().keyRelease(KeyEvent.VK_A); GameAction.getRobot().delay(waitAfter); }
51bff049-eaab-467c-972d-8ef3830a1e1d
public static void turnRight(int movementDuration, int waitAfter) { GameAction.getRobot().keyPress(KeyEvent.VK_D); GameAction.getRobot().delay(movementDuration); GameAction.getRobot().keyRelease(KeyEvent.VK_D); GameAction.getRobot().delay(waitAfter); }
9c6456f4-852d-450e-8916-eaec33b97170
public static Robot getRobot() { if (robot == null) { synchronized (GameAction.class) { if (robot == null) { try { robot = new Robot(); } catch (AWTException e) { e.printStackTrace(); } } } } return robot; }
748be741-7548-4551-bb2b-ecac94062086
public static void nextFoe() { GameAction.getRobot().keyPress(KeyEvent.VK_TAB); GameAction.getRobot().delay(10); GameAction.getRobot().keyRelease(KeyEvent.VK_TAB); GameAction.getRobot().delay(10); }
4da4c74e-644a-4f12-884c-c6efcfc8a95d
public static void nearestFoe() { GameAction.getRobot().keyPress(KeyEvent.VK_BACK_SPACE); GameAction.getRobot().delay(10); GameAction.getRobot().keyRelease(KeyEvent.VK_BACK_SPACE); GameAction.getRobot().delay(10); }
f3aa8d79-b156-4b35-9097-361288f548e9
public static void nearestNPC() { GameAction.getRobot().keyPress(KeyEvent.VK_F10); GameAction.getRobot().delay(10); GameAction.getRobot().keyRelease(KeyEvent.VK_F10); GameAction.getRobot().delay(10); }
aa91ce48-eccf-40bb-bfe4-9ca5d9396b83
public static void self() { GameAction.getRobot().keyPress(KeyEvent.VK_BACK_SLASH); GameAction.getRobot().delay(10); GameAction.getRobot().keyRelease(KeyEvent.VK_BACK_SLASH); GameAction.getRobot().delay(10); }
4cca4ff5-445d-4076-881d-2da6321dec2f
public static void undo() { GameAction.getRobot().keyPress(KeyEvent.VK_ESCAPE); GameAction.getRobot().delay(10); GameAction.getRobot().keyRelease(KeyEvent.VK_ESCAPE); GameAction.getRobot().delay(10); }
b6f2fd82-3900-4d6b-869b-1ccbf52a4fb0
Duo(String name, int keyCode) { this.name = name; this.keyCode = keyCode; listOfActions.add(this); }
666aca30-182b-484f-8f8a-f25e3edc694b
public static void initialize() { skill_1 = new Duo("1", KeyEvent.VK_1); skill_2 = new Duo("2", KeyEvent.VK_2); skill_3 = new Duo("3", KeyEvent.VK_3); skill_4 = new Duo("4", KeyEvent.VK_4); skill_5 = new Duo("5", KeyEvent.VK_5); skill_6 = new Duo("6", KeyEvent.VK_6); skill_7 = new Duo("5", KeyEvent.VK_7); skill_8 = new Duo("8", KeyEvent.VK_8); skill_9 = new Duo("9", KeyEvent.VK_9); skill_0 = new Duo("SelfHeal", KeyEvent.VK_0); skill_minus = new Duo("PetSummon", KeyEvent.VK_MINUS); skill_equals = new Duo("PetAttack", KeyEvent.VK_EQUALS); skill_F1 = new Duo("F1", KeyEvent.VK_F1); skill_F2 = new Duo("F2", KeyEvent.VK_F2); skill_F3 = new Duo("F3", KeyEvent.VK_F3); skill_F4 = new Duo("F4", KeyEvent.VK_F4); skill_F5 = new Duo("F5", KeyEvent.VK_F5); skill_F6 = new Duo("F6", KeyEvent.VK_F6); skill_F7 = new Duo("F7", KeyEvent.VK_F7); listOfActions.remove(skill_0); listOfActions.remove(skill_minus); listOfActions.remove(skill_equals); }
e9d93eb7-e44e-4495-9337-b61757e49527
public void use() { GameAction.getRobot().keyPress(this.keyCode); GameAction.getRobot().delay(200); GameAction.getRobot().keyRelease(this.keyCode); GameAction.getRobot().delay(200); }
df0738ea-b089-465a-9d57-44333487f6dc
Ranged(String name, int keyCode) { this.name = name; this.keyCode = keyCode; listOfActions.add(this); }
ba8e5152-65cb-4d92-9eaa-71cdc18cf018
public static void initialize() { skill_1 = new Ranged("1", KeyEvent.VK_1); skill_2 = new Ranged("2", KeyEvent.VK_2); skill_3 = new Ranged("3", KeyEvent.VK_3); skill_4 = new Ranged("4", KeyEvent.VK_4); skill_5 = new Ranged("5", KeyEvent.VK_5); skill_6 = new Ranged("6", KeyEvent.VK_6); skill_7 = new Ranged("6", KeyEvent.VK_7); skill_8 = new Ranged("8", KeyEvent.VK_8); skill_9 = new Ranged("9", KeyEvent.VK_9); skill_0 = new Ranged("SelfHeal", KeyEvent.VK_0); skill_minus = new Ranged("-", KeyEvent.VK_MINUS); skill_equals = new Ranged("=", KeyEvent.VK_EQUALS); skill_F1 = new Ranged("F1", KeyEvent.VK_F1); skill_F2 = new Ranged("F2", KeyEvent.VK_F2); skill_F3 = new Ranged("F3", KeyEvent.VK_F3); skill_F4 = new Ranged("F4", KeyEvent.VK_F4); skill_F5 = new Ranged("F5", KeyEvent.VK_F5); skill_F6 = new Ranged("F6", KeyEvent.VK_F6); skill_F7 = new Ranged("X", KeyEvent.VK_F7); listOfActions.remove(skill_0); }
13906ba5-d2c1-4cb7-a891-ba80b5fd31dc
public void use() { GameAction.getRobot().keyPress(this.keyCode); GameAction.getRobot().delay(200); GameAction.getRobot().keyRelease(this.keyCode); GameAction.getRobot().delay(200); }
d1c8d94c-bf04-40ae-8c97-c03e854e820e
public Tile(Rectangle bounds) { this.bounds = bounds; occupied = false; blocked = false; setInnerTiles(); }
b6de3f12-2e69-4d83-bbff-fb1560bee933
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { texture.draw(bounds.getMinX(), bounds.getMinY()); }
d30ec6d1-537b-42cc-912d-204a72ac718d
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { }
6f80fa1e-fe5d-4e1d-ae99-d834076b7d0c
private void setInnerTiles() { innerTiles = new ArrayList<>(); innerTiles.add(new SmallTile(new Rectangle(bounds.getMinX(), bounds.getMinY(), bounds.getWidth() / 2, bounds.getHeight() / 2))); innerTiles.add(new SmallTile(new Rectangle(bounds.getMinX() + (bounds.getWidth() / 2), bounds.getMinY(), bounds.getWidth() / 2, bounds.getHeight() / 2))); innerTiles.add(new SmallTile(new Rectangle(bounds.getMinX(), bounds.getMinY() + (bounds.getHeight() / 2), bounds.getWidth() / 2, bounds.getHeight() / 2))); innerTiles.add(new SmallTile(new Rectangle(bounds.getMinX() + (bounds.getWidth() / 2), bounds.getMinY() + (bounds.getHeight() / 2), bounds.getWidth() / 2, bounds.getHeight() / 2))); }
692eaddd-826b-450d-a281-e023f1fef448
public ArrayList<SmallTile> getInnerTiles() { return innerTiles; }
d0d3428b-0903-4119-ab3a-047dec474e87
public void setInnerTiles(ArrayList<SmallTile> innerTiles) { this.innerTiles = innerTiles; }
74dedcb1-040c-49b8-b5ae-b0c0e4f71fdd
public void chooseTexture() { }
17de5355-8e09-49df-a53a-fe980f9231ec
public int getId() { return id; }
2417b02e-f5d9-4a57-a42a-96d54a76b9e9
public void setId(int id) { this.id = id; }
82f1c10b-05ff-4ed7-8370-e6a9b3ba251a
public Rectangle getBounds() { return bounds; }
8eebaa89-e5a1-491a-a260-54c7ba76f77f
public void setBounds(Rectangle bounds) { this.bounds = bounds; }
32f027ec-deba-4a1e-99e0-cc236cdd9efc
public boolean isOccupied() { return occupied; }
a505b31c-163c-4126-b8a9-a11c706efb99
public void setOccupied(boolean occupied) { this.occupied = occupied; }
7b83505a-693d-4d41-8526-9c49057254bc
public boolean isBlocked() { return blocked; }
8ed7e9c4-d528-448d-bf84-5be0a95aa68f
public void setBlocked(boolean blocked) { this.blocked = blocked; }
8f7cd4d4-372c-402b-8ee6-befc22e33274
public float getMoveCost() { return moveCost; }
a6336d03-3c31-4642-af04-6169db5f0417
public void setMoveCost(float moveCost) { this.moveCost = moveCost; }
8793204c-d617-477c-a259-038f47260a76
public SmallTile(Rectangle bounds) { this.bounds = bounds; occupied = false; }
bd82ef16-ec60-48e8-b5f4-d38e826f5f56
public Rectangle getBounds() { return bounds; }
94beba0a-051e-4ac1-b1e4-1d05c2ee580e
public void setBounds(Rectangle bounds) { this.bounds = bounds; }
d3a8c63a-d24e-4987-afe7-22ffc56dbe92
public boolean isOccupied() { return occupied; }
08248ae2-a321-4492-a846-18fe52ad64eb
public void setOccupied(boolean occupied) { this.occupied = occupied; }
5fed1988-82c5-4fd3-af35-da2687a782a6
public boolean isBlocked() { return blocked; }
17efdd74-2237-45f3-a9e5-8ff5731d850f
public void setBlocked(boolean blocked) { this.blocked = blocked; }
1c146fd0-cb5d-45c5-9402-e9417a84a1bf
public float getMoveCost() { return moveCost; }
d3697a4a-2baf-4b06-b7ee-5e26702c5ae0
public void setMoveCost(float moveCost) { this.moveCost = moveCost; }
efda8d30-0428-4461-932a-0c852b822bf6
public GrassTile(Rectangle bounds) { super(bounds); t9Texture = ImageArchive.getT9Grass(); id = 1; }
f050e25b-2db6-492c-b067-79754c611d4f
public void chooseTexture() { int[] surroundingTiles = TileMap.getSurroundingTiles((int) bounds.getMinX() / (int) bounds.getWidth(), (int) bounds.getMinY() / (int) bounds.getHeight()); if (surroundingTiles[0] == 2) { if (surroundingTiles[1] == 2) { texture = t9Texture.getSubImage(0, 0, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } else if (surroundingTiles[2] == 2) { texture = t9Texture.getSubImage((int) t9Texture.getWidth() / 2, 0, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } else { texture = t9Texture.getSubImage((int) t9Texture.getWidth() / 4, 0, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } } else if (surroundingTiles[1] == 2) { if (surroundingTiles[3] == 2) { texture = t9Texture.getSubImage(0, t9Texture.getHeight() / 2, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } else { texture = t9Texture.getSubImage(0, t9Texture.getHeight() / 4, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } } else if (surroundingTiles[2] == 2) { if (surroundingTiles[3] == 2) { texture = t9Texture.getSubImage(t9Texture.getWidth() / 2, t9Texture.getHeight() / 2, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } else { texture = t9Texture.getSubImage(t9Texture.getWidth() / 2, t9Texture.getHeight() / 4, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } } else if (surroundingTiles[3] == 2) { texture = t9Texture.getSubImage(t9Texture.getWidth() / 4, t9Texture.getHeight() / 2, (int) bounds.getWidth(), (int) bounds.getHeight()); return; } texture = t9Texture.getSubImage((int) t9Texture.getWidth() / 4, (int) t9Texture.getHeight() / 4, (int) bounds.getWidth(), (int) bounds.getHeight()); }
8a9364fa-c5e2-4eee-9d40-9020d5b54b2c
public TileMap() { map = new Tile[mapWidth][mapHeight]; populateTileMap(); }
38d49467-4491-4aed-a782-a6224d4458c2
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { drawMap(container, game, g); }
36854354-9ec3-4501-aaf8-060ace470f2b
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException { }
99babe12-04b1-4a19-95c4-8919eab14f8c
private void populateTileMap() { for (int x = 0; x < mapWidth; x++) { for (int y = 0; y < mapHeight; y++) { map[x][y] = new GrassTile(new Rectangle(x * tileSize, y * tileSize, tileSize, tileSize)); } } map[5][5].setId(2); map[6][5].setId(2); map[6][6].setId(2); for (int x = 0; x < mapWidth; x++) { for (int y = 0; y < mapHeight; y++) { map[x][y].chooseTexture(); } } }
85b8efc8-6f10-449a-9e2a-c1037b704e4b
public void drawMap(GameContainer container, StateBasedGame game, Graphics g) throws SlickException { g.setColor(Color.white); for (int x = 0; x < mapWidth; x++) { for (int y = 0; y < mapHeight; y++) { g.setColor(Color.white); Tile t = map[x][y]; t.render(container, game, g); g.drawRect(t.getBounds().getMinX(), t.getBounds().getMinY(), t.getBounds().getWidth(), t.getBounds().getHeight()); g.setColor(Color.yellow); for (SmallTile st : t.getInnerTiles()) { //g.drawRect(st.getBounds().getMinX(), st.getBounds().getMinY(), st.getBounds().getWidth(), st.getBounds().getHeight()); } } } }
7f57c97b-00f0-4d28-a62e-d672a59e76f6
public static int[] getSurroundingTiles(int x, int y) { int[] surrounding = new int[4]; try { surrounding[0] = surroundingTile(x, y - 1); } catch (ArrayIndexOutOfBoundsException | NullPointerException ex) { surrounding[0] = -1; } try { surrounding[1] = surroundingTile(x - 1, y); } catch (ArrayIndexOutOfBoundsException | NullPointerException ex) { surrounding[1] = -1; } try { surrounding[2] = surroundingTile(x + 1, y); } catch (ArrayIndexOutOfBoundsException | NullPointerException ex) { surrounding[2] = -1; } try { surrounding[3] = surroundingTile(x, y + 1); } catch (ArrayIndexOutOfBoundsException | NullPointerException ex) { surrounding[3] = -1; } for (int i : surrounding) { System.out.println(i); } return surrounding; }
48eb2e66-8538-4463-a1ef-31bb0f87eb9a
private static int surroundingTile(int x, int y) { switch (map[x][y].getId()) { case 1: return 1; case 2: return 2; } return -1; }
e68abf43-32c9-4ade-a015-6d30c87fbb4c
@Override public int getWidthInTiles() { return mapWidth; }
12d3714a-28c9-4911-b375-25e78f6ff097
@Override public int getHeightInTiles() { return mapHeight; }
ad060a32-4b2d-4d8f-b9bf-e67ae9871b6b
@Override public void pathFinderVisited(int x, int y) { visited[x][y] = true; }
9cf0ff06-5893-4703-931a-6fa30c02f334
@Override public boolean blocked(PathFindingContext context, int tx, int ty) { return map[tx][ty].isBlocked(); }
00d8807c-a955-4cbb-939b-8a6bdf58bbe3
@Override public float getCost(PathFindingContext context, int tx, int ty) { return map[tx][ty].getMoveCost(); }
81ecc5b1-57bb-4b6e-89f8-444d9b233bb0
public static void main(String[] args) throws SlickException { AppGameContainer app = new AppGameContainer(new Game("Game")); app.setTargetFrameRate(60); Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); app.setDisplayMode(screenSize.width, screenSize.height, true); app.setVerbose(true); app.setShowFPS(true); app.start(); }
5b579c44-5e3d-43f8-baf9-5a2104c0598a
public Game(String name) throws SlickException { super(name); inputReceiver = new InputReceiver(); }
df1ddf69-49ea-4ee0-a19b-c1ed9ed5db55
@Override public void initStatesList(GameContainer container) throws SlickException { initControl(container, this); addState(new PlayState(PLAYSTATE, this)); getState(PLAYSTATE).init(container, this); enterState(PLAYSTATE); }
ff584c4f-9213-4b3b-ac05-8aafe0fb7b61
public void initControl(GameContainer container, StateBasedGame game) throws SlickException { ImageArchive.init(container, game); }
e4046d3f-ec5f-4cba-8ae6-37306feca114
public PlayState(int id, Game ga) { this.id = id; this.ga = ga; tileMap = new TileMap(); }
d0613373-492a-4c05-b8ce-d7450b4dad5d
@Override public int getID() { return id; }
ad9544a0-7ba0-4126-bc3b-94698a53f543
@Override public void init(GameContainer container, StateBasedGame game) throws SlickException { }