From b97f6d881d030ba63853eebc2848f8435d8fb6d9 Mon Sep 17 00:00:00 2001 From: coutjojo Date: Sat, 22 May 2021 18:26:29 +0200 Subject: [PATCH] Window and other base stuff --- out/production/3D_Demo/Launcher.class | Bin 527 -> 573 bytes src/Launcher.java | 1 + src/Main.java | 36 ++++++++++++++++++++++++++ src/Object/Polygone.java | 32 +++++++++++++++++++++++ src/Object/Vector.java | 15 +++++++++++ src/WindowMannaging/Window.java | 32 +++++++++++++++++++++++ 6 files changed, 116 insertions(+) create mode 100644 src/Main.java create mode 100644 src/Object/Polygone.java create mode 100644 src/Object/Vector.java create mode 100644 src/WindowMannaging/Window.java diff --git a/out/production/3D_Demo/Launcher.class b/out/production/3D_Demo/Launcher.class index 3027462f4e07a25ce28f71c6394eb75141914892..45b9cfe2ebe35b9c493f29535c0992370985b7bf 100644 GIT binary patch delta 219 zcmYL?Jr06U5QOK!1N21{P4Hh4{3(oyy=Q;}P+Hn}1utM?h$qoP5{=fz$`cvqNnx?y zW_D+15ArV6>vMeoSYei_rz?~7W~<=CbkND(d)tonnONC68r*`->t3wCRs zL!5r=9;w%0^~p+MzyL$4G6IY^(Z>nHbZGqyr{P{uyTMO$wBmnI6($WPN()GMe5@0j T#T7zCR36g;j7fnBwSnmuk|q}? delta 176 zcmdnX($B(m>ff$?3=9lb3`!HZPE35*HMxXQu3nUZ2`I(@BpDf48Q6fNIFP3gq#1!U ztJZb~#*JWU2_OlQW&mPIAjtz!z#zpS4dih$$S}wPML?R(!G;0FHZiaZ@or<_M;O2b dwvCyAgMkHNh#1%uP6jy!d9cX}K$3|;5dcA%5N!Ye diff --git a/src/Launcher.java b/src/Launcher.java index 17df93c..e343c60 100644 --- a/src/Launcher.java +++ b/src/Launcher.java @@ -1,5 +1,6 @@ public class Launcher { public static void main(String[] args) { System.out.println("Hello World"); + Main main = new Main(); } } diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..5358329 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,36 @@ +import WindowMannaging.Window; + +import java.awt.*; +import java.awt.image.BufferStrategy; + +public class Main { + ///////////////////////////////// + private static final int WIDTH = 1000; + private static final int HEIGHT = 700; + Window window; + Graphics g; + BufferStrategy bs; + ////////////////////////////////// Class attributes + public Main (){ + window = new Window(WIDTH,HEIGHT,"3D-Game"); + init(); + } + + private void init(){ + bs = window.getCanvas().getBufferStrategy(); + if(window.getCanvas().getBufferStrategy() == null){ + window.getCanvas().createBufferStrategy(3); + return; + } + g = bs.getDrawGraphics(); + g.clearRect(0,0, window.getWidth(), window.getHeight()); + render(g); + } + + public void tick(){} + + public void render(Graphics g){ + + + } +} diff --git a/src/Object/Polygone.java b/src/Object/Polygone.java new file mode 100644 index 0000000..0b96b88 --- /dev/null +++ b/src/Object/Polygone.java @@ -0,0 +1,32 @@ +package Object; + +import java.awt.*; + +/** + * Ein Quader object + */ +public class Polygone { + ////////////////////////// + Dimension startpoint; + int length; + int height; + int depth; + ////////////////////////// Class attributes + + /** + * + * @param startpoint der Obere linke punkt des Quaders + * @param length die Länge des Quaders + * @param height die Höhe des Quaders + * @param depth die Tiefe des Quaders + */ + public Polygone(Dimension startpoint , int length, int height, int depth){ + this.startpoint = startpoint; + this.length = length; + this.height = height; + this.depth = depth; + } + public void render(Graphics g){ + + } +} diff --git a/src/Object/Vector.java b/src/Object/Vector.java new file mode 100644 index 0000000..eb0fc32 --- /dev/null +++ b/src/Object/Vector.java @@ -0,0 +1,15 @@ +package Object; + +import java.awt.*; + +public class Vector { + double x,y,z; + public Vector(double x,double y,double z){ + this.x = x; + this.y = y; + this.z = z; + } + public Point convertTo2D(Vector v){ + return new Point((int)(500+y),(int)(350+z)); + } +} diff --git a/src/WindowMannaging/Window.java b/src/WindowMannaging/Window.java new file mode 100644 index 0000000..dccf954 --- /dev/null +++ b/src/WindowMannaging/Window.java @@ -0,0 +1,32 @@ +package WindowMannaging; +import javax.swing.*; +import java.awt.*; +public class Window extends JFrame { + Canvas canvas; + /** + * + * @param length the Length of the Window + * @param height The Height of the Window + * @param WindowLable the Name of the Window + */ + public Window(int length , int height,String WindowLable){ + super(WindowLable); + this.setSize(length,height); + this.setDefaultCloseOperation(EXIT_ON_CLOSE); + this.setLocationRelativeTo(null); + this.setVisible(true); + canvas.setSize(length,height); + this.add(canvas); + } + /** + * + * @param comp an + */ + public void addPane(Component comp){ + this.add(comp); + } + + public Canvas getCanvas(){ + return canvas; + } +}