v9
25
.VSCodeCounter/2023-11-19_20-17-30/details.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Details
|
||||
|
||||
Date : 2023-11-19 20:17:30
|
||||
|
||||
Directory c:\\Users\\User\\Documents\\My Programs\\Java\\Trident\\src
|
||||
|
||||
Total : 10 files, 1396 codes, 11 comments, 109 blanks, all 1516 lines
|
||||
|
||||
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
|
||||
## Files
|
||||
| filename | language | code | comment | blank | total |
|
||||
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||
| [src/main/Main.java](/src/main/Main.java) | Java | 202 | 2 | 16 | 220 |
|
||||
| [src/main/MainPanel.java](/src/main/MainPanel.java) | Java | 48 | 1 | 19 | 68 |
|
||||
| [src/project/Project.java](/src/project/Project.java) | Java | 849 | 8 | 21 | 878 |
|
||||
| [src/project/Scene.java](/src/project/Scene.java) | Java | 118 | 0 | 6 | 124 |
|
||||
| [src/project/TridEntity.java](/src/project/TridEntity.java) | Java | 52 | 0 | 14 | 66 |
|
||||
| [src/project/ent/BoxColl.java](/src/project/ent/BoxColl.java) | Java | 30 | 0 | 8 | 38 |
|
||||
| [src/project/ent/BoxNoColl.java](/src/project/ent/BoxNoColl.java) | Java | 38 | 0 | 8 | 46 |
|
||||
| [src/project/ent/CustomEntity.java](/src/project/ent/CustomEntity.java) | Java | 14 | 0 | 4 | 18 |
|
||||
| [src/project/ent/InvisColl.java](/src/project/ent/InvisColl.java) | Java | 24 | 0 | 7 | 31 |
|
||||
| [src/project/ent/PlrStart.java](/src/project/ent/PlrStart.java) | Java | 21 | 0 | 6 | 27 |
|
||||
|
||||
[Summary](results.md) / Details / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
15
.VSCodeCounter/2023-11-19_20-17-30/diff-details.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
# Diff Details
|
||||
|
||||
Date : 2023-11-19 20:17:30
|
||||
|
||||
Directory c:\\Users\\User\\Documents\\My Programs\\Java\\Trident\\src
|
||||
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
||||
|
||||
## Files
|
||||
| filename | language | code | comment | blank | total |
|
||||
| :--- | :--- | ---: | ---: | ---: | ---: |
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / [Diff Summary](diff.md) / Diff Details
|
2
.VSCodeCounter/2023-11-19_20-17-30/diff.csv
Normal file
|
@ -0,0 +1,2 @@
|
|||
"filename", "language", "", "comment", "blank", "total"
|
||||
"Total", "-", , 0, 0, 0
|
|
19
.VSCodeCounter/2023-11-19_20-17-30/diff.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Diff Summary
|
||||
|
||||
Date : 2023-11-19 20:17:30
|
||||
|
||||
Directory c:\\Users\\User\\Documents\\My Programs\\Java\\Trident\\src
|
||||
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
||||
|
||||
## Languages
|
||||
| language | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
|
||||
## Directories
|
||||
| path | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
|
||||
[Summary](results.md) / [Details](details.md) / Diff Summary / [Diff Details](diff-details.md)
|
22
.VSCodeCounter/2023-11-19_20-17-30/diff.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
Date : 2023-11-19 20:17:30
|
||||
Directory : c:\Users\User\Documents\My Programs\Java\Trident\src
|
||||
Total : 0 files, 0 codes, 0 comments, 0 blanks, all 0 lines
|
||||
|
||||
Languages
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| language | files | code | comment | blank | total |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
|
||||
Directories
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
| path | files | code | comment | blank | total |
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
+------+------------+------------+------------+------------+------------+
|
||||
|
||||
Files
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
| filename | language | code | comment | blank | total |
|
||||
+----------+----------+------------+------------+------------+------------+
|
||||
| Total | | 0 | 0 | 0 | 0 |
|
||||
+----------+----------+------------+------------+------------+------------+
|
12
.VSCodeCounter/2023-11-19_20-17-30/results.csv
Normal file
|
@ -0,0 +1,12 @@
|
|||
"filename", "language", "Java", "comment", "blank", "total"
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\main\Main.java", "Java", 202, 2, 16, 220
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\main\MainPanel.java", "Java", 48, 1, 19, 68
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\Project.java", "Java", 849, 8, 21, 878
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\Scene.java", "Java", 118, 0, 6, 124
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\TridEntity.java", "Java", 52, 0, 14, 66
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\BoxColl.java", "Java", 30, 0, 8, 38
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\BoxNoColl.java", "Java", 38, 0, 8, 46
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\CustomEntity.java", "Java", 14, 0, 4, 18
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\InvisColl.java", "Java", 24, 0, 7, 31
|
||||
"c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\PlrStart.java", "Java", 21, 0, 6, 27
|
||||
"Total", "-", 1396, 11, 109, 1516
|
|
1
.VSCodeCounter/2023-11-19_20-17-30/results.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/Scene.java":{"language":"Java","code":118,"comment":0,"blank":6},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/TridEntity.java":{"language":"Java","code":52,"comment":0,"blank":14},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/ent/PlrStart.java":{"language":"Java","code":21,"comment":0,"blank":6},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/Project.java":{"language":"Java","code":849,"comment":8,"blank":21},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/ent/InvisColl.java":{"language":"Java","code":24,"comment":0,"blank":7},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/ent/CustomEntity.java":{"language":"Java","code":14,"comment":0,"blank":4},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/ent/BoxNoColl.java":{"language":"Java","code":38,"comment":0,"blank":8},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/project/ent/BoxColl.java":{"language":"Java","code":30,"comment":0,"blank":8},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/main/MainPanel.java":{"language":"Java","code":48,"comment":1,"blank":19},"file:///c%3A/Users/User/Documents/My%20Programs/Java/Trident/src/main/Main.java":{"language":"Java","code":202,"comment":2,"blank":16}}
|
25
.VSCodeCounter/2023-11-19_20-17-30/results.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Summary
|
||||
|
||||
Date : 2023-11-19 20:17:30
|
||||
|
||||
Directory c:\\Users\\User\\Documents\\My Programs\\Java\\Trident\\src
|
||||
|
||||
Total : 10 files, 1396 codes, 11 comments, 109 blanks, all 1516 lines
|
||||
|
||||
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
||||
|
||||
## Languages
|
||||
| language | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| Java | 10 | 1,396 | 11 | 109 | 1,516 |
|
||||
|
||||
## Directories
|
||||
| path | files | code | comment | blank | total |
|
||||
| :--- | ---: | ---: | ---: | ---: | ---: |
|
||||
| . | 10 | 1,396 | 11 | 109 | 1,516 |
|
||||
| main | 2 | 250 | 3 | 35 | 288 |
|
||||
| project | 8 | 1,146 | 8 | 74 | 1,228 |
|
||||
| project (Files) | 3 | 1,019 | 8 | 41 | 1,068 |
|
||||
| project\\ent | 5 | 127 | 0 | 33 | 160 |
|
||||
|
||||
Summary / [Details](details.md) / [Diff Summary](diff.md) / [Diff Details](diff-details.md)
|
38
.VSCodeCounter/2023-11-19_20-17-30/results.txt
Normal file
|
@ -0,0 +1,38 @@
|
|||
Date : 2023-11-19 20:17:30
|
||||
Directory : c:\Users\User\Documents\My Programs\Java\Trident\src
|
||||
Total : 10 files, 1396 codes, 11 comments, 109 blanks, all 1516 lines
|
||||
|
||||
Languages
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| language | files | code | comment | blank | total |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
| Java | 10 | 1,396 | 11 | 109 | 1,516 |
|
||||
+----------+------------+------------+------------+------------+------------+
|
||||
|
||||
Directories
|
||||
+------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
| path | files | code | comment | blank | total |
|
||||
+------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
| . | 10 | 1,396 | 11 | 109 | 1,516 |
|
||||
| main | 2 | 250 | 3 | 35 | 288 |
|
||||
| project | 8 | 1,146 | 8 | 74 | 1,228 |
|
||||
| project (Files) | 3 | 1,019 | 8 | 41 | 1,068 |
|
||||
| project\ent | 5 | 127 | 0 | 33 | 160 |
|
||||
+------------------------------------------------------------------------------------+------------+------------+------------+------------+------------+
|
||||
|
||||
Files
|
||||
+------------------------------------------------------------------------------------+----------+------------+------------+------------+------------+
|
||||
| filename | language | code | comment | blank | total |
|
||||
+------------------------------------------------------------------------------------+----------+------------+------------+------------+------------+
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\main\Main.java | Java | 202 | 2 | 16 | 220 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\main\MainPanel.java | Java | 48 | 1 | 19 | 68 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\Project.java | Java | 849 | 8 | 21 | 878 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\Scene.java | Java | 118 | 0 | 6 | 124 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\TridEntity.java | Java | 52 | 0 | 14 | 66 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\BoxColl.java | Java | 30 | 0 | 8 | 38 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\BoxNoColl.java | Java | 38 | 0 | 8 | 46 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\CustomEntity.java | Java | 14 | 0 | 4 | 18 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\InvisColl.java | Java | 24 | 0 | 7 | 31 |
|
||||
| c:\Users\User\Documents\My Programs\Java\Trident\src\project\ent\PlrStart.java | Java | 21 | 0 | 6 | 27 |
|
||||
| Total | | 1,396 | 11 | 109 | 1,516 |
|
||||
+------------------------------------------------------------------------------------+----------+------------+------------+------------+------------+
|
7
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
BIN
bin/main/Main$1.class
Normal file
BIN
bin/main/Main$2.class
Normal file
BIN
bin/main/Main$3.class
Normal file
BIN
bin/main/Main$4.class
Normal file
BIN
bin/main/Main$5.class
Normal file
BIN
bin/main/Main$6.class
Normal file
BIN
bin/main/Main$7.class
Normal file
BIN
bin/main/Main$8.class
Normal file
BIN
bin/main/Main.class
Normal file
BIN
bin/main/MainPanel$InputListener.class
Normal file
BIN
bin/main/MainPanel$ServerListener.class
Normal file
BIN
bin/main/MainPanel.class
Normal file
BIN
bin/project/Project.class
Normal file
BIN
bin/project/Scene.class
Normal file
BIN
bin/project/TridEntity.class
Normal file
BIN
bin/project/ent/BoxColl.class
Normal file
BIN
bin/project/ent/BoxNoColl.class
Normal file
BIN
bin/project/ent/CustomEntity.class
Normal file
BIN
bin/project/ent/InvisColl.class
Normal file
BIN
bin/project/ent/Light.class
Normal file
BIN
bin/project/ent/PlrStart.class
Normal file
BIN
bin/project/ent/Trigger.class
Normal file
BIN
data/icon.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
data/images/crosshair.png
Normal file
After Width: | Height: | Size: 111 B |
BIN
data/images/cursors/move.png
Normal file
After Width: | Height: | Size: 387 B |
BIN
data/images/cursors/resize.png
Normal file
After Width: | Height: | Size: 417 B |
BIN
data/images/cursors/select.png
Normal file
After Width: | Height: | Size: 351 B |
BIN
data/images/dropdown/box.png
Normal file
After Width: | Height: | Size: 366 B |
BIN
data/images/dropdown/boxColl.png
Normal file
After Width: | Height: | Size: 366 B |
BIN
data/images/dropdown/collision.png
Normal file
After Width: | Height: | Size: 222 B |
BIN
data/images/dropdown/customEnt.png
Normal file
After Width: | Height: | Size: 399 B |
BIN
data/images/dropdown/delete.png
Normal file
After Width: | Height: | Size: 252 B |
BIN
data/images/dropdown/duplicate.png
Normal file
After Width: | Height: | Size: 189 B |
BIN
data/images/dropdown/edit.png
Normal file
After Width: | Height: | Size: 192 B |
BIN
data/images/dropdown/light.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
data/images/dropdown/move.png
Normal file
After Width: | Height: | Size: 153 B |
BIN
data/images/dropdown/plrStart.png
Normal file
After Width: | Height: | Size: 309 B |
BIN
data/images/dropdown/quit.png
Normal file
After Width: | Height: | Size: 225 B |
BIN
data/images/dropdown/reset.png
Normal file
After Width: | Height: | Size: 228 B |
BIN
data/images/dropdown/resize.png
Normal file
After Width: | Height: | Size: 177 B |
BIN
data/images/dropdown/select.png
Normal file
After Width: | Height: | Size: 222 B |
BIN
data/images/dropdown/trigger.png
Normal file
After Width: | Height: | Size: 222 B |
BIN
data/images/player/idleE.png
Normal file
After Width: | Height: | Size: 156 B |
BIN
data/images/player/idleN.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
data/images/player/idleS.png
Normal file
After Width: | Height: | Size: 170 B |
BIN
data/images/player/idleW.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
data/images/player/walkE.png
Normal file
After Width: | Height: | Size: 376 B |
BIN
data/images/player/walkN.png
Normal file
After Width: | Height: | Size: 403 B |
BIN
data/images/player/walkS.png
Normal file
After Width: | Height: | Size: 397 B |
BIN
data/images/player/walkW.png
Normal file
After Width: | Height: | Size: 361 B |
BIN
data/images/trident/box.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
data/images/trident/boxColl.png
Normal file
After Width: | Height: | Size: 459 B |
BIN
data/images/trident/collision.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
data/images/trident/consolebg.png
Normal file
After Width: | Height: | Size: 588 KiB |
BIN
data/images/trident/customEnt.png
Normal file
After Width: | Height: | Size: 486 B |
BIN
data/images/trident/light.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
data/images/trident/plrStart.png
Normal file
After Width: | Height: | Size: 444 B |
BIN
data/images/trident/splash.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
data/images/trident/trigger.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
data/libraries/BLib.jar
Normal file
BIN
data/libraries/JHLabs Filters.jar
Normal file
2
data/projectRegistry.bson
Normal file
|
@ -0,0 +1,2 @@
|
|||
{ projects
|
||||
}
|
17
data/templates/blank2d/data/animations/intro.anim
Normal file
|
@ -0,0 +1,17 @@
|
|||
intro
|
||||
false
|
||||
1.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
1000
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
0.0
|
||||
3000
|
||||
0.0
|
||||
0.0
|
||||
1.0
|
||||
0.0
|
||||
1000
|
BIN
data/templates/blank2d/data/icon.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
data/templates/blank2d/data/images/player/idleE.png
Normal file
After Width: | Height: | Size: 156 B |
BIN
data/templates/blank2d/data/images/player/idleN.png
Normal file
After Width: | Height: | Size: 173 B |
BIN
data/templates/blank2d/data/images/player/idleS.png
Normal file
After Width: | Height: | Size: 170 B |
BIN
data/templates/blank2d/data/images/player/idleW.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
data/templates/blank2d/data/images/player/walkE.png
Normal file
After Width: | Height: | Size: 376 B |
BIN
data/templates/blank2d/data/images/player/walkN.png
Normal file
After Width: | Height: | Size: 403 B |
BIN
data/templates/blank2d/data/images/player/walkS.png
Normal file
After Width: | Height: | Size: 397 B |
BIN
data/templates/blank2d/data/images/player/walkW.png
Normal file
After Width: | Height: | Size: 361 B |
BIN
data/templates/blank2d/data/images/trident/box.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
data/templates/blank2d/data/images/trident/boxColl.png
Normal file
After Width: | Height: | Size: 459 B |
BIN
data/templates/blank2d/data/images/trident/collision.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
data/templates/blank2d/data/images/trident/consolebg.png
Normal file
After Width: | Height: | Size: 588 KiB |
BIN
data/templates/blank2d/data/images/trident/customEnt.png
Normal file
After Width: | Height: | Size: 486 B |
BIN
data/templates/blank2d/data/images/trident/light.png
Normal file
After Width: | Height: | Size: 333 B |
BIN
data/templates/blank2d/data/images/trident/plrStart.png
Normal file
After Width: | Height: | Size: 444 B |
BIN
data/templates/blank2d/data/images/trident/splash.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
data/templates/blank2d/data/images/trident/trigger.png
Normal file
After Width: | Height: | Size: 333 B |
43
data/templates/blank2d/data/scenes/default.bson
Normal file
|
@ -0,0 +1,43 @@
|
|||
string name default
|
||||
string dir east
|
||||
int light 25
|
||||
{ bgColor
|
||||
int 255
|
||||
int 255
|
||||
int 255
|
||||
}
|
||||
{ entities
|
||||
string boxcoll
|
||||
double -200
|
||||
double 0
|
||||
boolean true
|
||||
int 100
|
||||
int 100
|
||||
int 0
|
||||
int 255
|
||||
int 0
|
||||
string plrstart
|
||||
double -300
|
||||
double 0
|
||||
boolean false
|
||||
string inviscoll
|
||||
double -200
|
||||
double 100
|
||||
boolean true
|
||||
int 100
|
||||
int 100
|
||||
string boxnocoll
|
||||
double -200
|
||||
double -100
|
||||
boolean false
|
||||
int 100
|
||||
int 100
|
||||
int 255
|
||||
int 0
|
||||
int 0
|
||||
string light
|
||||
double -200
|
||||
double 200
|
||||
boolean false
|
||||
int 100
|
||||
}
|
36
data/templates/blank2d/src/ent/ExampleEntity.java
Normal file
|
@ -0,0 +1,36 @@
|
|||
package ent;
|
||||
|
||||
import blib.util.*;
|
||||
import trident.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class ExampleEntity extends TridEntity {
|
||||
|
||||
// Constructor, runs when the entity is created
|
||||
public ExampleEntity(Position pos){
|
||||
super(pos);
|
||||
}
|
||||
// Registry constructor, used only for adding to the registry
|
||||
public ExampleEntity(){
|
||||
super("example", false, 0);
|
||||
}
|
||||
// Custom constructor, used by the engine when building a scene
|
||||
public TridEntity construct(Position pos, Dimension collision, int[] data){
|
||||
return new ExampleEntity(pos);
|
||||
}
|
||||
|
||||
// Render while in game
|
||||
public void render(Graphics g, JPanel panel, int x, int y){
|
||||
|
||||
}
|
||||
|
||||
// Runs every tick while the game is running
|
||||
public void update(long elapsedTime){
|
||||
|
||||
}
|
||||
|
||||
// Runs at the beginning of the scene
|
||||
public void sceneStart(String scene){
|
||||
|
||||
}
|
||||
}
|
18
data/templates/blank2d/src/trident/Main.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package trident;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class Main{
|
||||
protected static JFrame window = new JFrame("blank2d");
|
||||
public static void main(String[] args){
|
||||
window.setSize(700, 500);
|
||||
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
window.setMinimumSize(new Dimension(700, 500));
|
||||
window.setIconImage(new ImageIcon("data/icon.png").getImage());
|
||||
// panel
|
||||
MainPanel panel = new MainPanel();
|
||||
window.add(panel);
|
||||
//
|
||||
window.setVisible(true);
|
||||
}
|
||||
}
|
226
data/templates/blank2d/src/trident/MainPanel.java
Normal file
|
@ -0,0 +1,226 @@
|
|||
package trident;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import blib.game.*;
|
||||
import blib.util.*;
|
||||
import java.awt.event.*;
|
||||
import blib.input.*;
|
||||
import java.util.ArrayList;
|
||||
import blib.anim.*;
|
||||
import trident.ent.*;
|
||||
import update.*;
|
||||
public class MainPanel extends JPanel {
|
||||
|
||||
protected FrameManager frameManager = new FrameManager();
|
||||
public static Server server;
|
||||
protected KeyManager km = new InputListener(this);
|
||||
private Animator introAnim;
|
||||
public static Position introPos = new Position();
|
||||
public static ImageIcon splash = new ImageIcon("data/images/trident/splash.png");
|
||||
public static boolean inIntro = false;
|
||||
private RenderingThread rendThread = new RenderingThread();
|
||||
|
||||
public MainPanel(){
|
||||
|
||||
System.setProperty("sun.java2d.opengl", "true"); // hardware acceleration?
|
||||
|
||||
setBackground(Color.black);
|
||||
|
||||
Trident.player = new Player(new Position(), km, 0.1, this, "data/images/player", 16, 16);
|
||||
Trident.player.camera.setDimension = new Dimension(frameManager.WIDTH, frameManager.HEIGHT);
|
||||
Trident.player.resizeImages(32, 32);
|
||||
Trident.currentScene = new Scene("Test Scene");
|
||||
Trident.camShake = new CamShake(Trident.player.camera);
|
||||
Trident.lightManager.blur.setRadius(100);
|
||||
|
||||
Trident.addCustomEntity(new BoxColl());
|
||||
Trident.addCustomEntity(new BoxNoColl());
|
||||
Trident.addCustomEntity(new InvisColl());
|
||||
Trident.addCustomEntity(new PlrStart());
|
||||
Trident.addCustomEntity(new Trigger());
|
||||
Trident.addCustomEntity(new TridLight());
|
||||
|
||||
setFocusTraversalKeysEnabled(false);
|
||||
|
||||
Update.setup();
|
||||
|
||||
Trident.setupScenes();
|
||||
|
||||
Trident.loadScene(Trident.defaultScene);
|
||||
|
||||
for(String s: Update.fonts){
|
||||
BTools.addFont(s, this);
|
||||
}
|
||||
|
||||
try{
|
||||
ArrayList<Animation> anims = new ArrayList<Animation>();
|
||||
anims.add(new Animation("data/animations/intro"));
|
||||
|
||||
introAnim = new Animator(introPos, anims);
|
||||
}catch(Exception e){
|
||||
Trident.intro = false;
|
||||
}
|
||||
if(Trident.intro){
|
||||
introAnim.play("intro");
|
||||
inIntro = true;
|
||||
}
|
||||
if(Trident.splash != null && BTools.hasImage(Trident.splash)){
|
||||
BTools.resizeImgIcon(Trident.splash, 160, 160);
|
||||
}
|
||||
|
||||
Trident.consoleError = false;
|
||||
rendThread.start();
|
||||
|
||||
server = new Server(new ServerListener(), this);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics graphics){
|
||||
super.paintComponent(graphics);
|
||||
Graphics g = frameManager.newFrame();
|
||||
|
||||
frameManager.bgColor = Trident.currentScene.bgColor;
|
||||
|
||||
if(rendThread.lastFrame != null){
|
||||
g.drawImage(rendThread.lastFrame, 0, 0, null);
|
||||
}
|
||||
|
||||
frameManager.renderFrame(this, graphics);
|
||||
}
|
||||
|
||||
public MainPanel panel = this;
|
||||
private class InputListener extends InputAdapter {
|
||||
public InputListener(JPanel panel){
|
||||
super(panel);
|
||||
}
|
||||
|
||||
public void onKeyPressed(int key){
|
||||
if(key == KeyEvent.VK_F12){
|
||||
frameManager.saveScreenshot("data/screenshots");
|
||||
Update.tridentEvent(Trident.EVENT_SCREENSHOT);
|
||||
}
|
||||
if(key == KeyEvent.VK_F11){
|
||||
Trident.fullscreen = !Trident.fullscreen;
|
||||
Main.window = BTools.getWindowFullscreen(Main.window, Trident.fullscreen, panel);
|
||||
return;
|
||||
}
|
||||
if(!inIntro){
|
||||
if(key == 192 && Trident.consoleEnabled){
|
||||
Trident.consoleOpen = !Trident.consoleOpen;
|
||||
Trident.consoleType = "";
|
||||
Trident.consoleError = false;
|
||||
}
|
||||
if(Trident.consoleOpen){
|
||||
if(key >= KeyEvent.VK_A && key <= KeyEvent.VK_Z){
|
||||
char c = KeyEvent.getKeyText(key).charAt(0);
|
||||
if(!km.getKeyDown(KeyEvent.VK_SHIFT)){
|
||||
c = Character.toLowerCase(c);
|
||||
}
|
||||
Trident.consoleType += c;
|
||||
}
|
||||
if(key >= KeyEvent.VK_0 && key <= KeyEvent.VK_9){
|
||||
char c = KeyEvent.getKeyText(key).charAt(0);
|
||||
Trident.consoleType += c;
|
||||
}
|
||||
if(key == KeyEvent.VK_SPACE){
|
||||
Trident.consoleType += " ";
|
||||
}
|
||||
if(key == KeyEvent.VK_MINUS){
|
||||
Trident.consoleType += "-";
|
||||
}
|
||||
if(key == KeyEvent.VK_PERIOD){
|
||||
Trident.consoleType += ".";
|
||||
}
|
||||
if(key == KeyEvent.VK_BACK_SPACE){
|
||||
if(Trident.consoleType.length() > 0) Trident.consoleType = Trident.consoleType.substring(0, Trident.consoleType.length() - 1);
|
||||
}
|
||||
if(key == KeyEvent.VK_UP){
|
||||
Trident.consoleType = Trident.lastCommand;
|
||||
}
|
||||
|
||||
if(key == KeyEvent.VK_ENTER){
|
||||
Trident.runCommand(Trident.consoleType);
|
||||
Trident.consoleType = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
Inputs.keyPressed(key);
|
||||
}
|
||||
}
|
||||
|
||||
public void onMousePressed(int mb, Point mousePos){
|
||||
mousePos = frameManager.getMousePos(panel, mousePos);
|
||||
Position worldPos = Trident.player.camera.mouseToPos(mousePos);
|
||||
if(!inIntro) Inputs.mousePressed(mb, mousePos, worldPos);
|
||||
}
|
||||
|
||||
public void onScroll(int scroll){
|
||||
if(!inIntro) Inputs.onScroll(scroll);
|
||||
}
|
||||
}
|
||||
|
||||
private class ServerListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(inIntro){
|
||||
introAnim.update(server.getElapsedTime());
|
||||
if(!introAnim.isPlaying()){
|
||||
inIntro = false;
|
||||
}
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!hasFocus()) km.reset();
|
||||
|
||||
if(!Trident.consoleOpen){
|
||||
Trident.mousePos = frameManager.getMousePos(panel, km.getMousePos());
|
||||
Trident.mouseDelta = km.getMouseDelta();
|
||||
Trident.mouseWorldPos = Trident.player.camera.mouseToPos(Trident.mousePos);
|
||||
|
||||
Trident.camShake.update(server.getElapsedTime());
|
||||
|
||||
if(!Trident.noclip) Trident.player.updateWithCollision(server.getElapsedTime(), Trident.currentScene.getCollision());
|
||||
else Trident.player.update(server.getElapsedTime());
|
||||
|
||||
for(int i = 0; i < Trident.getEntities().size(); i++){
|
||||
TridEntity e = Trident.getEntities().get(i);
|
||||
e.update(server.getElapsedTime());
|
||||
if(e instanceof Trigger){
|
||||
Trigger trig = (Trigger)e;
|
||||
if(trig.containsPos(Trident.player.getPos())){
|
||||
Update.trigger(trig.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Trident.reset){
|
||||
km.reset();
|
||||
Trident.reset = false;
|
||||
}
|
||||
for(int i = 0; i < 255; i++){
|
||||
Trident.keys[i] = km.getKeyDown(i);
|
||||
}
|
||||
Trident.m1 = km.getMouseDown(1);
|
||||
Trident.m2 = km.getMouseDown(2);
|
||||
Trident.m3 = km.getMouseDown(3);
|
||||
Trident.m4 = km.getMouseDown(4);
|
||||
Trident.m5 = km.getMouseDown(5);
|
||||
|
||||
if(Trident.newSprite != null){
|
||||
Trident.player = new Player(Trident.player.getPos(), km, 0.2, panel, Trident.newSprite, 16, 16);
|
||||
Trident.newSprite = null;
|
||||
Trident.player.resizeImages(32, 32);
|
||||
Trident.player.camera.setDimension = new Dimension(frameManager.WIDTH, frameManager.HEIGHT);
|
||||
Trident.camShake = new CamShake(Trident.player.camera);
|
||||
Trident.player.shortCollision = true;
|
||||
}
|
||||
|
||||
Update.update(server.getElapsedTime());
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {Trident.getEntities().sort((o1, o2) -> o2.compareSort(o1));} catch(Exception e){}
|
||||
}
|
||||
}
|
||||
}
|
148
data/templates/blank2d/src/trident/RenderingThread.java
Normal file
|
@ -0,0 +1,148 @@
|
|||
package trident;
|
||||
|
||||
import java.awt.image.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import blib.util.*;
|
||||
import java.awt.*;
|
||||
import blib.game.*;
|
||||
import javax.swing.*;
|
||||
public class RenderingThread extends Thread {
|
||||
|
||||
public BufferedImage lastFrame = null;
|
||||
private long elapsedTime, previousStartTime = -1;
|
||||
|
||||
private ImageIcon consoleBg = new ImageIcon("data/images/trident/consolebg.png");
|
||||
private long errorFlashTime = 0;
|
||||
|
||||
public RenderingThread(){
|
||||
BTools.resizeImgIcon(consoleBg, Trident.getFrameWidth(), 483);
|
||||
}
|
||||
|
||||
public void run(){
|
||||
while(true){
|
||||
try{
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
elapsedTime = previousStartTime != -1 ? now - previousStartTime : 0;
|
||||
previousStartTime = now;
|
||||
int WIDTH = Trident.getFrameWidth(), HEIGHT = Trident.getFrameHeight();
|
||||
int offX, offY;
|
||||
offX = Trident.camShake.offX;
|
||||
offY = Trident.camShake.offY;
|
||||
BufferedImage newFrame = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics g = newFrame.getGraphics();
|
||||
|
||||
if(Trident.engineDraw){
|
||||
for(TridEntity e: Trident.currentScene.entities){
|
||||
Point p = Trident.player.camera.worldToScreen(e.position);
|
||||
e.engineRender(g, null, p.x, p.y);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<ArrayList<Entity>> splitEnt = Trident.player.camera.splitEntities(Trident.tridArrToEntArr(Trident.currentScene.entities), 16);
|
||||
if(!Trident.engineDraw) Trident.player.camera.render(g, splitEnt.get(2), offX, offY);
|
||||
if(!Trident.engineDraw) Trident.player.camera.render(g, splitEnt.get(0), offX, offY);
|
||||
if(Trident.drawPlayer){
|
||||
Trident.player.render(null, g, WIDTH / 2 - offX, HEIGHT / 2 - offY);
|
||||
}
|
||||
if(!Trident.engineDraw) Trident.player.camera.render(g, splitEnt.get(1), offX, offY);
|
||||
|
||||
Trident.lightManager.render(Trident.player.camera, Trident.lights, g, offX, offY);
|
||||
|
||||
if(!Trident.engineDraw) Trident.player.camera.render(g, splitEnt.get(3), offX, offY);
|
||||
|
||||
|
||||
|
||||
|
||||
if(Trident.drawCollision){
|
||||
g.setColor(Color.red);
|
||||
ArrayList<Rectangle> collision = Trident.currentScene.getCollision();
|
||||
collision.add(Trident.player.getCollision());
|
||||
for(Rectangle r: collision){
|
||||
Point p = Trident.player.camera.worldToScreen(new Position(r.x, r.y));
|
||||
g.drawRect(p.x, p.y, r.width, r.height);
|
||||
g.drawLine(p.x, p.y, p.x + r.width, p.y + r.height);
|
||||
}
|
||||
}
|
||||
|
||||
if(Trident.drawPos){
|
||||
g.setColor(Trident.debugColor);
|
||||
g.setFont(new Font("Arial", Font.ITALIC, 10));
|
||||
TextBox.draw(Trident.player.getPos().toStringSimple(), g, 10, 20);
|
||||
}
|
||||
if(Trident.drawFrames){
|
||||
g.setColor(Trident.debugColor);
|
||||
g.setFont(new Font("Arial", Font.ITALIC, 10));
|
||||
TextBox.draw("TPS: " + (1000 / Math.max(MainPanel.server.getElapsedTime(), 1)) + " (" + MainPanel.server.getElapsedTime() + " ms)", g, 10, 30);
|
||||
TextBox.draw("FPS: " + (1000 / Math.max(elapsedTime, 1)) + " (" + elapsedTime + " ms)", g, 10, 40);
|
||||
}
|
||||
|
||||
// Apply Post Processing
|
||||
if(Trident.enableExposure){
|
||||
Trident.exposure.filter(newFrame, newFrame);
|
||||
}
|
||||
if(Trident.enableBloom){
|
||||
Trident.bloom.filter(newFrame, newFrame);
|
||||
}
|
||||
|
||||
if(MainPanel.inIntro){
|
||||
g.setColor(Color.black);
|
||||
g.fillRect(0, 0, 700, 500);
|
||||
|
||||
if(Trident.splash != null && BTools.hasImage(Trident.splash)){
|
||||
// Trident splash + custom splash
|
||||
MainPanel.splash.paintIcon(null, g, WIDTH / 2 - 80, 40);
|
||||
Trident.splash.paintIcon(null, g, WIDTH / 2 - 80, HEIGHT - 200);
|
||||
}else{
|
||||
// Trident splash only
|
||||
MainPanel.splash.paintIcon(null, g, WIDTH / 2 - 80, HEIGHT / 2 - 80);
|
||||
}
|
||||
|
||||
float alpha = (float)MainPanel.introPos.x;
|
||||
g.setColor(new Color(0f, 0f, 0f, alpha));
|
||||
g.fillRect(0, 0, 700, 500);
|
||||
}
|
||||
|
||||
if(Trident.consoleOpen){
|
||||
// bg
|
||||
consoleBg.paintIcon(null, g, 0, -252);
|
||||
g.setColor(new Color(0f, 0f, 0f, 0.7f));
|
||||
g.fillRect(0, 0, Trident.getFrameWidth(), Trident.getFrameHeight() / 2);
|
||||
|
||||
// text
|
||||
g.setColor(Color.white);
|
||||
g.setFont(new Font("Arial", Font.PLAIN, 10));
|
||||
for(int i = 0; i < Trident.consoleLines.size(); i++){
|
||||
int index = BTools.flip(i, Trident.consoleLines.size() - 1);
|
||||
TextBox.draw(Trident.consoleLines.get(index), g, 5, Trident.getFrameHeight() / 2 - 25 - (i * 10));
|
||||
}
|
||||
|
||||
// borders
|
||||
g.setColor(new Color(32, 12, 121));
|
||||
g.drawRect(0, 0, Trident.getFrameWidth() - 1, Trident.getFrameHeight() / 2);
|
||||
g.drawLine(0, Trident.getFrameHeight() / 2 - 10, Trident.getFrameWidth(), Trident.getFrameHeight() / 2 - 10);
|
||||
|
||||
// text entry box
|
||||
g.setColor(Color.white);
|
||||
g.setFont(new Font("Arial", Font.PLAIN, 10));
|
||||
TextBox.draw("> " + Trident.consoleType + "_", g, 3, Trident.getFrameHeight() / 2 - 5);
|
||||
}
|
||||
if(Trident.consoleError){
|
||||
errorFlashTime += elapsedTime;
|
||||
g.setColor(new Color(1f, (float)(Math.min(1, Math.sin(errorFlashTime / 500.0) / 2 + 0.5)), (float)(Math.min(1, Math.sin(errorFlashTime / 500.0) / 2 + 0.5))));
|
||||
g.setFont(new Font("Arial", Font.BOLD, 20));
|
||||
TextBox.draw("ERROR\nOpen console with [~](tilde)", g, Trident.getFrameWidth() / 2, 10, TextBox.CENTER);
|
||||
}
|
||||
|
||||
lastFrame = newFrame;
|
||||
}catch(Exception e){
|
||||
if(!(e instanceof ConcurrentModificationException)){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
104
data/templates/blank2d/src/trident/Scene.java
Normal file
|
@ -0,0 +1,104 @@
|
|||
package trident;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import blib.bson.*;
|
||||
import blib.util.*;
|
||||
import trident.ent.*;
|
||||
import blib.game.*;
|
||||
public class Scene {
|
||||
|
||||
public final String name;
|
||||
public ArrayList<TridEntity> entities;
|
||||
protected Position plrStart = new Position();
|
||||
protected int plrDir = Player.SOUTH;
|
||||
protected Color bgColor = Color.white;
|
||||
protected int defaultLight = 255;
|
||||
|
||||
public Scene(String n){ // Empty scene
|
||||
name = n;
|
||||
entities = new ArrayList<TridEntity>();
|
||||
}
|
||||
public Scene(File f) throws IOException{
|
||||
entities = new ArrayList<TridEntity>();
|
||||
ArrayList<BSonObject> objects = BSonParser.readFile(f.getAbsolutePath());
|
||||
BSonObject obj = BSonParser.getObject("name", objects);
|
||||
name = obj.getString();
|
||||
obj = BSonParser.getObject("dir", objects);
|
||||
if(obj != null){
|
||||
String str = obj.getString();
|
||||
if(str.equals("west")) plrDir = Player.WEST;
|
||||
if(str.equals("north")) plrDir = Player.NORTH;
|
||||
if(str.equals("east")) plrDir = Player.EAST;
|
||||
}
|
||||
obj = BSonParser.getObject("bgColor", objects);
|
||||
BSonList asList = (BSonList)obj;
|
||||
int r, g, b;
|
||||
r = asList.list.get(0).getInt();
|
||||
g = asList.list.get(1).getInt();
|
||||
b = asList.list.get(2).getInt();
|
||||
bgColor = new Color(r, g, b);
|
||||
obj = BSonParser.getObject("light", objects);
|
||||
defaultLight = obj.getInt();
|
||||
obj = BSonParser.getObject("entities", objects);
|
||||
asList = (BSonList)obj;
|
||||
for(int i = 0; i < asList.list.size(); i++){
|
||||
String objName = asList.list.get(i).getString();
|
||||
i++;
|
||||
boolean foundEnt = false;
|
||||
for(TridEntity e: Trident.entRegistry){
|
||||
if(e.name.equals(objName)){
|
||||
double x, y;
|
||||
x = asList.list.get(i).getDouble();
|
||||
i++;
|
||||
y = asList.list.get(i).getDouble();
|
||||
i++;
|
||||
int w = 0, h = 0;
|
||||
i++;
|
||||
if(e.HASCOLLISION){
|
||||
w = asList.list.get(i).getInt();
|
||||
i++;
|
||||
h = asList.list.get(i).getInt();
|
||||
i++;
|
||||
}
|
||||
int[] data = new int[e.numData];
|
||||
for(int j = 0; j < e.numData; j++){
|
||||
data[j] = asList.list.get(i).getInt();
|
||||
i++;
|
||||
}
|
||||
i--;
|
||||
entities.add(e.construct(new Position(x, y), (e.HASCOLLISION ? (new Dimension(w, h)) : null), data));
|
||||
foundEnt = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!foundEnt) Trident.printConsole("ERROR: no entity type '" + objName + "' found");
|
||||
}
|
||||
|
||||
// Check for plrstart
|
||||
for(TridEntity e: entities){
|
||||
if(e instanceof PlrStart){
|
||||
plrStart = e.position.copy();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Scene loadScene(String path){ // stub method ::: Load a scene from a file
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<Rectangle> getCollision(){
|
||||
ArrayList<Rectangle> collision = new ArrayList<Rectangle>();
|
||||
for(int i = 0; i < entities.size(); i++){
|
||||
TridEntity e = entities.get(i);
|
||||
if(e.HASCOLLISION){
|
||||
collision.add(e.getCollision());
|
||||
}
|
||||
}
|
||||
|
||||
return collision;
|
||||
}
|
||||
|
||||
}
|
101
data/templates/blank2d/src/trident/TridEntity.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package trident;
|
||||
|
||||
import blib.game.*;
|
||||
import blib.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
public class TridEntity extends Entity {
|
||||
|
||||
public final boolean HASCOLLISION;
|
||||
private final Dimension collision;
|
||||
public String engineRenderData = "";
|
||||
private ImageIcon engineImg = new ImageIcon("data/images/trident/customEnt.png");
|
||||
protected String name;
|
||||
protected int numData;
|
||||
|
||||
public TridEntity(Position pos){
|
||||
super(pos);
|
||||
HASCOLLISION = false;
|
||||
collision = null;
|
||||
}
|
||||
public TridEntity(Position pos, Dimension collision){
|
||||
super(pos);
|
||||
if(collision.equals(new Dimension(0, 0))) HASCOLLISION = false;
|
||||
else HASCOLLISION = true;
|
||||
this.collision = collision;
|
||||
}
|
||||
public TridEntity(String n, boolean hasColl, int numData){
|
||||
super(new Position());
|
||||
HASCOLLISION = hasColl;
|
||||
collision = null;
|
||||
name = n;
|
||||
this.numData = numData;
|
||||
}
|
||||
public TridEntity construct(Position pos, Dimension collision, int[] data){
|
||||
System.out.println("Error: tried to create an empty entity");
|
||||
return null;
|
||||
}
|
||||
|
||||
public Rectangle getCollision(){
|
||||
return new Rectangle((int)position.x - (collision.width / 2), (int)position.y - (collision.height / 2), collision.width, collision.height);
|
||||
}
|
||||
|
||||
public void render(Graphics g, JPanel panel, int x, int y){
|
||||
|
||||
}
|
||||
|
||||
protected void engineRender(Graphics g, JPanel panel, int x, int y){
|
||||
if(HASCOLLISION){
|
||||
g.setColor(Color.red);
|
||||
g.drawRect(x - getCollision().width / 2, y - getCollision().height / 2, getCollision().width, getCollision().height);
|
||||
g.drawLine(x - getCollision().width / 2, y - getCollision().height / 2, x + getCollision().width / 2, y + getCollision().height / 2);
|
||||
}
|
||||
engineImg.paintIcon(panel, g, x - engineImg.getIconWidth() / 2, y - engineImg.getIconHeight() / 2);
|
||||
}
|
||||
|
||||
public void update(long elapsedTime){
|
||||
|
||||
}
|
||||
|
||||
public void sceneStart(String scene){
|
||||
|
||||
}
|
||||
|
||||
public int getRendDatSort(){
|
||||
if(renderType == Entity.TALL){
|
||||
return 2;
|
||||
}
|
||||
if(renderType == Entity.UNDER){
|
||||
return 1;
|
||||
}
|
||||
if(renderType == Entity.ABOVE){
|
||||
return 3;
|
||||
}
|
||||
if(renderType == Entity.BOTTOMPRIORITY){
|
||||
return 0;
|
||||
}
|
||||
if(renderType == Entity.TOPPRIORITY){
|
||||
return 4;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int compareSort(TridEntity e){
|
||||
if(e.getRendDatSort() > getRendDatSort()){
|
||||
// e should be above
|
||||
return 1;
|
||||
}else if(e.getRendDatSort() < getRendDatSort()){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(e.position.y > position.y){
|
||||
return 1;
|
||||
}else if(e.position.y < position.y){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
516
data/templates/blank2d/src/trident/Trident.java
Normal file
|
@ -0,0 +1,516 @@
|
|||
package trident;
|
||||
|
||||
import blib.game.*;
|
||||
import blib.util.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
import javax.swing.*;
|
||||
import update.*;
|
||||
import java.io.*;
|
||||
import trident.ent.*;
|
||||
import com.jhlabs.image.GlowFilter;
|
||||
import com.jhlabs.image.ExposureFilter;
|
||||
public class Trident {
|
||||
|
||||
// Debug Settings
|
||||
public static boolean drawPos = false;
|
||||
public static boolean drawCollision = false;
|
||||
public static boolean noclip = false;
|
||||
public static boolean engineDraw = false;
|
||||
public static Color debugColor = Color.red;
|
||||
public static boolean intro = true;
|
||||
public static ImageIcon splash = null;
|
||||
public static boolean drawFrames = false;
|
||||
public static boolean consoleEnabled = true;
|
||||
public static boolean consoleOpen = false;
|
||||
public static boolean consoleError = false;
|
||||
public static String lastCommand = "";
|
||||
|
||||
// Public Variables
|
||||
public static Point mousePos;
|
||||
public static Point mouseDelta;
|
||||
public static boolean drawPlayer = true;
|
||||
public static Position mouseWorldPos = new Position();
|
||||
public static boolean enableBloom = true, enableExposure = true;
|
||||
|
||||
|
||||
// Trident Variables
|
||||
protected static Player player;
|
||||
protected static Scene currentScene;
|
||||
protected static boolean fullscreen = false;
|
||||
protected static ArrayList<Scene> loadedScenes = new ArrayList<Scene>();
|
||||
protected static ArrayList<TridEntity> entRegistry = new ArrayList<TridEntity>();
|
||||
protected static String defaultScene = "default";
|
||||
protected static boolean m1 = false, m2 = false, m3 = false, m4 = false, m5 = false;
|
||||
protected static boolean[] keys = new boolean[255];
|
||||
protected static CamShake camShake;
|
||||
protected static ArrayList<Entity> lights = new ArrayList<Entity>();
|
||||
protected static LightManager lightManager = new LightManager(255);
|
||||
protected static GlowFilter bloom = new GlowFilter();
|
||||
protected static ExposureFilter exposure = new ExposureFilter();
|
||||
protected static boolean reset = false;
|
||||
protected static String newSprite = null;
|
||||
|
||||
// Trident events
|
||||
public static final int EVENT_SCREENSHOT = 0;
|
||||
|
||||
|
||||
// Setting methods
|
||||
public static void setPlrSpeed(double speed){
|
||||
player.speed = speed;
|
||||
}
|
||||
public static void setPlrPos(Position pos){
|
||||
player.goToPos(pos);
|
||||
}
|
||||
public static void setShortCollision(boolean b){
|
||||
player.shortCollision = b;
|
||||
}
|
||||
public static void setWindowTitle(String title){
|
||||
Main.window.setTitle(title);
|
||||
}
|
||||
public static void setupScenes(){
|
||||
try{
|
||||
loadedScenes = new ArrayList<Scene>();
|
||||
File dir = new File("data/scenes");
|
||||
File[] files = dir.listFiles();
|
||||
ArrayList<File> sceneFiles = new ArrayList<File>();
|
||||
for(File f: files){
|
||||
if(BTools.hasExtension(f, "bson")) sceneFiles.add(f);
|
||||
}
|
||||
|
||||
for(File f: sceneFiles){
|
||||
loadedScenes.add(new Scene(f));
|
||||
}
|
||||
}catch(Exception e){
|
||||
printException("Error setting up scenes", e);
|
||||
}
|
||||
|
||||
}
|
||||
public static void loadScene(String name){
|
||||
lights = new ArrayList<Entity>();
|
||||
for(Scene s: loadedScenes){
|
||||
if(s.name.equals(name)){
|
||||
currentScene = s;
|
||||
player.goToPos(s.plrStart);
|
||||
player.setDirection(s.plrDir);
|
||||
for(TridEntity e: s.entities){
|
||||
if(e instanceof TridLight){
|
||||
TridLight asLight = (TridLight)e;
|
||||
lights.add(new Light(asLight.position, asLight.radius));
|
||||
}
|
||||
e.sceneStart(s.name);
|
||||
}
|
||||
lightManager.defaultLight = s.defaultLight;
|
||||
Update.sceneStart(name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
printConsole("***********************************************************************************");
|
||||
printConsole("Error loading scene: No scene with name '" + name + "' found.");
|
||||
printError("***********************************************************************************");
|
||||
}
|
||||
public static void addCustomEntity(TridEntity e){ // Add a cutsom entity to the registry
|
||||
entRegistry.add(e);
|
||||
}
|
||||
public static void spawnEntity(TridEntity e){
|
||||
currentScene.entities.add(e);
|
||||
}
|
||||
public static void setDefaultScene(String s){
|
||||
defaultScene = s;
|
||||
}
|
||||
public static void destroy(TridEntity object){
|
||||
getEntities().remove(object);
|
||||
}
|
||||
public static void shakeCam(double intensity){
|
||||
camShake.addTrauma(intensity);
|
||||
}
|
||||
public static void removeShake(){
|
||||
camShake.trauma = 0;
|
||||
}
|
||||
public static void setShakeStrength(int str){
|
||||
camShake.strength = str;
|
||||
}
|
||||
public static void setShakeLoss(double loss){
|
||||
camShake.traumaLoss = loss;
|
||||
}
|
||||
public static void setBloom(double amount){
|
||||
bloom.setAmount((float)amount);
|
||||
}
|
||||
public static void setExposure(double exp){
|
||||
exposure.setExposure((float)exp);
|
||||
}
|
||||
public static void setLightBlur(int level){
|
||||
lightManager.blur.setIterations(level);
|
||||
}
|
||||
public static void addLight(Light l){
|
||||
lights.add(l);
|
||||
}
|
||||
public static void resetKeys(){
|
||||
reset = true;
|
||||
}
|
||||
public static void setPlrSprite(String path){
|
||||
newSprite = path;
|
||||
}
|
||||
public static void removeLight(Light l){
|
||||
lights.remove(l);
|
||||
}
|
||||
public static void setDefaultLight(int level){
|
||||
lightManager.defaultLight = level;
|
||||
}
|
||||
public static void stopShake(){
|
||||
camShake.trauma = 0;
|
||||
}
|
||||
|
||||
// Getting methods
|
||||
public static double getPlrSpeed(){
|
||||
return player.speed;
|
||||
}
|
||||
public static Position getPlrPos(){
|
||||
return player.getPos().copy();
|
||||
}
|
||||
public static Scene getCurrentScene(){
|
||||
return currentScene;
|
||||
}
|
||||
public static boolean getFullscreen(){
|
||||
return fullscreen;
|
||||
}
|
||||
public static ArrayList<Entity> tridArrToEntArr(ArrayList<TridEntity> entities){
|
||||
ArrayList<Entity> newEntities = new ArrayList<Entity>();
|
||||
for(TridEntity e: entities){
|
||||
newEntities.add((Entity)e);
|
||||
}
|
||||
return newEntities;
|
||||
}
|
||||
public static ArrayList<TridEntity> entArrToTridArr(ArrayList<Entity> entities){
|
||||
ArrayList<TridEntity> newEntities = new ArrayList<TridEntity>();
|
||||
for(Entity e: entities){
|
||||
newEntities.add((TridEntity)e);
|
||||
}
|
||||
return newEntities;
|
||||
}
|
||||
public static ArrayList<TridEntity> getEntities(){
|
||||
return currentScene.entities;
|
||||
}
|
||||
public static ArrayList<Rectangle> getCollision(){
|
||||
return currentScene.getCollision();
|
||||
}
|
||||
public static boolean getMouseDown(int mb){
|
||||
if(mb == 1){
|
||||
return m1;
|
||||
}
|
||||
if(mb == 2){
|
||||
return m2;
|
||||
}
|
||||
if(mb == 3){
|
||||
return m3;
|
||||
}
|
||||
if(mb == 4){
|
||||
return m4;
|
||||
}
|
||||
if(mb == 5){
|
||||
return m5;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public static boolean getKeyDown(int key){
|
||||
return keys[key];
|
||||
}
|
||||
public static Player getPlr(){
|
||||
return player;
|
||||
}
|
||||
public static int getFrameWidth(){
|
||||
return 684;
|
||||
}
|
||||
public static int getFrameHeight(){
|
||||
return 462;
|
||||
}
|
||||
public static Point getShakeOffset(){
|
||||
return new Point(camShake.offX, camShake.offY);
|
||||
}
|
||||
|
||||
|
||||
// Commands
|
||||
public static ArrayList<String> consoleLines = new ArrayList<String>();
|
||||
public static String consoleType = ""; // What the user is typing
|
||||
|
||||
public static void runCommand(String command){
|
||||
if(command != null && command.length() > 0){
|
||||
lastCommand = command;
|
||||
printConsole(" > " + command);
|
||||
|
||||
ArrayList<String> cmdParts = new ArrayList<String>();
|
||||
Scanner scanner = new Scanner(command);
|
||||
while(scanner.hasNext()){
|
||||
cmdParts.add(scanner.next());
|
||||
}
|
||||
scanner.close();
|
||||
|
||||
if(cmdParts.size() == 0) return;
|
||||
try{
|
||||
switch(cmdParts.get(0)){
|
||||
case "drawCollision":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("drawCollision is " + Trident.drawCollision);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.drawCollision = true;
|
||||
printConsole("set drawCollision to " + Trident.drawCollision);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.drawCollision = false;
|
||||
printConsole("set drawCollision to " + Trident.drawCollision);
|
||||
}
|
||||
break;
|
||||
case "engineDraw":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("engineDraw is " + Trident.engineDraw);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.engineDraw = true;
|
||||
printConsole("set engineDraw to " + Trident.engineDraw);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.engineDraw = false;
|
||||
printConsole("set engineDraw to " + Trident.engineDraw);
|
||||
}
|
||||
break;
|
||||
case "drawPos":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("drawPos is " + Trident.drawPos);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.drawPos = true;
|
||||
printConsole("set drawPos to " + Trident.drawPos);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.drawPos = false;
|
||||
printConsole("set drawPos to " + Trident.drawPos);
|
||||
}
|
||||
break;
|
||||
case "noclip":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("noclip is " + Trident.noclip);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.noclip = true;
|
||||
printConsole("set noclip to " + Trident.noclip);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.noclip = false;
|
||||
printConsole("set noclip to " + Trident.noclip);
|
||||
}
|
||||
break;
|
||||
case "tp":
|
||||
int x = Integer.parseInt(cmdParts.get(1));
|
||||
int y = Integer.parseInt(cmdParts.get(2));
|
||||
Trident.setPlrPos(new Position(x, y));
|
||||
printConsole("teleported player to (" + x + ", " + y + ")");
|
||||
break;
|
||||
case "loadMap":
|
||||
String map = "";
|
||||
for(int i = 1; i < cmdParts.size(); i++){
|
||||
map += cmdParts.get(i);
|
||||
if(i != cmdParts.size() - 1) map += " ";
|
||||
}
|
||||
Trident.loadScene(map);
|
||||
break;
|
||||
case "drawFrames":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("drawFrames is " + Trident.drawFrames);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.drawFrames = true;
|
||||
printConsole("set drawFrames to " + Trident.drawFrames);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.drawFrames = false;
|
||||
printConsole("set drawFrames to " + Trident.drawFrames);
|
||||
}
|
||||
break;
|
||||
case "debugColor":
|
||||
int r, g, b;
|
||||
float alpha = -1;
|
||||
r = Integer.parseInt(cmdParts.get(1));
|
||||
g = Integer.parseInt(cmdParts.get(2));
|
||||
b = Integer.parseInt(cmdParts.get(3));
|
||||
if(cmdParts.size() == 5){
|
||||
alpha = Float.parseFloat(cmdParts.get(4));
|
||||
}
|
||||
if(alpha != -1){
|
||||
Trident.debugColor = new Color(r / 255f, g / 255f, b / 255f, alpha);
|
||||
printConsole("set debugColor to (" + r + ", " + g + ", " + b + ", " + alpha + ")");
|
||||
}else{
|
||||
Trident.debugColor = new Color(r, g, b);
|
||||
printConsole("set debugColor to (" + r + ", " + g + ", " + b + ")");
|
||||
}
|
||||
break;
|
||||
case "enableBloom":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("enableBloom is " + Trident.enableBloom);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.enableBloom = true;
|
||||
printConsole("set enableBloom to " + Trident.enableBloom);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.enableBloom = false;
|
||||
printConsole("set enableBloom to " + Trident.enableBloom);
|
||||
}
|
||||
break;
|
||||
case "enableExposure":
|
||||
if(cmdParts.size() == 1){
|
||||
printConsole("enableExposure is " + Trident.enableExposure);
|
||||
break;
|
||||
}
|
||||
if(cmdParts.get(1).equals("1") || cmdParts.get(1).equals("true")){
|
||||
Trident.enableExposure = true;
|
||||
printConsole("set enableExposure to " + Trident.enableExposure);
|
||||
}
|
||||
if(cmdParts.get(1).equals("0") || cmdParts.get(1).equals("false")){
|
||||
Trident.enableExposure = false;
|
||||
printConsole("set enableExposure to " + Trident.enableExposure);
|
||||
}
|
||||
break;
|
||||
case "setBloom":
|
||||
double amount = Double.parseDouble(cmdParts.get(1));
|
||||
Trident.setBloom(amount);
|
||||
printConsole("set bloom to " + amount);
|
||||
break;
|
||||
case "setExposure":
|
||||
double expo = Double.parseDouble(cmdParts.get(1));
|
||||
Trident.setExposure(expo);
|
||||
printConsole("set exposure to " + expo);
|
||||
break;
|
||||
case "setLightBlur":
|
||||
int blurLevel = Integer.parseInt(cmdParts.get(1));
|
||||
Trident.setLightBlur(blurLevel);
|
||||
printConsole("set lightBlur to " + blurLevel + " (recommended: 1)");
|
||||
break;
|
||||
case "clear":
|
||||
consoleLines = new ArrayList<String>();
|
||||
break;
|
||||
case "help":
|
||||
int page = 1;
|
||||
if(cmdParts.size() > 1) page = Integer.parseInt(cmdParts.get(1));
|
||||
printHelp(page);
|
||||
break;
|
||||
case "customHelp":
|
||||
int p = 1;
|
||||
if(cmdParts.size() > 1) p = Integer.parseInt(cmdParts.get(1));
|
||||
printCustomHelp(p);
|
||||
break;
|
||||
case "credits":
|
||||
runCommand("clear");
|
||||
printConsole("Trident Engine built in Java by Blocky");
|
||||
printConsole("---");
|
||||
printConsole("Github: @HeyIts-Blocky");
|
||||
printConsole("Insta: @heyits_blocky");
|
||||
printConsole("Itch.io: blockmanblue.itch.io <TYPE 'openItch' TO GO TO SITE>");
|
||||
printConsole("---");
|
||||
printConsole("");
|
||||
break;
|
||||
case "openItch":
|
||||
BTools.openWebsite("https://blockmanblue.itch.io/");
|
||||
break;
|
||||
case "errorTest":
|
||||
consoleOpen = false;
|
||||
printError("Error test");
|
||||
break;
|
||||
case "roll":
|
||||
printConsole("You got " + BTools.randInt(0, 101) + " points");
|
||||
break;
|
||||
default:
|
||||
int cmd = Update.command(cmdParts);
|
||||
if(cmd != 0){
|
||||
printConsole("Unknown command: " + cmdParts.get(0));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}catch(Exception e){
|
||||
printConsole("Something went wrong while running your command.");
|
||||
printException("", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static void printConsole(String text){
|
||||
consoleLines.add(text);
|
||||
if(consoleLines.size() > 30) consoleLines.remove(0);
|
||||
}
|
||||
public static void printError(String text){
|
||||
consoleError = true;
|
||||
printConsole(text);
|
||||
}
|
||||
public static void printException(String text, Exception e){
|
||||
consoleError = true;
|
||||
printConsole(text);
|
||||
printConsole("Error type: " + e.getClass().getName());
|
||||
}
|
||||
public static void printExceptionSilent(String text, Exception e){
|
||||
printConsole(text);
|
||||
printConsole("Error type: " + e.getClass().getName());
|
||||
}
|
||||
private static String[] cmds = {
|
||||
"credits",
|
||||
"drawCollision [0/1, false/true]",
|
||||
"engineDraw [0/1, false/true]",
|
||||
"drawPos [0/1, false/true]",
|
||||
"noclip [0/1, false/true]",
|
||||
"tp <x> <y>",
|
||||
"loadMap <name>",
|
||||
"drawFrames [0/1, false/true]",
|
||||
"debugColor <r> <g> <b> [a]",
|
||||
"enableBloom [0/1, false/true]",
|
||||
"enableExposure [0/1, false/true]",
|
||||
"setBloom <amount>",
|
||||
"setExposure <amount>",
|
||||
"setLightBlur <amount>",
|
||||
"clear",
|
||||
"help [page]",
|
||||
"customHelp [page]",
|
||||
"errorTest",
|
||||
"roll",
|
||||
};
|
||||
|
||||
public static void printHelp(int page){
|
||||
int startIndex = (page - 1) * 10;
|
||||
if(startIndex > cmds.length - 1){
|
||||
printConsole("page beyond bounds: " + page);
|
||||
printConsole("number of pages: " + (cmds.length / 10 + ((cmds.length % 10 != 0) ? 1 : 0)));
|
||||
return;
|
||||
}
|
||||
|
||||
printConsole("-- BUILT-IN COMMANDS --");
|
||||
printConsole("Page " + page + " of " + (cmds.length / 10 + ((cmds.length % 10 != 0) ? 1 : 0)));
|
||||
printConsole("");
|
||||
for(int i = startIndex; (i < cmds.length && i < startIndex + 10); i++){
|
||||
printConsole("} " + cmds[i]);
|
||||
}
|
||||
printConsole("");
|
||||
}
|
||||
|
||||
public static void printCustomHelp(int page){
|
||||
int startIndex = (page - 1) * 10;
|
||||
if(startIndex > Update.commands.length - 1){
|
||||
printConsole("page beyond bounds: " + page);
|
||||
printConsole("number of pages: " + (Update.commands.length / 10 + ((Update.commands.length % 10 != 0) ? 1 : 0)));
|
||||
return;
|
||||
}
|
||||
|
||||
printConsole("-- GAME-SPECIFIC COMMANDS --");
|
||||
printConsole("Page " + page + " of " + (Update.commands.length / 10 + ((Update.commands.length % 10 != 0) ? 1 : 0)));
|
||||
printConsole("");
|
||||
for(int i = startIndex; (i < Update.commands.length && i < startIndex + 10); i++){
|
||||
printConsole("} " + Update.commands[i]);
|
||||
}
|
||||
printConsole("");
|
||||
}
|
||||
|
||||
}
|
37
data/templates/blank2d/src/trident/ent/BoxColl.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package trident.ent;
|
||||
|
||||
import blib.util.*;
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import trident.*;
|
||||
public class BoxColl extends TridEntity{
|
||||
|
||||
public Color color = Color.white;
|
||||
|
||||
private ImageIcon engineImg = new ImageIcon("data/images/trident/boxColl.png");
|
||||
|
||||
public BoxColl(Position pos, Dimension size, Color c){
|
||||
super(pos, size);
|
||||
color = c;
|
||||
}
|
||||
public BoxColl(Position pos, Dimension size){
|
||||
super(pos, size);
|
||||
}
|
||||
public BoxColl(){
|
||||
super("boxcoll", true, 3);
|
||||
}
|
||||
public TridEntity construct(Position pos, Dimension collision, int[] data){
|
||||
return new BoxColl(pos, collision, new Color(data[0], data[1], data[2]));
|
||||
}
|
||||
|
||||
public void render(Graphics g, JPanel panel, int x, int y){
|
||||
g.setColor(color);
|
||||
g.fillRect(x - getCollision().width / 2, y - getCollision().height / 2, getCollision().width, getCollision().height);
|
||||
}
|
||||
|
||||
public void engineRender(Graphics g, JPanel panel, int x, int y){
|
||||
render(g, panel, x, y);
|
||||
engineImg.paintIcon(panel, g, x - engineImg.getIconWidth() / 2, y - engineImg.getIconHeight() / 2);
|
||||
}
|
||||
}
|