diff --git a/.gitignore b/.gitignore index 6143e53..5cf39ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +bin +/bin/ + # Compiled class file *.class diff --git a/README.md b/README.md index b6276db..94afc03 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # Forlorn-Hope old abandoned game of mine, using my sjgs engine +------------------------------------- + +*Discontinued*: 2016 + +Might be useful if anyone wanted to see an example of the engine. + +Other than that, this is just a place to store it for nostalgia. + +-------------------- + +If you want to try it, simple `java -jar` the jar in /build diff --git a/dev/Forlorn Hope - Plot.odt.lrz b/dev/Forlorn Hope - Plot.odt.lrz new file mode 100755 index 0000000..c311b04 Binary files /dev/null and b/dev/Forlorn Hope - Plot.odt.lrz differ diff --git a/dev/PyxelEdit/Player.pyxel b/dev/PyxelEdit/Player.pyxel new file mode 100755 index 0000000..1fe4194 Binary files /dev/null and b/dev/PyxelEdit/Player.pyxel differ diff --git a/dev/PyxelEdit/defaultGun.pyxel b/dev/PyxelEdit/defaultGun.pyxel new file mode 100755 index 0000000..1279f85 Binary files /dev/null and b/dev/PyxelEdit/defaultGun.pyxel differ diff --git a/dev/unused art/GameBoy Color Pallete.png b/dev/unused art/GameBoy Color Pallete.png new file mode 100755 index 0000000..8db0ad9 Binary files /dev/null and b/dev/unused art/GameBoy Color Pallete.png differ diff --git a/dev/unused art/butterfly.png b/dev/unused art/butterfly.png new file mode 100755 index 0000000..2c37e62 Binary files /dev/null and b/dev/unused art/butterfly.png differ diff --git a/dev/unused art/flowers.png b/dev/unused art/flowers.png new file mode 100755 index 0000000..0adb7c4 Binary files /dev/null and b/dev/unused art/flowers.png differ diff --git a/res/Forlorn-Hope.jpg b/res/Forlorn-Hope.jpg new file mode 100755 index 0000000..66f1117 Binary files /dev/null and b/res/Forlorn-Hope.jpg differ diff --git a/res/backgrounds/.getxfer.7000.61.mega b/res/backgrounds/.getxfer.7000.61.mega new file mode 100755 index 0000000..e69de29 diff --git a/res/backgrounds/background.png b/res/backgrounds/background.png new file mode 100755 index 0000000..fa84c1d Binary files /dev/null and b/res/backgrounds/background.png differ diff --git a/res/backgrounds/foreground.png b/res/backgrounds/foreground.png new file mode 100755 index 0000000..90907c6 Binary files /dev/null and b/res/backgrounds/foreground.png differ diff --git a/res/backgrounds/midground.png b/res/backgrounds/midground.png new file mode 100755 index 0000000..39dc43f Binary files /dev/null and b/res/backgrounds/midground.png differ diff --git a/res/backgrounds/scenery-demo.png b/res/backgrounds/scenery-demo.png new file mode 100755 index 0000000..332d65f Binary files /dev/null and b/res/backgrounds/scenery-demo.png differ diff --git a/res/data/map.png b/res/data/map.png new file mode 100755 index 0000000..5b102bc Binary files /dev/null and b/res/data/map.png differ diff --git a/res/sounds/effects/jump_sound.mp3 b/res/sounds/effects/jump_sound.mp3 new file mode 100755 index 0000000..49f7fe4 Binary files /dev/null and b/res/sounds/effects/jump_sound.mp3 differ diff --git a/res/sounds/effects/splat.mp3 b/res/sounds/effects/splat.mp3 new file mode 100755 index 0000000..8a6d44a Binary files /dev/null and b/res/sounds/effects/splat.mp3 differ diff --git a/res/sounds/effects/tir.mp3 b/res/sounds/effects/tir.mp3 new file mode 100755 index 0000000..3c5ba0f Binary files /dev/null and b/res/sounds/effects/tir.mp3 differ diff --git a/res/spritesheets/hud/asdf.png b/res/spritesheets/hud/asdf.png new file mode 100755 index 0000000..ab10313 Binary files /dev/null and b/res/spritesheets/hud/asdf.png differ diff --git a/res/spritesheets/hud/test.png b/res/spritesheets/hud/test.png new file mode 100755 index 0000000..b8a9fe5 Binary files /dev/null and b/res/spritesheets/hud/test.png differ diff --git a/res/spritesheets/mobs/scraveller.png b/res/spritesheets/mobs/scraveller.png new file mode 100755 index 0000000..4d7b827 Binary files /dev/null and b/res/spritesheets/mobs/scraveller.png differ diff --git a/res/spritesheets/player/Player1.png b/res/spritesheets/player/Player1.png new file mode 100755 index 0000000..a88d6dc Binary files /dev/null and b/res/spritesheets/player/Player1.png differ diff --git a/res/spritesheets/player/Player2.png b/res/spritesheets/player/Player2.png new file mode 100755 index 0000000..d41b775 Binary files /dev/null and b/res/spritesheets/player/Player2.png differ diff --git a/res/spritesheets/player/Player3.png b/res/spritesheets/player/Player3.png new file mode 100755 index 0000000..f3dee3a Binary files /dev/null and b/res/spritesheets/player/Player3.png differ diff --git a/res/spritesheets/player/Player4.png b/res/spritesheets/player/Player4.png new file mode 100755 index 0000000..02f65d0 Binary files /dev/null and b/res/spritesheets/player/Player4.png differ diff --git a/res/spritesheets/player/Player5.png b/res/spritesheets/player/Player5.png new file mode 100755 index 0000000..5023184 Binary files /dev/null and b/res/spritesheets/player/Player5.png differ diff --git a/res/spritesheets/player/default_gun.png b/res/spritesheets/player/default_gun.png new file mode 100755 index 0000000..d6dcdd0 Binary files /dev/null and b/res/spritesheets/player/default_gun.png differ diff --git a/res/spritesheets/tiles/tile.png b/res/spritesheets/tiles/tile.png new file mode 100755 index 0000000..fd18a52 Binary files /dev/null and b/res/spritesheets/tiles/tile.png differ diff --git a/src/core/Console.java b/src/core/Console.java new file mode 100755 index 0000000..327782f --- /dev/null +++ b/src/core/Console.java @@ -0,0 +1,16 @@ +package core; + +import sjgs.core.DeveloperConsole; +import sjgs.core.Engine; + +public class Console extends DeveloperConsole { + + public Console(final Engine engine) { super(engine); } + + @Override + protected void commands(final String action, final String item, final String value) { + + } + + +} diff --git a/src/core/Main.java b/src/core/Main.java new file mode 100755 index 0000000..8eecdeb --- /dev/null +++ b/src/core/Main.java @@ -0,0 +1,62 @@ +package core; + +import static sjgs.utils.Utils.pythagoras; +import java.awt.Graphics2D; +import core.input.KeyInput; +import core.input.MouseInput; +import jython.Jython; +import player.Player; +import sjgs.core.Camera; +import sjgs.core.DeveloperConsole; +import sjgs.core.Engine; +import sjgs.core.Handler; +import sjgs.physics.Physics; +import textures.TextureLoader; +import worldgen.WorldGenerator; + +public final class Main extends Engine { + + public Main(int WIDTH, int HEIGHT, String title) { + super(WIDTH, HEIGHT, title); + } + + public static final int TILE_SIZE = 6; + public static final float TILE_DIAGONAL = pythagoras(TILE_SIZE, TILE_SIZE); + public static final double SCALE_FACTOR = 8d; + public static final float GRAVITY = 0.25f, TERIMNAL_VELOCITY = 2f, FRICTION = 0.1175f; + + public static Main engine; + public static Camera camera; + public static Player player; + + public static void main(final String[] args) { + engine = new Main(1280, 720, "Forlorn Hope"); + } + + @Override + protected void init() { + new Jython().init(); + camera = new Camera(this); + new MouseInput(this); + Physics.init(GRAVITY, TERIMNAL_VELOCITY, FRICTION); + setScaleFactor(SCALE_FACTOR); + new Console(this); + TextureLoader.getTextures(); + WorldGenerator.generateWorld(); + } + + @Override + protected void render(final Graphics2D g2d) { + WorldGenerator.currentBackground.render(g2d, camera, getScaleFactor()); + Handler.render(g2d, camera, getScaleFactor()); + } + + @Override + protected void tick() { + if(DeveloperConsole.CONSOLE_OPEN) return; + camera.tick(player.getCenter(), getScaleFactor()); + Handler.tick(camera, getScaleFactor()); + KeyInput.tick(player); + } + +} diff --git a/src/core/input/KeyInput.java b/src/core/input/KeyInput.java new file mode 100755 index 0000000..d97f4ba --- /dev/null +++ b/src/core/input/KeyInput.java @@ -0,0 +1,34 @@ +package core.input; + +import static sjgs.utils.Utils.exit; +import player.Player; +import player.gun.PlayerGun; +import sjgs.core.input.Keyboard; +import sjgs.enums.Facing; +import worldgen.WorldGenerator; + +public class KeyInput implements Keyboard { + + public static void tick(final Player player) { + + if(Keyboard.D()) { if(!player.getProne()) player.setVelX(Player.WALKING_SPEED); player.setFacing(Facing.RIGHT); } + else if(Keyboard.A()) { if(!player.getProne()) player.setVelX(-Player.WALKING_SPEED); player.setFacing(Facing.LEFT); } + + if(Keyboard.S()) { + player.setProne(true); + player.setLookingUp(false); + } else player.setProne(false); + + if(Keyboard.W()) { player.setLookingUp(true); player.setProne(false); } + else player.setLookingUp(false); + + if(Keyboard.SPACE() && !player.getJumping() && !player.getFalling() && player.getVelY() >= 0) { player.jump(); } + + if(Keyboard.F()) PlayerGun.shoot(player); + + if(Keyboard.R()) WorldGenerator.generateWorld(); + if(Keyboard.Q()) exit(); + + } + +} diff --git a/src/core/input/MouseInput.java b/src/core/input/MouseInput.java new file mode 100755 index 0000000..e4fcec1 --- /dev/null +++ b/src/core/input/MouseInput.java @@ -0,0 +1,38 @@ +package core.input; + +import java.awt.event.MouseEvent; +import java.awt.event.MouseWheelEvent; +import core.Main; +import player.gun.PlayerGun; +import sjgs.core.Engine; +import sjgs.core.input.Mouse; + +public class MouseInput extends Mouse { + + private final Engine engine; + + public MouseInput(final Engine engine) { super(engine); this.engine = engine; } + + @Override + public void mouseClicked(final MouseEvent e) { + Main.player.setHealth(Main.player.getHealth() - 1); + } + + @Override + public void mouseMoved(final MouseEvent e) {} + + @Override + public void mousePressed(final MouseEvent e) { + if(e.getButton() == 1) PlayerGun.shoot(Main.player); + } + + @Override + public void mouseReleased(final MouseEvent e) {} + + @Override + public void mouseWheelMoved(final MouseWheelEvent e) { + // engine.setScaleFactor(engine.getScaleFactor() + -e.getPreciseWheelRotation() / 5f); + // engine.setScaleFactor(clamp(engine.getScaleFactor(), 0.1f, 15f)); + } + +} diff --git a/src/jython/Jython.java b/src/jython/Jython.java new file mode 100755 index 0000000..63f6f28 --- /dev/null +++ b/src/jython/Jython.java @@ -0,0 +1,40 @@ +package jython; + +import static sjgs.core.jython.Jython.pi; +import static sjgs.utils.Utils.readTextFileAsString; +import mobs.scraveller.Scraveller; +import player.Player; +import player.gun.PlayerGun; + +public class Jython { + + public void init() { + imports(); + loadMethodsIntoInterpretor(); + createPyFuncs(); + } + + // IMPORTS ALL NECESSARY JAVA CLASSES FOR INTERP + private static void imports() { + pi.exec(readTextFileAsString("/jython/forlorn_hope_jython_imports.py")); + } + + // RUNS THE MODULES THROUGH THE INTERP TO LOAD THE NAMES OF FUNCS + private static void loadMethodsIntoInterpretor() { + // Player scripts + pi.exec(readTextFileAsString("/player/gun/player_gun.py")); + pi.exec(readTextFileAsString("/player/player_animations.py")); + // MOB AI + pi.exec(readTextFileAsString("/mobs/scraveller/scraveller_ai.py")); + } + + private static void createPyFuncs() { + // PlayerScripts + PlayerGun.initPyFuncs(); + Player.createPyFuncs(); + // MOBS + Scraveller.createPyFuncs(); + } + + +} diff --git a/src/jython/forlorn_hope_jython_imports.py b/src/jython/forlorn_hope_jython_imports.py new file mode 100755 index 0000000..0388305 --- /dev/null +++ b/src/jython/forlorn_hope_jython_imports.py @@ -0,0 +1,31 @@ +from core.input import MouseInput +from core import Main + +from ui.inventory.ItemIDs import * + +from player import Player +from player.gun.PlayerBulletDamages import * +from textures.player import PlayerTextures + +from player.gun.bullets import PlayerBullet +from player.gun.bullets import DefaultBullet +from player.gun import PlayerGun + +from tiles import Tile + +from worldgen import WorldGenerator + +### MOBS +import mobs.MobDamages +import mobs.MobHealths +import mobs.MobSpeeds +from mobs.MobDamages import * +from mobs.MobHealths import * +from mobs.MobSpeeds import * + +from mobs.scraveller import Scraveller + + +## IMPORT JMP3 +from jmp3 import MP3Player +from jmp3 import AdvancedMP3Player diff --git a/src/mobs/MobDamages.java b/src/mobs/MobDamages.java new file mode 100755 index 0000000..2008a18 --- /dev/null +++ b/src/mobs/MobDamages.java @@ -0,0 +1,8 @@ +package mobs; + +public interface MobDamages { + + public static final float SCRAVELLER_DAMAGE = 5; + + +} diff --git a/src/mobs/MobHealths.java b/src/mobs/MobHealths.java new file mode 100755 index 0000000..0f28458 --- /dev/null +++ b/src/mobs/MobHealths.java @@ -0,0 +1,9 @@ +package mobs; + +public interface MobHealths { + + + public static final int SCRAVELLER_HEALTH = 6; + + +} diff --git a/src/mobs/MobSpeeds.java b/src/mobs/MobSpeeds.java new file mode 100755 index 0000000..52100ff --- /dev/null +++ b/src/mobs/MobSpeeds.java @@ -0,0 +1,7 @@ +package mobs; + +public interface MobSpeeds { + + public static final float SCRAVELLER_SPEED = 0.175f; + +} diff --git a/src/mobs/scraveller/Scraveller.java b/src/mobs/scraveller/Scraveller.java new file mode 100755 index 0000000..8e7d488 --- /dev/null +++ b/src/mobs/scraveller/Scraveller.java @@ -0,0 +1,108 @@ +package mobs.scraveller; + +import static sjgs.core.jython.Jython.pi; +import static sjgs.utils.pyutils.PyUtils.java2py; +import java.awt.Graphics2D; +import org.python.core.PyBoolean; +import org.python.core.PyFloat; +import org.python.core.PyFunction; +import org.python.core.PyObject; +import core.Main; +import jmp3.MP3Player; +import mobs.MobDamages; +import mobs.MobHealths; +import mobs.MobSpeeds; +import sjgs.base_objects.Bullet; +import sjgs.base_objects.Mob; +import sjgs.graphics.Animation; +import sjgs.utils.data_structures.Stack; +import sjgs.utils.data_structures.shapes.Rectangle; +import textures.mobs.ScravellerTextures; + +public class Scraveller extends Mob { + + /******* SOUNDS ************************************/ + public static final String deathSound = "/splat.mp3", walkSound = "???"; + /***************************************************/ + + private static PyFloat speed = new PyFloat(MobSpeeds.SCRAVELLER_SPEED); + + public static final int WIDTH = 4, HEIGHT = 4; + public Rectangle territory; + private final PyObject _territory; + public int pointsIndex; + public boolean clockWise; + + /** @hitBullets: all the bullets that have already hit the mob as to not + * calc damage on them every tick if they are in the stack */ + public final Stack hitBullets; + + public Scraveller(final Rectangle territory, final boolean clockWise) { + super(territory.pos.x, territory.pos.y - HEIGHT, WIDTH, HEIGHT); + self = java2py(this); + move = ScravellerTextures.move.clone(); + moveFlipped = ScravellerTextures.moveFlipped.clone(); + rotatedRight = ScravellerTextures.rotatedRight; + rotatedLeft = ScravellerTextures.rotatedLeft; + this.territory = territory; + this.clockWise = clockWise; + health = MobHealths.SCRAVELLER_HEALTH; + damage = MobDamages.SCRAVELLER_DAMAGE; + hitBullets = new Stack(); + _territory = java2py(territory); + } + + @Override + protected void init() { } + + @Override + public void tick() { + ai.__call__(self, _territory, speed, new PyBoolean(clockWise)); + scravellerCollision.__call__(self); + updatePosition(); + runAnimations.__call__(self); + checkIfAlive(); + } + + @Override + public void render(final Graphics2D g2d) { + final float vx = getVelX(); + final float vy = getVelY(); + if(clockWise) { + if(vx < 0) moveFlipped.drawAnimation(g2d, getBounds()); + else if(vx > 0) move.drawAnimation(g2d, getBounds()); + else if(vy > 0) rotatedRight.drawAnimation(g2d, getBounds()); + else if(vy < 0) rotatedLeft.drawAnimation(g2d, getBounds()); + } else { + if(vx < 0) move.drawAnimation(g2d, getBounds()); + else if(vx > 0) moveFlipped.drawAnimation(g2d, getBounds()); + else if(vy > 0) rotatedLeft.drawAnimation(g2d, getBounds()); + else if(vy < 0) rotatedRight.drawAnimation(g2d, getBounds()); + } + // g2d.setColor(red); + // territory.draw(g2d); + } + + @Override + protected void destroy() { + hitBullets.clear(); + removeFromHandler(); + final float distance = getCenter().distance(Main.player.getCenter()); + final float gain = -(distance / Main.TILE_DIAGONAL)*3; + if (gain > -65) MP3Player.play(deathSound); + } + + // --------------------------------- ANIMATIONS ------------------------------------------------------------------------------------------------- // + public final Animation move, moveFlipped, rotatedRight, rotatedLeft; + // ------------------------------------ PYTHON -------------------------------------------------------------------------------------------------- // + private static PyFunction ai, runAnimations, scravellerCollision; private final PyObject self; + public static void createPyFuncs() { + ai = pi.get("mob_travel_around_rectangle_ai", PyFunction.class); + runAnimations = pi.get("scraveller_run_animations", PyFunction.class); + scravellerCollision = pi.get("scraveller_collision", PyFunction.class); + } + + public void reverseDirection() { clockWise = !clockWise; } + public void setClockwise(final boolean clockWise) { this.clockWise = clockWise; } + +} diff --git a/src/mobs/scraveller/scraveller_ai.py b/src/mobs/scraveller/scraveller_ai.py new file mode 100755 index 0000000..c99faf7 --- /dev/null +++ b/src/mobs/scraveller/scraveller_ai.py @@ -0,0 +1,42 @@ +def scraveller_collision(s): + response = s.getCollidedObjects() + + bullets = response.collided_bullets; + + for b in bullets: + if not s.hitBullets.contains(b): + s.hitBullets.add(b) + + # IF IS A PLAYER BULLET + if isinstance(b, PlayerBullet): + # IF IS THE DEFAULT BULLET + if isinstance(b, DefaultBullet): + s.setHealth(s.getHealth() - DEFAULT_GUN_DAMAGE) + + players = response.collided_players; + + + bullets.clear() + players.clear() + response.discard() + +#def scraveller_walk_sound(s): + #d = s.getCenter().distance(Main.player.getCenter()) + #gain = -(d / Main.TILE_DIAGONAL)*3 + #if gain < -60: return + #SoundPlayer.play(s.walkSound, gain) + +def scraveller_run_animations(s): + vx = s.getVelX() + vy = s.getVelY() + if s.clockWise: + if vx < 0: s.moveFlipped.runAnimation() + elif vx > 0: s.move.runAnimation() + elif vy > 0: s.rotatedRight.runAnimation() + elif vy < 0: s.rotatedLeft.runAnimation() + else: + if vx < 0: s.move.runAnimation() + elif vx > 0: s.moveFlipped.runAnimation() + elif vy > 0: s.rotatedLeft.runAnimation() + elif vy < 0: s.rotatedRight.runAnimation() + \ No newline at end of file diff --git a/src/player/Player.java b/src/player/Player.java new file mode 100755 index 0000000..edf2c5b --- /dev/null +++ b/src/player/Player.java @@ -0,0 +1,62 @@ +package player; + +import static sjgs.core.jython.Jython.pi; +import static sjgs.utils.pyutils.PyUtils.java2py; +import java.awt.Graphics2D; +import org.python.core.PyFunction; +import org.python.core.PyObject; +import core.Main; +import jmp3.MP3Player; +import sjgs.base_objects.PlayerBase; +import sjgs.physics.structs.CollisionResponse; + +public class Player extends PlayerBase { + + public static final float WALKING_SPEED = Main.TILE_SIZE/6, JUMPING_SPEED = -Main.TILE_SIZE/2; + public static final float WIDTH = Main.TILE_SIZE, HEIGHT = Main.TILE_SIZE; + + private boolean prone, lookingUp; + private final PyObject self; + private final int playerMaxHealth; + + public Player(final float x, final float y) { + super(x, y, WIDTH, HEIGHT); + self = java2py(this); + playerMaxHealth = 7; + setHealth(playerMaxHealth); + } + + @Override + protected void init() {} + + @Override + public void tick() { + final CollisionResponse response = applyPhysics(); + response.discard(); + manageJumping(); + runAnimations.__call__(self); + } + + @Override + public void render(final Graphics2D g2d) { PlayerRenderer.render(this, g2d); } + + @Override + protected void destroy() { removeFromHandler(); } + + // ------------------------- GETTERS AND SETTERS ------------------------------------------------------------------------------// + public boolean getProne() { return prone; } + public boolean getLookingUp() { return lookingUp; } + public void setProne(final boolean prone) { this.prone = prone; } + public void setLookingUp(final boolean lookingUp) { this.lookingUp = lookingUp; } + public PyObject getSelf() { return self; } + // ------------------------ END GETTERS AND SETTERS ---------------------------------------------------------------------------// + + public void jump() { + setVelY(Player.JUMPING_SPEED); setJumping(true); + MP3Player.play("/jump_sound.mp3"); + } + public float getPlayerMaxHealth() { return playerMaxHealth; } + + private static PyFunction runAnimations; + public static void createPyFuncs() { runAnimations = pi.get("run_player_animations", PyFunction.class); } +} diff --git a/src/player/PlayerRenderer.java b/src/player/PlayerRenderer.java new file mode 100755 index 0000000..5cbd5a0 --- /dev/null +++ b/src/player/PlayerRenderer.java @@ -0,0 +1,177 @@ +package player; + +import static textures.player.PlayerTextures.*; +import java.awt.Graphics2D; + +class PlayerRenderer { + + private static final float _white = 0.70f, + _gray = 0.50f, + _pale_green = 0.30f, + _green = 0.10f; + + private final static int offset = 2; // NOTE YOU DO NEED THIS! + + static void render(final Player player, final Graphics2D g2d) { + + final boolean right = player.facingRight(); + final boolean lookingUp = player.getLookingUp(); + final boolean jumping = player.getJumping(); + final boolean falling = player.getFalling(); + final boolean prone = player.getProne(); + final boolean stopped = player.stopped(); + final boolean white = player.getHealth() >= player.getPlayerMaxHealth() * _white; + final boolean gray = player.getHealth() >= player.getPlayerMaxHealth() * _gray; + final boolean pale_green = player.getHealth() >= player.getPlayerMaxHealth() * _pale_green; + final boolean green = player.getHealth() >= player.getPlayerMaxHealth() * _green; + final int x = (int)player.getX(); + final int y = (int)player.getY(); + + + + if(white) { + if(prone) { + if(falling || jumping) g2d.drawImage(right ? playerLookingDownRight : playerLookingDownLeft, x - offset, y - offset, null); + else g2d.drawImage(right ? playerProneRight : playerProneLeft, x - offset, y - offset, null); + } else if(!lookingUp) { + if(falling) g2d.drawImage(right ? playerFallingRight : playerFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? playerJumpingRight : playerJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) playerIdleRight.drawAnimation(g2d, x - offset, y - offset); + else playerIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) playerWalkRight.drawAnimation(g2d, x - offset, y - offset); + else playerWalkLeft.drawAnimation(g2d, x - offset, y - offset); + } + } else { + if(falling) g2d.drawImage(right ? playerLookingUpFallingRight : playerLookingUpFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? playerLookingUpJumpingRight : playerLookingUpJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) playerLookingUpIdleRight.drawAnimation(g2d, x - offset, y - offset); + else playerLookingUpIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) playerLookingUpRunningRight.drawAnimation(g2d, x - offset, y - offset); + else playerLookingUpRunningLeft.drawAnimation(g2d, x - offset, y - offset); + } + } + } + + + + else if(gray) { + if(prone) { + if(falling || jumping) g2d.drawImage(right ? GRAYplayerLookingDownRight : GRAYplayerLookingDownLeft, x - offset, y - offset, null); + else g2d.drawImage(right ? GRAYplayerProneRight : GRAYplayerProneLeft, x - offset, y - offset, null); + } else if(!lookingUp) { + if(falling) g2d.drawImage(right ? GRAYplayerFallingRight : GRAYplayerFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? GRAYplayerJumpingRight : GRAYplayerJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) GRAYplayerIdleRight.drawAnimation(g2d, x - offset, y - offset); + else GRAYplayerIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) GRAYplayerWalkRight.drawAnimation(g2d, x - offset, y - offset); + else GRAYplayerWalkLeft.drawAnimation(g2d, x - offset, y - offset); + } + } else { + if(falling) g2d.drawImage(right ? GRAYplayerLookingUpFallingRight : GRAYplayerLookingUpFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? GRAYplayerLookingUpJumpingRight : GRAYplayerLookingUpJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) GRAYplayerLookingUpIdleRight.drawAnimation(g2d, x - offset, y - offset); + else GRAYplayerLookingUpIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) GRAYplayerLookingUpRunningRight.drawAnimation(g2d, x - offset, y - offset); + else GRAYplayerLookingUpRunningLeft.drawAnimation(g2d, x - offset, y - offset); + } + } + } + + + + else if(pale_green) { + if(prone) { + if(falling || jumping) g2d.drawImage(right ? PALE_GREENplayerLookingDownRight : PALE_GREENplayerLookingDownLeft, x - offset, y - offset, null); + else g2d.drawImage(right ? PALE_GREENplayerProneRight : PALE_GREENplayerProneLeft, x - offset, y - offset, null); + } else if(!lookingUp) { + if(falling) g2d.drawImage(right ? PALE_GREENplayerFallingRight : PALE_GREENplayerFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? PALE_GREENplayerJumpingRight : PALE_GREENplayerJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) PALE_GREENplayerIdleRight.drawAnimation(g2d, x - offset, y - offset); + else PALE_GREENplayerIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) PALE_GREENplayerWalkRight.drawAnimation(g2d, x - offset, y - offset); + else PALE_GREENplayerWalkLeft.drawAnimation(g2d, x - offset, y - offset); + } + } else { + if(falling) g2d.drawImage(right ? PALE_GREENplayerLookingUpFallingRight : PALE_GREENplayerLookingUpFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? PALE_GREENplayerLookingUpJumpingRight : PALE_GREENplayerLookingUpJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) PALE_GREENplayerLookingUpIdleRight.drawAnimation(g2d, x - offset, y - offset); + else PALE_GREENplayerLookingUpIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) PALE_GREENplayerLookingUpRunningRight.drawAnimation(g2d, x - offset, y - offset); + else PALE_GREENplayerLookingUpRunningLeft.drawAnimation(g2d, x - offset, y - offset); + } + } + } + + + + else if(green) { + if(prone) { + if(falling || jumping) g2d.drawImage(right ? GREENplayerLookingDownRight : GREENplayerLookingDownLeft, x - offset, y - offset, null); + else g2d.drawImage(right ? GREENplayerProneRight : GREENplayerProneLeft, x - offset, y - offset, null); + } else if(!lookingUp) { + if(falling) g2d.drawImage(right ? GREENplayerFallingRight : GREENplayerFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? GREENplayerJumpingRight : GREENplayerJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) GREENplayerIdleRight.drawAnimation(g2d, x - offset, y - offset); + else GREENplayerIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) GREENplayerWalkRight.drawAnimation(g2d, x - offset, y - offset); + else GREENplayerWalkLeft.drawAnimation(g2d, x - offset, y - offset); + } + } else { + if(falling) g2d.drawImage(right ? GREENplayerLookingUpFallingRight : GREENplayerLookingUpFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? GREENplayerLookingUpJumpingRight : GREENplayerLookingUpJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) GREENplayerLookingUpIdleRight.drawAnimation(g2d, x - offset, y - offset); + else GREENplayerLookingUpIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) GREENplayerLookingUpRunningRight.drawAnimation(g2d, x - offset, y - offset); + else GREENplayerLookingUpRunningLeft.drawAnimation(g2d, x - offset, y - offset); + } + } + } + + + + // BROWN --- below 10% health + else { + if(prone) { + if(falling || jumping) g2d.drawImage(right ? BROWNplayerLookingDownRight : BROWNplayerLookingDownLeft, x - offset, y - offset, null); + else g2d.drawImage(right ? BROWNplayerProneRight : BROWNplayerProneLeft, x - offset, y - offset, null); + } else if(!lookingUp) { + if(falling) g2d.drawImage(right ? BROWNplayerFallingRight : BROWNplayerFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? BROWNplayerJumpingRight : BROWNplayerJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) BROWNplayerIdleRight.drawAnimation(g2d, x - offset, y - offset); + else BROWNplayerIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) BROWNplayerWalkRight.drawAnimation(g2d, x - offset, y - offset); + else BROWNplayerWalkLeft.drawAnimation(g2d, x - offset, y - offset); + } + } else { + if(falling) g2d.drawImage(right ? BROWNplayerLookingUpFallingRight : BROWNplayerLookingUpFallingLeft, x - offset, y - offset, null); + else if(jumping) g2d.drawImage(right ? BROWNplayerLookingUpJumpingRight : BROWNplayerLookingUpJumpingLeft, x - offset, y - offset, null); + else if(stopped) { + if(right) BROWNplayerLookingUpIdleRight.drawAnimation(g2d, x - offset, y - offset); + else BROWNplayerLookingUpIdleLeft.drawAnimation(g2d, x - offset, y - offset); + } else { + if(right) BROWNplayerLookingUpRunningRight.drawAnimation(g2d, x - offset, y - offset); + else BROWNplayerLookingUpRunningLeft.drawAnimation(g2d, x - offset, y - offset); + } + } + } + } + +} diff --git a/src/player/gun/PlayerBulletDamages.java b/src/player/gun/PlayerBulletDamages.java new file mode 100755 index 0000000..44c7eb3 --- /dev/null +++ b/src/player/gun/PlayerBulletDamages.java @@ -0,0 +1,8 @@ +package player.gun; + +public interface PlayerBulletDamages { + + + public static float DEFAULT_GUN_DAMAGE = 3; + +} diff --git a/src/player/gun/PlayerGun.java b/src/player/gun/PlayerGun.java new file mode 100755 index 0000000..ed8bb93 --- /dev/null +++ b/src/player/gun/PlayerGun.java @@ -0,0 +1,28 @@ +package player.gun; + +import static sjgs.core.jython.Jython.pi; +import org.python.core.PyFunction; +import player.Player; + +public class PlayerGun { + + private static long then; + + public static void shoot(final Player player) { + + if(System.currentTimeMillis() - then > 175) { + shoot.__call__(player.getSelf()); + then = System.currentTimeMillis(); + } + + /* uncomment for interactive scripting */ + // pi.exec(readTextFileAsString("/player/gun/player_gun.py")); + // initPyFuncs(); + } + + private static PyFunction shoot; + public static void initPyFuncs() { + shoot = pi.get("player_shoot", PyFunction.class); + } + +} diff --git a/src/player/gun/bullets/DefaultBullet.java b/src/player/gun/bullets/DefaultBullet.java new file mode 100755 index 0000000..e211b6c --- /dev/null +++ b/src/player/gun/bullets/DefaultBullet.java @@ -0,0 +1,76 @@ +package player.gun.bullets; + +import static sjgs.utils.Utils.isPositive; +import java.awt.Graphics2D; +import core.Main; +import sjgs.enums.Facing; +import sjgs.graphics.Animation; +import sjgs.physics.structs.CollisionResponse; +import sjgs.utils.data_structures.vectors.Point2f; +import textures.player.PlayerGunTextures; + +public class DefaultBullet extends PlayerBullet { + + public static final String sound = "/tir.mp3"; + + private static final int w = 8, h = 1, health_timer = 18; + private final Animation animation; + private final Point2f p; + private final Facing facing; + + /** @constructor: velX / velY are the player's velocity at initial shot */ + public DefaultBullet(final Point2f p, final Facing facing, final float velX, final float velY) { + // note the +2 and +1, leave them! + super(p.x + 2, p.y + 1, facing == Facing.RIGHT || facing == Facing.LEFT ? w : h, facing == Facing.RIGHT || facing == Facing.LEFT ? h : w, velX, velY, 0, health_timer); + this.p = p; this.facing = facing; + switch(facing) { + case RIGHT: animation = PlayerGunTextures.default_gun_right.clone(); break; + case LEFT: animation = PlayerGunTextures.default_gun_left.clone(); break; + case ABOVE: animation = PlayerGunTextures.default_gun_up.clone(); break; + default: animation = PlayerGunTextures.default_gun_down.clone(); break; // (down) + } + } + + @Override + protected void init() {} + + @Override + public void tick() { + final CollisionResponse response = getCollidedObjects(); + + // do collision stuff here + + response.discard(); + + animation.playAnimationOnce(); + + if(isMoving()) { + // if player changed directions since last shot, set the bullet velocity to zero + final float pvx = Main.player.getVelX(), pvy = Main.player.getVelY(), vx = getVelX(), vy = getVelY(); + if(pvx == 0 || isPositive(vx) ^ isPositive(pvx)) setVelX(0); + if(pvy == 0 || isPositive(vy) ^ isPositive(pvy)) setVelY(0); + // update animation position + p.x += getVelX(); + p.y += getVelY(); + } + + // NOTE YOU DO NEED THIS, it updates the bounds pos when running to match animation + updatePosition(); + + if(timer.tick()) destroy(); + } + + @Override + public void render(final Graphics2D g2d) { + if(animation != null) animation.drawAnimation(g2d, p); + + // g2d.setColor(Color.blue); + // getFullBounds().draw(g2d); + } + + @Override + protected void destroy() { + removeFromHandler(); + } + +} diff --git a/src/player/gun/bullets/PlayerBullet.java b/src/player/gun/bullets/PlayerBullet.java new file mode 100755 index 0000000..f37a9cc --- /dev/null +++ b/src/player/gun/bullets/PlayerBullet.java @@ -0,0 +1,21 @@ +package player.gun.bullets; + +import java.awt.Graphics2D; +import sjgs.base_objects.Bullet; + +public abstract class PlayerBullet extends Bullet { + + public PlayerBullet(final float x, final float y, final float w, final float h, final float velX, final float velY, final int elasticity, final int health_timer) { + super(x, y, w, h, velX, velY, elasticity, health_timer); + } + + @Override + protected abstract void init(); + @Override + public abstract void tick(); + @Override + public abstract void render(Graphics2D g2d); + @Override + protected abstract void destroy(); + +} diff --git a/src/player/gun/player_gun.py b/src/player/gun/player_gun.py new file mode 100755 index 0000000..f5302a8 --- /dev/null +++ b/src/player/gun/player_gun.py @@ -0,0 +1,136 @@ +# DIFFERENT BULLETS: +DEFAULT_GUN = 1 + +import textures.player.PlayerTextures as PlayerTextures + +# creates the bullet for gun to shoot +def player_shoot(player): + p = getPlayerGunPositionPoint(player) + dir = getPlayerBulletDirection(player) + b = whichPlayerBullet(player) + + # create the bullet + if b == DEFAULT_GUN: + down_multiplier = 1/3 + if dir == Facing.BELOW or dir == Facing.ABOVE: DefaultBullet(p, dir, 0, player.getVelY() * down_multiplier) + elif (dir == Facing.RIGHT or dir == Facing.LEFT) or dir == Facing.ABOVE and player.getVelX() != 0: DefaultBullet(p, dir, player.getVelX(), 0) + else: DefaultBullet(p, dir, 0, 0) + + # play shooting sound + playerBulletSound(b) + +# gets the position of the gun barrel location +# NOTE: use (int) as graphics cannot be floating points! +def getPlayerGunPositionPoint(player): + x = 0 + y = 0 + + # get variables for clarity + right = player.getFacing() == Facing.RIGHT + left = not right + jumping = player.getJumping() + falling = player.getFalling() + up = player.getLookingUp() + down = player.getProne() and (player.getFalling() or player.getJumping()) + moving = player.getVelX() != 0 or player.getVelY() != 0 + prone = player.getProne() and not (player.getFalling() or player.getJumping()) and not moving + + cx = int(player.getCenterX()) + cy = int(player.getCenterY()) + + idle = not falling and not jumping and not up and not down and not prone and not moving + idleUp = not falling and not jumping and up and not down and not prone and not moving + running = not falling and not jumping and not up and not down and not prone and moving + runningUp = not falling and not jumping and up and not down and not prone and moving + jumping = (jumping or falling) and not up + jumpingUp = (jumping or falling or player.getVelY() < 0) and up + +############ IF FACING RIGHT ############################################################################ + if right: + if idle: + x = cx + 4 + y = cy - 2 + if PlayerTextures.playerIdleRight.currentFrame == PlayerTextures.playerIdleRight.size() - 1: y += 1 + elif idleUp: + x = cx - 1 + y = cy - 14 + if PlayerTextures.playerLookingUpIdleRight.currentFrame == PlayerTextures.playerLookingUpIdleRight.size() - 1: y += 1 + elif running: + x = cx + 4 + y = cy - 2 + if PlayerTextures.playerWalkRight.currentFrame % 2 == 0: y -= 1 + if PlayerTextures.playerWalkRight.currentFrame == 1: x += 1 + if PlayerTextures.playerWalkRight.currentFrame == 3: x -= 1 + elif runningUp: + x = cx + y = cy - 14 + if PlayerTextures.playerLookingUpRunningRight.currentFrame % 2 == 0: y -= 1 + if PlayerTextures.playerLookingUpRunningRight.currentFrame == 1: x += 1 + if PlayerTextures.playerLookingUpRunningRight.currentFrame == 3: x -= 1 + elif prone: + x = cx + 5 + y = cy + elif down: + x = cx - 2 + y = cy + 5 + elif jumping: + x = cx + 4 + y = cy - 1 + elif jumpingUp: + x = cx - 1 + y = cy - 9 +################## IF FACING LEFT ####################################################################### + else: + if idle: + x = cx - 13 + y = cy - 2 + if PlayerTextures.playerIdleLeft.currentFrame == PlayerTextures.playerIdleLeft.size() - 1: y += 1 + elif idleUp: + x = cx - 2 + y = cy - 14 + if PlayerTextures.playerLookingUpIdleLeft.currentFrame == PlayerTextures.playerLookingUpIdleLeft.size() - 1: y += 1 + elif running: + x = cx - 13 + y = cy - 2 + if PlayerTextures.playerWalkLeft.currentFrame % 2 == 0: y -= 1 + if PlayerTextures.playerWalkLeft.currentFrame == 1: x -= 1 + if PlayerTextures.playerWalkLeft.currentFrame == 3: x += 1 + elif runningUp: + x = cx - 2 + y = cy - 14 + if PlayerTextures.playerLookingUpRunningLeft.currentFrame % 2 == 0: y -= 1 + if PlayerTextures.playerLookingUpRunningLeft.currentFrame == 1: x -= 1 + if PlayerTextures.playerLookingUpRunningLeft.currentFrame == 3: x += 1 + elif prone: + x = cx - 14 + y = cy + elif down: + x = cx - 1 + y = cy + 7 + elif jumping: + x = cx - 12 + y = cy - 1 + elif jumpingUp: + x = cx - 2 + y = cy - 9 +################################################################################################################## + return Point2f(x, y) + +def playerBulletSound(b): + if b == DEFAULT_GUN: MP3Player.play(DefaultBullet.sound) + +def getPlayerBulletDirection(player): + right = player.getFacing() == Facing.RIGHT + left = not right + prone = player.getProne() and not (player.getFalling() or player.getJumping()) + up = player.getLookingUp() + down = player.getProne() and (player.getFalling() or player.getJumping()) + + if right and not down and not up: return Facing.RIGHT + elif left and not down and not up: return Facing.LEFT + elif down: return Facing.BELOW + elif up: return Facing.ABOVE + +# determines which kind of bullet to shoot +def whichPlayerBullet(player): + return DEFAULT_GUN \ No newline at end of file diff --git a/src/player/player_animations.py b/src/player/player_animations.py new file mode 100755 index 0000000..902e060 --- /dev/null +++ b/src/player/player_animations.py @@ -0,0 +1,60 @@ +### NOTE we run them all here as its the easiest way to get them sync'd up, and +# with my animation implementation its only incrementing an int, so its not resource intensive. + +def run_player_animations(p): + # IF RUNNING NORMALLY + if not p.getProne() and not p.getFalling() and not p.getLookingUp() and not p.stopped(): + if p.facingRight(): + PlayerTextures.playerWalkRight.runAnimation() + PlayerTextures.GRAYplayerWalkRight.runAnimation() + PlayerTextures.PALE_GREENplayerWalkRight.runAnimation() + PlayerTextures.GREENplayerWalkRight.runAnimation() + PlayerTextures.BROWNplayerWalkRight.runAnimation() + else: + PlayerTextures.playerWalkLeft.runAnimation() + PlayerTextures.GRAYplayerWalkLeft.runAnimation() + PlayerTextures.PALE_GREENplayerWalkLeft.runAnimation() + PlayerTextures.GREENplayerWalkLeft.runAnimation() + PlayerTextures.BROWNplayerWalkLeft.runAnimation() + # IF RUNNING LOOKING UP + elif not p.getProne() and not p.getFalling() and not p.stopped(): + if p.facingRight(): + PlayerTextures.playerLookingUpRunningRight.runAnimation() + PlayerTextures.GRAYplayerLookingUpRunningRight.runAnimation() + PlayerTextures.PALE_GREENplayerLookingUpRunningRight.runAnimation() + PlayerTextures.GREENplayerLookingUpRunningRight.runAnimation() + PlayerTextures.BROWNplayerLookingUpRunningRight.runAnimation() + else: + PlayerTextures.playerLookingUpRunningLeft.runAnimation() + PlayerTextures.GRAYplayerLookingUpRunningLeft.runAnimation() + PlayerTextures.PALE_GREENplayerLookingUpRunningLeft.runAnimation() + PlayerTextures.GREENplayerLookingUpRunningLeft.runAnimation() + PlayerTextures.BROWNplayerLookingUpRunningLeft.runAnimation() + # IF IDLE NORMAL + elif not p.getProne() and not p.getFalling() and not p.getLookingUp(): + if p.facingRight(): + PlayerTextures.playerIdleRight.runAnimation() + PlayerTextures.GRAYplayerIdleRight.runAnimation() + PlayerTextures.PALE_GREENplayerIdleRight.runAnimation() + PlayerTextures.GREENplayerIdleRight.runAnimation() + PlayerTextures.BROWNplayerIdleRight.runAnimation() + else: + PlayerTextures.playerIdleLeft.runAnimation() + PlayerTextures.GRAYplayerIdleLeft.runAnimation() + PlayerTextures.PALE_GREENplayerIdleLeft.runAnimation() + PlayerTextures.GREENplayerIdleLeft.runAnimation() + PlayerTextures.BROWNplayerIdleLeft.runAnimation() + # IF IDLE LOOKING UP + elif not p.getProne() and not p.getFalling() and p.stopped() and p.getLookingUp(): + if p.facingRight(): + PlayerTextures.playerLookingUpIdleRight.runAnimation() + PlayerTextures.GRAYplayerLookingUpIdleRight.runAnimation() + PlayerTextures.PALE_GREENplayerLookingUpIdleRight.runAnimation() + PlayerTextures.GREENplayerLookingUpIdleRight.runAnimation() + PlayerTextures.BROWNplayerLookingUpIdleRight.runAnimation() + else: + PlayerTextures.playerLookingUpIdleLeft.runAnimation() + PlayerTextures.GRAYplayerLookingUpIdleLeft.runAnimation() + PlayerTextures.PALE_GREENplayerLookingUpIdleLeft.runAnimation() + PlayerTextures.GREENplayerLookingUpIdleLeft.runAnimation() + PlayerTextures.BROWNplayerLookingUpIdleLeft.runAnimation() \ No newline at end of file diff --git a/src/tiles/Tile.java b/src/tiles/Tile.java new file mode 100755 index 0000000..0954881 --- /dev/null +++ b/src/tiles/Tile.java @@ -0,0 +1,31 @@ +package tiles; + +import java.awt.Graphics2D; +import sjgs.base_objects.BaseTile; +import textures.tiles.TileTextures; + +public class Tile extends BaseTile { + + public Tile(final int x, final int y, final int w, final int h, final float startingHeightPercentage, final float endingHeightPercentage) { + super(x, y, w, h, startingHeightPercentage, endingHeightPercentage); + } + + // no args = not angled + public Tile(final int x, final int y, final int w, final int h) { super(x, y, w, h, 0, 0); } + + @Override + public void init() {} + + @Override + public void tick() {} + + @Override + public void render(final Graphics2D g2d) { + g2d.drawImage(TileTextures.tile1, (int)getX(), (int)getY(), null); // NOTE YOU NEED THE +2!!! + } + + + @Override + public void destroy() { removeFromHandler(); } + +} diff --git a/src/ui/HUD.java b/src/ui/HUD.java new file mode 100755 index 0000000..83e8499 --- /dev/null +++ b/src/ui/HUD.java @@ -0,0 +1,3 @@ +package ui; + +public class HUD {} diff --git a/src/ui/inventory/Inventory.java b/src/ui/inventory/Inventory.java new file mode 100755 index 0000000..80c4d5a --- /dev/null +++ b/src/ui/inventory/Inventory.java @@ -0,0 +1,48 @@ +package ui.inventory; + +import java.awt.Graphics2D; +import sjgs.graphics.ui.InventorySystem; +import sjgs.graphics.ui.InventorySystemSlot; + +public class Inventory extends InventorySystem { + + public Inventory(final float x, final float y, final float width, final float height) { + super(x, y, width, height); + } + + @Override + public void init() { + + } + + + @Override + public void onLeftClick() { + baseOnLeftClick(); + } + + @Override + public int getStackableAmount(final int itemId) { return 0; } + + @Override + public boolean isStackable(final int itemId) { return false; } + + @Override + public void render(final Graphics2D g2d) { + for(final InventorySystemSlot slot : getSlots()) slot.render(g2d); + } + + @Override + public void tick() { + for(final InventorySystemSlot slot : getSlots()) slot.tick(); + } + + @Override + public void swapSlots(final InventorySystemSlot a, final InventorySystemSlot b) { + baseSwapSlots(a, b); + } + + @Override + public void destroy() {} + +} diff --git a/src/ui/inventory/InventorySlot.java b/src/ui/inventory/InventorySlot.java new file mode 100755 index 0000000..81a3b8b --- /dev/null +++ b/src/ui/inventory/InventorySlot.java @@ -0,0 +1,35 @@ +package ui.inventory; + +import java.awt.Graphics2D; +import sjgs.graphics.ui.InventorySystemSlot; + +public class InventorySlot extends InventorySystemSlot { + + + public InventorySlot(final float x, final float y, final float w, final float h, final int slotNumber) { + super(x, y, w, h, slotNumber); + } + + @Override + public void init() { + + } + + @Override + public void render(final Graphics2D g2d) { + + } + + @Override + public void reset() { + baseReset(); + } + + @Override + public void tick() { + + } + + + +} diff --git a/src/ui/inventory/ItemIDs.java b/src/ui/inventory/ItemIDs.java new file mode 100755 index 0000000..f4dbc2e --- /dev/null +++ b/src/ui/inventory/ItemIDs.java @@ -0,0 +1,17 @@ +package ui.inventory; + +public interface ItemIDs { + + + public static final int UPGRADED_DEFAULT_GUN = 1, + DOUBLE_JUMP = 2, + NIGHT_VISION = 3, + DASH_BOOSTER = 4, + LAVA_SUIT = 5, + WATER_SUIT = 6, + MAP = 7, + DEFAULT_GUN = 8; + + + +} diff --git a/src/worldgen/TestMapCreator.java b/src/worldgen/TestMapCreator.java new file mode 100755 index 0000000..b08d441 --- /dev/null +++ b/src/worldgen/TestMapCreator.java @@ -0,0 +1,59 @@ +package worldgen; + +import static sjgs.utils.Utils.COIN_FLIP; +import static sjgs.utils.Utils.loadImage; +import static sjgs.utils.Utils.unpackBlue; +import static sjgs.utils.Utils.unpackGreen; +import static sjgs.utils.Utils.unpackRed; +import java.awt.image.BufferedImage; +import core.Main; +import mobs.scraveller.Scraveller; +import sjgs.utils.data_structures.shapes.Rectangle; +import sjgs.utils.data_structures.vectors.Point2f; +import sjgs.utils.multithreading.Runner; +import tiles.Tile; + +public class TestMapCreator { + + public static void createTestMap() { + + final int TILE_SIZE = Main.TILE_SIZE; + + final BufferedImage map = loadImage("/map.png"); + Main.camera.setLimitsWithRect(0, 0, map.getWidth()*6, map.getHeight()*6); + + for (int i = 0; i < map.getHeight(); i++) { + for (int j = 0; j < map.getWidth(); j++) { + final int col = i, row = j; + new Runner(() -> { + + final int pixel = map.getRGB(col, row); + final int r = unpackRed(pixel); + final int g = unpackGreen(pixel); + final int b = unpackBlue(pixel); + + if(r == 64 && g == 64 && b == 64) new Tile(col * TILE_SIZE, row * TILE_SIZE, TILE_SIZE, TILE_SIZE); + else if(r == 0 && g == 0 && b == 255) Main.player.setLocation(col * TILE_SIZE, row * TILE_SIZE); + else if(r == 255 && g == 0 && b == 0) { + new Tile(col * TILE_SIZE, row * TILE_SIZE, TILE_SIZE, TILE_SIZE); + new Scraveller( new Rectangle( new Point2f(col * TILE_SIZE, row * TILE_SIZE), 2*TILE_SIZE, TILE_SIZE ), COIN_FLIP() ); + } + else if(r == 255 && g == 255 && b == 255) { + new Tile(col * TILE_SIZE, row * TILE_SIZE, TILE_SIZE, TILE_SIZE); + new Scraveller( new Rectangle( new Point2f(col * TILE_SIZE, row * TILE_SIZE), 3*TILE_SIZE, TILE_SIZE ), COIN_FLIP() ); + } + else if(r == 255 && g == 200 && b == 0) { + new Tile(col * TILE_SIZE, row * TILE_SIZE, TILE_SIZE, TILE_SIZE); + new Scraveller( new Rectangle( new Point2f(col * TILE_SIZE, row * TILE_SIZE), TILE_SIZE, TILE_SIZE ), COIN_FLIP() ); + } + + + } ).run(); + + } + } + } + + + +} diff --git a/src/worldgen/WorldGenerator.java b/src/worldgen/WorldGenerator.java new file mode 100755 index 0000000..e9428cb --- /dev/null +++ b/src/worldgen/WorldGenerator.java @@ -0,0 +1,36 @@ +package worldgen; + +import static sjgs.utils.Utils.loadImage; +import core.Main; +import player.Player; +import sjgs.core.Handler; +import sjgs.graphics.backgrounds.Background; +import sjgs.graphics.backgrounds.ParallaxBackground; + +public class WorldGenerator { + + public static ParallaxBackground currentBackground; + + public static void generateWorld() { + Handler.clearAll(); + Main.player = new Player(0, 0); + TestMapCreator.createTestMap(); + + final int startX = 0, startY = 0; + + final Background background = new Background(loadImage("/background.png"), startX, startY, 100, 0, true); + final Background midground = new Background(loadImage("/midground.png"), startX, startY, 50, 100, true); + final Background foreground = new Background(loadImage("/foreground.png"), startX, startY, 80, 0, true); + + + + + currentBackground = new ParallaxBackground(background, midground, foreground); + + + +// currentBackground = new ParallaxBackground(midground); + } + + +} diff --git a/textures/textures/Texture.java b/textures/textures/Texture.java new file mode 100755 index 0000000..17a79e5 --- /dev/null +++ b/textures/textures/Texture.java @@ -0,0 +1,7 @@ +package textures; + +public interface Texture { + + abstract void getTextures(); + +} diff --git a/textures/textures/TextureLoader.java b/textures/textures/TextureLoader.java new file mode 100755 index 0000000..5047581 --- /dev/null +++ b/textures/textures/TextureLoader.java @@ -0,0 +1,25 @@ +package textures; + +import sjgs.utils.multithreading.Runner; +import textures.mobs.ScravellerTextures; +import textures.player.PlayerGunTextures; +import textures.player.PlayerTextures; +import textures.tiles.TileTextures; + +public final class TextureLoader { + + + public static void getTextures() { + // PLAYER STUFF + new Runner(() -> new PlayerTextures().getTextures() ).run(); + new Runner(() -> new PlayerGunTextures().getTextures() ).run(); + + new Runner(() -> new TileTextures().getTextures() ).run(); + //MOBS + new Runner(() -> new ScravellerTextures().getTextures() ).run(); + } + + + + +} diff --git a/textures/textures/mobs/ScravellerTextures.java b/textures/textures/mobs/ScravellerTextures.java new file mode 100755 index 0000000..df03105 --- /dev/null +++ b/textures/textures/mobs/ScravellerTextures.java @@ -0,0 +1,27 @@ +package textures.mobs; + +import static sjgs.utils.Utils.grabSprite; +import static sjgs.utils.Utils.loadImage; +import java.awt.image.BufferedImage; +import sjgs.graphics.Animation; +import textures.Texture; + +public class ScravellerTextures implements Texture { + + public static Animation move, moveFlipped, rotatedRight, rotatedLeft; + + @Override + public void getTextures() { + final int MOVE_SPEED = 15; + final int width = 5, height = 4; + final BufferedImage ss = loadImage("/scraveller.png"); + + move = new Animation(MOVE_SPEED, + grabSprite(ss, 0, 0, width, height), + grabSprite(ss, 1, 0, width, height) + ); + moveFlipped = move.getInverted(); + rotatedRight = move.getRotatedRight(); + rotatedLeft = move.getRotatedLeft(); + } +} diff --git a/textures/textures/player/PlayerGunTextures.java b/textures/textures/player/PlayerGunTextures.java new file mode 100755 index 0000000..c344fa8 --- /dev/null +++ b/textures/textures/player/PlayerGunTextures.java @@ -0,0 +1,34 @@ +package textures.player; + +import static sjgs.utils.Utils.grabSprite; +import static sjgs.utils.Utils.loadImage; +import java.awt.image.BufferedImage; +import sjgs.graphics.Animation; +import textures.Texture; + +public class PlayerGunTextures implements Texture { + + public static Animation default_gun_right, default_gun_left, default_gun_up, default_gun_down; + + @Override + public void getTextures() { + final int default_gun_speed = 2; + final BufferedImage default_gun_ss = loadImage("/default_gun.png"); + final int default_gun_width = 11, default_gun_height = 5; + + default_gun_right = new Animation(default_gun_speed, + grabSprite(default_gun_ss, 0, 0, default_gun_width, default_gun_height), + grabSprite(default_gun_ss, 1, 0, default_gun_width, default_gun_height), + grabSprite(default_gun_ss, 2, 0, default_gun_width, default_gun_height), + grabSprite(default_gun_ss, 3, 0, default_gun_width, default_gun_height), + grabSprite(default_gun_ss, 4, 0, default_gun_width, default_gun_height)); + default_gun_left = default_gun_right.getReverse(); + default_gun_up = default_gun_right.getRotatedLeft(); + default_gun_down = default_gun_right.getRotatedRight(); + } + + + + + +} diff --git a/textures/textures/player/PlayerTextures.java b/textures/textures/player/PlayerTextures.java new file mode 100755 index 0000000..6f3d688 --- /dev/null +++ b/textures/textures/player/PlayerTextures.java @@ -0,0 +1,299 @@ +package textures.player; + +import static sjgs.utils.Utils.grabSprite; +import static sjgs.utils.Utils.loadImage; +import static sjgs.utils.Utils.reverseImage; +import java.awt.image.BufferedImage; +import sjgs.graphics.Animation; +import textures.Texture; + +public class PlayerTextures implements Texture { + + + // ------------------- WHITE EYE ----------------------------------------------------------------- // + public static Animation playerWalkRight, playerWalkLeft, playerIdleLeft, playerIdleRight, + playerLookingUpRunningRight, playerLookingUpRunningLeft, playerLookingUpIdleRight, + playerLookingUpIdleLeft; + public static BufferedImage playerJumpingRight, playerJumpingLeft, playerFallingRight, playerFallingLeft, + playerLookingDownRight, playerLookingDownLeft, playerProneRight, playerProneLeft, playerLookingUpJumpingRight, + playerLookingUpJumpingLeft, playerLookingUpFallingRight, playerLookingUpFallingLeft; + // ------------------ END WHITE EYE -------------------------------------------------------------- // + + // ------------------- GRAY EYE ----------------------------------------------------------------- // + public static Animation GRAYplayerWalkRight, GRAYplayerWalkLeft, GRAYplayerIdleLeft, GRAYplayerIdleRight, + GRAYplayerLookingUpRunningRight, GRAYplayerLookingUpRunningLeft, GRAYplayerLookingUpIdleRight, GRAYplayerLookingUpIdleLeft; + public static BufferedImage GRAYplayerJumpingRight, GRAYplayerJumpingLeft, GRAYplayerFallingRight, GRAYplayerFallingLeft, + GRAYplayerLookingDownRight, GRAYplayerLookingDownLeft, GRAYplayerProneRight, GRAYplayerProneLeft, + GRAYplayerLookingUpJumpingRight, GRAYplayerLookingUpJumpingLeft, GRAYplayerLookingUpFallingRight, + GRAYplayerLookingUpFallingLeft; + // ------------------ END GRAY EYE -------------------------------------------------------------- // + // ------------------- PALE GREEN EYE ----------------------------------------------------------------- // + public static Animation PALE_GREENplayerWalkRight, PALE_GREENplayerWalkLeft, PALE_GREENplayerIdleLeft, PALE_GREENplayerIdleRight, + PALE_GREENplayerLookingUpRunningRight, PALE_GREENplayerLookingUpRunningLeft, PALE_GREENplayerLookingUpIdleRight, PALE_GREENplayerLookingUpIdleLeft; + public static BufferedImage PALE_GREENplayerJumpingRight, PALE_GREENplayerJumpingLeft, PALE_GREENplayerFallingRight, PALE_GREENplayerFallingLeft, + PALE_GREENplayerLookingDownRight, PALE_GREENplayerLookingDownLeft, PALE_GREENplayerProneRight, PALE_GREENplayerProneLeft, + PALE_GREENplayerLookingUpJumpingRight, PALE_GREENplayerLookingUpJumpingLeft, PALE_GREENplayerLookingUpFallingRight, + PALE_GREENplayerLookingUpFallingLeft; + // ------------------ END PALE GREEN EYE -------------------------------------------------------------- // + // ------------------- GREEN EYE ----------------------------------------------------------------- // + public static Animation GREENplayerWalkRight, GREENplayerWalkLeft, GREENplayerIdleLeft, GREENplayerIdleRight, + GREENplayerLookingUpRunningRight, GREENplayerLookingUpRunningLeft, GREENplayerLookingUpIdleRight, GREENplayerLookingUpIdleLeft; + public static BufferedImage GREENplayerJumpingRight, GREENplayerJumpingLeft, GREENplayerFallingRight, GREENplayerFallingLeft, + GREENplayerLookingDownRight, GREENplayerLookingDownLeft, GREENplayerProneRight, GREENplayerProneLeft, + GREENplayerLookingUpJumpingRight, GREENplayerLookingUpJumpingLeft, GREENplayerLookingUpFallingRight, + GREENplayerLookingUpFallingLeft; + // ------------------ END GREEN EYE -------------------------------------------------------------- // + // ------------------- BROWN EYE ----------------------------------------------------------------- // + public static Animation BROWNplayerWalkRight, BROWNplayerWalkLeft, BROWNplayerIdleLeft, BROWNplayerIdleRight, + BROWNplayerLookingUpRunningRight, BROWNplayerLookingUpRunningLeft, BROWNplayerLookingUpIdleRight, BROWNplayerLookingUpIdleLeft; + public static BufferedImage BROWNplayerJumpingRight, BROWNplayerJumpingLeft, BROWNplayerFallingRight, BROWNplayerFallingLeft, + BROWNplayerLookingDownRight, BROWNplayerLookingDownLeft, BROWNplayerProneRight, BROWNplayerProneLeft, + BROWNplayerLookingUpJumpingRight, BROWNplayerLookingUpJumpingLeft, BROWNplayerLookingUpFallingRight, + BROWNplayerLookingUpFallingLeft; + // ------------------ END BROWN EYE -------------------------------------------------------------- // + + + @Override + public void getTextures() { + // WHITE EYE + final int w = 12, h = 12; + final int RUNNING_SPEED = 8, IDLE_SPEED = 20; + BufferedImage ss = loadImage("/Player1.png"); + playerWalkRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 0, w, h), + grabSprite(ss, 1, 0, w, h), + grabSprite(ss, 2, 0, w, h), + grabSprite(ss, 3, 0, w, h) + ); + playerWalkLeft = playerWalkRight.getReverse(); + + playerIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 1, w, h), + grabSprite(ss, 1, 1, w, h) + ); + playerIdleLeft = playerIdleRight.getReverse(); + + playerJumpingRight = grabSprite(ss, 2, 1, w, h); + playerJumpingLeft = reverseImage(playerJumpingRight); + + playerFallingRight = grabSprite(ss, 3, 1, w, h); + playerFallingLeft = reverseImage(playerFallingRight); + + playerLookingUpJumpingRight = grabSprite(ss, 4, 0, w, h); + playerLookingUpJumpingLeft = reverseImage(playerLookingUpJumpingRight); + + playerLookingUpFallingRight = grabSprite(ss, 4, 1, w, h); + playerLookingUpFallingLeft = reverseImage(playerLookingUpFallingRight); + + playerLookingUpIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 2, w, h), + grabSprite(ss, 1, 2, w, h) + ); + playerLookingUpIdleLeft = playerLookingUpIdleRight.getReverse(); + + playerProneRight = grabSprite(ss, 2, 2, w, h); + playerProneLeft = reverseImage(playerProneRight); + + playerLookingDownRight = grabSprite(ss, 3, 2, w, h); + playerLookingDownLeft = reverseImage(playerLookingDownRight); + + playerLookingUpRunningRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 3, w, h), + grabSprite(ss, 1, 3, w, h), + grabSprite(ss, 2, 3, w, h), + grabSprite(ss, 3, 3, w, h) + ); + playerLookingUpRunningLeft = playerLookingUpRunningRight.getReverse(); + + + // GRAY EYE + ss = loadImage("/Player2.png"); + GRAYplayerWalkRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 0, w, h), + grabSprite(ss, 1, 0, w, h), + grabSprite(ss, 2, 0, w, h), + grabSprite(ss, 3, 0, w, h) + ); + GRAYplayerWalkLeft = GRAYplayerWalkRight.getReverse(); + + GRAYplayerIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 1, w, h), + grabSprite(ss, 1, 1, w, h) + ); + GRAYplayerIdleLeft = GRAYplayerIdleRight.getReverse(); + + GRAYplayerJumpingRight = grabSprite(ss, 2, 1, w, h); + GRAYplayerJumpingLeft = reverseImage(GRAYplayerJumpingRight); + + GRAYplayerFallingRight = grabSprite(ss, 3, 1, w, h); + GRAYplayerFallingLeft = reverseImage(GRAYplayerFallingRight); + + GRAYplayerLookingUpJumpingRight = grabSprite(ss, 4, 0, w, h); + GRAYplayerLookingUpJumpingLeft = reverseImage(GRAYplayerLookingUpJumpingRight); + + GRAYplayerLookingUpFallingRight = grabSprite(ss, 4, 1, w, h); + GRAYplayerLookingUpFallingLeft = reverseImage(GRAYplayerLookingUpFallingRight); + + GRAYplayerLookingUpIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 2, w, h), + grabSprite(ss, 1, 2, w, h) + ); + GRAYplayerLookingUpIdleLeft = GRAYplayerLookingUpIdleRight.getReverse(); + + GRAYplayerProneRight = grabSprite(ss, 2, 2, w, h); + GRAYplayerProneLeft = reverseImage(GRAYplayerProneRight); + + GRAYplayerLookingDownRight = grabSprite(ss, 3, 2, w, h); + GRAYplayerLookingDownLeft = reverseImage(GRAYplayerLookingDownRight); + + GRAYplayerLookingUpRunningRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 3, w, h), + grabSprite(ss, 1, 3, w, h), + grabSprite(ss, 2, 3, w, h), + grabSprite(ss, 3, 3, w, h) + ); + GRAYplayerLookingUpRunningLeft = playerLookingUpRunningRight.getReverse(); + // PALE GREEN EYE + ss = loadImage("/Player3.png"); + PALE_GREENplayerWalkRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 0, w, h), + grabSprite(ss, 1, 0, w, h), + grabSprite(ss, 2, 0, w, h), + grabSprite(ss, 3, 0, w, h) + ); + PALE_GREENplayerWalkLeft = PALE_GREENplayerWalkRight.getReverse(); + + PALE_GREENplayerIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 1, w, h), + grabSprite(ss, 1, 1, w, h) + ); + PALE_GREENplayerIdleLeft = PALE_GREENplayerIdleRight.getReverse(); + + PALE_GREENplayerJumpingRight = grabSprite(ss, 2, 1, w, h); + PALE_GREENplayerJumpingLeft = reverseImage(PALE_GREENplayerJumpingRight); + + PALE_GREENplayerFallingRight = grabSprite(ss, 3, 1, w, h); + PALE_GREENplayerFallingLeft = reverseImage(PALE_GREENplayerFallingRight); + + PALE_GREENplayerLookingUpJumpingRight = grabSprite(ss, 4, 0, w, h); + PALE_GREENplayerLookingUpJumpingLeft = reverseImage(PALE_GREENplayerLookingUpJumpingRight); + + PALE_GREENplayerLookingUpFallingRight = grabSprite(ss, 4, 1, w, h); + PALE_GREENplayerLookingUpFallingLeft = reverseImage(PALE_GREENplayerLookingUpFallingRight); + + PALE_GREENplayerLookingUpIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 2, w, h), + grabSprite(ss, 1, 2, w, h) + ); + PALE_GREENplayerLookingUpIdleLeft = PALE_GREENplayerLookingUpIdleRight.getReverse(); + + PALE_GREENplayerProneRight = grabSprite(ss, 2, 2, w, h); + PALE_GREENplayerProneLeft = reverseImage(PALE_GREENplayerProneRight); + + PALE_GREENplayerLookingDownRight = grabSprite(ss, 3, 2, w, h); + PALE_GREENplayerLookingDownLeft = reverseImage(PALE_GREENplayerLookingDownRight); + + PALE_GREENplayerLookingUpRunningRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 3, w, h), + grabSprite(ss, 1, 3, w, h), + grabSprite(ss, 2, 3, w, h), + grabSprite(ss, 3, 3, w, h) + ); + PALE_GREENplayerLookingUpRunningLeft = PALE_GREENplayerLookingUpRunningRight.getReverse(); + // GREEN EYE + ss = loadImage("/Player4.png"); + GREENplayerWalkRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 0, w, h), + grabSprite(ss, 1, 0, w, h), + grabSprite(ss, 2, 0, w, h), + grabSprite(ss, 3, 0, w, h) + ); + GREENplayerWalkLeft = GREENplayerWalkRight.getReverse(); + + GREENplayerIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 1, w, h), + grabSprite(ss, 1, 1, w, h) + ); + GREENplayerIdleLeft = GREENplayerIdleRight.getReverse(); + + GREENplayerJumpingRight = grabSprite(ss, 2, 1, w, h); + GREENplayerJumpingLeft = reverseImage(GREENplayerJumpingRight); + + GREENplayerFallingRight = grabSprite(ss, 3, 1, w, h); + GREENplayerFallingLeft = reverseImage(GREENplayerFallingRight); + + GREENplayerLookingUpJumpingRight = grabSprite(ss, 4, 0, w, h); + GREENplayerLookingUpJumpingLeft = reverseImage(GREENplayerLookingUpJumpingRight); + + GREENplayerLookingUpFallingRight = grabSprite(ss, 4, 1, w, h); + GREENplayerLookingUpFallingLeft = reverseImage(GREENplayerLookingUpFallingRight); + + GREENplayerLookingUpIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 2, w, h), + grabSprite(ss, 1, 2, w, h) + ); + GREENplayerLookingUpIdleLeft = GREENplayerLookingUpIdleRight.getReverse(); + + GREENplayerProneRight = grabSprite(ss, 2, 2, w, h); + GREENplayerProneLeft = reverseImage(GREENplayerProneRight); + + GREENplayerLookingDownRight = grabSprite(ss, 3, 2, w, h); + GREENplayerLookingDownLeft = reverseImage(GREENplayerLookingDownRight); + + GREENplayerLookingUpRunningRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 3, w, h), + grabSprite(ss, 1, 3, w, h), + grabSprite(ss, 2, 3, w, h), + grabSprite(ss, 3, 3, w, h) + ); + GREENplayerLookingUpRunningLeft = GREENplayerLookingUpRunningRight.getReverse(); + // BROWN EYE + ss = loadImage("/Player5.png"); + BROWNplayerWalkRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 0, w, h), + grabSprite(ss, 1, 0, w, h), + grabSprite(ss, 2, 0, w, h), + grabSprite(ss, 3, 0, w, h) + ); + BROWNplayerWalkLeft = BROWNplayerWalkRight.getReverse(); + + BROWNplayerIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 1, w, h), + grabSprite(ss, 1, 1, w, h) + ); + BROWNplayerIdleLeft = BROWNplayerIdleRight.getReverse(); + + BROWNplayerJumpingRight = grabSprite(ss, 2, 1, w, h); + BROWNplayerJumpingLeft = reverseImage(BROWNplayerJumpingRight); + + BROWNplayerFallingRight = grabSprite(ss, 3, 1, w, h); + BROWNplayerFallingLeft = reverseImage(BROWNplayerFallingRight); + + BROWNplayerLookingUpJumpingRight = grabSprite(ss, 4, 0, w, h); + BROWNplayerLookingUpJumpingLeft = reverseImage(BROWNplayerLookingUpJumpingRight); + + BROWNplayerLookingUpFallingRight = grabSprite(ss, 4, 1, w, h); + BROWNplayerLookingUpFallingLeft = reverseImage(BROWNplayerLookingUpFallingRight); + + BROWNplayerLookingUpIdleRight = new Animation(IDLE_SPEED, + grabSprite(ss, 0, 2, w, h), + grabSprite(ss, 1, 2, w, h) + ); + BROWNplayerLookingUpIdleLeft = BROWNplayerLookingUpIdleRight.getReverse(); + + BROWNplayerProneRight = grabSprite(ss, 2, 2, w, h); + BROWNplayerProneLeft = reverseImage(BROWNplayerProneRight); + + BROWNplayerLookingDownRight = grabSprite(ss, 3, 2, w, h); + BROWNplayerLookingDownLeft = reverseImage(BROWNplayerLookingDownRight); + + BROWNplayerLookingUpRunningRight = new Animation(RUNNING_SPEED, + grabSprite(ss, 0, 3, w, h), + grabSprite(ss, 1, 3, w, h), + grabSprite(ss, 2, 3, w, h), + grabSprite(ss, 3, 3, w, h) + ); + BROWNplayerLookingUpRunningLeft = BROWNplayerLookingUpRunningRight.getReverse(); + } + +} diff --git a/textures/textures/tiles/TileTextures.java b/textures/textures/tiles/TileTextures.java new file mode 100755 index 0000000..b62b61d --- /dev/null +++ b/textures/textures/tiles/TileTextures.java @@ -0,0 +1,19 @@ +package textures.tiles; + +import static sjgs.utils.Utils.grabSprite; +import static sjgs.utils.Utils.loadImage; +import java.awt.image.BufferedImage; +import textures.Texture; + +public class TileTextures implements Texture { + + public static BufferedImage tile1; + + @Override + public void getTextures() { + final BufferedImage image = loadImage("/tile.png"); + final int width = 6, height = 6; + tile1 = grabSprite(image, 0, 0, width, height); + } + +}