Delete Trident directory

This commit is contained in:
Blocky 2024-07-01 15:51:22 -06:00 committed by GitHub
parent 8b78628a28
commit d1ecb7b835
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
75 changed files with 0 additions and 2907 deletions

View file

@ -1,18 +0,0 @@
## Getting Started
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
## Folder Structure
The workspace contains two folders by default, where:
- `src`: the folder to maintain sources
- `lib`: the folder to maintain dependencies
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
## Dependency Management
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 417 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 399 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 333 B

View file

@ -1,2 +0,0 @@
{ projects
}

Binary file not shown.

View file

@ -1,246 +0,0 @@
package main;
import javax.swing.*;
import project.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.nio.file.Files;
public class Main {
public static Image icon = new ImageIcon("data/icon.png").getImage();
public static void main(String[] args){
Project.loadRegistry();
JFrame selWindow = new JFrame("Trident");
selWindow.setSize(400, 200);
selWindow.setResizable(false);
selWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
selWindow.setIconImage(icon);
selWindow.setLayout(new GridLayout(2, 3));
selWindow.setLocation(400, 300);
JButton loadButton = new JButton("Load Project");
loadButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
selWindow.dispose();
selection(0);
}
});
loadButton.setBackground(new Color(0, 0, 50));
loadButton.setForeground(Color.white);
selWindow.add(loadButton);
JButton newButton = new JButton("New Project");
newButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
selWindow.dispose();
selection(1);
}
});
newButton.setBackground(new Color(0, 0, 50));
newButton.setForeground(Color.white);
selWindow.add(newButton);
JButton importButton = new JButton("Import Project");
importButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
selWindow.dispose();
selection(2);
}
});
importButton.setBackground(new Color(0, 0, 50));
importButton.setForeground(Color.white);
selWindow.add(importButton);
JTextArea loadText = new JTextArea("Load a project");
loadText.setEditable(false);
loadText.setBackground(new Color(0, 0, 100));
loadText.setForeground(Color.white);
selWindow.add(loadText);
JTextArea newText = new JTextArea("Create a new project");
newText.setEditable(false);
newText.setBackground(new Color(0, 0, 100));
newText.setForeground(Color.white);
selWindow.add(newText);
JTextArea importText = new JTextArea("Get a project put\ninto the registry");
importText.setEditable(false);
importText.setBackground(new Color(0, 0, 100));
importText.setForeground(Color.white);
selWindow.add(importText);
selWindow.setVisible(true);
}
public static int loadSel = 0;
public static void selection(int sel){
if(sel == 0){ // Load project
if(Project.projRegistry.length == 0){
JOptionPane.showMessageDialog(null, "You don't have any projects!", "Trident", JOptionPane.ERROR_MESSAGE);
main(new String[0]);
return;
}
JFrame selWindow = new JFrame("Trident");
selWindow.setSize(500, 200);
selWindow.setResizable(false);
selWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
selWindow.setIconImage(icon);
selWindow.setLayout(new GridLayout(2, 3));
selWindow.setLocation(400, 300);
JTextField text = new JTextField(Project.projRegistry[0] + "\n(1/" + Project.projRegistry.length + ")");
text.setEditable(false);
text.setBackground(new Color(0, 0, 100));
text.setForeground(Color.white);
JButton prevButton = new JButton("<");
prevButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
loadSel--;
if(loadSel < 0){
loadSel = Project.projRegistry.length - 1;
}
text.setText(Project.projRegistry[loadSel] + "\n(" + (loadSel + 1) + "/" + Project.projRegistry.length + ")");
}
});
prevButton.setBackground(new Color(0, 0, 50));
prevButton.setForeground(Color.white);
selWindow.add(prevButton);
selWindow.add(text);
JButton nextButton = new JButton(">");
nextButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
loadSel++;
if(loadSel > Project.projRegistry.length - 1){
loadSel = 0;
}
text.setText(Project.projRegistry[loadSel] + "\n(" + (loadSel + 1) + "/" + Project.projRegistry.length + ")");
}
});
nextButton.setBackground(new Color(0, 0, 50));
nextButton.setForeground(Color.white);
selWindow.add(nextButton);
JButton loadButton = new JButton("Load");
loadButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
selWindow.dispose();
loadProject(loadSel);
}
});
loadButton.setBackground(new Color(0, 0, 50));
loadButton.setForeground(Color.white);
selWindow.add(loadButton);
JButton deleteButton = new JButton("Delete Project");
deleteButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
int sel = JOptionPane.showConfirmDialog(selWindow, "Are you sure you want to delete this project?", "Trident", JOptionPane.YES_NO_OPTION);
if(sel == 0){
deleteDir(new File("data/projects/" + Project.projRegistry[loadSel]));
String[] newRegistry = new String[Project.projRegistry.length - 1];
for(int i = 0, j = 0; i < Project.projRegistry.length; i++){
if(i != loadSel){
newRegistry[j] = Project.projRegistry[i];
j++;
}
}
Project.projRegistry = newRegistry;
loadSel = 0;
Project.saveRegistry();
JOptionPane.showMessageDialog(selWindow, "Deleted the project.", "Trident", JOptionPane.INFORMATION_MESSAGE);
if(Project.projRegistry.length == 0){
selWindow.dispose();
main(new String[0]);
return;
}
text.setText(Project.projRegistry[loadSel] + "\n(" + (loadSel + 1) + "/" + Project.projRegistry.length + ")");
}
}
});
deleteButton.setBackground(new Color(0, 0, 50));
deleteButton.setForeground(Color.white);
selWindow.add(deleteButton);
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
selWindow.dispose();
main(new String[0]);
}
});
cancelButton.setBackground(new Color(0, 0, 50));
cancelButton.setForeground(Color.white);
selWindow.add(cancelButton);
selWindow.setVisible(true);
}
if(sel == 1){ // New project
String name = JOptionPane.showInputDialog(null, "Enter the project name. If a project already exists with that name, keep in mind that it will replace it.", "Trident", JOptionPane.QUESTION_MESSAGE);
if(name == null){
main(new String[0]);
return;
}
String[] newRegistry = new String[Project.projRegistry.length + 1];
for(int i = 0; i < Project.projRegistry.length; i++){
newRegistry[i] = Project.projRegistry[i];
}
newRegistry[newRegistry.length - 1] = name;
Project.projRegistry = newRegistry;
Project.saveRegistry();
new Project(name);
JOptionPane.showMessageDialog(null, "Project successfully created.", "Trident", JOptionPane.INFORMATION_MESSAGE);
main(new String[0]);
}
if(sel == 2){ // Import project
String name = JOptionPane.showInputDialog(null, "Enter the project name. Make sure it's in the projects folder before you open it.", "Trident", JOptionPane.QUESTION_MESSAGE);
if(name == null){
main(new String[0]);
return;
}
String[] newRegistry = new String[Project.projRegistry.length + 1];
for(int i = 0; i < Project.projRegistry.length; i++){
newRegistry[i] = Project.projRegistry[i];
}
newRegistry[newRegistry.length - 1] = name;
Project.projRegistry = newRegistry;
Project.saveRegistry();
main(new String[0]);
}
}
public static void deleteDir(File file) {
if(!file.exists()) return;
File[] contents = file.listFiles();
if (contents != null) {
for (File f : contents) {
if (! Files.isSymbolicLink(f.toPath())) {
deleteDir(f);
}
}
}
file.delete();
}
public static JFrame window;
public static void loadProject(int proj){
window = new JFrame("Trident Editor");
window.setSize(700, 500);
window.setMinimumSize(new Dimension(700, 500));
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setIconImage(icon);
// panel
MainPanel panel = new MainPanel(new Project(proj));
window.add(panel);
//
window.setVisible(true);
}
}

View file

@ -1,631 +0,0 @@
package main;
import javax.swing.*;
import project.*;
import blib.util.*;
import blib.input.*;
import java.awt.event.*;
import java.awt.*;
import blib.game.*;
import java.io.*;
import project.ent.*;
import project.ent.Light;
public class MainPanel extends JPanel {
Project project;
Server server;
FrameManager frameManager = new FrameManager();
KeyManager km = new InputListener(this);
Camera cam;
ImageIcon icon = new ImageIcon("data/icon.png");
int tool = 0;
boolean drawLight = false;
Cursor[] cursors = {
BTools.getCustomCursor(new ImageIcon("data/images/cursors/select.png")),
BTools.getCustomCursor(new ImageIcon("data/images/cursors/move.png")),
BTools.getCustomCursor(new ImageIcon("data/images/cursors/resize.png")),
};
Point mouse = new Point(); // only used for better delta
boolean dropDown = false;
int dropType = 0;
/*
* 0 = trident button
* 1 = add new object
* 2 = delete object
*/
Rectangle dropRect = null;
ImageIcon selectImg = new ImageIcon("data/images/dropdown/select.png"), moveImg = new ImageIcon("data/images/dropdown/move.png"), resizeImg = new ImageIcon("data/images/dropdown/resize.png"), resetImg = new ImageIcon("data/images/dropdown/reset.png"), quitImg = new ImageIcon("data/images/dropdown/quit.png");
ImageIcon deleteImg = new ImageIcon("data/images/dropdown/delete.png");
ImageIcon boxImg = new ImageIcon("data/images/dropdown/box.png");
ImageIcon boxCollImg = new ImageIcon("data/images/dropdown/boxColl.png");
ImageIcon collisionImg = new ImageIcon("data/images/dropdown/collision.png");
ImageIcon plrStartImg = new ImageIcon("data/images/dropdown/plrStart.png");
ImageIcon customImg = new ImageIcon("data/images/dropdown/customEnt.png");
ImageIcon duplicateImg = new ImageIcon("data/images/dropdown/duplicate.png");
ImageIcon editImg = new ImageIcon("data/images/dropdown/edit.png");
ImageIcon triggerImg = new ImageIcon("data/images/dropdown/trigger.png");
ImageIcon lightImg = new ImageIcon("data/images/dropdown/light.png");
ImageIcon crosshair = new ImageIcon("data/images/crosshair.png");
boolean drawCross = true;
long saveTime = 0;
TridEntity selectedEntity = null;
public MainPanel(Project proj){
project = proj;
BTools.resizeImgIcon(icon, 32, 32);
cam = new Camera(new Position(), this);
setBackground(Color.black);
frameManager.bgColor = Color.white;
cam.setDimension = new Dimension(frameManager.WIDTH, frameManager.HEIGHT);
server = new Server(new ServerListener());
}
public void paintComponent(Graphics graphics){
super.paintComponent(graphics);
Graphics g = frameManager.newFrame();
frameManager.bgColor = project.currentScene.bgColor;
for(TridEntity e: project.currentScene.entities){
Point p = cam.worldToScreen(e.position);
e.engineRender(g, this, p.x, p.y);
if(e.equals(selectedEntity)){
g.setColor(new Color(0f, 0.2f, 1f, 0.5f));
g.fillOval(p.x - 32, p.y - 32, 64, 64);
}
if(e instanceof CustomEntity){
CustomEntity c = (CustomEntity)e;
String str = "[";
for(int i = 0; i < c.data.length; i++){
str += c.data[i] + "";
if(i == c.data.length - 1){
str += "]";
}else{
str += ", ";
}
}
if(c.data.length == 0) str = "NO DATA";
g.setColor(Color.white);
int width = Math.max(g.getFontMetrics().stringWidth(str), g.getFontMetrics().stringWidth(c.name));
g.fillRect(p.x - width / 2, p.y + 32 - 5, width, 20);
g.setColor(Color.black);
g.setFont(new Font("Arial", Font.PLAIN, 10));
TextBox.draw(c.name + "\n" + str, g, p.x, p.y + 32, TextBox.CENTER);
}
if(e instanceof Trigger){
Trigger trig = (Trigger)e;
String str = "" + trig.id;
g.setColor(Color.white);
int width = g.getFontMetrics().stringWidth(str);
g.fillRect(p.x - width / 2, p.y + 32 - 5, width, 10);
g.setColor(Color.black);
g.setFont(new Font("Arial", Font.PLAIN, 10));
TextBox.draw(str, g, p.x, p.y + 32, TextBox.CENTER);
}
}
if(drawLight){
int darkness = -project.currentScene.defaultLight + 255;
frameManager.fillScreen(new Color(0f, 0f, 0f, (darkness / 255f)));
}
g.setColor(new Color(0f, 0f, 0f, 0.5f));
g.fillRect(0, 0, frameManager.WIDTH, 40);
g.fillRect(0, frameManager.HEIGHT - 40, frameManager.WIDTH, 40);
g.setColor(Color.white);
g.setFont(new Font("Arial", Font.PLAIN, 20));
TextBox.draw("Code Load Scene New Scene Save PlrDir: " + project.currentScene.getDir(), g, 40, 20);
icon.paintIcon(this, g, 4, 4);
TextBox.draw("[L] Show Darkness: " + drawLight + " Default light level: " + project.currentScene.defaultLight, g, frameManager.WIDTH - 10, frameManager.HEIGHT - 20, TextBox.RIGHT);
g.setColor(new Color(1f, 1f, 1f, (saveTime / 1000f)));
TextBox.draw("Saved!", g, 10, frameManager.HEIGHT - 20);
g.setColor(Color.white);
g.setFont(new Font("Arial", Font.PLAIN, 15));
TextBox.draw("(" + cam.pos.toStringSimple() + ")", g, frameManager.WIDTH, 10, TextBox.RIGHT);
if(dropDown){
g.setColor(Color.lightGray);
g.fillRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height);
g.setColor(Color.gray);
g.drawRect(dropRect.x, dropRect.y, dropRect.width, dropRect.height);
for(int i = 0; i < dropRect.height / 32; i++){
g.drawLine(dropRect.x, dropRect.y + (i * 32), dropRect.x + dropRect.width, dropRect.y + (i * 32));
}
g.setColor(Color.black);
g.setFont(new Font("Arial", Font.PLAIN, 20));
if(dropType == 0){
selectImg.paintIcon(this, g, dropRect.x, dropRect.y);
TextBox.draw("Select", g, dropRect.x + 32, dropRect.y + 16);
moveImg.paintIcon(this, g, dropRect.x, dropRect.y + 32);
TextBox.draw("Move", g, dropRect.x + 32, dropRect.y + 16 + 32);
resizeImg.paintIcon(this, g, dropRect.x, dropRect.y + 64);
TextBox.draw("Resize", g, dropRect.x + 32, dropRect.y + 16 + 64);
resetImg.paintIcon(this, g, dropRect.x, dropRect.y + 64 + 32);
TextBox.draw("Return to (0, 0)", g, dropRect.x + 32, dropRect.y + 16 + 64 + 32);
editImg.paintIcon(this, g, dropRect.x, dropRect.y + 128);
TextBox.draw("Change bg color", g, dropRect.x + 32, dropRect.y + 16 + 128);
lightImg.paintIcon(this, g, dropRect.x, dropRect.y + 128 + 32);
TextBox.draw("Set Default Light", g, dropRect.x + 32, dropRect.y + 16 + 128 + 32);
quitImg.paintIcon(this, g, dropRect.x, dropRect.y + 128 + 64);
TextBox.draw("Save and Quit", g, dropRect.x + 32, dropRect.y + 16 + 128 + 64);
}
if(dropType == 1){
deleteImg.paintIcon(this, g, dropRect.x, dropRect.y);
TextBox.draw("Delete", g, dropRect.x + 32, dropRect.y + 16);
duplicateImg.paintIcon(this, g, dropRect.x, dropRect.y + 32);
TextBox.draw("Duplicate", g, dropRect.x + 32, dropRect.y + 16 + 32);
editImg.paintIcon(this, g, dropRect.x, dropRect.y + 64);
TextBox.draw("Edit", g, dropRect.x + 32, dropRect.y + 16 + 64);
resetImg.paintIcon(this, g, dropRect.x, dropRect.y + 64 + 32);
TextBox.draw("Bring here", g, dropRect.x + 32, dropRect.y + 16 + 64 + 32);
}
if(dropType == 2){
boxImg.paintIcon(this, g, dropRect.x, dropRect.y);
TextBox.draw("Add BoxNoColl", g, dropRect.x + 32, dropRect.y + 16);
boxCollImg.paintIcon(this, g, dropRect.x, dropRect.y + 32);
TextBox.draw("Add BoxColl", g, dropRect.x + 32, dropRect.y + 16 + 32);
collisionImg.paintIcon(this, g, dropRect.x, dropRect.y + 64);
TextBox.draw("Add InvisColl", g, dropRect.x + 32, dropRect.y + 16 + 64);
plrStartImg.paintIcon(this, g, dropRect.x, dropRect.y + 64 + 32);
TextBox.draw("Add PlrStart", g, dropRect.x + 32, dropRect.y + 16 + 64 + 32);
triggerImg.paintIcon(this, g, dropRect.x, dropRect.y + 128);
TextBox.draw("Add Trigger", g, dropRect.x + 32, dropRect.y + 16 + 128);
customImg.paintIcon(this, g, dropRect.x, dropRect.y + 128 + 32);
TextBox.draw("Add Custom Entity", g, dropRect.x + 32, dropRect.y + 16 + 128 + 32);
lightImg.paintIcon(this, g, dropRect.x, dropRect.y + 128 + 64);
TextBox.draw("Add Light", g, dropRect.x + 32, dropRect.y + 16 + 128 + 64);
}
}
if(drawCross) crosshair.paintIcon(this, g, frameManager.WIDTH / 2 - 4, frameManager.HEIGHT / 2 - 4);
frameManager.renderFrame(this, graphics);
}
public int getDropSel(int y){
return (y - dropRect.y) / 32;
}
private class InputListener extends InputAdapter{
public InputListener(JPanel panel){
super(panel);
}
public void onKeyPressed(int key){
if(key == KeyEvent.VK_R){
cam.pos = new Position();
}
if(key == KeyEvent.VK_1){
tool = 0;
}
if(key == KeyEvent.VK_2){
tool = 1;
}
if(key == KeyEvent.VK_3){
tool = 2;
}
if(key == KeyEvent.VK_DELETE && selectedEntity != null){
project.currentScene.entities.remove(selectedEntity);
selectedEntity = null;
}
if(key == KeyEvent.VK_M && km.getKeyDown(KeyEvent.VK_CONTROL)){
project.currentScene.save("data/projects/" + project.name);
}
if(key == KeyEvent.VK_C && km.getKeyDown(KeyEvent.VK_CONTROL)){
if(selectedEntity instanceof BoxColl){
BoxColl box = (BoxColl)selectedEntity;
project.currentScene.entities.add(new BoxColl(box.position.copy(), new Dimension(box.collision.width, box.collision.height), box.color));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof BoxNoColl){
BoxNoColl box = (BoxNoColl)selectedEntity;
project.currentScene.entities.add(new BoxNoColl(box.position.copy(), box.color, box.width, box.height));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof InvisColl){
InvisColl box = (InvisColl)selectedEntity;
project.currentScene.entities.add(new InvisColl(box.position.copy(), new Dimension(box.collision.width, box.collision.height)));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof Trigger){
Trigger box = (Trigger)selectedEntity;
project.currentScene.entities.add(new Trigger(box.position.copy(), new Dimension(box.box.width, box.box.height), box.id));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof PlrStart){
PlrStart box = (PlrStart)selectedEntity;
project.currentScene.entities.add(new PlrStart(box.position.copy()));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof Light){
Light box = (Light)selectedEntity;
project.currentScene.entities.add(new Light(box.position.copy(), box.radius));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof CustomEntity){
CustomEntity box = (CustomEntity)selectedEntity;
int[] data = new int[box.data.length];
for(int i = 0; i < data.length; i++){
data[i] = box.data[i];
}
Dimension collision = null;
if(box.collision != null) collision = new Dimension(box.collision.width, box.collision.height);
project.currentScene.entities.add(new CustomEntity(box.position.copy(), collision, data, box.name));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
}
if(key == KeyEvent.VK_L){
drawLight = !drawLight;
}
if(key == KeyEvent.VK_C && !km.getKeyDown(KeyEvent.VK_CONTROL)){
drawCross = !drawCross;
}
}
public void onMousePressed(int mb, Point mousePos){
mousePos = frameManager.getMousePos(panel, mousePos);
if(mousePos.equals(new Point())) return; // likely outside of frame
if(mb == 1){
if(dropDown){
if(dropRect.contains(mousePos)){
int sel = getDropSel(mousePos.y);
if(dropType == 0){
switch(sel){
case 0:
case 1:
case 2:
tool = sel;
break;
case 3:
cam.pos = new Position();
break;
case 4:
try{
int r, g, b;
String input = JOptionPane.showInputDialog(panel, "Enter the red value.", "Trident", JOptionPane.QUESTION_MESSAGE);
r = Integer.parseInt(input);
input = JOptionPane.showInputDialog(panel, "Enter the green value.", "Trident", JOptionPane.QUESTION_MESSAGE);
g = Integer.parseInt(input);
input = JOptionPane.showInputDialog(panel, "Enter the blue value.", "Trident", JOptionPane.QUESTION_MESSAGE);
b = Integer.parseInt(input);
Color c = new Color(r, g, b);
project.currentScene.bgColor = c;
}catch(Exception e){}
break;
case 5:
try{
int level;
String input = JOptionPane.showInputDialog(panel, "Enter the new default light level", "Trident", JOptionPane.QUESTION_MESSAGE);
level = Integer.parseInt(input);
level = BTools.clamp(level, 0, 255);
project.currentScene.defaultLight = level;
}catch(Exception e){}
break;
case 6:
project.currentScene.save("data/projects/" + project.name);
Main.window.dispose();
Main.main(new String[0]);
return;
}
}
if(dropType == 1){
switch(sel){
case 0:
project.currentScene.entities.remove(selectedEntity);
selectedEntity = null;
break;
case 1:
if(selectedEntity instanceof BoxColl){
BoxColl box = (BoxColl)selectedEntity;
project.currentScene.entities.add(new BoxColl(box.position.copy(), new Dimension(box.collision.width, box.collision.height), box.color));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof BoxNoColl){
BoxNoColl box = (BoxNoColl)selectedEntity;
project.currentScene.entities.add(new BoxNoColl(box.position.copy(), box.color, box.width, box.height));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof InvisColl){
InvisColl box = (InvisColl)selectedEntity;
project.currentScene.entities.add(new InvisColl(box.position.copy(), new Dimension(box.collision.width, box.collision.height)));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof Trigger){
Trigger box = (Trigger)selectedEntity;
project.currentScene.entities.add(new Trigger(box.position.copy(), new Dimension(box.box.width, box.box.height), box.id));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof PlrStart){
PlrStart box = (PlrStart)selectedEntity;
project.currentScene.entities.add(new PlrStart(box.position.copy()));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof Light){
Light box = (Light)selectedEntity;
project.currentScene.entities.add(new Light(box.position.copy(), box.radius));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
if(selectedEntity instanceof CustomEntity){
CustomEntity box = (CustomEntity)selectedEntity;
int[] data = new int[box.data.length];
for(int i = 0; i < data.length; i++){
data[i] = box.data[i];
}
Dimension collision = null;
if(box.collision != null) collision = new Dimension(box.collision.width, box.collision.height);
project.currentScene.entities.add(new CustomEntity(box.position.copy(), collision, data, box.name));
selectedEntity = project.currentScene.entities.get(project.currentScene.entities.size() - 1);
}
break;
case 2:
if(selectedEntity instanceof BoxColl){
try{
int[] data = new int[3];
for(int i = 0; i < 3; i++){
String input = JOptionPane.showInputDialog(panel, "Enter data[" + i + "]", "Trident", JOptionPane.QUESTION_MESSAGE);
data[i] = Integer.parseInt(input);
}
BoxColl box = (BoxColl)selectedEntity;
box.color = new Color(data[0], data[1], data[2]);
}catch(Exception e){}
}
if(selectedEntity instanceof BoxNoColl){
try{
int[] data = new int[3];
for(int i = 0; i < 3; i++){
String input = JOptionPane.showInputDialog(panel, "Enter data[" + i + "]", "Trident", JOptionPane.QUESTION_MESSAGE);
data[i] = Integer.parseInt(input);
}
BoxNoColl box = (BoxNoColl)selectedEntity;
box.color = new Color(data[0], data[1], data[2]);
}catch(Exception e){}
}
if(selectedEntity instanceof CustomEntity){
try{
CustomEntity c = (CustomEntity)selectedEntity;
int[] data = new int[c.data.length];
for(int i = 0; i < c.data.length; i++){
String input = JOptionPane.showInputDialog(panel, "Enter data[" + i + "]", "Trident", JOptionPane.QUESTION_MESSAGE);
data[i] = Integer.parseInt(input);
}
c.data = data;
}catch(Exception e){}
}
if(selectedEntity instanceof Trigger){
try{
int[] data = new int[1];
for(int i = 0; i < 1; i++){
String input = JOptionPane.showInputDialog(panel, "Enter data[" + i + "]", "Trident", JOptionPane.QUESTION_MESSAGE);
data[i] = Integer.parseInt(input);
}
Trigger box = (Trigger)selectedEntity;
box.id = data[0];
}catch(Exception e){}
}
break;
case 3:
Position worldPos = cam.mouseToPos(new Point(dropRect.x, dropRect.y));
selectedEntity.position = worldPos;
break;
}
}
if(dropType == 2){
Position worldPos = cam.mouseToPos(new Point(dropRect.x, dropRect.y));
switch(sel){
case 0:
project.currentScene.entities.add(new BoxNoColl(worldPos, Color.black, 100, 100));
break;
case 1:
project.currentScene.entities.add(new BoxColl(worldPos, new Dimension(100, 100), Color.black));
break;
case 2:
project.currentScene.entities.add(new InvisColl(worldPos, new Dimension(100, 100)));
break;
case 3:
project.currentScene.entities.add(new PlrStart(worldPos));
break;
case 4:
try{
String input = JOptionPane.showInputDialog(panel, "Enter the ID for the trigger", "Trident", JOptionPane.QUESTION_MESSAGE);
int id = Integer.parseInt(input);
project.currentScene.entities.add(new Trigger(worldPos, new Dimension(100, 100), id));
}catch(Exception e){}
break;
case 5:
String name = JOptionPane.showInputDialog(panel, "Enter the object name", "Trident", JOptionPane.QUESTION_MESSAGE);
if(name != null){
int coll = JOptionPane.showConfirmDialog(panel, "Does the object have collision?", "Trident", JOptionPane.YES_NO_CANCEL_OPTION);
if(coll == 2) break;
Dimension collider = null;
if(coll == 0) collider = new Dimension(100, 100);
String input = JOptionPane.showInputDialog(panel, "Enter the amount of data you need", "Trident", JOptionPane.QUESTION_MESSAGE);
try{
int numData = Integer.parseInt(input);
int[] data = new int[numData];
for(int i = 0; i < numData; i++){
String dataStr = JOptionPane.showInputDialog(panel, "Enter data[" + i + "]", "Trident", JOptionPane.QUESTION_MESSAGE);
data[i] = Integer.parseInt(dataStr);
}
project.currentScene.entities.add(new CustomEntity(worldPos, collider, data, name));
System.out.println("created entity");
}catch(Exception e){
e.printStackTrace();
dropDown = false;
return;
}
}
break;
case 6:
project.currentScene.entities.add(new project.ent.Light(worldPos, 50));
break;
}
}
dropDown = false;
return;
}else{
dropDown = false;
return;
}
}
if(mousePos.y < 40){
System.out.println(mousePos.x);
// Toolbar
if(mousePos.x < 40){
dropDown = true;
dropType = 0;
dropRect = new Rectangle(0, 40, 200, 32 * 7);
}else if(mousePos.x < 90){
BTools.openHighlightFile(new File("data/projects/" + project.name).getAbsolutePath());
}else if(mousePos.x < 212){
String name = JOptionPane.showInputDialog(panel, "Enter the scene name", "Trident", JOptionPane.QUESTION_MESSAGE);
if(name != null){
boolean loaded = project.loadScene(name);
if(!loaded){
JOptionPane.showMessageDialog(panel, "Error: no scene with name '" + name + "' found.", "Trident", JOptionPane.ERROR_MESSAGE);
}else{
cam.pos = new Position();
}
}
}else if(mousePos.x < 327){
String name = JOptionPane.showInputDialog(panel, "Enter the scene name", "Trident", JOptionPane.QUESTION_MESSAGE);
if(name != null){
Scene scene = new Scene(name);
scene.save("data/projects/" + project.name);
project.setupScenes();
project.loadScene(name);
cam.pos = new Position();
}
}else if(mousePos.x < 391){
project.currentScene.save("data/projects/" + project.name);
saveTime = 1000;
}else if(mousePos.x < 520){
project.currentScene.plrDir++;
if(project.currentScene.plrDir > 3) project.currentScene.plrDir = 0;
}else{
try{
double x, y;
String inputX = JOptionPane.showInputDialog(panel, "Enter the x position", "Trident", JOptionPane.QUESTION_MESSAGE);
if(inputX != null){
x = Double.parseDouble(inputX);
String inputY = JOptionPane.showInputDialog(panel, "Enter the y position", "Trident", JOptionPane.QUESTION_MESSAGE);
if(inputY != null){
y = Double.parseDouble(inputY);
cam.pos = new Position(x, y);
}
}
}catch(Exception e){
JOptionPane.showMessageDialog(panel, "Invalid input", "Trident", JOptionPane.ERROR_MESSAGE);
}
}
}else{
if(tool == 0){
if(selectedEntity != null){
selectedEntity = null;
}
Position worldPos = cam.mouseToPos(mousePos);
for(TridEntity e: project.currentScene.entities){
if(BTools.getDistance(e.position, worldPos) < 32){
selectedEntity = e;
return;
}
}
}
}
}
if(mb == 3){
if(selectedEntity == null){
dropDown = true;
dropType = 2;
dropRect = new Rectangle(mousePos.x, mousePos.y, 200, 32 * 7);
}else{
dropDown = true;
dropType = 1;
dropRect = new Rectangle(mousePos.x, mousePos.y, 200, 32 * 4);
}
}
}
}
MainPanel parent = this;
private class ServerListener implements ActionListener{
public void actionPerformed(ActionEvent event){
Point delta = new Point(-mouse.x + frameManager.getMousePos(parent, km.getMousePos()).x, -mouse.y + frameManager.getMousePos(parent, km.getMousePos()).y);
mouse = frameManager.getMousePos(parent, km.getMousePos());
// Movement
Point dir = new Point();
if(km.getKeyDown(KeyEvent.VK_W)) dir.y--;
if(km.getKeyDown(KeyEvent.VK_S)) dir.y++;
if(km.getKeyDown(KeyEvent.VK_A)) dir.x--;
if(km.getKeyDown(KeyEvent.VK_D)) dir.x++;
double speed = 0.5;
if(km.getKeyDown(KeyEvent.VK_SHIFT)) speed *= 2;
if(km.getKeyDown(KeyEvent.VK_CONTROL)) speed /= 2;
cam.pos.x += dir.x * server.getElapsedTime() * speed;
cam.pos.y += dir.y * server.getElapsedTime() * speed;
saveTime -= server.getElapsedTime();
if(saveTime < 0) saveTime = 0;
if(tool == 1 && selectedEntity != null && km.getMouseDown(1)){
selectedEntity.position.x += delta.x;
selectedEntity.position.y += delta.y;
selectedEntity.position.x += dir.x * server.getElapsedTime() * speed;
selectedEntity.position.y += dir.y * server.getElapsedTime() * speed;
}
if(tool == 2 && selectedEntity != null && km.getMouseDown(1)){
if(selectedEntity instanceof project.ent.Light){
project.ent.Light light = (project.ent.Light)selectedEntity;
light.radius += delta.x;
if(light.radius < 0) light.radius = 0;
}
if(selectedEntity instanceof BoxNoColl){
BoxNoColl box = (BoxNoColl)selectedEntity;
box.width += delta.x;
box.height -= delta.y;
if(box.width < 0) box.width = 0;
if(box.height < 0) box.height = 0;
}
if(selectedEntity instanceof Trigger){
Trigger trig = (Trigger)selectedEntity;
trig.box.width += delta.x;
trig.box.height -= delta.y;
if(trig.box.width < 0) trig.box.width = 0;
if(trig.box.height < 0) trig.box.height = 0;
}
if(selectedEntity.HASCOLLISION){
selectedEntity.collision.width += delta.x;
selectedEntity.collision.height -= delta.y;
if(selectedEntity.collision.width < 0) selectedEntity.collision.width = 0;
if(selectedEntity.collision.height < 0) selectedEntity.collision.height = 0;
}
}
setCursor(cursors[tool]);
repaint();
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,181 +0,0 @@
package project;
import java.util.ArrayList;
import java.awt.*;
import java.io.*;
import blib.bson.*;
import blib.util.*;
import blib.game.*;
import project.ent.*;
public class Scene {
public final String name;
public ArrayList<TridEntity> entities;
protected Position plrStart = new Position();
public int plrDir = Player.SOUTH;
public Color bgColor = Color.white;
private TridEntity[] entRegistry = {
new BoxColl(),
new BoxNoColl(),
new InvisColl(),
new PlrStart(),
new Trigger(),
new project.ent.Light(),
};
public 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: 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){
double x, y;
x = asList.list.get(i).getDouble();
i++;
y = asList.list.get(i).getDouble();
i++;
int w = 0, h = 0;
boolean hasColl = asList.list.get(i).getBoolean();
i++;
if(hasColl){
w = asList.list.get(i).getInt();
i++;
h = asList.list.get(i).getInt();
i++;
}
int[] data = new int[0];
while(i < asList.list.size() && asList.list.get(i).type == BSonObject.INT){
int[] newData = new int[data.length + 1];
for(int j = 0; j < data.length; j++) newData[j] = data[j];
newData[data.length] = asList.list.get(i).getInt();
data = newData;
i++;
}
entities.add(new CustomEntity(new Position(x, y), new Dimension(w, h), data, objName));
i--;
}
}
}
public String getDir(){
if(plrDir == Player.SOUTH) return "south";
if(plrDir == Player.EAST) return "east";
if(plrDir == Player.WEST) return "west";
if(plrDir == Player.NORTH) return "north";
return "unknown direction";
}
public void save(String projDir){
try{
File file = new File(projDir + "/data/scenes/" + name + ".bson");
file.createNewFile();
PrintWriter writer = new PrintWriter(file);
writer.println("string name " + name);
writer.println("string dir " + getDir());
writer.println("int light " + defaultLight);
writer.println("{ bgColor");
writer.println("int " + bgColor.getRed());
writer.println("int " + bgColor.getGreen());
writer.println("int " + bgColor.getBlue());
writer.println("}");
writer.println("{ entities");
for(TridEntity e: entities){
writer.println("string " + e.name);
writer.println("double " + e.position.x);
writer.println("double " + e.position.y);
writer.println("boolean " + e.HASCOLLISION);
if(e.HASCOLLISION){
writer.println("int " + e.getCollision().width);
writer.println("int " + e.getCollision().height);
}
if(e instanceof BoxNoColl){
BoxNoColl box = (BoxNoColl)e;
writer.println("int " + box.width);
writer.println("int " + box.height);
writer.println("int " + box.color.getRed());
writer.println("int " + box.color.getGreen());
writer.println("int " + box.color.getBlue());
}
if(e instanceof BoxColl){
BoxColl box = (BoxColl)e;
writer.println("int " + box.color.getRed());
writer.println("int " + box.color.getGreen());
writer.println("int " + box.color.getBlue());
}
if(e instanceof Trigger){
Trigger trig = (Trigger)e;
writer.println("int " + trig.box.width);
writer.println("int " + trig.box.height);
writer.println("int " + trig.id);
}
if(e instanceof project.ent.Light){
project.ent.Light light = (project.ent.Light)e;
writer.println("int " + light.radius);
}
if(e instanceof CustomEntity){
CustomEntity custom = (CustomEntity)e;
for(int i: custom.data){
writer.println("int " + i);
}
}
}
writer.println("}");
writer.close();
}catch(Exception e){}
}
}

View file

@ -1,65 +0,0 @@
package project;
import blib.game.*;
import blib.util.*;
import javax.swing.*;
import java.awt.*;
public class TridEntity extends Entity {
public final boolean HASCOLLISION;
public Dimension collision;
public String engineRenderData = "";
private ImageIcon engineImg = new ImageIcon("data/images/trident/customEnt.png");
public 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 == null || 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 final Rectangle getCollision(){
return new Rectangle((int)position.x - (collision.width / 2), (int)position.y - (collision.height / 2), collision.width, collision.height);
}
public void gameStart(){
}
public void render(Graphics g, JPanel panel, int x, int y){
}
public 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){
}
}

View file

@ -1,39 +0,0 @@
package project.ent;
import blib.util.*;
import java.awt.*;
import javax.swing.*;
import project.*;
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;
name = "boxcoll";
}
public BoxColl(Position pos, Dimension size){
super(pos, size);
name = "boxcoll";
}
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);
}
}

View file

@ -1,47 +0,0 @@
package project.ent;
import blib.util.*;
import java.awt.*;
import javax.swing.*;
import blib.game.*;
import project.*;
public class BoxNoColl extends TridEntity{
public Color color = Color.white;
public int width, height;
private ImageIcon engineImg = new ImageIcon("data/images/trident/box.png");
public BoxNoColl(Position pos, Color c, int w, int h){
super(pos);
color = c;
width = w;
height = h;
renderType = Entity.UNDER;
name = "boxnocoll";
}
public BoxNoColl(Position pos, int w, int h){
super(pos);
width = w;
height = h;
renderType = Entity.UNDER;
name = "boxnocoll";
}
public BoxNoColl(){
super("boxnocoll", false, 5);
}
public TridEntity construct(Position pos, Dimension collision, int[] data){
return new BoxNoColl(pos, new Color(data[2], data[3], data[4]), data[0], data[1]);
}
public void render(Graphics g, JPanel panel, int x, int y){
g.setColor(color);
g.fillRect(x - width / 2, y - height / 2, width, 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);
}
}

View file

@ -1,18 +0,0 @@
package project.ent;
import blib.util.*;
import project.*;
import java.awt.*;
public class CustomEntity extends TridEntity{
public int[] data;
public CustomEntity(Position pos, Dimension d, int[] dat, String n){
super(pos, d);
data = dat;
name = n;
}
public CustomEntity(){
super("custom", false, 0);
}
}

View file

@ -1,31 +0,0 @@
package project.ent;
import blib.util.*;
import java.awt.*;
import javax.swing.*;
import project.*;
public class InvisColl extends TridEntity{
public Color color = Color.red;
private ImageIcon engineImg = new ImageIcon("data/images/trident/collision.png");
public InvisColl(Position pos, Dimension size){
super(pos, size);
name = "inviscoll";
}
public InvisColl(){
super("inviscoll", true, 0);
}
public TridEntity construct(Position pos, Dimension collision, int[] data){
return new InvisColl(pos, collision);
}
public void engineRender(Graphics g, JPanel panel, int x, int y){
g.setColor(color);
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);
}
}

View file

@ -1,31 +0,0 @@
package project.ent;
import blib.util.*;
import java.awt.*;
import javax.swing.*;
import project.*;
public class Light extends TridEntity{
public int radius;
private ImageIcon engineImg = new ImageIcon("data/images/trident/light.png");
public Light(Position pos, int r){
super(pos);
name = "light";
radius = r;
}
public Light(){
super("light", false, 1);
}
public TridEntity construct(Position pos, Dimension collision, int[] data){
return new Light(pos, data[0]);
}
public void engineRender(Graphics g, JPanel panel, int x, int y){
engineImg.paintIcon(panel, g, x - engineImg.getIconWidth() / 2, y - engineImg.getIconHeight() / 2);
g.setColor(Color.red);
g.drawOval(x - radius, y - radius, radius * 2, radius * 2);
}
}

View file

@ -1,27 +0,0 @@
package project.ent;
import blib.util.*;
import java.awt.*;
import javax.swing.*;
import project.*;
public class PlrStart extends TridEntity{
public Color color = Color.red;
private ImageIcon engineImg = new ImageIcon("data/images/trident/plrStart.png");
public PlrStart(Position pos){
super(pos);
name = "plrstart";
}
public PlrStart(){
super("plrstart", false, 0);
}
public TridEntity construct(Position pos, Dimension collision, int[] data){
return new PlrStart(pos);
}
public void engineRender(Graphics g, JPanel panel, int x, int y){
engineImg.paintIcon(panel, g, x - engineImg.getIconWidth() / 2, y - engineImg.getIconHeight() / 2);
}
}

View file

@ -1,35 +0,0 @@
package project.ent;
import blib.util.*;
import java.awt.*;
import javax.swing.*;
import project.*;
public class Trigger extends TridEntity{
public Color color = Color.blue;
public Dimension box;
public int id;
private ImageIcon engineImg = new ImageIcon("data/images/trident/trigger.png");
public Trigger(Position pos, Dimension size, int i){
super(pos);
name = "trigger";
box = size;
id = i;
}
public Trigger(){
super("trigger", false, 3);
}
public TridEntity construct(Position pos, Dimension collision, int[] data){
return new Trigger(pos, new Dimension(data[0], data[1]), data[2]);
}
public void engineRender(Graphics g, JPanel panel, int x, int y){
g.setColor(color);
g.drawRect(x - box.width / 2, y - box.height / 2, box.width, box.height);
g.drawLine(x - box.width / 2, y - box.height / 2, x + box.width / 2, y + box.height / 2);
engineImg.paintIcon(panel, g, x - engineImg.getIconWidth() / 2, y - engineImg.getIconHeight() / 2);
}
}