commit cf06698621ee7a069d245938fa72df1e2de2535a Author: Tim Date: Mon Jun 21 09:46:09 2021 +0200 init diff --git a/Zulda/.classpath b/Zulda/.classpath new file mode 100644 index 0000000..922af14 --- /dev/null +++ b/Zulda/.classpath @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/Zulda/.project b/Zulda/.project new file mode 100644 index 0000000..96a4336 --- /dev/null +++ b/Zulda/.project @@ -0,0 +1,17 @@ + + + Zulda + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Zulda/.settings/org.eclipse.jdt.core.prefs b/Zulda/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..24c133d --- /dev/null +++ b/Zulda/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,116 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=15 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=15 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=15 diff --git a/Zulda/bin/main/Launcher.class b/Zulda/bin/main/Launcher.class new file mode 100644 index 0000000..c29d238 Binary files /dev/null and b/Zulda/bin/main/Launcher.class differ diff --git a/Zulda/bin/main/Malin.class b/Zulda/bin/main/Malin.class new file mode 100644 index 0000000..b837b45 Binary files /dev/null and b/Zulda/bin/main/Malin.class differ diff --git a/Zulda/bin/main/Map.class b/Zulda/bin/main/Map.class new file mode 100644 index 0000000..b9be31b Binary files /dev/null and b/Zulda/bin/main/Map.class differ diff --git a/Zulda/bin/main/Player.class b/Zulda/bin/main/Player.class new file mode 100644 index 0000000..879b7d1 Binary files /dev/null and b/Zulda/bin/main/Player.class differ diff --git a/Zulda/bin/main/PlayerSheetLoader.class b/Zulda/bin/main/PlayerSheetLoader.class new file mode 100644 index 0000000..8eb5a06 Binary files /dev/null and b/Zulda/bin/main/PlayerSheetLoader.class differ diff --git a/Zulda/bin/main/Tile.class b/Zulda/bin/main/Tile.class new file mode 100644 index 0000000..dd1397f Binary files /dev/null and b/Zulda/bin/main/Tile.class differ diff --git a/Zulda/bin/main/World.class b/Zulda/bin/main/World.class new file mode 100644 index 0000000..603cb4b Binary files /dev/null and b/Zulda/bin/main/World.class differ diff --git a/Zulda/bin/res/images/monster_1.gif b/Zulda/bin/res/images/monster_1.gif new file mode 100644 index 0000000..c9f7343 Binary files /dev/null and b/Zulda/bin/res/images/monster_1.gif differ diff --git a/Zulda/bin/res/images/player_sprite_sheet.png b/Zulda/bin/res/images/player_sprite_sheet.png new file mode 100644 index 0000000..44cdbe2 Binary files /dev/null and b/Zulda/bin/res/images/player_sprite_sheet.png differ diff --git a/Zulda/bin/res/images/tiles/grass.png b/Zulda/bin/res/images/tiles/grass.png new file mode 100644 index 0000000..aee316b Binary files /dev/null and b/Zulda/bin/res/images/tiles/grass.png differ diff --git a/Zulda/bin/res/images/tiles/stone_floor.png b/Zulda/bin/res/images/tiles/stone_floor.png new file mode 100644 index 0000000..5638a31 Binary files /dev/null and b/Zulda/bin/res/images/tiles/stone_floor.png differ diff --git a/Zulda/bin/res/images/tiles/wall_bottom.png b/Zulda/bin/res/images/tiles/wall_bottom.png new file mode 100644 index 0000000..6316bd4 Binary files /dev/null and b/Zulda/bin/res/images/tiles/wall_bottom.png differ diff --git a/Zulda/bin/res/images/tiles/wall_top.png b/Zulda/bin/res/images/tiles/wall_top.png new file mode 100644 index 0000000..712f9cb Binary files /dev/null and b/Zulda/bin/res/images/tiles/wall_top.png differ diff --git a/Zulda/bin/res/images/trank_grau.png b/Zulda/bin/res/images/trank_grau.png new file mode 100644 index 0000000..d98f33f Binary files /dev/null and b/Zulda/bin/res/images/trank_grau.png differ diff --git a/Zulda/bin/res/images/trank_lila.png b/Zulda/bin/res/images/trank_lila.png new file mode 100644 index 0000000..edc8ac9 Binary files /dev/null and b/Zulda/bin/res/images/trank_lila.png differ diff --git a/Zulda/bin/res/sounds/And-the-Machines-Came-at-Midnight.mp3 b/Zulda/bin/res/sounds/And-the-Machines-Came-at-Midnight.mp3 new file mode 100644 index 0000000..186354e Binary files /dev/null and b/Zulda/bin/res/sounds/And-the-Machines-Came-at-Midnight.mp3 differ diff --git a/Zulda/bin/res/sounds/Blob-Monsters-on-the-Loose.mp3 b/Zulda/bin/res/sounds/Blob-Monsters-on-the-Loose.mp3 new file mode 100644 index 0000000..3c6c355 Binary files /dev/null and b/Zulda/bin/res/sounds/Blob-Monsters-on-the-Loose.mp3 differ diff --git a/Zulda/bin/res/sounds/Game-Menu_v001.mp3 b/Zulda/bin/res/sounds/Game-Menu_v001.mp3 new file mode 100644 index 0000000..21d1158 Binary files /dev/null and b/Zulda/bin/res/sounds/Game-Menu_v001.mp3 differ diff --git a/Zulda/bin/res/sounds/Hypnotic-Puzzle2.mp3 b/Zulda/bin/res/sounds/Hypnotic-Puzzle2.mp3 new file mode 100644 index 0000000..2bde60d Binary files /dev/null and b/Zulda/bin/res/sounds/Hypnotic-Puzzle2.mp3 differ diff --git a/Zulda/bin/res/sounds/Runaway-Food-Truck.mp3 b/Zulda/bin/res/sounds/Runaway-Food-Truck.mp3 new file mode 100644 index 0000000..68ba792 Binary files /dev/null and b/Zulda/bin/res/sounds/Runaway-Food-Truck.mp3 differ diff --git a/Zulda/bin/res/sounds/Water-Balloon-Maniacs.mp3 b/Zulda/bin/res/sounds/Water-Balloon-Maniacs.mp3 new file mode 100644 index 0000000..3bcfe9e Binary files /dev/null and b/Zulda/bin/res/sounds/Water-Balloon-Maniacs.mp3 differ diff --git a/Zulda/bin/res/sounds/lizenz.txt b/Zulda/bin/res/sounds/lizenz.txt new file mode 100644 index 0000000..1f85117 --- /dev/null +++ b/Zulda/bin/res/sounds/lizenz.txt @@ -0,0 +1,2 @@ +Music by Eric Matyas +http://soundimage.org \ No newline at end of file diff --git a/Zulda/lib/Engine.Alpha.jar b/Zulda/lib/Engine.Alpha.jar new file mode 100644 index 0000000..a3d7fc2 Binary files /dev/null and b/Zulda/lib/Engine.Alpha.jar differ diff --git a/Zulda/src/main/Launcher.java b/Zulda/src/main/Launcher.java new file mode 100644 index 0000000..e41419a --- /dev/null +++ b/Zulda/src/main/Launcher.java @@ -0,0 +1,8 @@ +package main; + +public class Launcher { + + public static void main(String[] args) { + new Malin(); + } +} diff --git a/Zulda/src/main/Malin.java b/Zulda/src/main/Malin.java new file mode 100644 index 0000000..64f4a5f --- /dev/null +++ b/Zulda/src/main/Malin.java @@ -0,0 +1,34 @@ +package main; + +import ea.Game; +import ea.Manager; + +public class Malin extends Game { + + private World world; + private Player player; + + public static final int WIDTH = 1440; + public static final int HEIGHT = 1056; + + public Malin() { + super(WIDTH, HEIGHT); + + player = new Player(this); + + world = new World(player); + wurzel.add(world); + + Manager manager = new Manager(); + manager.anmelden(player, 20); + } + + @Override + public void tasteReagieren(int code) { + + } + + public World getWorld() { + return world; + } +} diff --git a/Zulda/src/main/Map.java b/Zulda/src/main/Map.java new file mode 100644 index 0000000..412e603 --- /dev/null +++ b/Zulda/src/main/Map.java @@ -0,0 +1,38 @@ +package main; + +import ea.Knoten; + +public class Map extends Knoten { + + private Tile[][] map; + + public Map() { + map = new Tile[15][11]; + for (int x = 0; x < map.length; x++) { + for (int y = 0; y < map[0].length; y++) { + int id = 0; + if (y == 1 || (x == 7 && y == 7)) { + id = Tile.WALL_BOTTOM; + } + if (y == 0 || y == map[0].length - 1 || x == 0 || x == map.length - 1 || (x == 7 && y == 6)) { + id = Tile.WALL_TOP; + } + map[x][y] = new Tile(id); + map[x][y].setX(x * Tile.getSize()); + map[x][y].setY(y * Tile.getSize()); + add(map[x][y]); + } + } + } + + public Tile getTile(int x, int y) { + if (x >= 0 && x < map.length && y >= 0 && y < map[0].length) { + return map[x][y]; + } + return null; + } + +// public int[][] getCollisionMap(){ +// +// } +} diff --git a/Zulda/src/main/Player.java b/Zulda/src/main/Player.java new file mode 100644 index 0000000..bfa212c --- /dev/null +++ b/Zulda/src/main/Player.java @@ -0,0 +1,202 @@ +package main; + +import ea.ActionFigur; +import ea.Rechteck; +import ea.Taste; +import ea.Ticker; + +public class Player extends ActionFigur implements Ticker { + + private Malin main; + private static PlayerSheetLoader loader = new PlayerSheetLoader(); + private boolean side; + + private float velX, velY; + private int oldPosX, oldPosY; + private float accelleration = 0.15f; + private float friction = 0.2f; + private Rechteck hitBox = new Rechteck(0, 0, 0, 0); + + public Player(Malin main) { + super(loader.getPlayer(0), "idle_left"); + this.main = main; + + neuerZustand(loader.getPlayer(1), "idle_right"); + neuerZustand(loader.getPlayer(2), "walk_left"); + neuerZustand(loader.getPlayer(3), "walk_right"); + neuerZustand(loader.getPlayer(4), "strike_left"); + neuerZustand(loader.getPlayer(5), "strike_right"); + neuerZustand(loader.getPlayer(6), "swipe_left"); + neuerZustand(loader.getPlayer(7), "swipe_right"); + neuerZustand(loader.getPlayer(8), "die"); + + loader.getPlayer(0).animationsGeschwindigkeitSetzen(200); + loader.getPlayer(1).animationsGeschwindigkeitSetzen(200); + loader.getPlayer(2).animationsGeschwindigkeitSetzen(50); + loader.getPlayer(3).animationsGeschwindigkeitSetzen(50); + + positionSetzen(Tile.getSize() * 2, Tile.getSize() * 2); + } + + @Override + public void tick() { + + if (!((aktuellesVerhalten() == "strike_left" || aktuellesVerhalten() == "strike_right") + && aktuelleFigur().aktuellesBild() < aktuelleFigur().animation().length - 1)) { + + if (main.tasteGedrueckt(Taste.W)) { + velY -= World.SCALE * accelleration; + } + if (main.tasteGedrueckt(Taste.S)) { + velY += World.SCALE * accelleration; + } + if (main.tasteGedrueckt(Taste.A)) { + velX -= World.SCALE * accelleration; + side = false; + } + if (main.tasteGedrueckt(Taste.D)) { + velX += World.SCALE * accelleration; + side = true; + } + + setX(getX() + velX); + setY(getY() + velY); + velX *= (1f - friction); + velY *= (1f - friction); + if (velX < 0.2f && velX > -0.2f) { + velX = 0f; + } + if (velY < 0.2f && velY > -0.2f) { + velY = 0f; + } + + hitBox.positionSetzen(positionX() + 103, positionY() + 35); + hitBox.breiteSetzen(50); + hitBox.hoeheSetzen(80); + + final int xOffset = hitBox.positionX() - positionX(); + final int yOffset = hitBox.positionY() - positionY(); + int tileX, tileY; + Tile t; + // collision left + if (hitBox.positionX() - oldPosX < 0) { + tileX = hitBox.positionX() / Tile.getSize(); + tileY = hitBox.positionY() / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velX = 0; + int x = t.getRight() - xOffset; + oldPosX = x; + positionSetzen(x, positionY()); + } + tileX = hitBox.positionX() / Tile.getSize(); + tileY = (int) (hitBox.positionY() + hitBox.getHoehe()) / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velX = 0; + int x = t.getRight() - xOffset; + oldPosX = x; + positionSetzen(x, positionY()); + } + } + // collision right + if (hitBox.positionX() - oldPosX > 0) { + tileX = (int) (hitBox.positionX() + hitBox.getBreite()) / Tile.getSize(); + tileY = hitBox.positionY() / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velX = 0; + int x = t.getLeft() - xOffset - (int) hitBox.getBreite(); + oldPosX = x; + positionSetzen(x, positionY()); + } + tileX = (int) (hitBox.positionX() + hitBox.getBreite()) / Tile.getSize(); + tileY = (int) (hitBox.positionY() + hitBox.getHoehe()) / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velX = 0; + int x = t.getLeft() - xOffset - (int) hitBox.getBreite(); + oldPosX = x; + positionSetzen(x, positionY()); + } + } + // collision top + if (hitBox.positionY() - oldPosY < 0) { + tileX = hitBox.positionX() / Tile.getSize(); + tileY = hitBox.positionY() / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velY = 0; + int y = t.getBottom() - yOffset; + oldPosY = y; + positionSetzen(positionX(), y); + } + tileX = (int) (hitBox.positionX() + hitBox.getBreite()) / Tile.getSize(); + tileY = hitBox.positionY() / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velY = 0; + int y = t.getBottom() - yOffset; + oldPosY = y; + positionSetzen(positionX(), y); + } + } + // collision bottom + if (hitBox.positionY() - oldPosY > 0) { + tileX = hitBox.positionX() / Tile.getSize(); + tileY = (int) (hitBox.positionY() + hitBox.getHoehe()) / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velY = 0; + int y = t.getTop() - (int) hitBox.getHoehe() - yOffset; + oldPosY = y; + positionSetzen(positionX(), y); + } + tileX = (int) (hitBox.positionX() + hitBox.getBreite()) / Tile.getSize(); + tileY = (int) (hitBox.positionY() + hitBox.getHoehe()) / Tile.getSize(); + t = main.getWorld().getCurrentMap().getTile(tileX, tileY); + if (t != null && t.isCollidable()) { + velY = 0; + int y = t.getTop() - (int) hitBox.getHoehe() - yOffset; + oldPosY = y; + positionSetzen(positionX(), y); + } + } + + oldPosX = hitBox.positionX(); + oldPosY = hitBox.positionY(); + + if (!((aktuellesVerhalten() == "swipe_left" || aktuellesVerhalten() == "swipe_right") + && aktuelleFigur().aktuellesBild() < aktuelleFigur().animation().length - 1)) { + if (velX == 0 && velY == 0) { + if (side) { + zustandSetzen("idle_right"); + } else { + zustandSetzen("idle_left"); + } + } else { + if (side) { + zustandSetzen("walk_right"); + } else { + zustandSetzen("walk_left"); + } + } + + if (main.tasteGedrueckt(Taste.LEERTASTE)) { + if (side) { + zustandSetzen("swipe_right"); + } else { + zustandSetzen("swipe_left"); + } + } + if (main.tasteGedrueckt(Taste.Q)) { + if (side) { + zustandSetzen("strike_right"); + } else { + zustandSetzen("strike_left"); + } + } + } + } + } +} diff --git a/Zulda/src/main/PlayerSheetLoader.java b/Zulda/src/main/PlayerSheetLoader.java new file mode 100644 index 0000000..f386c34 --- /dev/null +++ b/Zulda/src/main/PlayerSheetLoader.java @@ -0,0 +1,86 @@ +package main; + +import java.awt.Color; +import java.awt.image.BufferedImage; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import ea.Figur; +import ea.internal.gra.PixelFeld; + +public class PlayerSheetLoader { + + private static Figur[] player; + + private static final float SCALE_DIV = 1.5f; + + public PlayerSheetLoader() { + try { + BufferedImage sheet = ImageIO.read(Tile.class.getResourceAsStream("/res/images/player_sprite_sheet.png")); + + PixelFeld[][] sprites = new PixelFeld[9][]; + sprites[0] = new PixelFeld[5]; + sprites[1] = new PixelFeld[5]; + sprites[2] = new PixelFeld[8]; + sprites[3] = new PixelFeld[8]; + sprites[4] = new PixelFeld[7]; + sprites[5] = new PixelFeld[7]; + sprites[6] = new PixelFeld[6]; + sprites[7] = new PixelFeld[6]; + sprites[8] = new PixelFeld[7]; + + loadSprites(sprites[0], 0, 64, 32, sheet, true); + loadSprites(sprites[1], 0, 64, 32, sheet, false); + loadSprites(sprites[2], 1, 64, 32, sheet, true); + loadSprites(sprites[3], 1, 64, 32, sheet, false); + loadSprites(sprites[4], 2, 64, 32, sheet, true); + loadSprites(sprites[5], 2, 64, 32, sheet, false); + loadSprites(sprites[6], 3, 64, 32, sheet, true); + loadSprites(sprites[7], 3, 64, 32, sheet, false); + loadSprites(sprites[8], 7, 64, 32, sheet, false); + + Figur fig; + player = new Figur[9]; + for (int i = 0; i < player.length; i++) { + fig = new Figur(); + fig.animationSetzen(sprites[i]); + player[i] = fig; + } + + } catch (IOException e) { + e.printStackTrace(); + } + } + + public Figur getPlayer(int y) { + return player[y]; + } + + private void loadSprites(PixelFeld[] sprites, int row, int w, int h, BufferedImage sheet, boolean reverse) { + for (int s = 0; s < sprites.length; s++) { + sprites[s] = new PixelFeld(w * (int) (World.SCALE / SCALE_DIV), h * (int) (World.SCALE / SCALE_DIV), 1); + for (int x = 0; x < w; x++) { + for (int y = 0; y < h; y++) { + Color clr = new Color(sheet.getRGB((s * w + x), (row * h + y)), true); + if (clr.getAlpha() > 0) { + for (int i = 0; i < World.SCALE / SCALE_DIV; i++) { + for (int j = 0; j < World.SCALE / SCALE_DIV; j++) { + sprites[s].farbeSetzen(x * (int) (World.SCALE / SCALE_DIV) + i, y * (int) (World.SCALE / SCALE_DIV) + j, clr); + } + } + } + } + } + if (reverse) { + PixelFeld copy = new PixelFeld(sprites[s].breite(), sprites[s].hoehe(), 1); + for (int x = 0; x < sprites[s].breite(); x++) { + for (int y = 0; y < sprites[s].hoehe(); y++) { + copy.farbeSetzen(sprites[s].breite() - x - 1, y, sprites[s].getPic()[x][y]); + } + } + sprites[s] = copy; + } + } + } +} diff --git a/Zulda/src/main/Tile.java b/Zulda/src/main/Tile.java new file mode 100644 index 0000000..b8f1882 --- /dev/null +++ b/Zulda/src/main/Tile.java @@ -0,0 +1,78 @@ +package main; + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImage; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import ea.Bild; +import ea.Knoten; + +public class Tile extends Knoten { + + public static final int GRASS = 0; + public static final int WALL_TOP = 1; + public static final int WALL_BOTTOM = 2; + + private Bild img; + private int id; + + public Tile(int id) { + this.id = id; + try { + BufferedImage buff = ImageIO.read(Tile.class.getResourceAsStream(getPathFromId(id))); + if (id == GRASS) { + buff = buff.getSubimage(16 * (int) (Math.random() * 8), 0, 16, 16); + } + BufferedImage after = new BufferedImage(buff.getWidth() * World.SCALE, buff.getHeight() * World.SCALE, BufferedImage.TYPE_INT_ARGB); + AffineTransform at = new AffineTransform(); + at.scale(World.SCALE, World.SCALE); + AffineTransformOp scaleOp = new AffineTransformOp(at, AffineTransformOp.TYPE_NEAREST_NEIGHBOR); + after = scaleOp.filter(buff, after); + int x = 0; + int y = 0; + img = new Bild(x, y, after); + } catch (IOException e) { + e.printStackTrace(); + } + add(img); + } + + private String getPathFromId(int id) { + switch (id) { + case GRASS: + return "/res/images/tiles/grass.png"; + case WALL_TOP: + return "/res/images/tiles/wall_top.png"; + case WALL_BOTTOM: + return "/res/images/tiles/wall_bottom.png"; + } + return null; + } + + public static int getSize() { + return 16 * World.SCALE; + } + + public boolean isCollidable() { + return id == WALL_TOP; + } + + public int getTop() { + return positionY(); + } + + public int getBottom() { + return positionY() + getSize(); + } + + public int getLeft() { + return positionX(); + } + + public int getRight() { + return positionX() + getSize(); + } +} diff --git a/Zulda/src/main/World.java b/Zulda/src/main/World.java new file mode 100644 index 0000000..15ad62c --- /dev/null +++ b/Zulda/src/main/World.java @@ -0,0 +1,21 @@ +package main; + +import ea.Knoten; + +public class World extends Knoten { + + public static final int SCALE = 3; + + private Map currentMap; + + public World(Player player) { + + currentMap = new Map(); + add(currentMap); + add(player); + } + + public Map getCurrentMap() { + return currentMap; + } +} diff --git a/Zulda/src/res/images/monster_1.gif b/Zulda/src/res/images/monster_1.gif new file mode 100644 index 0000000..c9f7343 Binary files /dev/null and b/Zulda/src/res/images/monster_1.gif differ diff --git a/Zulda/src/res/images/player_sprite_sheet.png b/Zulda/src/res/images/player_sprite_sheet.png new file mode 100644 index 0000000..44cdbe2 Binary files /dev/null and b/Zulda/src/res/images/player_sprite_sheet.png differ diff --git a/Zulda/src/res/images/tiles/grass.png b/Zulda/src/res/images/tiles/grass.png new file mode 100644 index 0000000..aee316b Binary files /dev/null and b/Zulda/src/res/images/tiles/grass.png differ diff --git a/Zulda/src/res/images/tiles/stone_floor.png b/Zulda/src/res/images/tiles/stone_floor.png new file mode 100644 index 0000000..5638a31 Binary files /dev/null and b/Zulda/src/res/images/tiles/stone_floor.png differ diff --git a/Zulda/src/res/images/tiles/wall_bottom.png b/Zulda/src/res/images/tiles/wall_bottom.png new file mode 100644 index 0000000..6316bd4 Binary files /dev/null and b/Zulda/src/res/images/tiles/wall_bottom.png differ diff --git a/Zulda/src/res/images/tiles/wall_top.png b/Zulda/src/res/images/tiles/wall_top.png new file mode 100644 index 0000000..712f9cb Binary files /dev/null and b/Zulda/src/res/images/tiles/wall_top.png differ diff --git a/Zulda/src/res/images/trank_grau.png b/Zulda/src/res/images/trank_grau.png new file mode 100644 index 0000000..d98f33f Binary files /dev/null and b/Zulda/src/res/images/trank_grau.png differ diff --git a/Zulda/src/res/images/trank_lila.png b/Zulda/src/res/images/trank_lila.png new file mode 100644 index 0000000..edc8ac9 Binary files /dev/null and b/Zulda/src/res/images/trank_lila.png differ diff --git a/Zulda/src/res/sounds/And-the-Machines-Came-at-Midnight.mp3 b/Zulda/src/res/sounds/And-the-Machines-Came-at-Midnight.mp3 new file mode 100644 index 0000000..186354e Binary files /dev/null and b/Zulda/src/res/sounds/And-the-Machines-Came-at-Midnight.mp3 differ diff --git a/Zulda/src/res/sounds/Blob-Monsters-on-the-Loose.mp3 b/Zulda/src/res/sounds/Blob-Monsters-on-the-Loose.mp3 new file mode 100644 index 0000000..3c6c355 Binary files /dev/null and b/Zulda/src/res/sounds/Blob-Monsters-on-the-Loose.mp3 differ diff --git a/Zulda/src/res/sounds/Game-Menu_v001.mp3 b/Zulda/src/res/sounds/Game-Menu_v001.mp3 new file mode 100644 index 0000000..21d1158 Binary files /dev/null and b/Zulda/src/res/sounds/Game-Menu_v001.mp3 differ diff --git a/Zulda/src/res/sounds/Hypnotic-Puzzle2.mp3 b/Zulda/src/res/sounds/Hypnotic-Puzzle2.mp3 new file mode 100644 index 0000000..2bde60d Binary files /dev/null and b/Zulda/src/res/sounds/Hypnotic-Puzzle2.mp3 differ diff --git a/Zulda/src/res/sounds/Runaway-Food-Truck.mp3 b/Zulda/src/res/sounds/Runaway-Food-Truck.mp3 new file mode 100644 index 0000000..68ba792 Binary files /dev/null and b/Zulda/src/res/sounds/Runaway-Food-Truck.mp3 differ diff --git a/Zulda/src/res/sounds/Water-Balloon-Maniacs.mp3 b/Zulda/src/res/sounds/Water-Balloon-Maniacs.mp3 new file mode 100644 index 0000000..3bcfe9e Binary files /dev/null and b/Zulda/src/res/sounds/Water-Balloon-Maniacs.mp3 differ diff --git a/Zulda/src/res/sounds/lizenz.txt b/Zulda/src/res/sounds/lizenz.txt new file mode 100644 index 0000000..1f85117 --- /dev/null +++ b/Zulda/src/res/sounds/lizenz.txt @@ -0,0 +1,2 @@ +Music by Eric Matyas +http://soundimage.org \ No newline at end of file