-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
176 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module software.onepiece.javarcade.inhabitant.floor { | ||
requires transitive software.onepiece.javarcade.model; | ||
|
||
exports software.onepiece.javarcade.inhabitant.floor; | ||
|
||
provides software.onepiece.javarcade.model.Inhabitant | ||
with software.onepiece.javarcade.inhabitant.floor.Floor; | ||
} |
17 changes: 17 additions & 0 deletions
17
inhabitant-floor/src/main/java/software/onepiece/javarcade/inhabitant/floor/Floor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package software.onepiece.javarcade.inhabitant.floor; | ||
|
||
import software.onepiece.javarcade.model.Inhabitant; | ||
|
||
import java.io.InputStream; | ||
|
||
public class Floor implements Inhabitant { | ||
@Override | ||
public char getRef() { | ||
return 'x'; | ||
} | ||
|
||
@Override | ||
public InputStream getImage() { | ||
return getClass().getResourceAsStream("assets/floor.png"); | ||
} | ||
} |
Binary file added
BIN
+143 Bytes
...rc/main/resources/software/onepiece/javarcade/inhabitant/floor/assets/floor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module software.onepiece.javarcade.level.classic { | ||
requires transitive software.onepiece.javarcade.model; | ||
|
||
exports software.onepiece.javarcade.level.classic; | ||
|
||
provides software.onepiece.javarcade.model.Level | ||
with software.onepiece.javarcade.level.classic.ClassicLevel; | ||
} |
25 changes: 25 additions & 0 deletions
25
level-classic/src/main/java/software/onepiece/javarcade/level/classic/ClassicLevel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package software.onepiece.javarcade.level.classic; | ||
|
||
import software.onepiece.javarcade.model.Level; | ||
|
||
public class ClassicLevel extends Level { | ||
@Override | ||
protected String define() { | ||
return """ | ||
.............. | ||
.xx.xxxxxx.xx. | ||
.x..........x. | ||
.x.xxxxxxxx.x. | ||
.x.xxxxxxxx.x. | ||
.x.xx....xx.x. | ||
.x.xx.xx.xx.x. | ||
.x.xx.xx.xx.x. | ||
.x.xx....xx.x. | ||
.x.xxxxxxxx.x. | ||
.x.xxxxxxxx.x. | ||
.x..........x. | ||
.xx.xxxxxx.xx. | ||
.............. | ||
"""; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
model/src/main/java/software/onepiece/javarcade/model/Inhabitant.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package software.onepiece.javarcade.model; | ||
|
||
import java.io.InputStream; | ||
|
||
public interface Inhabitant { | ||
Inhabitant EMPTY = new Inhabitant() { | ||
@Override | ||
public char getRef() { | ||
return ' '; | ||
} | ||
|
||
@Override | ||
public InputStream getImage() { | ||
return null; | ||
} | ||
}; | ||
|
||
char getRef(); | ||
|
||
InputStream getImage(); | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
model/src/main/java/software/onepiece/javarcade/model/Level.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package software.onepiece.javarcade.model; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
public abstract class Level { | ||
|
||
protected abstract String define(); | ||
|
||
public List<Spot> render() { | ||
List<Integer> symbols = Arrays.stream(define().split("\n")).flatMap(line -> line.chars().boxed()).toList(); | ||
|
||
return IntStream.range(0, Spot.MATRIX_WIDTH * Spot.MATRIX_HEIGHT).mapToObj(p -> new Spot( | ||
p < symbols.size() ? (char) symbols.get(p).intValue() : ' ', p) | ||
).collect(Collectors.toList()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters