diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..fec82f4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + org.example + My2DGameAlt + 1.0-SNAPSHOT + + + 21 + 21 + UTF-8 + + + \ No newline at end of file diff --git a/src/main/java/se/urmo/my2dgame/ImageUtil.java b/src/main/java/se/urmo/my2dgame/ImageUtil.java new file mode 100644 index 0000000..b6f4620 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/ImageUtil.java @@ -0,0 +1,17 @@ +package se.urmo.my2dgame; + +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Objects; + +public class ImageUtil { + public static BufferedImage loadImage(String name) { + try { + return ImageIO.read(Objects.requireNonNull(ImageUtil.class.getResourceAsStream(name))); + }catch (IOException e) { + e.printStackTrace(); + return null; + } + } +} diff --git a/src/main/java/se/urmo/my2dgame/Main.java b/src/main/java/se/urmo/my2dgame/Main.java new file mode 100644 index 0000000..87c02d7 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/Main.java @@ -0,0 +1,9 @@ +package se.urmo.my2dgame; + +import se.urmo.my2dgame.main.Game; + +public class Main { + public static void main(String[] args) { + new Game().start(); + } +} diff --git a/src/main/java/se/urmo/my2dgame/entity/Entity.java b/src/main/java/se/urmo/my2dgame/entity/Entity.java new file mode 100644 index 0000000..cb2d6e8 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/entity/Entity.java @@ -0,0 +1,46 @@ +package se.urmo.my2dgame.entity; + +import java.awt.*; +import java.awt.image.BufferedImage; +import java.util.EnumSet; +import java.util.Map; + + +public abstract class Entity { + public int worldX; + public int worldY; + public int speed; + + public static BufferedImage[] entityImages; + public Direction direction; + + public int spriteCount = 0; + public int spriteNum = 1; + + public Rectangle solidArea; + public boolean collisionOn = false; + + public abstract int boxLeft(); + public abstract int boxRight(); + public abstract int boxTop(); + public abstract int boxBottom(); + + public enum Direction { + N, NE, E, SE, S, SW, W, NW; + } + protected final EnumSet norths = EnumSet.of(Direction.N, Direction.NE, Direction.NW); + protected final EnumSet souths = EnumSet.of(Direction.S, Direction.SE, Direction.SW); + protected final EnumSet easts = EnumSet.of(Direction.E, Direction.NE, Direction.SE); + protected final EnumSet wests = EnumSet.of(Direction.W, Direction.NW, Direction.SW); + + protected static final Map directionMap = Map.ofEntries( + Map.entry(new Point(0, -1), Direction.N), + Map.entry(new Point(1, -1), Direction.NE), + Map.entry(new Point(1, 0), Direction.E), + Map.entry(new Point(1, 1), Direction.SE), + Map.entry(new Point(0, 1), Direction.S), + Map.entry(new Point(-1, 1), Direction.SW), + Map.entry(new Point(-1, 0), Direction.W), + Map.entry(new Point(-1, -1), Direction.NW) + ); +} diff --git a/src/main/java/se/urmo/my2dgame/entity/Player.java b/src/main/java/se/urmo/my2dgame/entity/Player.java new file mode 100644 index 0000000..77df5a5 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/entity/Player.java @@ -0,0 +1,147 @@ +package se.urmo.my2dgame.entity; + +import se.urmo.my2dgame.ImageUtil; +import se.urmo.my2dgame.main.CollisionChecker; +import se.urmo.my2dgame.main.KeyHandler; +import se.urmo.my2dgame.main.Screen; +import se.urmo.my2dgame.main.UpdateListener; + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class Player extends Entity implements UpdateListener { + private static final int up1 = 0, up2 = 1, down1 = 2, down2 = 3, left1 = 4, left2 = 5, right1 = 6, right2 = 7; + private final CollisionChecker collisionChecker; + private final KeyHandler keyHandler; + public static final int SCREEN_X = Screen.SCREEN_WIDTH / 2 - (Screen.TILE_SIZE / 2); + public static final int SCREEN_Y = Screen.SCREEN_HEIGHT / 2 - (Screen.TILE_SIZE / 2); + + static { + entityImages = new BufferedImage[8]; + entityImages[up1] = ImageUtil.loadImage("/player/boy_up_1.png"); + entityImages[up2] = ImageUtil.loadImage("/player/boy_up_2.png"); + entityImages[down1] = ImageUtil.loadImage("/player/boy_down_1.png"); + entityImages[down2] = ImageUtil.loadImage("/player/boy_down_2.png"); + entityImages[left1] = ImageUtil.loadImage("/player/boy_left_1.png"); + entityImages[left2] = ImageUtil.loadImage("/player/boy_left_2.png"); + entityImages[right1] = ImageUtil.loadImage("/player/boy_right_1.png"); + entityImages[right2] = ImageUtil.loadImage("/player/boy_right_2.png"); + } + + public Player(CollisionChecker collisionChecker, KeyHandler keyHandler) { + this.collisionChecker = collisionChecker; + this.keyHandler = keyHandler; + + solidArea = new Rectangle(8, 16, 32, 32); + + worldX = Screen.TILE_SIZE * 22; + worldY = Screen.TILE_SIZE * 22; + speed = 1; + direction = Direction.S; + } + + + public void update() { + if (keyHandler.upPressed || keyHandler.downPressed + || keyHandler.leftPressed || keyHandler.rightPressed) { + + int dx = 0; + int dy = 0; + + // Vertical movement + if (keyHandler.upPressed && !keyHandler.downPressed) { + dy = -1; + } else if (keyHandler.downPressed && !keyHandler.upPressed) { + dy = 1; + } + + // Horizontal movement + if (keyHandler.rightPressed && !keyHandler.leftPressed) { + dx = 1; + } else if (keyHandler.leftPressed && !keyHandler.rightPressed) { + dx = -1; + } + + // Apply movement + worldX += dx * speed; + worldY += dy * speed; + + // Lookup direction + Point movement = new Point(dx, dy); + direction = directionMap.getOrDefault(movement, direction); + + if (direction != null && collisionChecker.checkTile(this)) { + if (norths.contains(direction)) { + worldY += speed; // negate + } + if (souths.contains(direction)) { + worldY -= speed; // negate + } + if (easts.contains(direction)) { + worldX -= speed; // negate + } + if (wests.contains(direction)) { + worldX += speed; // negate + } + } + + spriteCount++; + if (spriteCount == 30) { // sprite animation update speed - only uodate animation every 30 + if (spriteNum == 1) { + spriteNum = 2; + } else if (spriteNum == 2) { + spriteNum = 1; + } + spriteCount = 0; + } + } + } + + public void draw(Graphics2D g2d) { + BufferedImage image = null; + switch (direction) { + case N -> image = spriteNum == 1 ? entityImages[up1] : entityImages[up2]; + case S -> image = spriteNum == 1 ? entityImages[down1] : entityImages[down2]; + case W, NW, SW -> image = spriteNum == 1 ? entityImages[left1] : entityImages[left2]; + case E, NE, SE -> image = spriteNum == 1 ? entityImages[right1] : entityImages[right2]; + } + + g2d.drawImage(image, SCREEN_X, SCREEN_Y, Screen.TILE_SIZE, Screen.TILE_SIZE, null); + } + + private void drawRectangel(Graphics2D g2d) { + int num = (worldX - 24) / Screen.TILE_SIZE; + int num2 = (worldY - 24) / Screen.TILE_SIZE; + g2d.drawRect(SCREEN_X - Screen.TILE_SIZE, SCREEN_Y - Screen.TILE_SIZE, 48, 48); + g2d.drawString(num + "," + num2, SCREEN_X - Screen.TILE_SIZE + 10, SCREEN_Y - Screen.TILE_SIZE + 20); + } + + @Override + public void onUpdate() { + update(); + } + + @Override + public int boxLeft() { + // solidare left side + return this.worldX + this.solidArea.x; + } + + @Override + public int boxRight() { + // solidare right side + return this.worldX + this.solidArea.x + this.solidArea.width; + } + + @Override + public int boxTop() { + // solidarea top + return this.worldY + this.solidArea.y; + } + + @Override + public int boxBottom() { + // solidarea bottom + return this.worldY + this.solidArea.y + this.solidArea.height; + } +} diff --git a/src/main/java/se/urmo/my2dgame/main/AssetSetter.java b/src/main/java/se/urmo/my2dgame/main/AssetSetter.java new file mode 100644 index 0000000..b9a8b68 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/main/AssetSetter.java @@ -0,0 +1,15 @@ +package se.urmo.my2dgame.main; + +import se.urmo.my2dgame.object.Key; + +public class AssetSetter { + Screen screen; + public AssetSetter(Screen screen) { + this.screen = screen; + } + + public void setObject() { + screen.obj[0] = new Key(23 * screen.TILE_SIZE, 7 * screen.TILE_SIZE); + screen.obj[1] = new Key(23 * screen.TILE_SIZE, 40 * screen.TILE_SIZE); + } +} diff --git a/src/main/java/se/urmo/my2dgame/main/CollisionChecker.java b/src/main/java/se/urmo/my2dgame/main/CollisionChecker.java new file mode 100644 index 0000000..66cbe71 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/main/CollisionChecker.java @@ -0,0 +1,75 @@ +package se.urmo.my2dgame.main; + +import se.urmo.my2dgame.entity.Entity; +import se.urmo.my2dgame.tile.TileManager; + +public class CollisionChecker { + + private final TileManager tileManager; + + public CollisionChecker(TileManager tileManager) { + this.tileManager = tileManager; + } + + public boolean checkTile(Entity entity) { + int entityLeftCol = entity.boxLeft() / Screen.TILE_SIZE; + int entityRightCol = entity.boxRight() / Screen.TILE_SIZE; + int entityTopRow = entity.boxTop() / Screen.TILE_SIZE; + int entityBottomRow = entity.boxBottom() / Screen.TILE_SIZE; + + switch (entity.direction){ + case N -> { + entityTopRow = (entity.boxTop() - entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityTopRow, entityLeftCol, entityTopRow, entityRightCol); + } + case S -> { + entityBottomRow = (entity.boxBottom() + entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityBottomRow,entityLeftCol,entityBottomRow,entityRightCol); + } + case W -> { + entityLeftCol = (entity.boxLeft() - entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityTopRow, entityLeftCol, entityBottomRow, entityLeftCol); + } + case E -> { + entityRightCol = (entity.boxRight() + entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityTopRow, entityRightCol, entityBottomRow, entityRightCol); + } + case NE -> { + entityTopRow = (entity.boxTop() - entity.speed)/ Screen.TILE_SIZE; + entityRightCol = (entity.boxRight() + entity.speed)/ Screen.TILE_SIZE; + entityLeftCol = (entity.boxLeft() + entity.speed)/ Screen.TILE_SIZE; + entityBottomRow = (entity.boxBottom() - entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityTopRow, entityLeftCol, entityBottomRow, entityRightCol); + } + case NW -> { + entityTopRow = (entity.boxTop() - entity.speed)/ Screen.TILE_SIZE; + entityRightCol = (entity.boxRight() - entity.speed)/ Screen.TILE_SIZE; + entityLeftCol = (entity.boxLeft() - entity.speed)/ Screen.TILE_SIZE; + entityBottomRow = (entity.boxBottom() - entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityBottomRow, entityLeftCol, entityTopRow, entityRightCol); + } + case SW -> { + entityTopRow = (entity.boxTop() + entity.speed)/ Screen.TILE_SIZE; + entityRightCol = (entity.boxRight() - entity.speed)/ Screen.TILE_SIZE; + entityLeftCol = (entity.boxLeft() - entity.speed)/ Screen.TILE_SIZE; + entityBottomRow = (entity.boxBottom() + entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityTopRow, entityLeftCol, entityBottomRow, entityRightCol); + } + case SE -> { + entityTopRow = (entity.boxTop() + entity.speed)/ Screen.TILE_SIZE; + entityRightCol = (entity.boxRight() + entity.speed)/ Screen.TILE_SIZE; + entityLeftCol = (entity.boxLeft() + entity.speed)/ Screen.TILE_SIZE; + entityBottomRow = (entity.boxBottom() + entity.speed)/ Screen.TILE_SIZE; + return isNonePassable(entityBottomRow, entityLeftCol, entityTopRow, entityRightCol); + } + } + return false; + } + + private boolean isNonePassable(int row1, int col1, int row2, int col2) { + int tileNum2 = tileManager.mapTileNum[row1][col1]; + int tileNum1 = tileManager.mapTileNum[row2][col2]; + + return tileManager.tiles[tileNum1].collission || tileManager.tiles[tileNum2].collission; + } +} diff --git a/src/main/java/se/urmo/my2dgame/main/Game.java b/src/main/java/se/urmo/my2dgame/main/Game.java new file mode 100644 index 0000000..dc7f4f6 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/main/Game.java @@ -0,0 +1,89 @@ +package se.urmo.my2dgame.main; + +import javax.swing.*; +import java.util.ArrayList; +import java.util.List; + +public class Game implements Runnable { + private final static int FPS_SET = 120; + private final static int UPS_SET = 200; + private final static double timePerFrame = 1000000000.0 / FPS_SET; + private final static double timePerUpdate = 1000000000.0 / UPS_SET; + + private final List updateListeners = new ArrayList<>(); + + private Thread gameThread; + private final JFrame window = new JFrame(); + private final Screen screen = new Screen(this); + + public void start() { + window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + window.setResizable(false); + window.setTitle("2d"); + + + window.add(screen); + + window.pack(); + + window.setLocationRelativeTo(null); + window.setVisible(true); + + screen.setupGame(); + startGameThread(); + } + + public void addUpdateListener(UpdateListener listener) { + updateListeners.add(listener); + } + + private void notifyUpdate() { + for (UpdateListener listener : updateListeners) { + listener.onUpdate(); + } + } + + public void startGameThread() { + this.gameThread = new Thread(this); + gameThread.start(); + } + + @Override + public void run() { + long previousTime = System.nanoTime(); + + int frames = 0; + int updates = 0; + long lastCheck = System.currentTimeMillis(); + + double deltaU = 0; + double deltaF = 0; + + while (gameThread !=null && gameThread.isAlive()) { + long currentTime = System.nanoTime(); + deltaU += (currentTime - previousTime) / timePerUpdate; + deltaF += (currentTime - previousTime) / timePerFrame; + + previousTime = currentTime; + + if (deltaU >= 1) { + notifyUpdate(); + updates++; + deltaU--; + } + + if (deltaF >= 1) { + screen.repaint(); // triggers JPanel paintComponent + frames++; + deltaF--; + } + + if (System.currentTimeMillis() - lastCheck >= 1000) { + lastCheck = System.currentTimeMillis(); + System.out.println("FPS: " + frames + " | UPS: " + updates); + frames = 0; + updates = 0; + } + } + } +} diff --git a/src/main/java/se/urmo/my2dgame/main/KeyHandler.java b/src/main/java/se/urmo/my2dgame/main/KeyHandler.java new file mode 100644 index 0000000..58689c7 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/main/KeyHandler.java @@ -0,0 +1,48 @@ +package se.urmo.my2dgame.main; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +public class KeyHandler implements KeyListener { + public boolean upPressed; + public boolean leftPressed; + public boolean downPressed; + public boolean rightPressed; + + @Override + public void keyTyped(KeyEvent e) {} + + @Override + public void keyPressed(KeyEvent e) { + int keyCode = e.getKeyCode(); + if (keyCode == KeyEvent.VK_W) { + upPressed = true; + } + if (keyCode == KeyEvent.VK_S) { + downPressed = true; + } + if (keyCode == KeyEvent.VK_A) { + leftPressed = true; + } + if (keyCode == KeyEvent.VK_D) { + rightPressed = true; + } + } + + @Override + public void keyReleased(KeyEvent e) { + int keyCode = e.getKeyCode(); + if (keyCode == KeyEvent.VK_W) { + upPressed = false; + } + if (keyCode == KeyEvent.VK_S) { + downPressed = false; + } + if (keyCode == KeyEvent.VK_A) { + leftPressed = false; + } + if (keyCode == KeyEvent.VK_D) { + rightPressed = false; + } + } +} diff --git a/src/main/java/se/urmo/my2dgame/main/Screen.java b/src/main/java/se/urmo/my2dgame/main/Screen.java new file mode 100644 index 0000000..63ee5b5 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/main/Screen.java @@ -0,0 +1,65 @@ +package se.urmo.my2dgame.main; + +import se.urmo.my2dgame.entity.Player; +import se.urmo.my2dgame.object.SuperObject; +import se.urmo.my2dgame.tile.TileManager; + +import javax.swing.*; +import java.awt.*; +import java.util.Arrays; +import java.util.Objects; + +public class Screen extends JPanel { + //SCREEN SETTINGS + public static final int ORIGINAL_TILE_SIZE = 16; + public static final int SCALE = 3; + public static final int TILE_SIZE = ORIGINAL_TILE_SIZE * SCALE; + public static final int MAX_SCREEN_COL = 16; + public static final int MAX_SCREEN_ROW = 12; + public static final int SCREEN_WIDTH = MAX_SCREEN_COL * TILE_SIZE; + public static final int SCREEN_HEIGHT = MAX_SCREEN_ROW * TILE_SIZE; + + //WORLD + public final int WORLD_MAX_COL = 50; + public final int WORLD_MAX_ROW = 50; + + TileManager tileManager = new TileManager(this); + KeyHandler keyHandler = new KeyHandler(); + + public CollisionChecker collisionChecker = new CollisionChecker(tileManager); + public AssetSetter assetSetter = new AssetSetter(this); + public Player player = new Player(collisionChecker, keyHandler); + public SuperObject[] obj = new SuperObject[10]; + + public Screen(Game game) { + game.addUpdateListener(player); + this.setPreferredSize(new Dimension(SCREEN_WIDTH, SCREEN_HEIGHT)); + this.setBackground(Color.BLACK); + this.setDoubleBuffered(true); + this.addKeyListener(keyHandler); + this.setFocusable(true); + } + + public void setupGame(){ + assetSetter.setObject(); + } + + public void paintComponent(Graphics g) { + super.paintComponent(g); + Graphics2D g2d = (Graphics2D) g; + + tileManager.draw(g2d); + Arrays.stream(obj) + .filter(Objects::nonNull) + .forEach(o -> o.draw(g2d, this)); + player.draw(g2d); + g2d.dispose(); + } + + public boolean isWithinScreen(int worldX, int worldY) { + return worldX + TILE_SIZE > player.worldX - player.SCREEN_X && + worldX - TILE_SIZE < player.worldX + player.SCREEN_X && + worldY + TILE_SIZE > player.worldY - player.SCREEN_Y && + worldY - TILE_SIZE < player.worldY + player.SCREEN_Y; + } +} diff --git a/src/main/java/se/urmo/my2dgame/main/UpdateListener.java b/src/main/java/se/urmo/my2dgame/main/UpdateListener.java new file mode 100644 index 0000000..668e65a --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/main/UpdateListener.java @@ -0,0 +1,5 @@ +package se.urmo.my2dgame.main; + +public interface UpdateListener { + void onUpdate(); +} diff --git a/src/main/java/se/urmo/my2dgame/object/Key.java b/src/main/java/se/urmo/my2dgame/object/Key.java new file mode 100644 index 0000000..9ceefa5 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/object/Key.java @@ -0,0 +1,18 @@ +package se.urmo.my2dgame.object; + +import javax.imageio.ImageIO; +import java.io.IOException; + +public class Key extends SuperObject{ + public Key(int x, int y) { + name = "Key"; + worldX = x; + worldY = y; + + try{ + image = ImageIO.read(getClass().getResourceAsStream("/objects/key.png")); + }catch(IOException e){ + e.printStackTrace(); + } + } +} diff --git a/src/main/java/se/urmo/my2dgame/object/SuperObject.java b/src/main/java/se/urmo/my2dgame/object/SuperObject.java new file mode 100644 index 0000000..6fc9604 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/object/SuperObject.java @@ -0,0 +1,26 @@ +package se.urmo.my2dgame.object; + +import se.urmo.my2dgame.main.Screen; + +import java.awt.*; +import java.awt.image.BufferedImage; + +public class SuperObject { + public String name; + public BufferedImage image; + public boolean collision = false; + public int worldX; + public int worldY; + + public void draw(Graphics2D g2d, Screen screen) { + // Only drawImage for tiles within camera + if (worldX + screen.TILE_SIZE > screen.player.worldX - screen.player.SCREEN_X && + worldX - screen.TILE_SIZE < screen.player.worldX + screen.player.SCREEN_X && + worldY + screen.TILE_SIZE > screen.player.worldY - screen.player.SCREEN_Y && + worldY - screen.TILE_SIZE < screen.player.worldY + screen.player.SCREEN_Y) { + int screenX = worldX - screen.player.worldX + screen.player.SCREEN_X; + int screenY = worldY - screen.player.worldY + screen.player.SCREEN_Y; + g2d.drawImage(image, screenX, screenY, screen.TILE_SIZE, screen.TILE_SIZE, null); + } + } +} diff --git a/src/main/java/se/urmo/my2dgame/tile/Tile.java b/src/main/java/se/urmo/my2dgame/tile/Tile.java new file mode 100644 index 0000000..3f730ad --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/tile/Tile.java @@ -0,0 +1,8 @@ +package se.urmo.my2dgame.tile; + +import java.awt.image.BufferedImage; + +public class Tile { + public BufferedImage image; + public boolean collission = false; +} diff --git a/src/main/java/se/urmo/my2dgame/tile/TileManager.java b/src/main/java/se/urmo/my2dgame/tile/TileManager.java new file mode 100644 index 0000000..c458d44 --- /dev/null +++ b/src/main/java/se/urmo/my2dgame/tile/TileManager.java @@ -0,0 +1,98 @@ +package se.urmo.my2dgame.tile; + +import se.urmo.my2dgame.main.Screen; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.Arrays; + +public class TileManager { + Screen screen; + public Tile[] tiles = new Tile[10]; + public int[][] mapTileNum; + + public TileManager(Screen screen) { + this.screen = screen; + getTileImage(); + this.mapTileNum = loadMap("/maps/world01.txt"); + } + + public int[][] loadMap(String path) { + int[][] map = new int[screen.WORLD_MAX_ROW][screen.WORLD_MAX_COL]; + try { + InputStream stream = Screen.class.getResourceAsStream(path); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + int row = 0; + String line; + while ((line = reader.readLine()) != null && row < screen.WORLD_MAX_ROW) { + map[row++] = Arrays.stream(line.split(" ")) + .mapToInt(Integer::parseInt) + .toArray(); + } + reader.close(); + } catch (Exception e) { + e.printStackTrace(); + } + return map; + } + + public void getTileImage() { + try { + tiles[0] = new Tile(); + tiles[0].image = ImageIO.read(Screen.class.getResourceAsStream("/tiles/grass.png")); + + tiles[1] = new Tile(); + tiles[1].image = ImageIO.read(Screen.class.getResourceAsStream("/tiles/wall.png")); + tiles[1].collission = true; + + tiles[2] = new Tile(); + tiles[2].image = ImageIO.read(Screen.class.getResourceAsStream("/tiles/water.png")); + tiles[2].collission = true; + + tiles[3] = new Tile(); + tiles[3].image = ImageIO.read(Screen.class.getResourceAsStream("/tiles/earth.png")); + + tiles[4] = new Tile(); + tiles[4].image = ImageIO.read(Screen.class.getResourceAsStream("/tiles/tree.png")); + tiles[4].collission = true; + + tiles[5] = new Tile(); + tiles[5].image = ImageIO.read(Screen.class.getResourceAsStream("/tiles/sand.png")); + + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void draw(Graphics2D g2d) { + int worldCol = 0; + int worldRow = 0; + + while (worldCol < screen.WORLD_MAX_COL && worldRow < screen.WORLD_MAX_ROW) { + int tileNum = mapTileNum[worldRow][worldCol]; + + int worldX = worldCol * screen.TILE_SIZE; + int worldY = worldRow * screen.TILE_SIZE; + + // Only drawImage for tiles within camera + if (screen.isWithinScreen(worldX, worldY)) { + int screenX = worldX - screen.player.worldX + screen.player.SCREEN_X; + int screenY = worldY - screen.player.worldY + screen.player.SCREEN_Y; + g2d.drawImage(tiles[tileNum].image, screenX, screenY, screen.TILE_SIZE, screen.TILE_SIZE, null); + } + + worldCol++; + + if (worldCol == screen.WORLD_MAX_COL) { + worldCol = 0; + worldRow++; + } + } + } + + +} diff --git a/src/main/resources/maps/map01.txt b/src/main/resources/maps/map01.txt new file mode 100644 index 0000000..e140f93 --- /dev/null +++ b/src/main/resources/maps/map01.txt @@ -0,0 +1,12 @@ +1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 +1 0 0 0 0 0 2 2 0 0 0 0 0 0 0 1 +1 0 0 0 0 2 2 2 2 0 0 0 0 0 0 1 +1 0 0 0 0 2 2 2 2 0 0 0 0 0 0 1 +1 0 0 0 0 2 2 2 2 2 0 0 0 0 0 1 +1 0 0 0 0 2 2 2 2 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 0 2 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 +1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 +1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 \ No newline at end of file diff --git a/src/main/resources/maps/world01.txt b/src/main/resources/maps/world01.txt new file mode 100644 index 0000000..c1178b2 --- /dev/null +++ b/src/main/resources/maps/world01.txt @@ -0,0 +1,50 @@ +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0 2 2 2 2 2 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 2 2 2 2 2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4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 \ No newline at end of file diff --git a/src/main/resources/maps/world02.txt b/src/main/resources/maps/world02.txt new file mode 100644 index 0000000..81681ac --- /dev/null +++ b/src/main/resources/maps/world02.txt @@ -0,0 +1,50 @@ +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 +4 4 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 +4 4 4 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 0 0 0 0 0 +4 4 4 4 4 4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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \ No newline at end of file diff --git a/src/main/resources/objects/axe.png b/src/main/resources/objects/axe.png new file mode 100644 index 0000000..68fc0a5 Binary files /dev/null and b/src/main/resources/objects/axe.png differ diff --git a/src/main/resources/objects/blueheart.png b/src/main/resources/objects/blueheart.png new file mode 100644 index 0000000..6441848 Binary files /dev/null and b/src/main/resources/objects/blueheart.png differ diff --git a/src/main/resources/objects/boots.png b/src/main/resources/objects/boots.png new file mode 100644 index 0000000..d75f642 Binary files /dev/null and b/src/main/resources/objects/boots.png differ diff --git a/src/main/resources/objects/chest (OLD).png b/src/main/resources/objects/chest (OLD).png new file mode 100644 index 0000000..d257eee Binary files /dev/null and b/src/main/resources/objects/chest (OLD).png differ diff --git a/src/main/resources/objects/chest.png b/src/main/resources/objects/chest.png new file mode 100644 index 0000000..64e06cd Binary files /dev/null and b/src/main/resources/objects/chest.png differ diff --git a/src/main/resources/objects/chest_opened.png b/src/main/resources/objects/chest_opened.png new file mode 100644 index 0000000..a600892 Binary files /dev/null and b/src/main/resources/objects/chest_opened.png differ diff --git a/src/main/resources/objects/coin_bronze.png b/src/main/resources/objects/coin_bronze.png new file mode 100644 index 0000000..938ae36 Binary files /dev/null and b/src/main/resources/objects/coin_bronze.png differ diff --git a/src/main/resources/objects/door.png b/src/main/resources/objects/door.png new file mode 100644 index 0000000..589a559 Binary files /dev/null and b/src/main/resources/objects/door.png differ diff --git a/src/main/resources/objects/door_iron.png b/src/main/resources/objects/door_iron.png new file mode 100644 index 0000000..24e699e Binary files /dev/null and b/src/main/resources/objects/door_iron.png differ diff --git a/src/main/resources/objects/heart_blank.png b/src/main/resources/objects/heart_blank.png new file mode 100644 index 0000000..a26c81b Binary files /dev/null and b/src/main/resources/objects/heart_blank.png differ diff --git a/src/main/resources/objects/heart_full.png b/src/main/resources/objects/heart_full.png new file mode 100644 index 0000000..4097771 Binary files /dev/null and b/src/main/resources/objects/heart_full.png differ diff --git a/src/main/resources/objects/heart_half.png b/src/main/resources/objects/heart_half.png new file mode 100644 index 0000000..42224ad Binary files /dev/null and b/src/main/resources/objects/heart_half.png differ diff --git a/src/main/resources/objects/key.png b/src/main/resources/objects/key.png new file mode 100644 index 0000000..6aabbc6 Binary files /dev/null and b/src/main/resources/objects/key.png differ diff --git a/src/main/resources/objects/lantern.png b/src/main/resources/objects/lantern.png new file mode 100644 index 0000000..6843fcf Binary files /dev/null and b/src/main/resources/objects/lantern.png differ diff --git a/src/main/resources/objects/manacrystal_blank.png b/src/main/resources/objects/manacrystal_blank.png new file mode 100644 index 0000000..057c189 Binary files /dev/null and b/src/main/resources/objects/manacrystal_blank.png differ diff --git a/src/main/resources/objects/manacrystal_full.png b/src/main/resources/objects/manacrystal_full.png new file mode 100644 index 0000000..322ecd4 Binary files /dev/null and b/src/main/resources/objects/manacrystal_full.png differ diff --git a/src/main/resources/objects/pickaxe.png b/src/main/resources/objects/pickaxe.png new file mode 100644 index 0000000..8435424 Binary files /dev/null and b/src/main/resources/objects/pickaxe.png differ diff --git a/src/main/resources/objects/potion_red.png b/src/main/resources/objects/potion_red.png new file mode 100644 index 0000000..eab1816 Binary files /dev/null and b/src/main/resources/objects/potion_red.png differ diff --git a/src/main/resources/objects/shield_blue.png b/src/main/resources/objects/shield_blue.png new file mode 100644 index 0000000..6ef2cac Binary files /dev/null and b/src/main/resources/objects/shield_blue.png differ diff --git a/src/main/resources/objects/shield_wood.png b/src/main/resources/objects/shield_wood.png new file mode 100644 index 0000000..25d2dda Binary files /dev/null and b/src/main/resources/objects/shield_wood.png differ diff --git a/src/main/resources/objects/sword_normal.png b/src/main/resources/objects/sword_normal.png new file mode 100644 index 0000000..666952d Binary files /dev/null and b/src/main/resources/objects/sword_normal.png differ diff --git a/src/main/resources/objects/tent.png b/src/main/resources/objects/tent.png new file mode 100644 index 0000000..bd9ef7b Binary files /dev/null and b/src/main/resources/objects/tent.png differ diff --git a/src/main/resources/player/boy_down_1.png b/src/main/resources/player/boy_down_1.png new file mode 100644 index 0000000..4807748 Binary files /dev/null and b/src/main/resources/player/boy_down_1.png differ diff --git a/src/main/resources/player/boy_down_2.png b/src/main/resources/player/boy_down_2.png new file mode 100644 index 0000000..0ff298c Binary files /dev/null and b/src/main/resources/player/boy_down_2.png differ diff --git a/src/main/resources/player/boy_left_1.png b/src/main/resources/player/boy_left_1.png new file mode 100644 index 0000000..85d10ad Binary files /dev/null and b/src/main/resources/player/boy_left_1.png differ diff --git a/src/main/resources/player/boy_left_2.png b/src/main/resources/player/boy_left_2.png new file mode 100644 index 0000000..92f39a8 Binary files /dev/null and b/src/main/resources/player/boy_left_2.png differ diff --git a/src/main/resources/player/boy_right_1.png b/src/main/resources/player/boy_right_1.png new file mode 100644 index 0000000..247ecea Binary files /dev/null and b/src/main/resources/player/boy_right_1.png differ diff --git a/src/main/resources/player/boy_right_2.png b/src/main/resources/player/boy_right_2.png new file mode 100644 index 0000000..4628500 Binary files /dev/null and b/src/main/resources/player/boy_right_2.png differ diff --git a/src/main/resources/player/boy_up_1.png b/src/main/resources/player/boy_up_1.png new file mode 100644 index 0000000..eb81fe2 Binary files /dev/null and b/src/main/resources/player/boy_up_1.png differ diff --git a/src/main/resources/player/boy_up_2.png b/src/main/resources/player/boy_up_2.png new file mode 100644 index 0000000..8bc797a Binary files /dev/null and b/src/main/resources/player/boy_up_2.png differ diff --git a/src/main/resources/tiles/earth.png b/src/main/resources/tiles/earth.png new file mode 100644 index 0000000..9255b38 Binary files /dev/null and b/src/main/resources/tiles/earth.png differ diff --git a/src/main/resources/tiles/grass.png b/src/main/resources/tiles/grass.png new file mode 100644 index 0000000..8a1892f Binary files /dev/null and b/src/main/resources/tiles/grass.png differ diff --git a/src/main/resources/tiles/sand.png b/src/main/resources/tiles/sand.png new file mode 100644 index 0000000..10971d4 Binary files /dev/null and b/src/main/resources/tiles/sand.png differ diff --git a/src/main/resources/tiles/tree.png b/src/main/resources/tiles/tree.png new file mode 100644 index 0000000..b0d91ba Binary files /dev/null and b/src/main/resources/tiles/tree.png differ diff --git a/src/main/resources/tiles/wall.png b/src/main/resources/tiles/wall.png new file mode 100644 index 0000000..d5f04bf Binary files /dev/null and b/src/main/resources/tiles/wall.png differ diff --git a/src/main/resources/tiles/water.png b/src/main/resources/tiles/water.png new file mode 100644 index 0000000..7f48fd6 Binary files /dev/null and b/src/main/resources/tiles/water.png differ