@@ -50,12 +50,24 @@ public void setup() {
5050 frameRate (60 );
5151 textSize (32 );
5252
53-
53+
5454 // Setup Server
5555 if (this .isServer ) {
56+ // Player
57+ float sqrDim = 50 ;
58+ PShape sqr = createShape (RECT , 0 , 0 , sqrDim , sqrDim );
59+ sqr .setFill (color (random (255 ), random (255 ), random (255 )));
60+ sqr .setStroke (false );
61+ this .player = new Player (sqr , height - sqrDim - 2 , 1 );
62+ this .objects .add (this .player );
63+ this .objectMap .put (this .player .getUUID (), this .player );
64+ this .movObjects .add (this .player );
65+
5666 this .server = new Server (9200 , this .threadPool , this .player );
5767 this .localClient = this .server .getLocalClient ();
5868 new Thread (this .server ).start ();
69+
70+ this .server .newPacket (Packet .PACKET_CREATE , this .player );
5971
6072
6173 // Add screen boundaries
@@ -126,15 +138,6 @@ public void setup() {
126138 this .server .newPacket (Packet .PACKET_CREATE , p );
127139 }
128140
129- // Player
130- float sqrDim = 50 ;
131- PShape sqr = createShape (RECT , 0 , 0 , sqrDim , sqrDim );
132- sqr .setFill (color (random (255 ), random (255 ), random (255 )));
133- sqr .setStroke (false );
134- this .player = new Player (sqr , height - sqrDim - 2 , 1 );
135- this .objectMap .put (this .player .getUUID (), this .player );
136- this .movObjects .add (this .player );
137- this .server .newPacket (Packet .PACKET_CREATE , this .player );
138141
139142 } else {
140143 try {
@@ -150,17 +153,9 @@ public void setup() {
150153
151154 public void draw () {
152155 background (0 );
153-
154- this .renderAll (objects );
155- // Walls
156- rect ((float ) this .floor .getPy ().getBounds2D ().getX (), (float ) this .floor .getPy ().getBounds2D ().getY (),
157- (float ) this .floor .getPy ().getBounds2D ().getWidth (), (float ) this .floor .getPy ().getBounds2D ().getHeight ());
158- rect ((float ) this .ceiling .getPy ().getBounds2D ().getX (), (float ) this .ceiling .getPy ().getBounds2D ().getY (),
159- (float ) this .ceiling .getPy ().getBounds2D ().getWidth (), (float ) this .ceiling .getPy ().getBounds2D ().getHeight ());
160- rect ((float ) this .leftWall .getPy ().getBounds2D ().getX (), (float ) this .leftWall .getPy ().getBounds2D ().getY (),
161- (float ) this .leftWall .getPy ().getBounds2D ().getWidth (), (float ) this .leftWall .getPy ().getBounds2D ().getHeight ());
162- rect ((float ) this .rightWall .getPy ().getBounds2D ().getX (), (float ) this .rightWall .getPy ().getBounds2D ().getY (),
163- (float ) this .rightWall .getPy ().getBounds2D ().getWidth (), (float ) this .rightWall .getPy ().getBounds2D ().getHeight ());
156+
157+ this .renderAll (this .objects );
158+
164159
165160 // Dummy Renderer?
166161 if (isServer ) {
@@ -169,10 +164,6 @@ public void draw() {
169164 obj .getPy ().update (obj , this .objects );
170165 }
171166 }
172- // Render
173- shape (this .localClient .getPlayer ().getShape (), this .localClient .getPlayer ().getPy ().getLocation ().x ,
174- this .localClient .getPlayer ().getPy ().getLocation ().y );
175-
176167
177168 // Only run update to clients 3fps?
178169 if (this .isServer && (frameCount % 20 == 0 )) {
0 commit comments