This commit is contained in:
Tim
2021-06-21 09:46:09 +02:00
commit cf06698621
48 changed files with 619 additions and 0 deletions

15
Zulda/.classpath Normal file
View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-15">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/Engine.Alpha.jar">
<attributes>
<attribute name="javadoc_location" value="https://engine-alpha.org/static/doc/"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>

17
Zulda/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Zulda</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -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

Binary file not shown.

BIN
Zulda/bin/main/Malin.class Normal file

Binary file not shown.

BIN
Zulda/bin/main/Map.class Normal file

Binary file not shown.

BIN
Zulda/bin/main/Player.class Normal file

Binary file not shown.

Binary file not shown.

BIN
Zulda/bin/main/Tile.class Normal file

Binary file not shown.

BIN
Zulda/bin/main/World.class Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
Music by Eric Matyas
http://soundimage.org

BIN
Zulda/lib/Engine.Alpha.jar Normal file

Binary file not shown.

View File

@@ -0,0 +1,8 @@
package main;
public class Launcher {
public static void main(String[] args) {
new Malin();
}
}

34
Zulda/src/main/Malin.java Normal file
View File

@@ -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;
}
}

38
Zulda/src/main/Map.java Normal file
View File

@@ -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(){
//
// }
}

202
Zulda/src/main/Player.java Normal file
View File

@@ -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");
}
}
}
}
}
}

View File

@@ -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;
}
}
}
}

78
Zulda/src/main/Tile.java Normal file
View File

@@ -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();
}
}

21
Zulda/src/main/World.java Normal file
View File

@@ -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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 430 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,2 @@
Music by Eric Matyas
http://soundimage.org