Advertisement
Guest User

Le Chasseur LD #25 Entry Source Code

a guest
Dec 16th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 29.81 KB | None | 0 0
  1. /* Requires only the lwjgl.jar, the natives folder packaged with it in the official release 2.8.4 */
  2. /* and the TWL's PNGDecoder, remaining dependancies can be acquired by installing the actual game */
  3. /* and extracting the images used by the game */
  4.  
  5. package ld25.lechasseur;
  6.  
  7. import java.awt.image.BufferedImage;
  8. import java.io.File;
  9. import java.io.IOException;
  10. import java.io.InputStream;
  11. import java.nio.ByteBuffer;
  12. import java.util.ArrayList;
  13. import java.util.HashMap;
  14. import java.util.Random;
  15.  
  16. import javax.imageio.ImageIO;
  17.  
  18. import org.lwjgl.BufferUtils;
  19. import org.lwjgl.LWJGLException;
  20. import org.lwjgl.LWJGLUtil;
  21. import org.lwjgl.Sys;
  22. import org.lwjgl.input.Keyboard;
  23. import org.lwjgl.input.Mouse;
  24. import org.lwjgl.opengl.Display;
  25. import org.lwjgl.opengl.DisplayMode;
  26.  
  27. import de.matthiasmann.twl.utils.PNGDecoder;
  28. import de.matthiasmann.twl.utils.PNGDecoder.Format;
  29.  
  30. import static org.lwjgl.opengl.GL11.*;
  31. import static org.lwjgl.opengl.GL14.*;
  32. import static org.lwjgl.opengl.GL30.*;
  33. import static org.lwjgl.util.glu.GLU.*;
  34.  
  35. public class LeChasseur {
  36.  
  37.     static {
  38.         System.setProperty("org.lwjgl.librarypath",
  39.                 new File(new File(System.getProperty("user.dir"), "native"),
  40.                         LWJGLUtil.getPlatformName()).getAbsolutePath());
  41.     }
  42.  
  43.     static final int SCREEN_WIDTH = 320, SCREEN_HEIGHT = 160, SCREEN_SCALE = 2;
  44.     static final int MAP_WIDTH = 64, MAP_HEIGHT = 64, TILESET_WIDTH = 4,
  45.             TILESET_HEIGHT = 4;
  46.     int defaultFBO = 0, scaledFBO, scaledFBOTexture;
  47.     HashMap<String, Integer> textures = new HashMap<String, Integer>();
  48.     long lastFrame, lastFPS;
  49.     int fps;
  50.     int mX, mY;
  51.     float rC;
  52.     float camX, camY;
  53.     Tile map[] = new Tile[64 * 64];
  54.     int msgTimer;
  55.     int hCount, sHCount;
  56.     int civPos[][];
  57.     String msg = null;
  58.     ArrayList<Human> humans = new ArrayList<Human>(),
  59.             dHumans = new ArrayList<Human>();;
  60.     ArrayList<Bullet> bullets = new ArrayList<Bullet>(),
  61.             dBullets = new ArrayList<Bullet>();
  62.     Human player = new Human(60, 60, 0, 0x5C9BC8);
  63.     Random rng = new Random();
  64.     int timerMsg2 = 300;
  65.     boolean dead;
  66.     int bCX, bCY;
  67.  
  68.     public void start() {
  69.         try {
  70.             Display.setDisplayMode(new DisplayMode(SCREEN_WIDTH * SCREEN_SCALE,
  71.                     SCREEN_HEIGHT * SCREEN_SCALE));
  72.             updateFPS();
  73.             Display.create();
  74.             Keyboard.enableRepeatEvents(false);
  75.         } catch (LWJGLException e) {
  76.             e.printStackTrace();
  77.             System.exit(0);
  78.         }
  79.  
  80.         init();
  81.         initGL();
  82.         getDelta();
  83.         lastFPS = getTime();
  84.  
  85.         while (!Display.isCloseRequested()) {
  86.             int delta = getDelta();
  87.  
  88.             if (!dead) {
  89.                 update(delta);
  90.             } else {
  91.                 displayMessage("You are dead, with " + player.cash
  92.                         + "$, rest in peace", 1);
  93.             }
  94.             renderGL();
  95.  
  96.             Display.update();
  97.             Display.sync(60);
  98.         }
  99.         Display.destroy();
  100.     }
  101.  
  102.     public void update(int delta) {
  103.         timerMsg2--;
  104.         if (timerMsg2 == 0) {
  105.             displayMessage(
  106.                     "Make as much money as you can, kill without getting yourself killed",
  107.                     10);
  108.         }
  109.         updateFPS();
  110.         checkInput(delta);
  111.         rC += Math.PI / 10f;
  112.         for (Human human : humans) {
  113.             if (human.x - camX + SCREEN_WIDTH / 2 + 16 > 0
  114.                     && human.x - camX + SCREEN_WIDTH / 2 - 16 < SCREEN_WIDTH
  115.                     && human.y - camY + SCREEN_HEIGHT / 2 + 16 > 0
  116.                     && human.y - camY + SCREEN_HEIGHT / 2 - 16 < SCREEN_HEIGHT) {
  117.                 human.update();
  118.             }
  119.         }
  120.         for (Human human : dHumans) {
  121.             if (human == player)
  122.                 dead = true;
  123.             humans.remove(human); // MUHEAUHAEHUAwUHUHAAHA
  124.         }
  125.         for (Bullet bullet : bullets) {
  126.             bullet.update();
  127.         }
  128.         for (Bullet bullet : dBullets) {
  129.             bullets.remove(bullet);
  130.         }
  131.         // System.out.println(player.x + ", " + player.y + ", " + player.lRot
  132.         // + ", " + player.rot);
  133.         map[(int) player.x / 16 + ((int) player.y / 16) * MAP_WIDTH].inside();
  134.  
  135.         if (humans.size() - sHCount - 1 < hCount) {
  136.             // System.out.println("Spawned " + (humans.size() - sHCount - 1));
  137.             int rct = rng.nextInt(hCount);
  138.             Human newH = new AIHuman(civPos[rct][0] * 16 + rng.nextInt(16),
  139.                     civPos[rct][1] * 16 + rng.nextInt(16), rng.nextInt(3),
  140.                     rng.nextInt(0xFFFFFF));
  141.             newH.lRot = rng.nextInt(360);
  142.             humans.add(newH);
  143.         }
  144.     }
  145.  
  146.     public void spawnCase() {
  147.         bCX = rng.nextInt(MAP_WIDTH);
  148.         bCY = rng.nextInt(MAP_HEIGHT);
  149.         while (!isCollidable(bCX, bCY)) {
  150.             bCX = rng.nextInt(MAP_WIDTH);
  151.             bCY = rng.nextInt(MAP_HEIGHT);
  152.         }
  153.         setCaseTile(bCX, bCY);
  154.         System.out.println(bCX + ", " + bCY);
  155.     }
  156.  
  157.     public void init() {
  158.         displayMessage(
  159.                 "WASD to move, E to equip, LSHIFT to run and LMB to shoot", 10);
  160.         humans.add(player);
  161.  
  162.         try {
  163.             BufferedImage map = ImageIO.read(LeChasseur.class
  164.                     .getResourceAsStream("/map.png"));
  165.  
  166.             for (int y = 0; y < MAP_WIDTH; y++) {
  167.                 for (int x = 0; x < MAP_WIDTH; x++) {
  168.                     setTile(x, y, getTileFromColor(map.getRGB(x, y))
  169.                             % TILESET_WIDTH, getTileFromColor(map.getRGB(x, y))
  170.                             / TILESET_HEIGHT);
  171.                 }
  172.             }
  173.  
  174.             BufferedImage people = ImageIO.read(LeChasseur.class
  175.                     .getResourceAsStream("/people.png"));
  176.  
  177.             for (int y = 0; y < MAP_WIDTH; y++) {
  178.                 for (int x = 0; x < MAP_WIDTH; x++) {
  179.                     if (people.getRGB(x, y) == 0xFF0094FF
  180.                             || people.getRGB(x, y) == 0xFF7F3300) {
  181.                         sHCount++;
  182.                     } else if (people.getRGB(x, y) == 0xFFB6FF00) {
  183.                         hCount++;
  184.                     }
  185.                 }
  186.             }
  187.  
  188.             civPos = new int[hCount][2];
  189.  
  190.             // System.out.println(hCount);
  191.  
  192.             int cCt = -1;
  193.  
  194.             for (int y = 0; y < MAP_WIDTH; y++) {
  195.                 for (int x = 0; x < MAP_WIDTH; x++) {
  196.                     int col = people.getRGB(x, y);
  197.  
  198.                     if (col == 0xFF0094FF || col == 0xFF7F3300) {
  199.                         Human newH = new StationaryHuman(x * 16
  200.                                 + rng.nextInt(16), y * 16 + rng.nextInt(16),
  201.                                 rng.nextInt(3), col == 0xFF7F3300);
  202.                         newH.lRot = rng.nextInt(360);
  203.                         humans.add(newH);
  204.                     } else if (col == 0xFFB6FF00) {
  205.                         cCt++;
  206.                         civPos[cCt][0] = x * 16 + rng.nextInt(16);
  207.                         civPos[cCt][1] = y * 16 + rng.nextInt(16);
  208.                         Human newH = new AIHuman(x * 16 + rng.nextInt(16), y
  209.                                 * 16 + rng.nextInt(16), rng.nextInt(3),
  210.                                 rng.nextInt(0xFFFFFF));
  211.                         newH.lRot = rng.nextInt(360);
  212.                         humans.add(newH);
  213.                     }
  214.                 }
  215.             }
  216.  
  217.             BufferedImage shops = ImageIO.read(LeChasseur.class
  218.                     .getResourceAsStream("/shops.png"));
  219.  
  220.             for (int y = 0; y < MAP_WIDTH; y++) {
  221.                 for (int x = 0; x < MAP_WIDTH; x++) {
  222.                     int col = shops.getRGB(x, y);
  223.  
  224.                     if (col == 0xFFFF0000) {
  225.                         setHealthTile(x, y);
  226.                     } else if (col == 0xFF00FF21) {
  227.                         setVestTile(x, y);
  228.                     } else if (col == 0xFFFFD800) {
  229.                         setAmmoTile(x, y);
  230.                     }
  231.                 }
  232.             }
  233.         } catch (Exception e) {
  234.             e.printStackTrace();
  235.         }
  236.  
  237.         spawnCase();
  238.     }
  239.  
  240.     public int getTileFromColor(int color) {
  241.         if (color == 0xFF7F0000)
  242.             return 0;
  243.         if (color == 0xFF7F6A00)
  244.             return 1;
  245.         if (color == 0xFF004A7F)
  246.             return 2;
  247.         if (color == 0xFFC0C0C0)
  248.             return 3;
  249.         if (color == 0xFF808080)
  250.             return 4;
  251.         if (color == 0xFF404040)
  252.             return 5;
  253.         if (color == 0xFF7F593F)
  254.             return 6;
  255.         if (color == 0xFF267F00)
  256.             return 7;
  257.         if (color == 0xFFFFB27F)
  258.             return 8;
  259.         if (color == 0xFFA0A0A0)
  260.             return 9;
  261.         if (color == 0xFFFF7F7F)
  262.             return 10;
  263.         if (color == 0xFFFFFFFF)
  264.             return 11;
  265.         if (color == 0xFFFFE97F)
  266.             return 12;
  267.  
  268.         return 0;
  269.     }
  270.  
  271.     public int getDelta() {
  272.         long time = getTime();
  273.         int delta = (int) (time - lastFrame);
  274.         lastFrame = time;
  275.  
  276.         return delta;
  277.     }
  278.  
  279.     private void checkInput(int delta) {
  280.         mX = Mouse.getX() / SCREEN_SCALE;
  281.         mY = (SCREEN_HEIGHT * SCREEN_SCALE - Mouse.getY()) / SCREEN_SCALE;
  282.         float bRot = -player.lRot - 90;
  283.         player.rot = -player.lRot - 90;
  284.         player.moving = false;
  285.         player.sprinting = false;
  286.  
  287.         if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
  288.             player.rot -= 90;
  289.             player.moving = true;
  290.         }
  291.         if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
  292.             player.rot += 90;
  293.             player.moving = true;
  294.         }
  295.         if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
  296.             player.rot += (bRot - player.rot) / 2f;
  297.             player.moving = true;
  298.         }
  299.         if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
  300.             player.rot -= (-(player.rot - bRot) / 2f == 0 ? 180
  301.                     : -(player.rot - bRot) / 2f);
  302.             player.moving = true;
  303.         }
  304.         if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
  305.             player.sprinting = true;
  306.         }
  307.  
  308.         while (Keyboard.next()) {
  309.             if (Keyboard.getEventKeyState()) {
  310.                 if (Keyboard.getEventKey() == Keyboard.KEY_E) {
  311.                     player.equip();
  312.                 }
  313.                 if (Keyboard.getEventKey() == Keyboard.KEY_R) {
  314.                     player.reload();
  315.                 }
  316.                 if (Keyboard.getEventKey() == Keyboard.KEY_Q) {
  317.                     map[(int) player.x / 16 + ((int) player.y / 16) * MAP_WIDTH]
  318.                             .use();
  319.                 }
  320.             }
  321.         }
  322.  
  323.         while (Mouse.next()) {
  324.             if (Mouse.getEventButtonState()) {
  325.                 if (Mouse.getEventButton() == 0) {
  326.                     player.shoot();
  327.                 }
  328.             }
  329.         }
  330.     }
  331.  
  332.     public long getTime() {
  333.         return (Sys.getTime() * 1000) / Sys.getTimerResolution();
  334.     }
  335.  
  336.     public void updateFPS() {
  337.         if (getTime() - lastFPS > 1000) {
  338.             Display.setTitle("Le Chasseur - FPS: " + fps);
  339.             fps = 0;
  340.             lastFPS += 1000;
  341.         }
  342.         fps++;
  343.     }
  344.  
  345.     public void initGL() {
  346.         glEnable(GL_TEXTURE_2D);
  347.         glEnable(GL_BLEND);
  348.         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  349.         initFBO();
  350.         initTextures();
  351.     }
  352.  
  353.     public void initFBO() {
  354.         scaledFBO = glGenFramebuffers();
  355.         scaledFBOTexture = glGenTextures();
  356.         int scaledFBODBuffer = glGenRenderbuffers();
  357.         glBindFramebuffer(GL_FRAMEBUFFER, scaledFBO);
  358.         glBindTexture(GL_TEXTURE_2D, scaledFBOTexture);
  359.         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  360.         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  361.         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, SCREEN_WIDTH, SCREEN_HEIGHT,
  362.                 0, GL_RGBA, GL_INT, (java.nio.ByteBuffer) null);
  363.         glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
  364.                 GL_TEXTURE_2D, scaledFBOTexture, 0);
  365.         glBindRenderbuffer(GL_RENDERBUFFER, scaledFBODBuffer);
  366.         glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24,
  367.                 SCREEN_WIDTH, SCREEN_HEIGHT);
  368.         glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
  369.                 GL_RENDERBUFFER, scaledFBODBuffer);
  370.         glBindFramebuffer(GL_FRAMEBUFFER, 0);
  371.     }
  372.  
  373.     public void initTextures() {
  374.         textures.put("font", loadTexture("/font.png"));
  375.         textures.put("tiles", loadTexture("/tiles.png"));
  376.     }
  377.  
  378.     public int loadTexture(String fileDirectory) {
  379.         InputStream in = LeChasseur.class.getResourceAsStream(fileDirectory);
  380.  
  381.         PNGDecoder decoder = null;
  382.         try {
  383.             decoder = new PNGDecoder(in);
  384.         } catch (IOException e) {
  385.             e.printStackTrace();
  386.         }
  387.  
  388.         ByteBuffer buffer = BufferUtils.createByteBuffer(4 * decoder.getWidth()
  389.                 * decoder.getHeight());
  390.  
  391.         try {
  392.             decoder.decode(buffer, decoder.getWidth() * 4, Format.RGBA);
  393.             buffer.flip();
  394.             in.close();
  395.         } catch (IOException e) {
  396.         }
  397.  
  398.         int texture = glGenTextures();
  399.  
  400.         glBindTexture(GL_TEXTURE_2D, texture);
  401.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  402.         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  403.         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, decoder.getWidth(),
  404.                 decoder.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
  405.         glBindTexture(GL_TEXTURE_2D, 0);
  406.  
  407.         glBindTexture(GL_TEXTURE_2D, 0);
  408.  
  409.         return texture;
  410.     }
  411.  
  412.     public int nPo2(final int a) {
  413.         int b = 1;
  414.         while (b < a) {
  415.             b = b << 1;
  416.         }
  417.         return b;
  418.     }
  419.  
  420.     public void renderString(int x, int y, String string) {
  421.         for (int i = 0; i < string.length(); i++) {
  422.             char ch = (char) (string.charAt(i) - 32);
  423.             float chX = (ch % 32) * 1 / 32f, chY = (ch / 32) * 1 / 3f;
  424.             glBindTexture(GL_TEXTURE_2D, textures.get("font"));
  425.  
  426.             glPushMatrix();
  427.  
  428.             glTranslatef(x + i * 4, y, 0);
  429.  
  430.             glBegin(GL_QUADS);
  431.  
  432.             glTexCoord2f(chX, chY);
  433.             glVertex2f(0, 0);
  434.  
  435.             glTexCoord2f(chX + 1 / 32f, chY);
  436.             glVertex2f(4, 0);
  437.  
  438.             glTexCoord2f(chX + 1 / 32f, chY + 1 / 3f);
  439.             glVertex2f(4, 6);
  440.  
  441.             glTexCoord2f(chX, chY + 1 / 3f);
  442.             glVertex2f(0, 6);
  443.  
  444.             glEnd();
  445.  
  446.             glPopMatrix();
  447.  
  448.             glBindTexture(GL_TEXTURE_2D, 0);
  449.         }
  450.     }
  451.  
  452.     public void renderQuad(float xS, float yS) {
  453.         glPushMatrix();
  454.  
  455.         glScalef(xS, yS, 1);
  456.  
  457.         glBegin(GL_QUADS);
  458.  
  459.         glVertex2f(-0.5f, -0.5f);
  460.  
  461.         glVertex2f(0.5f, -0.5f);
  462.  
  463.         glVertex2f(0.5f, 0.5f);
  464.  
  465.         glVertex2f(-0.5f, 0.5f);
  466.  
  467.         glEnd();
  468.  
  469.         glPopMatrix();
  470.     }
  471.  
  472.     public void renderCQuad(float xS, float yS) {
  473.         glPushMatrix();
  474.  
  475.         glScalef(xS, yS, 1);
  476.  
  477.         glBegin(GL_QUADS);
  478.  
  479.         glVertex2f(0, 0);
  480.  
  481.         glVertex2f(1f, 0);
  482.  
  483.         glVertex2f(1f, 1f);
  484.  
  485.         glVertex2f(0, 1f);
  486.  
  487.         glEnd();
  488.  
  489.         glPopMatrix();
  490.     }
  491.  
  492.     public void renderTile(int x, int y) {
  493.         float tX = 1f / TILESET_WIDTH * x, tY = 1f / TILESET_HEIGHT * y;
  494.         glBindTexture(GL_TEXTURE_2D, textures.get("tiles"));
  495.  
  496.         glPushMatrix();
  497.  
  498.         glBegin(GL_QUADS);
  499.  
  500.         glTexCoord2f(tX, tY);
  501.         glVertex2f(0, 0);
  502.  
  503.         glTexCoord2f(tX + 1f / TILESET_WIDTH, tY);
  504.         glVertex2f(16, 0);
  505.  
  506.         glTexCoord2f(tX + 1f / TILESET_WIDTH, tY + 1f / TILESET_HEIGHT);
  507.         glVertex2f(16, 16);
  508.  
  509.         glTexCoord2f(tX, tY + 1f / TILESET_HEIGHT);
  510.         glVertex2f(0, 16);
  511.  
  512.         glEnd();
  513.  
  514.         glPopMatrix();
  515.  
  516.         glBindTexture(GL_TEXTURE_2D, 0);
  517.     }
  518.  
  519.     public void renderCTile(int x, int y) {
  520.         float tX = 1f / TILESET_WIDTH * x, tY = 1f / TILESET_HEIGHT * y;
  521.         glBindTexture(GL_TEXTURE_2D, textures.get("tiles"));
  522.  
  523.         glPushMatrix();
  524.  
  525.         glBegin(GL_QUADS);
  526.  
  527.         glTexCoord2f(tX, tY);
  528.         glVertex2f(-8, -8);
  529.  
  530.         glTexCoord2f(tX + 1f / TILESET_WIDTH, tY);
  531.         glVertex2f(8, -8);
  532.  
  533.         glTexCoord2f(tX + 1f / TILESET_WIDTH, tY + 1f / TILESET_HEIGHT);
  534.         glVertex2f(8, 8);
  535.  
  536.         glTexCoord2f(tX, tY + 1f / TILESET_HEIGHT);
  537.         glVertex2f(-8, 8);
  538.  
  539.         glEnd();
  540.  
  541.         glPopMatrix();
  542.  
  543.         glBindTexture(GL_TEXTURE_2D, 0);
  544.     }
  545.  
  546.     public void renderHuman(int c1, int c2, int c3, float armRot, float wL) {
  547.         glPushMatrix();
  548.         glPushMatrix();
  549.         glRotate(armRot);
  550.         if (wL != 0) {
  551.             glTranslatef(0, -wL * 1.5f, 0);
  552.             glColori(0x48413E);
  553.             renderQuad(1.75f, wL); // Weapon
  554.             glTranslatef(0, wL * 1.5f, 0);
  555.             glColori(c1);
  556.             glTranslatef(0, -3, 0);
  557.             glPushMatrix();
  558.             glTranslatef(-3, 0, 0);
  559.             glRotate(60);
  560.             renderQuad(7, 3); // ArmL
  561.             glPopMatrix();
  562.             glPushMatrix();
  563.             glTranslatef(3, 0, 0);
  564.             glRotate(-60);
  565.             renderQuad(7, 3); // ArmR
  566.             glPopMatrix();
  567.         } else {
  568.             glColori(c1);
  569.             renderQuad(14, 3); // Arm
  570.         }
  571.         glPopMatrix();
  572.         glColori(c2);
  573.         renderQuad(10, 5); // Body
  574.         glColori(c3);
  575.         renderQuad(4, 5); // Head
  576.         glColori(0xFFFFFF);
  577.         glPopMatrix();
  578.     }
  579.  
  580.     public void glColori(int color) {
  581.         glColor3f((color >> 16 & 0xFF) / 255f, (color >> 8 & 0xFF) / 255f,
  582.                 (color & 0xFF) / 255f);
  583.     }
  584.  
  585.     public void glRotate(float rot) {
  586.         glRotatef(rot, 0, 0, -1);
  587.     }
  588.  
  589.     public void setTile(int x, int y, int tX, int tY) {
  590.         map[x + y * MAP_WIDTH] = new Tile(tX, tY);
  591.     }
  592.  
  593.     public void setAmmoTile(int x, int y) {
  594.         map[x + y * MAP_WIDTH] = new AmmoTile();
  595.     }
  596.  
  597.     public void setVestTile(int x, int y) {
  598.         map[x + y * MAP_WIDTH] = new VestTile();
  599.     }
  600.  
  601.     public void setHealthTile(int x, int y) {
  602.         map[x + y * MAP_WIDTH] = new HealthTile();
  603.     }
  604.  
  605.     public void setCaseTile(int x, int y) {
  606.         map[x + y * MAP_WIDTH] = new CaseTile(map[x + y * MAP_WIDTH].tX, map[x
  607.                 + y * MAP_WIDTH].tY);
  608.     }
  609.  
  610.     public void readyScaledFBO() {
  611.         glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
  612.         glBindFramebuffer(GL_FRAMEBUFFER, scaledFBO);
  613.     }
  614.  
  615.     public void clearGL() {
  616.         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  617.         glClearColor(0.1f, 0.1f, 0.1f, 1f);
  618.     }
  619.  
  620.     public void ready2D() {
  621.         glMatrixMode(GL_PROJECTION);
  622.         glLoadIdentity();
  623.  
  624.         gluOrtho2D(0.0f, SCREEN_WIDTH, SCREEN_HEIGHT, 0.0f);
  625.  
  626.         glMatrixMode(GL_MODELVIEW);
  627.         glLoadIdentity();
  628.         glTranslatef(0.375f, 0.375f, 0.0f);
  629.  
  630.         glDisable(GL_DEPTH_TEST);
  631.     }
  632.  
  633.     public void render2D() {
  634.         glColori(0xFFFFFF);
  635.  
  636.         camX = player.x;
  637.         camY = player.y;
  638.  
  639.         float rot = (float) Math.toDegrees(Math.atan2(SCREEN_HEIGHT / 2 - mY,
  640.                 mX - SCREEN_WIDTH / 2)) - 90;
  641.         glPushMatrix();
  642.         glTranslatef(SCREEN_WIDTH / 2 - (int) camX, SCREEN_HEIGHT / 2
  643.                 - (int) camY, 0);
  644.  
  645.         for (int x = 0; x < MAP_WIDTH; x++) {
  646.             for (int y = 0; y < MAP_HEIGHT; y++) {
  647.                 if (SCREEN_WIDTH / 2 - (int) camX + x * 16 < -16
  648.                         || SCREEN_WIDTH / 2 - (int) camX + x * 16 > SCREEN_WIDTH
  649.                         || SCREEN_HEIGHT / 2 - (int) camY + y * 16 < -16
  650.                         || SCREEN_HEIGHT / 2 - (int) camY + y * 16 > SCREEN_HEIGHT)
  651.                     continue;
  652.                 glPushMatrix();
  653.                 glTranslatef(x * 16, y * 16, 0);
  654.                 renderTile(map[x + y * MAP_WIDTH].tX, map[x + y * MAP_WIDTH].tY);
  655.                 if (map[x + y * MAP_WIDTH] instanceof CaseTile) {
  656.                     glPushMatrix();
  657.                     glTranslatef(8, 8, 0);
  658.                     glRotate(rC * 10);
  659.                     renderCTile(3, 3);
  660.                     glPopMatrix();
  661.                 }
  662.                 glPopMatrix();
  663.             }
  664.         }
  665.  
  666.         player.lRot = rot;
  667.  
  668.         for (Human human : humans) {
  669.             human.render();
  670.         }
  671.  
  672.         for (Bullet bullet : bullets) {
  673.             bullet.render();
  674.         }
  675.  
  676.         glPopMatrix();
  677.  
  678.         renderUI();
  679.     }
  680.  
  681.     public void renderUI() {
  682.         glColori(0xFFFFFF);
  683.  
  684.         // glColori(0x2C3952);
  685.         // renderString(3 + 1, 48 + 1, "X: " + (int) player.x / 16 + " Y: " +
  686.         // (int) player.y / 16);
  687.         // glColori(0xDFDFDF);
  688.         // renderString(3, 48, "X: " + (int) player.x / 16 + " Y: " + (int)
  689.         // player.y / 16);
  690.  
  691.         glColori(0x2C3952);
  692.         renderString(3 + 1, 3 + 1, "Blood: " + (int) player.hp + "%");
  693.         glColori(0xDFDFDF);
  694.         renderString(3, 3, "Blood: " + (int) player.hp + "%");
  695.  
  696.         if ((int) player.v > 0) {
  697.             glColori(0x2C3952);
  698.             renderString(3 + 12 * 4 + 1, 3 + 1, "Vest: " + (int) player.v + "%");
  699.             glColori(0xDFDFDF);
  700.             renderString(3 + 12 * 4, 3, "Vest: " + (int) player.v + "%");
  701.         }
  702.         glColori(0x2C3952);
  703.         renderString(3 + 1, 11 + 1, "Ammo: " + player.mag + "/" + player.ammo);
  704.         glColori(0xDFDFDF);
  705.         renderString(3, 11, "Ammo: " + player.mag + "/" + player.ammo);
  706.         glColori(0x2C3952);
  707.         renderString(3 + 1, 19 + 1, player.cash + "$");
  708.         glColori(0xDFDFDF);
  709.         renderString(3, 19, player.cash + "$");
  710.  
  711.         glColori(0x2C3952);
  712.         renderString(2 + 1, SCREEN_HEIGHT - 8 + 1,
  713.                 "Le Chasseur - Ludum Dare 25");
  714.         glColori(0xDFDFDF);
  715.         renderString(2, SCREEN_HEIGHT - 8, "Le Chasseur - Ludum Dare 25");
  716.  
  717.         msgTimer--;
  718.         if (msg != null && msgTimer > 0) {
  719.             glColori(0x2C3952);
  720.             renderString((SCREEN_WIDTH - msg.length() * 4) / 2 + 1,
  721.                     SCREEN_HEIGHT - 20 + 1, msg);
  722.             glColori(0xDFDFDF);
  723.             renderString((SCREEN_WIDTH - msg.length() * 4) / 2,
  724.                     SCREEN_HEIGHT - 20, msg);
  725.         }
  726.     }
  727.  
  728.     public void displayMessage(String msg, int time) {
  729.         this.msg = msg;
  730.         msgTimer = time * 30;
  731.     }
  732.  
  733.     public void renderScaledFBO() {
  734.         glViewport(0, 0, SCREEN_WIDTH * SCREEN_SCALE, SCREEN_HEIGHT
  735.                 * SCREEN_SCALE);
  736.         glBindFramebuffer(GL_READ_FRAMEBUFFER, scaledFBO);
  737.         glBindFramebuffer(GL_DRAW_FRAMEBUFFER, defaultFBO);
  738.         glBlitFramebuffer(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, SCREEN_WIDTH
  739.                 * SCREEN_SCALE, SCREEN_HEIGHT * SCREEN_SCALE,
  740.                 GL_COLOR_BUFFER_BIT, GL_NEAREST);
  741.     }
  742.  
  743.     public void renderGL() {
  744.         readyScaledFBO();
  745.         clearGL();
  746.         ready2D();
  747.         render2D();
  748.         renderScaledFBO();
  749.     }
  750.  
  751.     public boolean isCollidable(int x, int y) {
  752.         if (x < 0 || y < 0) {
  753.             return false;
  754.         }
  755.         try {
  756.             return map[x + y * MAP_WIDTH].collidable;
  757.         } catch (Exception e) {
  758.             return false;
  759.         }
  760.     }
  761.  
  762.     public boolean isBCollidable(int x, int y) {
  763.         if (x < 0 || y < 0) {
  764.             return false;
  765.         }
  766.         try {
  767.             return map[x + y * MAP_WIDTH].bCollidable;
  768.         } catch (Exception e) {
  769.             return false;
  770.         }
  771.     }
  772.  
  773.     public static void main(String[] argv) {
  774.         LeChasseur main = new LeChasseur();
  775.         main.start();
  776.     }
  777.  
  778.     public class Human {
  779.         float x, y;
  780.         int hp = 100, v = 0;
  781.         float rot, lRot;
  782.         boolean moving, sprinting;
  783.         int race, cc1, cc2;
  784.         int mag = 7, ammo = 49, cash = 50;
  785.         int reloadTimer, rST;
  786.         boolean us = true, weapon = false, wA;
  787.         boolean rS;
  788.  
  789.         public Human(float x, float y, int race, int cc1, int cc2) {
  790.             this.x = x;
  791.             this.y = y;
  792.             this.race = race;
  793.             this.cc1 = cc1;
  794.             this.cc2 = cc2;
  795.         }
  796.  
  797.         public Human(float x, float y, int race, int cc2) {
  798.             this.x = x;
  799.             this.y = y;
  800.             this.race = race;
  801.             this.cc2 = cc2;
  802.             us = false;
  803.         }
  804.  
  805.         public void update() {
  806.             move();
  807.             hitCheck();
  808.             deadCheck();
  809.         }
  810.  
  811.         public void deadCheck() {
  812.             if (hp <= 0) {
  813.                 hp = 0;
  814.                 dHumans.add(this);
  815.             }
  816.         }
  817.  
  818.         public void hitCheck() {
  819.             for (Bullet bullet : bullets) {
  820.                 if (bullet.parent != this) {
  821.                     float dist = (float) Math.sqrt(Math.pow(bullet.x - x, 2)
  822.                             + Math.pow(bullet.y - y, 2));
  823.                     if (dist <= 6) {
  824.                         int dmg = (int) ((7 - dist) * 2);
  825.                         if (v > 0) {
  826.                             v -= dmg;
  827.                             if (v < 0) {
  828.                                 hp += v;
  829.                             }
  830.                         } else {
  831.                             hp -= dmg;
  832.                         }
  833.                         dBullets.add(bullet);
  834.                     }
  835.                 }
  836.             }
  837.         }
  838.  
  839.         public void move() {
  840.             float xInc = (float) (moving ? sprinting ? Math.cos(Math
  841.                     .toRadians(rot)) * 1.5f : Math.cos(Math.toRadians(rot)) : 0), yInc = (float) (moving ? sprinting ? Math
  842.                     .sin(Math.toRadians(rot)) * 1.5f : Math.sin(Math
  843.                     .toRadians(rot))
  844.                     : 0);
  845.             int nTX = (int) Math.floor((x + xInc) / 16f), nTY = (int) Math
  846.                     .floor((y + yInc) / 16f);
  847.  
  848.             if (isCollidable(nTX, (int) y / 16)) {
  849.                 x += xInc;
  850.             }
  851.             if (isCollidable((int) x / 16, nTY)) {
  852.                 y += yInc;
  853.             }
  854.         }
  855.  
  856.         public void render() {
  857.             rST--;
  858.             rS = rST > 0;
  859.             reloadTimer--;
  860.  
  861.             if (reloadTimer <= 0 && wA == false) {
  862.                 wA = true;
  863.                 if (ammo < 7 - mag) {
  864.                     mag += ammo;
  865.                     ammo = 0;
  866.                 } else {
  867.                     ammo -= 7 - mag;
  868.                     mag += 7 - mag;
  869.                 }
  870.             }
  871.  
  872.             glPushMatrix();
  873.             glTranslatef(x, y, 0);
  874.             glRotate(lRot);
  875.             float rot2 = moving ? (float) Math
  876.                     .sin(rC * (sprinting ? 1f : 0.7f))
  877.                     * (sprinting ? 20f : weapon ? 7f : 15f) : 0;
  878.             renderHuman(us ? cc1 : raceColor() - 0x0A0A0A, cc2, raceColor(),
  879.                     rot2, weapon ? 5 : 0);
  880.             glPopMatrix();
  881.         }
  882.  
  883.         public void shoot() {
  884.             if (weapon) {
  885.                 rST = 20;
  886.                 rS = true;
  887.                 float rot2 = moving ? (float) Math.sin(rC
  888.                         * (sprinting ? 1f : 0.7f))
  889.                         * (sprinting ? 20f : weapon ? 7f : 15f) : (float) Math
  890.                         .sin(rC) * 3f;
  891.                 if (mag > 0) {
  892.                     mag--;
  893.                     if (mag <= 0) {
  894.                         reload();
  895.                     }
  896.                     bullets.add(new Bullet(x
  897.                             + (float) Math.cos(Math
  898.                                     .toRadians(-lRot - 90 + rot2)) * 6, y
  899.                             + (float) Math.sin(Math
  900.                                     .toRadians(-lRot - 90 + rot2)) * 6, -lRot
  901.                             - 90 + rot2, this));
  902.                 }
  903.             }
  904.         }
  905.  
  906.         public void equip() {
  907.             if (wA) {
  908.                 weapon ^= true;
  909.             } else {
  910.                 weapon = false;
  911.             }
  912.         }
  913.  
  914.         public void reload() {
  915.             reloadTimer = 40;
  916.             weapon = false;
  917.             wA = false;
  918.         }
  919.  
  920.         public int raceColor() {
  921.             return race == 0 ? 0xDAA873 - 0x0A0A0A
  922.                     : race == 1 ? 0xA77F56 - 0x0A0A0A : 0x4B331A - 0x0A0A0A;
  923.         }
  924.     }
  925.  
  926.     public class AIHuman extends Human {
  927.  
  928.         int newAT, newA;
  929.         int moveTimer;
  930.         boolean aggro;
  931.  
  932.         public AIHuman(float x, float y, int race, int cc1, int cc2) {
  933.             super(x, y, race, cc1, cc2);
  934.             ammo = Integer.MAX_VALUE;
  935.         }
  936.  
  937.         public AIHuman(float x, float y, int race, int cc2) {
  938.             super(x, y, race, cc2);
  939.             us = false;
  940.         }
  941.  
  942.         public void update() {
  943.             newAT--;
  944.             move();
  945.             hitCheck();
  946.             deadCheck();
  947.             float dist = (float) Math.sqrt(Math.pow(player.x - x, 2)
  948.                     + Math.pow(player.y - y, 2));
  949.  
  950.             rot = -lRot - 90;
  951.  
  952.             if (!aggro) {
  953.                 moving = false;
  954.                 weapon = false;
  955.                 if (dist < 60) {
  956.                     rotateTo((float) -Math.toDegrees(Math.atan2(player.y - y,
  957.                             player.x - x)) - 90, 18);
  958.                     if (player.weapon) {
  959.                         weapon = true;
  960.                     }
  961.                 } else {
  962.                     if (newAT < 0) {
  963.                         newA = rng.nextInt(360);
  964.                         newAT = 40 + rng.nextInt(40);
  965.                     }
  966.                     moveTimer--;
  967.                     if (moveTimer > 0) {
  968.                         moving = true;
  969.                     } else if (moveTimer <= 0 && moveTimer > -50) {
  970.                         moving = false;
  971.                     } else {
  972.                         moveTimer = 20 + rng.nextInt(40);
  973.                     }
  974.                     rotateTo(newA, 20);
  975.                 }
  976.                 if (dist < 90 && player.rS) {
  977.                     aggro = true;
  978.                 }
  979.             } else {
  980.                 moving = true;
  981.                 weapon = true;
  982.                 if (dist > 90) {
  983.                     aggro = false;
  984.                 }
  985.                 if (dist < 24) {
  986.                     moving = false;
  987.                 }
  988.                 if (rST < -10) {
  989.                     shoot();
  990.                 }
  991.                 rotateTo((float) -Math.toDegrees(Math.atan2(player.y - y,
  992.                         player.x - x)) - 90, 2 + rng.nextInt(3));
  993.             }
  994.         }
  995.  
  996.         public void rotateTo(float angle, float div) {
  997.             // Normalize angle
  998.             while (angle < 0) {
  999.                 angle += 360.f;
  1000.             }
  1001.             while (angle > 360) {
  1002.                 angle -= 360.f;
  1003.             }
  1004.  
  1005.             // Normalize lRot too, just in case (remove if you know it's not
  1006.             // needed)
  1007.             while (lRot < 0) {
  1008.                 lRot += 360.f;
  1009.             }
  1010.             while (lRot > 360) {
  1011.                 lRot -= 360.f;
  1012.             }
  1013.  
  1014.             // Difference between angles
  1015.             float angdiff = Math.abs(angle - lRot);
  1016.  
  1017.             // When angle diff is very small, snap to it directly
  1018.             if (angdiff <= 0.25f) {
  1019.                 lRot = angle;
  1020.             } else {
  1021.                 // Let's decide if we have to turn left or right to reach the
  1022.                 // target angle the quickest
  1023.                 // You might have to switch the signs, not sure which is which
  1024.                 if ((int) ((angle - lRot + 360) % 360) > 180) {
  1025.                     lRot -= angdiff / div;
  1026.                 } else {
  1027.                     lRot += angdiff / div;
  1028.                 }
  1029.             }
  1030.         }
  1031.  
  1032.         public void deadCheck() {
  1033.             if (hp <= 0) {
  1034.                 hp = 0;
  1035.                 player.cash += 8 + rng.nextInt(8);
  1036.                 dHumans.add(this);
  1037.             }
  1038.         }
  1039.     }
  1040.  
  1041.     public class StationaryHuman extends Human {
  1042.  
  1043.         int newAT, newA;
  1044.  
  1045.         public StationaryHuman(float x, float y, int race, boolean dealer) {
  1046.             super(x, y, race, dealer ? 0x7A7776 : 0x3F647F, dealer ? 0x565453
  1047.                     : 0x6099C1);
  1048.         }
  1049.  
  1050.         public void update() {
  1051.             newAT--;
  1052.             move();
  1053.             hitCheck();
  1054.             float dist = (float) Math.sqrt(Math.pow(player.x - x, 2)
  1055.                     + Math.pow(player.y - y, 2));
  1056.             if (dist < 60) {
  1057.                 rotateTo((float) -Math.toDegrees(Math.atan2(player.y - y,
  1058.                         player.x - x)) - 90);
  1059.             } else {
  1060.                 if (newAT < 0) {
  1061.                     newA = rng.nextInt(360);
  1062.                     newAT = 40 + rng.nextInt(40);
  1063.                 }
  1064.                 rotateTo(newA);
  1065.             }
  1066.         }
  1067.  
  1068.         public void rotateTo(float angle) {
  1069.             // Normalize angle
  1070.             while (angle < 0) {
  1071.                 angle += 360.f;
  1072.             }
  1073.             while (angle > 360) {
  1074.                 angle -= 360.f;
  1075.             }
  1076.  
  1077.             // Normalize lRot too, just in case (remove if you know it's not
  1078.             // needed)
  1079.             while (lRot < 0) {
  1080.                 lRot += 360.f;
  1081.             }
  1082.             while (lRot > 360) {
  1083.                 lRot -= 360.f;
  1084.             }
  1085.  
  1086.             // Difference between angles
  1087.             float angdiff = Math.abs(angle - lRot);
  1088.  
  1089.             // When angle diff is very small, snap to it directly
  1090.             if (angdiff <= 0.25f) {
  1091.                 lRot = angle;
  1092.             } else {
  1093.                 // Let's decide if we have to turn left or right to reach the
  1094.                 // target angle the quickest
  1095.                 // You might have to switch the signs, not sure which is which
  1096.                 if ((int) ((angle - lRot + 360) % 360) > 180) {
  1097.                     lRot -= angdiff / 20f;
  1098.                 } else {
  1099.                     lRot += angdiff / 20f;
  1100.                 }
  1101.             }
  1102.         }
  1103.     }
  1104.  
  1105.     public class Bullet {
  1106.         float x, y;
  1107.         float hp = 100;
  1108.         float rot;
  1109.         Human parent;
  1110.  
  1111.         public Bullet(float x, float y, float rot, Human parent) {
  1112.             this.x = x;
  1113.             this.y = y;
  1114.             this.rot = rot;
  1115.             this.parent = parent;
  1116.         }
  1117.  
  1118.         public void update() {
  1119.             move();
  1120.             deadCheck();
  1121.         }
  1122.  
  1123.         public void deadCheck() {
  1124.             hp--;
  1125.             if (hp <= 0) {
  1126.                 dBullets.add(this);
  1127.             }
  1128.         }
  1129.  
  1130.         public void move() {
  1131.             float xInc = (float) Math.cos(Math.toRadians(rot)) * 5f, yInc = (float) Math
  1132.                     .sin(Math.toRadians(rot)) * 5f;
  1133.             int nTX = (int) Math.floor((x + xInc) / 16f), nTY = (int) Math
  1134.                     .floor((y + yInc) / 16f);
  1135.  
  1136.             if (isBCollidable(nTX, (int) y / 16)) {
  1137.                 x += xInc;
  1138.             }
  1139.             if (isBCollidable((int) x / 16, nTY)) {
  1140.                 y += yInc;
  1141.             }
  1142.             if (!isBCollidable(nTX, (int) y / 16)
  1143.                     || !isBCollidable((int) x / 16, nTY)) {
  1144.                 dBullets.add(this);
  1145.             }
  1146.         }
  1147.  
  1148.         public void render() {
  1149.             glPushMatrix();
  1150.             glTranslatef(x, y, 0);
  1151.             glRotate(-rot);
  1152.             glColori(0xFFE97F);
  1153.             renderQuad(3, 1);
  1154.             glPopMatrix();
  1155.         }
  1156.     }
  1157.  
  1158.     public class Tile {
  1159.  
  1160.         boolean collidable = true, bCollidable = true;
  1161.         int tX, tY;
  1162.  
  1163.         public Tile(int tX, int tY) {
  1164.             this.tX = tX;
  1165.             this.tY = tY;
  1166.             if (tX < 3 && tY == 0) {
  1167.                 collidable = false;
  1168.                 bCollidable = false;
  1169.             }
  1170.             if (tX == 0 && tY == 2) {
  1171.                 collidable = false;
  1172.                 bCollidable = false;
  1173.             }
  1174.             if (tX == 2 && tY == 1) {
  1175.                 collidable = false;
  1176.             }
  1177.         }
  1178.  
  1179.         public void inside() {
  1180.         }
  1181.  
  1182.         public void use() {
  1183.         }
  1184.     }
  1185.  
  1186.     public class AmmoTile extends Tile {
  1187.         int bP = 4, aC = 14;
  1188.  
  1189.         public AmmoTile() {
  1190.             super(0, 3);
  1191.         }
  1192.  
  1193.         public void inside() {
  1194.             displayMessage(aC + " bullets for " + bP + "$, press Q to buy", 3);
  1195.         }
  1196.  
  1197.         public void use() {
  1198.             if (player.cash >= bP) {
  1199.                 player.cash -= bP;
  1200.                 player.ammo += 14;
  1201.                 displayMessage("Bought " + aC + " bullets for " + bP + "$", 3);
  1202.             }
  1203.         }
  1204.     }
  1205.  
  1206.     public class HealthTile extends Tile {
  1207.         int bP;
  1208.  
  1209.         public HealthTile() {
  1210.             super(0, 3);
  1211.         }
  1212.  
  1213.         public void inside() {
  1214.             bP = (int) ((100 - player.hp) / 2);
  1215.             if (bP < 1) {
  1216.                 displayMessage("No need for wound recovery", 3);
  1217.             } else {
  1218.                 displayMessage(
  1219.                         "Wound recovery for " + bP + "$, press Q to buy", 3);
  1220.             }
  1221.         }
  1222.  
  1223.         public void use() {
  1224.             bP = (int) ((100 - player.hp) / 2);
  1225.             if (player.cash >= bP) {
  1226.                 player.cash -= bP;
  1227.                 player.hp = 100;
  1228.                 displayMessage("Recovered wounds for " + bP + "$", 3);
  1229.             }
  1230.         }
  1231.     }
  1232.  
  1233.     public class VestTile extends Tile {
  1234.         int bP = 40;
  1235.  
  1236.         public VestTile() {
  1237.             super(0, 3);
  1238.         }
  1239.  
  1240.         public void inside() {
  1241.             displayMessage("Kevlar vest for " + bP + "$, press Q to buy", 3);
  1242.         }
  1243.  
  1244.         public void use() {
  1245.             if (player.cash >= bP) {
  1246.                 player.cash -= bP;
  1247.                 player.v = 100;
  1248.                 displayMessage("Bought kevlar vest for " + bP + "$", 3);
  1249.             }
  1250.         }
  1251.     }
  1252.  
  1253.     public class CaseTile extends Tile {
  1254.         int r = 1 + rng.nextInt(50);
  1255.  
  1256.         public CaseTile(int tX, int tY) {
  1257.             super(tX, tY);
  1258.         }
  1259.  
  1260.         public void inside() {
  1261.             displayMessage("Briefcase with money inside, press Q to take", 3);
  1262.         }
  1263.  
  1264.         public void use() {
  1265.             player.cash += r;
  1266.             displayMessage("Found briefcase with " + r + "$ inside", 20);
  1267.             for (Human aggrodude : humans) {
  1268.                 if (aggrodude instanceof AIHuman) {
  1269.                     aggrodude.x = player.x - 2 + rng.nextInt(4);
  1270.                     aggrodude.y = player.y - 2 + rng.nextInt(4);
  1271.                     ((AIHuman) aggrodude).aggro = true; // AGGRODUDE GO!
  1272.                     break;
  1273.                 }
  1274.             }
  1275.             setTile((int) (player.x / 16), (int) (player.y / 16), tX, tY);
  1276.             spawnCase();
  1277.         }
  1278.     }
  1279. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement