-
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
0 parents
commit b1532de
Showing
12 changed files
with
446 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
public class Character { | ||
String name; | ||
} |
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,3 @@ | ||
public class Datamgr { | ||
|
||
} |
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,3 @@ | ||
public class Gamemgr { | ||
|
||
} |
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,19 @@ | ||
public class Graphicsmgr { | ||
final boolean isGUI; | ||
public Graphicsmgr(boolean isGUI){ | ||
this.isGUI = isGUI; | ||
} | ||
public void draw(){ | ||
if(isGUI){ | ||
drawGUI(); | ||
}else{ | ||
drawConsole(); | ||
} | ||
} | ||
private void drawGUI(){ | ||
System.out.println("Drawing GUI"); | ||
} | ||
private void drawConsole(){ | ||
System.out.println("Drawing Console"); | ||
} | ||
} |
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,3 @@ | ||
public class Interactable { | ||
|
||
} |
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,48 @@ | ||
public class Main{ | ||
public static void main(String[] args){ | ||
java.io.PrintWriter out = new java.io.PrintWriter(System.out); | ||
Reader in = new Reader(); | ||
out.println("Enter mode:\n1. tile map editor\n2. test tile map and overlay"); | ||
out.flush(); | ||
int mode = 0; | ||
try{mode = in.nextInt();}catch(Exception e){e.printStackTrace();} | ||
if(mode==1){ | ||
Tilemapmgr.makeMap(); | ||
out.print("Enter map name to draw:"); | ||
out.flush(); | ||
try{out.println(Tilemapmgr.draw(in.readLine().strip()));}catch(Exception e){e.printStackTrace();} | ||
}else if(mode==2){ | ||
Tilemapmgr.loadFromImage("test", "C:\\Users\\shunt\\apcs\\CSQuest\\tilemaps\\test.png"); | ||
RenderedMap map=Tilemapmgr.draw("test"); | ||
int x=0, y=0; | ||
String input=""; | ||
OUTER: | ||
while (true) { | ||
map=Tilemapmgr.draw("test"); | ||
map.overlay(new RenderedMap(2, 4, 'X'), x, y); | ||
out.println(map); | ||
out.flush(); | ||
try{input=in.readLine();}catch(Exception e){e.printStackTrace();} | ||
switch (input) { | ||
case "w": | ||
y--; | ||
break; | ||
case "s": | ||
y++; | ||
break; | ||
case "a": | ||
x--; | ||
break; | ||
case "d": | ||
x++; | ||
break; | ||
case "q": | ||
break OUTER; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
out.flush(); | ||
} | ||
} |
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,146 @@ | ||
// Source code is decompiled from a .class file using FernFlower decompiler. | ||
import java.io.DataInputStream; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
|
||
public class Reader { | ||
private final int BUFFER_SIZE = 65536; | ||
private DataInputStream din; | ||
private byte[] buffer; | ||
private int bufferPointer; | ||
private int bytesRead; | ||
|
||
public Reader() { | ||
this.din = new DataInputStream(System.in); | ||
this.buffer = new byte[65536]; | ||
this.bufferPointer = this.bytesRead = 0; | ||
} | ||
|
||
public Reader(String file_name) throws IOException { | ||
this.din = new DataInputStream(new FileInputStream(file_name)); | ||
this.buffer = new byte[65536]; | ||
this.bufferPointer = this.bytesRead = 0; | ||
} | ||
|
||
public String readLine() throws IOException { | ||
byte[] buf = new byte[64]; | ||
int cnt = 0; | ||
|
||
byte c; | ||
while((c = this.read()) != -1) { | ||
if (c == 10) { | ||
if (cnt != 0) { | ||
break; | ||
} | ||
} else { | ||
buf[cnt++] = (byte)c; | ||
} | ||
} | ||
|
||
return new String(buf, 0, cnt - 1); | ||
} | ||
|
||
public String readLine(int bufsize) throws IOException { | ||
byte[] buf = new byte[bufsize]; | ||
int cnt = 0; | ||
|
||
byte c; | ||
while((c = this.read()) != -1) { | ||
if (c == 10) { | ||
if (cnt != 0) { | ||
break; | ||
} | ||
} else { | ||
buf[cnt++] = (byte)c; | ||
} | ||
} | ||
|
||
return new String(buf, 0, cnt - 1); | ||
} | ||
|
||
public int nextInt() throws IOException { | ||
int ret = 0; | ||
|
||
byte c; | ||
for(c = this.read(); c <= 32; c = this.read()) { | ||
} | ||
|
||
boolean neg = c == 45; | ||
if (neg) { | ||
c = this.read(); | ||
} | ||
|
||
do { | ||
ret = ret * 10 + c - 48; | ||
} while((c = this.read()) >= 48 && c <= 57); | ||
|
||
return neg ? -ret : ret; | ||
} | ||
|
||
public long nextLong() throws IOException { | ||
long ret = 0L; | ||
|
||
byte c; | ||
for(c = this.read(); c <= 32; c = this.read()) { | ||
} | ||
|
||
boolean neg = c == 45; | ||
if (neg) { | ||
c = this.read(); | ||
} | ||
|
||
do { | ||
ret = ret * 10L + (long)c - 48L; | ||
} while((c = this.read()) >= 48 && c <= 57); | ||
|
||
return neg ? -ret : ret; | ||
} | ||
|
||
public double nextDouble() throws IOException { | ||
double ret = 0.0; | ||
double div = 1.0; | ||
|
||
byte c; | ||
for(c = this.read(); c <= 32; c = this.read()) { | ||
} | ||
|
||
boolean neg = c == 45; | ||
if (neg) { | ||
c = this.read(); | ||
} | ||
|
||
do { | ||
ret = ret * 10.0 + (double)c - 48.0; | ||
} while((c = this.read()) >= 48 && c <= 57); | ||
|
||
if (c == 46) { | ||
while((c = this.read()) >= 48 && c <= 57) { | ||
ret += (double)(c - 48) / (div *= 10.0); | ||
} | ||
} | ||
|
||
return neg ? -ret : ret; | ||
} | ||
|
||
private void fillBuffer() throws IOException { | ||
this.bytesRead = this.din.read(this.buffer, this.bufferPointer = 0, 65536); | ||
if (this.bytesRead == -1) { | ||
this.buffer[0] = -1; | ||
} | ||
|
||
} | ||
|
||
private byte read() throws IOException { | ||
if (this.bufferPointer == this.bytesRead) { | ||
this.fillBuffer(); | ||
} | ||
|
||
return this.buffer[this.bufferPointer++]; | ||
} | ||
|
||
public void close() throws IOException { | ||
if (this.din != null) { | ||
this.din.close(); | ||
} | ||
} | ||
} |
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,56 @@ | ||
public class RenderedMap { | ||
char[][] map; | ||
public RenderedMap(char[][] map){ | ||
this.map = map; | ||
} | ||
public RenderedMap(int width, int height){ | ||
map = new char[width][height]; | ||
} | ||
public RenderedMap(int width, int height, char c){ | ||
map = new char[height][width]; | ||
for(int x = 0; x < height; x++){ | ||
for(int y = 0; y < width; y++){ | ||
map[x][y] = c; | ||
} | ||
} | ||
} | ||
public void overlay(RenderedMap overlay){ | ||
if(overlay.map.length != map.length || overlay.map[0].length != map[0].length){ | ||
throw new IllegalArgumentException("Overlay must be the same size as the map. If you want to place it in a specific location, use the other overlay method."); | ||
} | ||
for(int x = 0; x < map.length; x++){ | ||
for(int y = 0; y < map[0].length; y++){ | ||
if(overlay.map[x][y] != 0){ | ||
map[x][y] = overlay.map[x][y]; | ||
} | ||
} | ||
} | ||
} | ||
public void overlay(RenderedMap overlay, int x, int y){ | ||
if(overlay.map.length + y > map.length || overlay.map[0].length + x > map[0].length){ | ||
throw new IllegalArgumentException("Overlay must fit within the map."); | ||
} | ||
for(int oy = 0; oy < overlay.map.length; oy++){ | ||
for(int ox = 0; ox < overlay.map[0].length; ox++){ | ||
if(overlay.map[oy][ox] != 0){ | ||
map[y+oy][x+ox] = overlay.map[oy][ox]; | ||
} | ||
} | ||
} | ||
} | ||
@Override | ||
public String toString(){ | ||
String s = ""; | ||
for(char[] row : map){ | ||
for(char c:row){ | ||
s += c; | ||
s += c; | ||
} | ||
s += "\n"; | ||
} | ||
return s; | ||
} | ||
public char get(int x, int y){ | ||
return map[x][y]; | ||
} | ||
} |
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,32 @@ | ||
|
||
public class Tilemap { | ||
public final int[][] tileids; | ||
public final int[][] tiledata; | ||
public Tilemap(int[][] tileids, int[][] tiledata){ | ||
this.tileids = tileids; | ||
this.tiledata = tiledata; | ||
} | ||
public Tilemap(int width, int height){ | ||
tileids = new int[height][width]; | ||
tiledata = new int[height][width]; | ||
} | ||
public Tilemap(int width, int height, int id, int data){ | ||
tileids = new int[height][width]; | ||
tiledata = new int[height][width]; | ||
for(int x = 0; x < height; x++){ | ||
for(int y = 0; y < width; y++){ | ||
tileids[x][y] = id; | ||
tiledata[x][y] = data; | ||
} | ||
} | ||
} | ||
public boolean checkBit(int x, int y, int digit){ | ||
return (tiledata[x][y] & (1 << digit)) != 0; | ||
} | ||
public boolean isWalkable(int x, int y){ | ||
return checkBit(x, y, 0); | ||
} | ||
public boolean isInteractable(int x, int y){ | ||
return checkBit(x, y, 1); | ||
} | ||
} |
Oops, something went wrong.