Compare commits
5 Commits
43212a033b
...
587a852ffb
| Author | SHA1 | Date | |
|---|---|---|---|
|
587a852ffb
|
|||
|
9970ef687f
|
|||
|
298e6c624e
|
|||
|
5879aec9a2
|
|||
|
ec1fbef483
|
@@ -6,6 +6,7 @@ import de.miaurizius.jgame2d.entity.Entity;
|
||||
import de.miaurizius.jgame2d.entity.Player;
|
||||
import de.miaurizius.jgame2d.tile.TileManager;
|
||||
|
||||
import javax.sound.sampled.Clip;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
@@ -144,7 +145,7 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
long passed = drawEnd - drawStart;
|
||||
|
||||
// DEBUG
|
||||
if(keyH.checkDrawTime) {
|
||||
if(keyH.debug) {
|
||||
graphics2d.setColor(Color.white);
|
||||
graphics2d.drawString("Draw Time: " + passed, 10, 400);
|
||||
graphics2d.drawString("FPS: " + fpsMeasure, 10, 400+tileSize);
|
||||
@@ -158,16 +159,20 @@ public class GamePanel extends JPanel implements Runnable {
|
||||
|
||||
// MUSIC
|
||||
public void playMusic(int i) {
|
||||
music.setFile(i);
|
||||
music.play();
|
||||
music.loop();
|
||||
Clip c = se.clips[i];
|
||||
if(c.isRunning()) c.stop();
|
||||
c.setFramePosition(0);
|
||||
c.start();
|
||||
c.loop(Clip.LOOP_CONTINUOUSLY);
|
||||
}
|
||||
public void stopMusic() {
|
||||
music.stop();
|
||||
}
|
||||
public void playSE(int i) {
|
||||
se.setFile(i);
|
||||
se.play();
|
||||
Clip c = se.clips[i];
|
||||
if(c.isRunning()) c.stop();
|
||||
c.setFramePosition(0);
|
||||
c.start();
|
||||
}
|
||||
|
||||
// SETTING THINGS UP
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.miaurizius.jgame2d.core;
|
||||
|
||||
import de.miaurizius.jgame2d.core.enums.GameState;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
import de.miaurizius.jgame2d.entity.objects.HeartObj;
|
||||
import de.miaurizius.jgame2d.entity.item.HeartObj;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -49,6 +49,9 @@ public class UI {
|
||||
case TITLE:
|
||||
drawTitleScreen();
|
||||
break;
|
||||
case CHARACTER:
|
||||
drawCharacterScreen();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +144,53 @@ public class UI {
|
||||
graphics2d.drawString(text, x, y);
|
||||
if(commandNum == 2) graphics2d.drawString(">", x-panel.tileSize, y);
|
||||
}
|
||||
public void drawCharacterScreen() {
|
||||
// DRAW FRAME
|
||||
final int frameX = panel.tileSize;
|
||||
final int frameY = panel.tileSize;
|
||||
final int frameWidth = panel.tileSize*5;
|
||||
final int frameHeight = panel.tileSize*10;
|
||||
drawSubWindow(frameX, frameY, frameWidth, frameHeight);
|
||||
|
||||
// TEXT
|
||||
graphics2d.setColor(Color.white);
|
||||
graphics2d.setFont(graphics2d.getFont().deriveFont(22F));
|
||||
|
||||
int textX = frameX + 20;
|
||||
int textY = frameY + panel.tileSize;
|
||||
final int lineHeight = 35;
|
||||
|
||||
// NAMES
|
||||
String[] names = {"Level", "Life", "Strength", "Dexterity", "Attack", "Defense", "Exp", "Next Level", "Coins", "Weapon", "Shield"};
|
||||
for(String name : names) {
|
||||
graphics2d.drawString(name, textX, textY);
|
||||
textY += lineHeight + (name.equals("Coins") ? 20 : (name.equals("Weapon") ? 15 : 0));
|
||||
}
|
||||
|
||||
// VALUES
|
||||
int tailX = (frameX + frameWidth) - 30;
|
||||
textY = frameY + panel.tileSize;
|
||||
String[] values = {
|
||||
String.valueOf(panel.player.level),
|
||||
(panel.player.life + "/" + panel.player.maxLife),
|
||||
String.valueOf(panel.player.strength),
|
||||
String.valueOf(panel.player.dexterity),
|
||||
String.valueOf(panel.player.attack),
|
||||
String.valueOf(panel.player.defense),
|
||||
String.valueOf(panel.player.exp),
|
||||
String.valueOf(panel.player.nextLevelExp),
|
||||
String.valueOf(panel.player.coins)
|
||||
};
|
||||
for(String value : values) {
|
||||
textX = getAlignedToRightX(value, tailX);
|
||||
graphics2d.drawString(value, textX, textY);
|
||||
textY += lineHeight;
|
||||
}
|
||||
|
||||
graphics2d.drawImage(panel.player.currentWeapon.down1, tailX - panel.tileSize, textY-14, null);
|
||||
textY += panel.tileSize;
|
||||
graphics2d.drawImage(panel.player.currentShield.down1, tailX - panel.tileSize, textY-14, null);
|
||||
}
|
||||
|
||||
// UTILITY
|
||||
public void drawSubWindow(int x, int y, int width, int height) {
|
||||
@@ -153,5 +203,8 @@ public class UI {
|
||||
public int getCenteredX(String text) {
|
||||
return panel.screenWidth / 2 - (int) graphics2d.getFontMetrics().getStringBounds(text, graphics2d).getWidth() / 2;
|
||||
}
|
||||
public int getAlignedToRightX(String text, int tailX) {
|
||||
return tailX - (int) graphics2d.getFontMetrics().getStringBounds(text, graphics2d).getWidth() / 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,5 +5,7 @@ public enum EntityType {
|
||||
PLAYER,
|
||||
NPC,
|
||||
MONSTER,
|
||||
ITEM,
|
||||
WORLD
|
||||
|
||||
}
|
||||
|
||||
@@ -6,5 +6,6 @@ public enum GameState {
|
||||
PAUSE,
|
||||
DIALOGUE,
|
||||
TITLE,
|
||||
CHARACTER,
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.miaurizius.jgame2d.core.handlers;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.entity.OldManNPC;
|
||||
import de.miaurizius.jgame2d.entity.npc.OldManNPC;
|
||||
import de.miaurizius.jgame2d.entity.monster.GreenSlimeMON;
|
||||
|
||||
public class AssetSetter {
|
||||
|
||||
@@ -74,6 +74,7 @@ public class EventHandler {
|
||||
|
||||
public void damagePit(GameState gameState) {
|
||||
panel.gameState = gameState;
|
||||
panel.playSE(6);
|
||||
panel.ui.currentDialogue = "You have fallen into a pit!";
|
||||
panel.player.life -= 1;
|
||||
canTouchEvent = false;
|
||||
@@ -82,6 +83,9 @@ public class EventHandler {
|
||||
public void healingPool(GameState gameState) {
|
||||
if(!panel.keyH.spacePressed) return;
|
||||
panel.gameState = gameState;
|
||||
panel.player.attackCancel = true;
|
||||
System.out.println("attack cancel");
|
||||
panel.playSE(2);
|
||||
panel.ui.currentDialogue = "You drank the holy water.\nYour life has been recovered!";
|
||||
panel.player.life = panel.player.maxLife;
|
||||
canTouchEvent = false;
|
||||
|
||||
@@ -10,42 +10,14 @@ public class KeyHandler implements KeyListener {
|
||||
|
||||
public boolean upPressed, downPressed, leftPressed, rightPressed, spacePressed;
|
||||
public GamePanel panel;
|
||||
// DEBUG
|
||||
public boolean checkDrawTime = false;
|
||||
public boolean debug;
|
||||
|
||||
public KeyHandler(GamePanel panel) {
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
int code = e.getKeyCode();
|
||||
switch(panel.gameState) {
|
||||
case PLAY:
|
||||
switch (code) {
|
||||
// CONTROLS
|
||||
case KeyEvent.VK_W, KeyEvent.VK_UP -> upPressed = true;
|
||||
case KeyEvent.VK_S, KeyEvent.VK_DOWN -> downPressed = true;
|
||||
case KeyEvent.VK_A, KeyEvent.VK_LEFT -> leftPressed = true;
|
||||
case KeyEvent.VK_D, KeyEvent.VK_RIGHT -> rightPressed = true;
|
||||
case KeyEvent.VK_SPACE -> spacePressed = true;
|
||||
|
||||
// DEBUG OPTIONS
|
||||
case KeyEvent.VK_T -> checkDrawTime = !checkDrawTime;
|
||||
|
||||
// GAME STATES
|
||||
case KeyEvent.VK_ESCAPE -> panel.gameState = GameState.PAUSE;
|
||||
}
|
||||
break;
|
||||
case DIALOGUE:
|
||||
if (code == KeyEvent.VK_SPACE) {
|
||||
panel.gameState = GameState.PLAY;
|
||||
}
|
||||
break;
|
||||
case TITLE:
|
||||
// STATE SPECIFIC KEYBIND CONFIGURATION
|
||||
public void handleTitle(int code) {
|
||||
switch (code) {
|
||||
case KeyEvent.VK_UP -> {
|
||||
if(panel.ui.commandNum != 0) panel.ui.commandNum--;
|
||||
@@ -68,22 +40,63 @@ public class KeyHandler implements KeyListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void handlePlay(int code) {
|
||||
switch (code) {
|
||||
// CONTROLS
|
||||
case KeyEvent.VK_W, KeyEvent.VK_UP -> upPressed = true;
|
||||
case KeyEvent.VK_S, KeyEvent.VK_DOWN -> downPressed = true;
|
||||
case KeyEvent.VK_A, KeyEvent.VK_LEFT -> leftPressed = true;
|
||||
case KeyEvent.VK_D, KeyEvent.VK_RIGHT -> rightPressed = true;
|
||||
case KeyEvent.VK_SPACE -> spacePressed = true;
|
||||
|
||||
// DEBUG OPTIONS
|
||||
case KeyEvent.VK_T -> debug = !debug;
|
||||
|
||||
// GAME STATES
|
||||
case KeyEvent.VK_ESCAPE -> panel.gameState = GameState.PAUSE;
|
||||
case KeyEvent.VK_C -> panel.gameState = GameState.CHARACTER;
|
||||
}
|
||||
}
|
||||
public void handlePause(int code) {
|
||||
// EXIT STATE
|
||||
if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY;
|
||||
}
|
||||
public void handleDialogue(int code) {
|
||||
// EXIT STATE
|
||||
if (code == KeyEvent.VK_SPACE) {
|
||||
panel.gameState = GameState.PLAY;
|
||||
}
|
||||
}
|
||||
public void handleCharacter(int code) {
|
||||
// EXIT STATE
|
||||
if(code == KeyEvent.VK_C) panel.gameState = GameState.PLAY;
|
||||
}
|
||||
|
||||
// KEY-LISTENER
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {}
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
int code = e.getKeyCode();
|
||||
switch(panel.gameState) {
|
||||
case PLAY:
|
||||
handlePlay(code);
|
||||
break;
|
||||
case DIALOGUE:
|
||||
handleDialogue(code);
|
||||
break;
|
||||
case TITLE:
|
||||
handleTitle(code);
|
||||
break;
|
||||
case PAUSE:
|
||||
if(code == KeyEvent.VK_ESCAPE) panel.gameState = GameState.PLAY;
|
||||
handlePause(code);
|
||||
break;
|
||||
case CHARACTER:
|
||||
handleCharacter(code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO: setup keybinds that will always work (like pausing the game)
|
||||
// public void alwaysOnKeys(int code) {
|
||||
// // GAME STATES
|
||||
// switch (code) {
|
||||
// case KeyEvent.VK_ESCAPE -> panel.gameState = GameState.PAUSE;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
int code = e.getKeyCode();
|
||||
|
||||
@@ -14,22 +14,20 @@ public class Sound {
|
||||
|
||||
Clip clip;
|
||||
URL[] soundURL = new URL[30];
|
||||
public Clip[] clips = new Clip[30];
|
||||
|
||||
public Sound() {
|
||||
try {
|
||||
soundURL[0] = new File("assets/sounds/BlueBoyAdventure.wav").toURI().toURL();
|
||||
soundURL[1] = new File("assets/sounds/coin.wav").toURI().toURL();
|
||||
soundURL[2] = new File("assets/sounds/powerup.wav").toURI().toURL();
|
||||
soundURL[3] = new File("assets/sounds/unlock.wav").toURI().toURL();
|
||||
soundURL[4] = new File("assets/sounds/fanfare.wav").toURI().toURL();
|
||||
soundURL[5] = new File("assets/sounds/hitmonster.wav").toURI().toURL();
|
||||
soundURL[6] = new File("assets/sounds/receivedamage.wav").toURI().toURL();
|
||||
soundURL[7] = new File("assets/sounds/blocked.wav").toURI().toURL();
|
||||
} catch(MalformedURLException e) {
|
||||
Boot.logger.log(Level.SEVERE, e.getMessage());
|
||||
}
|
||||
load(0, "assets/sounds/BlueBoyAdventure.wav");
|
||||
load(1, "assets/sounds/coin.wav");
|
||||
load(2, "assets/sounds/powerup.wav");
|
||||
load(3, "assets/sounds/unlock.wav");
|
||||
load(4, "assets/sounds/fanfare.wav");
|
||||
load(5, "assets/sounds/hitmonster.wav");
|
||||
load(6, "assets/sounds/receivedamage.wav");
|
||||
load(7, "assets/sounds/blocked.wav");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setFile(int i) {
|
||||
try {
|
||||
AudioInputStream ais = AudioSystem.getAudioInputStream(soundURL[i]);
|
||||
@@ -40,6 +38,16 @@ public class Sound {
|
||||
}
|
||||
}
|
||||
|
||||
private void load(int index, String path) {
|
||||
try {
|
||||
AudioInputStream ais = AudioSystem.getAudioInputStream(new File(path));
|
||||
clips[index] = AudioSystem.getClip();
|
||||
clips[index].open(ais); // Wird nur einmal gemacht!
|
||||
} catch (Exception e) {
|
||||
Boot.logger.log(Level.SEVERE, "Could not load Sound File: " + soundURL[index], e);
|
||||
}
|
||||
}
|
||||
|
||||
public void play() {
|
||||
clip.start();
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Entity {
|
||||
public Rectangle attackArea = new Rectangle(0, 0, 0, 0);
|
||||
public int solidAreaDefaultX, solidAreaDefaultY;
|
||||
public boolean collision;
|
||||
String[] dialogue = new String[20];
|
||||
protected String[] dialogue = new String[20];
|
||||
|
||||
// STATE
|
||||
public int worldX, worldY;
|
||||
@@ -44,12 +44,26 @@ public class Entity {
|
||||
int dyingCount;
|
||||
int hpBarCounter;
|
||||
|
||||
// ATTRIBUTES
|
||||
// CHARACTER ATTRIBUTES
|
||||
public EntityType type;
|
||||
public String name;
|
||||
public int speed;
|
||||
public int maxLife;
|
||||
public int life;
|
||||
public int level;
|
||||
public int strength;
|
||||
public int dexterity;
|
||||
public int attack;
|
||||
public int defense;
|
||||
public int exp;
|
||||
public int nextLevelExp;
|
||||
public int coins;
|
||||
public Entity currentWeapon;
|
||||
public Entity currentShield;
|
||||
|
||||
// ITEM ATTRIBUTES
|
||||
public int attackValue;
|
||||
public int defenseValue;
|
||||
|
||||
public Entity(GamePanel panel) {
|
||||
this.panel = panel;
|
||||
|
||||
@@ -5,6 +5,8 @@ import de.miaurizius.jgame2d.core.enums.Direction;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.core.enums.GameState;
|
||||
import de.miaurizius.jgame2d.core.handlers.KeyHandler;
|
||||
import de.miaurizius.jgame2d.entity.item.ShieldWoodObj;
|
||||
import de.miaurizius.jgame2d.entity.item.SwordNormalObj;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -14,6 +16,9 @@ public class Player extends Entity {
|
||||
public final int screenX;
|
||||
public final int screenY;
|
||||
|
||||
// STATE
|
||||
public boolean attackCancel;
|
||||
|
||||
public Player(GamePanel panel, KeyHandler keyH) {
|
||||
super(panel);
|
||||
this.keyH = keyH;
|
||||
@@ -83,6 +88,13 @@ public class Player extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
if(keyH.spacePressed && !attackCancel) {
|
||||
panel.playSE(7);
|
||||
attacking = true;
|
||||
spriteCounter = 0;
|
||||
}
|
||||
|
||||
attackCancel = false;
|
||||
panel.keyH.spacePressed = false;
|
||||
|
||||
spriteCounter++;
|
||||
@@ -111,11 +123,13 @@ public class Player extends Entity {
|
||||
public void interactMonster(int index) {
|
||||
if(index == 999) return;
|
||||
if(invincible) return;
|
||||
if(panel.monster[index].dying || !panel.monster[index].alive) return;
|
||||
life -= 1;
|
||||
panel.playSE(6);
|
||||
invincible = true;
|
||||
}
|
||||
public void attacking() {
|
||||
if(attackCancel) return;
|
||||
spriteCounter++;
|
||||
if(spriteCounter <= 5) spriteNum = 1;
|
||||
if(spriteCounter > 5 && spriteCounter <= 25) {
|
||||
@@ -160,14 +174,9 @@ public class Player extends Entity {
|
||||
}
|
||||
|
||||
public void interactNPC(int index) {
|
||||
if(index == 999) {
|
||||
if(panel.keyH.spacePressed) {
|
||||
attacking = true;
|
||||
//panel.playSE(7); //remains disabled because game does weird things while playing the sound
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(index == 999) return;
|
||||
//if(!panel.keyH.spacePressed) return; //Only uncomment if text should only appear if player hits space
|
||||
attackCancel = true;
|
||||
panel.gameState = GameState.DIALOGUE;
|
||||
panel.npc[index].speak();
|
||||
}
|
||||
@@ -186,6 +195,22 @@ public class Player extends Entity {
|
||||
// PLAYER STATUS (1 heart = 2 lives)
|
||||
maxLife = 6;
|
||||
life = maxLife;
|
||||
level = 1;
|
||||
strength = 1;
|
||||
dexterity = 1;
|
||||
exp = 0;
|
||||
nextLevelExp = 5;
|
||||
coins = 0;
|
||||
currentWeapon = new SwordNormalObj(panel);
|
||||
currentShield = new ShieldWoodObj(panel);
|
||||
attack = getAttack();
|
||||
defense = getDefense();
|
||||
}
|
||||
public int getAttack() {
|
||||
return attack = strength * currentWeapon.attackValue;
|
||||
}
|
||||
public int getDefense() {
|
||||
return defense = dexterity * currentShield.attackValue;
|
||||
}
|
||||
public void getPlayerImage() {
|
||||
up1 = initEntitySprites("player/boy_up_1");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.miaurizius.jgame2d.entity.objects;
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class BootsObj extends Entity {
|
||||
@@ -8,6 +9,7 @@ public class BootsObj extends Entity {
|
||||
public BootsObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "boots";
|
||||
type = EntityType.ITEM;
|
||||
down1 = initEntitySprites("objects/boots.png");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.miaurizius.jgame2d.entity.objects;
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class HeartObj extends Entity {
|
||||
@@ -8,6 +9,7 @@ public class HeartObj extends Entity {
|
||||
public HeartObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "heart";
|
||||
type = EntityType.ITEM;
|
||||
image = initEntitySprites("objects/heart_full");
|
||||
image2 = initEntitySprites("objects/heart_half");
|
||||
image3 = initEntitySprites("objects/heart_blank");
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.miaurizius.jgame2d.entity.objects;
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class KeyObj extends Entity {
|
||||
@@ -8,6 +9,7 @@ public class KeyObj extends Entity {
|
||||
public KeyObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "key";
|
||||
type = EntityType.ITEM;
|
||||
down1 = initEntitySprites("objects/key");
|
||||
}
|
||||
|
||||
17
src/de/miaurizius/jgame2d/entity/item/ShieldWoodObj.java
Normal file
17
src/de/miaurizius/jgame2d/entity/item/ShieldWoodObj.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class ShieldWoodObj extends Entity {
|
||||
|
||||
public ShieldWoodObj(GamePanel panel) {
|
||||
super(panel);
|
||||
name = "shield-wood";
|
||||
type = EntityType.ITEM;
|
||||
down1 = initEntitySprites("objects/shield_wood");
|
||||
defenseValue = 1;
|
||||
}
|
||||
|
||||
}
|
||||
18
src/de/miaurizius/jgame2d/entity/item/SwordNormalObj.java
Normal file
18
src/de/miaurizius/jgame2d/entity/item/SwordNormalObj.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package de.miaurizius.jgame2d.entity.item;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
public class SwordNormalObj extends Entity {
|
||||
|
||||
public SwordNormalObj(GamePanel panel) {
|
||||
super(panel);
|
||||
|
||||
name = "sword-normal";
|
||||
type = EntityType.ITEM;
|
||||
down1 = initEntitySprites("objects/sword_normal");
|
||||
attackValue = 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package de.miaurizius.jgame2d.entity;
|
||||
package de.miaurizius.jgame2d.entity.npc;
|
||||
|
||||
import de.miaurizius.jgame2d.core.enums.Direction;
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.core.enums.EntityType;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package de.miaurizius.jgame2d.entity.objects;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@Deprecated
|
||||
public class SuperObject {
|
||||
|
||||
public BufferedImage image, image2, image3;
|
||||
public String name;
|
||||
public boolean collision = false;
|
||||
public int worldX, worldY;
|
||||
public Rectangle solidArea = new Rectangle(0, 0, 48, 48);
|
||||
public int solidAreaDefaultX = 0;
|
||||
public int solidAreaDefaultY = 0;
|
||||
|
||||
public void draw(Graphics2D graphics2D, GamePanel panel) {
|
||||
int screenX = worldX - panel.player.worldX + panel.player.screenX;
|
||||
int screenY = worldY - panel.player.worldY + panel.player.screenY;
|
||||
|
||||
if(worldX + panel.tileSize > panel.player.worldX - panel.player.screenX &&
|
||||
worldX - panel.tileSize < panel.player.worldX + panel.player.screenX &&
|
||||
worldY + panel.tileSize > panel.player.worldY - panel.player.screenY &&
|
||||
worldY - panel.tileSize < panel.player.worldY + panel.player.screenY
|
||||
) graphics2D.drawImage(image, screenX, screenY, panel.tileSize, panel.tileSize, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.miaurizius.jgame2d.entity.objects;
|
||||
package de.miaurizius.jgame2d.entity.world;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
@@ -1,4 +1,4 @@
|
||||
package de.miaurizius.jgame2d.entity.objects;
|
||||
package de.miaurizius.jgame2d.entity.world;
|
||||
|
||||
import de.miaurizius.jgame2d.core.GamePanel;
|
||||
import de.miaurizius.jgame2d.entity.Entity;
|
||||
Reference in New Issue
Block a user