Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 13
1  Discussions / Business and Project Management Discussions / Re: Starting a small dev business on: 2014-10-01 13:35:25
I highly advise taking a step back and starting much smaller.

You're approaching this from the wrong angle: instead of starting out trying to make money and start a company, why don't you just have fun? It sounds like you're interested in programming, and that's great. Why not use that interest and invest in yourself by getting as much practice as possible?

You don't do this by trying to make a profit or start a company (whatever that means). Instead, you do this by just sitting down and programming stuff. You practice, maybe start gaining a following (if you're lucky), and only then (which might take years) should you start worrying about making money.

But if you're dead-set on trying to sell your product (which I highly advise against), you might try putting your stuff on Google Play or something like Desura (note: I've never used Desura, but it might be worth looking into).

Alternatively, you could think about advertisements instead of sales. Put a banner ad on your website, and if your games are popular enough to attract a following, you might make some money that way.

But seriously, don't worry about money.
2  Game Development / Newbie & Debugging Questions / Re: [LIBGDX] How to draw terrain for truck/car game? on: 2014-09-30 14:31:13
Step 1 is to get something really basic working, then work your way up. Can you draw a single point? Can you draw a triangle? Can you draw an entirely flat terrain?

If you're having trouble with that, post an MCVE with hard-coded (not randomized) values and we can take a look.

If you can get the basics working, then start thinking about that dumb friend of yours. Write out (in English, not code) exactly what you're trying to do.

When you have the basics working perfectly, and the instructions written out clearly, then you can think about combining them.
3  Discussions / Miscellaneous Topics / Re: Java won't let me time travel on: 2014-09-30 14:00:16
Haha!

Guess I'll just keep my fingers crossed for the singularity then!
4  Game Development / Newbie & Debugging Questions / Re: How to draw terrain for truck/car game? on: 2014-09-30 13:22:43
What are you using for the? Java2D? LibGDX? LWJGL? JOGL? JMonkeyEngine? Slick? Something else?

What about this is giving you trouble? What have you tried so far?

How would you do this with a pencil on a piece of paper, without a computer? Pretend you have a really dumb friend who has no idea how to draw this kind of terrain (again, on a piece of paper with a pencil, without a computer). Write out instructions that he could follow to draw the kind of terrain you're looking for on a piece of graph paper. Remember how dumb your friend is, so make sure all the instructions are as easy to follow as possible! If an instruction can  be broken down into smaller steps, then break it down into smaller steps.

When you have those instructions written out, you'll have an algorithm that you can start thinking about implementing in code.
5  Discussions / Miscellaneous Topics / Re: Java won't let me time travel on: 2014-09-30 13:18:44
The trick is not to wait a negative amount of time, but to wait so long that the universe collapses back into itself, creates another big bang, and repeats up until the point you want to go back to.

What could possibly go wrong?
6  Game Development / Newbie & Debugging Questions / Re: New Member Trying to Choose a Path on: 2014-09-29 16:05:42
Shameless self-promotion: I've written tutorials aimed at novice game developers that take you from knowing nothing about computers, through Processing, and eventually to Java2D. I'm hoping to keep them going through libGDX and 3D stuff in JOGL. They're available here if you feel like checking them out: http://staticvoidgames.com/tutorials/intro/index
7  Game Development / Game Mechanics / Re: JOGL: 3D Sphere/Plane Collision (distance between 3D point and plane) on: 2014-09-29 14:42:53
Huzzah! I finally got it working thanks to you. Thanks for being so understanding; I owe you a beer or something!

Here is the code I came up with, it seems to work, but any further comments or suggestions for improvement are welcome:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
323  
324  
325  
326  
327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
import java.awt.BorderLayout;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.swing.JFrame;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.FPSAnimator;

public class SpherePlaneTest implements GLEventListener {

   private final GLCanvas canvas = new GLCanvas();

   private final int worldX = -400;
   private final int worldY = -400;
   private final int worldWidth = 800;
   private final int worldHeight = 800;
   private final int worldZ = 100;
   private final int worldDepth = 800;

   Sphere sphere = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);

   Triangle triangle = new Triangle();

   private GL gl;

   public SpherePlaneTest(){

      canvas.addGLEventListener(this);
      gl = canvas.getGL();

      Animator animator = new FPSAnimator(canvas, 60);
      animator.start();

      JFrame frame = new JFrame("SpherePlaneTest");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(canvas, BorderLayout.CENTER);

      frame.setSize(1000, 1000);
      frame.setVisible(true);

      canvas.requestFocusInWindow();
   }


   public void init(GLAutoDrawable drawable) {

   }

   public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
      gl.glEnable(GL.GL_DEPTH_TEST);
      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
      gl.glFrustum(-1.25, 1.25, -1.25, 1.25, 1, 1000);
      gl.glViewport(0, 0, width, height);
   }


   public void display(GLAutoDrawable drawable){

      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

      triangle.render();

      sphere.step();
      sphere.drawSphere();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -worldZ);
      gl.glVertex3d(worldX+worldWidth, worldY, -worldZ);
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -worldZ);
      gl.glVertex3d(worldX, worldY+worldHeight, -worldZ);
      gl.glEnd();


      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX, worldY, -(worldZ));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();
   }



   public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
   }


   private class Sphere{

      double maxSpeed = 5;
      Vector3D delta = new Vector3D(-maxSpeed+Math.random()*(maxSpeed*2), -maxSpeed+Math.random()*(maxSpeed*2), -maxSpeed+Math.random()*(maxSpeed*2));

      Vector3D centerPoint;


      float radius;
     

   
      public Sphere(double x, double y, double z, float radius){
         centerPoint = new Vector3D(x, y, z);
         this.radius = radius;
      }

      public void drawSphere(){
         gl.glColor3d(1, 1, 1);
         gl.glPointSize(radius);
         gl.glBegin(GL.GL_POINTS);
         gl.glVertex3d(centerPoint.x, centerPoint.y, -centerPoint.z);
         gl.glEnd();
      }
     
     
      public void step(){
         centerPoint = centerPoint.add(delta);

         
         if(triangle.closestPointOnPlane(centerPoint).distance(centerPoint) < radius){
            if(triangle.contains(triangle.closestPointOnPlane(centerPoint))){
               System.out.println("BOUNCING OFF PLANE");
               bounceAround(triangle.getNormal().normalize());
               
               
               while(triangle.closestPointOnPlane(centerPoint).distance(centerPoint) < radius &&triangle.contains(triangle.closestPointOnPlane(centerPoint))){
                  centerPoint = centerPoint.add(delta);
               }
            }
         }

         if(centerPoint.x-radius < worldX){
            bounceOffPoint(new Vector3D(centerPoint.x-radius, centerPoint.y, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.x+radius > worldX+worldWidth){
            bounceOffPoint(new Vector3D(centerPoint.x+radius, centerPoint.y, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.y-radius < worldY){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y-radius, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.y+radius > worldX+worldHeight){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y+radius, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.z-radius < worldZ){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y, centerPoint.z-radius));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.z+radius > worldZ+worldDepth){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y, centerPoint.z+radius));
            centerPoint = centerPoint.add(delta);
         }
      }

      public void bounceAround(Vector3D around){
         delta = delta.reverse().reflect(around);
      }
     
      public void bounceOffPoint(Vector3D point) {

         double deltaX =  point.x - centerPoint.x;
         double deltaY = point.y - centerPoint.y;
         double deltaZ = point.z - centerPoint.z;

         Vector3D around = new Vector3D(deltaX, deltaY, deltaZ).normalize();

         delta = delta.reverse().reflect(around);
      }
   }


   private class Triangle{
      Sphere planePoint1 = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);
      Sphere planePoint2 = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);
      Sphere planePoint3 = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);

     
      public Vector3D getNormal(){
         Vector3D edge1 = planePoint2.centerPoint.minus(planePoint1.centerPoint);
         Vector3D edge2 = planePoint3.centerPoint.minus(planePoint1.centerPoint);
         return edge1.crossProduct(edge2);
      }
     

      public Vector3D closestPointOnPlane(Vector3D point){

          //float dot = dot(plane.normal, v - plane.point);
        double dot = getNormal().normalize().dotProduct(point.minus(planePoint1.centerPoint));
         
         //vec3 d = plane.normal * dot;
        Vector3D d = getNormal().normalize().timesScalar(dot);
         
         //return v + d;
        return point.add(d);
      }
     
      public boolean contains(Vector3D p)
      {
        Vector3D v0 = planePoint3.centerPoint.minus(planePoint1.centerPoint); // like "edges" when computing triangle normal
       Vector3D v1 = planePoint2.centerPoint.minus(planePoint1.centerPoint);

        Vector3D v2 = p.minus(planePoint1.centerPoint);

        double dot00 = v0.dotProduct(v0);
        double dot01 = v0.dotProduct(v1);
        double dot02 = v0.dotProduct(v2);
        double dot11 = v1.dotProduct(v1);
        double dot12 = v1.dotProduct(v2);

        // barycentric coordinates
       double invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01);
        double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
        double v = (dot00 * dot12 - dot01 * dot02) * invDenom;

        return (u >= 0.0) && (v >= 0.0) && (u + v <= 1.0);
      }
     
     
      public void render() {
         gl.glColor4d(1, .5, .5, .5);
         
         planePoint1.drawSphere();
         planePoint2.drawSphere();
         planePoint3.drawSphere();
         
         gl.glColor4d(1, .5, .5, .5);
         gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
         gl.glBegin(GL.GL_TRIANGLES);
         gl.glVertex3d(planePoint1.centerPoint.x, planePoint1.centerPoint.y, -planePoint1.centerPoint.z);
         gl.glVertex3d(planePoint2.centerPoint.x, planePoint2.centerPoint.y, -planePoint2.centerPoint.z);
         gl.glVertex3d(planePoint3.centerPoint.x, planePoint3.centerPoint.y, -planePoint3.centerPoint.z);
         gl.glEnd();
      }

   }

   private static class Vector3D{
      private final double x;
      private final double y;
      private final double z;

      public Vector3D(double x, double y, double z){
         this.x = x;
         this.y = y;
         this.z = z;
      }


      public Vector3D timesScalar(double s) {
         return new Vector3D(x*s, y*s, z*s);
      }


      public Vector3D crossProduct(Vector3D other) {
         double cX = this.y*other.z - this.z*other.y;
         double cY = this.z*other.x - this.x*other.z;
         double cZ = this.x*other.y - this.y*other.x;
         return new Vector3D(cX, cY, cZ);
      }


      public Vector3D minus(Vector3D other) {
         return new Vector3D(x-other.x, y-other.y, z-other.z);
      }


      public Vector3D add(Vector3D delta) {
         return new Vector3D(x+delta.x, y+delta.y, z+delta.z);
      }

      public Vector3D reflect(Vector3D around) {

         double reflectedX = 2 * this.dotProduct(around) * around.x - this.x;
         double reflectedY = 2 * this.dotProduct(around) * around.y - this.y;
         double reflectedZ = 2 * this.dotProduct(around) * around.z - this.z;

         return new Vector3D(reflectedX, reflectedY, reflectedZ);
      }

      public double dotProduct(Vector3D v2) {
         return (this.x * v2.x + this.y * v2.y + this.z * v2.z);
      }

      public Vector3D normalize(){
         double d = Math.sqrt(x * x + y * y + z * z);

         if (d == 0) {
            return this;
         }
         double normalizedX = x/d;
         double normalizedY = y/d;
         double normalizedZ = z/d;

         return new Vector3D(normalizedX, normalizedY, normalizedZ);
      }

      public Vector3D reverse(){
         return new Vector3D(-x, -y, -z);
      }

      private double distance(Vector3D other) {
         return Math.sqrt((x-other.x)*(x-other.x) + (y-other.y)*(y-other.y) + (z-other.z)*(z-other.z));
      }
   }

   public static void main(String[] args) {
      new SpherePlaneTest();
   }
}
8  Game Development / Game Mechanics / Re: JOGL: 3D Sphere/Plane Collision (distance between 3D point and plane) on: 2014-09-26 17:57:17
ja, i know what you mean. reading about such stuffs is sorta weird since others expect you to know the context they're in, but forget to explain that.

i would simplify it a bit. i dont think we need the "closest point inside a triangle - to another point". we want to know if a sphere intersects with a triangle right ?

there are many ways to get there, one could be :

- convert triangel into plane (grab any vertex of triangle, grab normal of triangle)
- compute closest point on the plane to source-point
- test if distance to point is smaller (or equal) then radius of sphere
- if - collision, if not - no collision.
- test if computed point is inside triangle
- if - collision, it not - no collision.

would that help ?

*edit* i think constraining a point inside a triangle is more cpu-hungry then this.

Thanks for the reply.

I've been trying to implement what you said, and I *think* I have the sphere bouncing off the infinite plane defined by the three points:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
282  
283  
284  
285  
286  
287  
288  
289  
290  
291  
292  
293  
294  
295  
296  
297  
298  
299  
300  
301  
302  
303  
import java.awt.BorderLayout;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.swing.JFrame;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.FPSAnimator;

public class SpherePlaneTest implements GLEventListener {

   private final GLCanvas canvas = new GLCanvas();

   private final int worldX = -400;
   private final int worldY = -400;
   private final int worldWidth = 800;
   private final int worldHeight = 800;
   private final int worldZ = 100;
   private final int worldDepth = 800;

   Sphere sphere = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);

   Triangle triangle = new Triangle();

   private GL gl;

   public SpherePlaneTest(){

      canvas.addGLEventListener(this);
      gl = canvas.getGL();

      Animator animator = new FPSAnimator(canvas, 60);
      animator.start();

      JFrame frame = new JFrame("SpherePlaneTest");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(canvas, BorderLayout.CENTER);

      frame.setSize(1000, 1000);
      frame.setVisible(true);

      canvas.requestFocusInWindow();
   }


   public void init(GLAutoDrawable drawable) {

   }

   public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
      gl.glEnable(GL.GL_DEPTH_TEST);
      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
      gl.glFrustum(-1, 1, -1, 1, 1, 1000);
      gl.glViewport(0, 0, width, height);
   }


   public void display(GLAutoDrawable drawable){

      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

      triangle.render();

      sphere.step();
      sphere.drawSphere();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -worldZ);
      gl.glVertex3d(worldX+worldWidth, worldY, -worldZ);
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -worldZ);
      gl.glVertex3d(worldX, worldY+worldHeight, -worldZ);
      gl.glEnd();


      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX, worldY, -(worldZ));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();
   }



   public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
   }


   private class Sphere{

      double maxSpeed = 5;
      Vector3D delta = new Vector3D(-maxSpeed+Math.random()*(maxSpeed*2), -maxSpeed+Math.random()*(maxSpeed*2), -maxSpeed+Math.random()*(maxSpeed*2));

      Vector3D centerPoint;

      float radius;
   
      public Sphere(double x, double y, double z, float radius){
         centerPoint = new Vector3D(x, y, z);
         this.radius = radius;
      }

      public void drawSphere(){
         gl.glColor3d(1, 1, 1);
         gl.glPointSize(radius);
         gl.glBegin(GL.GL_POINTS);
         gl.glVertex3d(centerPoint.x, centerPoint.y, -centerPoint.z);
         gl.glEnd();
      }
     
     
      public void step(){
         centerPoint = centerPoint.add(delta);

         
         System.out.println(triangle.distanceToPoint(centerPoint));
         
         if(triangle.distanceToPoint(centerPoint) < radius){
            System.out.println("BOUNCING OFF PLANE");
            bounceAround(triangle.getNormal().normalize());
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.x-radius < worldX){
            bounceOffPoint(new Vector3D(centerPoint.x-radius, centerPoint.y, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.x+radius > worldX+worldWidth){
            bounceOffPoint(new Vector3D(centerPoint.x+radius, centerPoint.y, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.y-radius < worldY){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y-radius, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.y+radius > worldX+worldHeight){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y+radius, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.z-radius < worldZ){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y, centerPoint.z-radius));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.z+radius > worldZ+worldDepth){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y, centerPoint.z+radius));
            centerPoint = centerPoint.add(delta);
         }
      }

      public void bounceAround(Vector3D around){
         delta = delta.reverse().reflect(around);
      }
     
      public void bounceOffPoint(Vector3D point) {

         double deltaX =  point.x - centerPoint.x;
         double deltaY = point.y - centerPoint.y;
         double deltaZ = point.z - centerPoint.z;

         Vector3D around = new Vector3D(deltaX, deltaY, deltaZ).normalize();

         delta = delta.reverse().reflect(around);
      }
   }


   private class Triangle{
      Sphere planePoint1 = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);
      Sphere planePoint2 = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);
      Sphere planePoint3 = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);

     
      public Vector3D getNormal(){
         Vector3D edge1 = planePoint2.centerPoint.minus(planePoint1.centerPoint);
         Vector3D edge2 = planePoint3.centerPoint.minus(planePoint1.centerPoint);
         return edge1.crossProduct(edge2);
      }
     
      public double getD(){
         Vector3D normal = getNormal().normalize();
         return -normal.x*planePoint1.centerPoint.x -normal.y*planePoint1.centerPoint.y -normal.z*planePoint1.centerPoint.z;
      }
     
      public double distanceToPoint(Vector3D point){
         Vector3D normal = getNormal().normalize();
         Vector3D w = new Vector3D(planePoint1.centerPoint.x - point.x, planePoint1.centerPoint.y - point.y, planePoint1.centerPoint.z - point.z);
         double d = Math.abs(w.dotProduct(normal));
         return d;
      }
     
     
      public void render() {
         gl.glColor4d(1, .5, .5, .5);
         
         planePoint1.drawSphere();
         planePoint2.drawSphere();
         planePoint3.drawSphere();
         
         gl.glColor4d(1, .5, .5, .5);
         gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
         gl.glBegin(GL.GL_TRIANGLES);
         gl.glVertex3d(planePoint1.centerPoint.x, planePoint1.centerPoint.y, -planePoint1.centerPoint.z);
         gl.glVertex3d(planePoint2.centerPoint.x, planePoint2.centerPoint.y, -planePoint2.centerPoint.z);
         gl.glVertex3d(planePoint3.centerPoint.x, planePoint3.centerPoint.y, -planePoint3.centerPoint.z);
         gl.glEnd();
      }

   }

   private static class Vector3D{
      private final double x;
      private final double y;
      private final double z;

      public Vector3D(double x, double y, double z){
         this.x = x;
         this.y = y;
         this.z = z;
      }


      public Vector3D crossProduct(Vector3D other) {
         double cX = this.y*other.z - this.z*other.y;
         double cY = this.z*other.x - this.x*other.z;
         double cZ = this.x*other.y - this.y*other.x;
         return new Vector3D(cX, cY, cZ);
      }


      public Vector3D minus(Vector3D other) {
         return new Vector3D(x-other.x, y-other.y, z-other.z);
      }


      public Vector3D add(Vector3D delta) {
         return new Vector3D(x+delta.x, y+delta.y, z+delta.z);
      }

      public Vector3D reflect(Vector3D around) {

         double reflectedX = 2 * this.dotProduct(around) * around.x - this.x;
         double reflectedY = 2 * this.dotProduct(around) * around.y - this.y;
         double reflectedZ = 2 * this.dotProduct(around) * around.z - this.z;

         return new Vector3D(reflectedX, reflectedY, reflectedZ);
      }

      public double dotProduct(Vector3D v2) {
         return (this.x * v2.x + this.y * v2.y + this.z * v2.z);
      }

      public Vector3D normalize(){
         double d = Math.sqrt(x * x + y * y + z * z);

         if (d == 0) {
            return this;
         }
         double normalizedX = x/d;
         double normalizedY = y/d;
         double normalizedZ = z/d;

         return new Vector3D(normalizedX, normalizedY, normalizedZ);
      }

      public Vector3D reverse(){
         return new Vector3D(-x, -y, -z);
      }

      private double distance(Vector3D other) {
         return Math.sqrt((x-other.x)*(x-other.x) + (y-other.y)*(y-other.y) + (z-other.z)*(z-other.z));
      }
   }

   public static void main(String[] args) {
      new SpherePlaneTest();
   }
}


However, this doesn't constrain the bouncing to the face of the triangle, so the sphere bounces off anything that's on the plane. This is closer to what I want, but it's still not what I'm actually looking for.

The only resources I can find are focused pretty heavily on the math, and don't do a lot of explaining the logic behind that math. Can somebody point me to a good tutorial that explains this stuff from a pretty low level, or show me some code that does what I want?

- convert triangel into plane (grab any vertex of triangle, grab normal of triangle)

I believe I've done that, in the getNormal() method of the Triangle class in the above code.

- compute closest point on the plane to source-point

This is exactly what I'm trying to do. How would you go about this, specifically?

- test if distance to point is smaller (or equal) then radius of sphere

Right. Once I know the closes point on the plane, the rest is pretty easy. It's getting that point that's giving me so much trouble.

- test if computed point is inside triangle

I think this is where I'm currently stuck. I *think* I can get the distance to the infinite plane. How would I calculate the closest point? And once I have that, how would I test if it's inside the triangle?
9  Game Development / Game Mechanics / JOGL: 3D Sphere/Plane Collision (distance between 3D point and plane) on: 2014-09-25 16:47:02
I'm in a 3D graphics class that uses JOGL for its rendering.

My current assignment is to get a sphere bouncing around the inside of the box. I've got that working. I've even got multiple spheres bouncing off of one another. Hooray.

But now I want to add some 3D shapes for the spheres to bounce off of. I understand how to do the bouncing once I've got the closest point on a plane to my sphere, but the question is: given a point in 3d space, and a polygon defined as 3 other points in 3d space, how do I find the point on that polygon closest to the first point? If I know that, then I can do the collision detection (compare the distance between that and the center of the sphere to the radius of the sphere) as well as bouncing in the correct direction (reflect the delta vector around that point).

I've put together a small test program that contains all of the essentials. I've left out the actual drawing of the sphere (since that has nothing to do with the problem), so right now it's just a point:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
import java.awt.BorderLayout;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.swing.JFrame;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.FPSAnimator;

public class SpherePlaneTest implements GLEventListener {

   private final GLCanvas canvas = new GLCanvas();

   private final int worldX = -400;
   private final int worldY = -400;
   private final int worldWidth = 800;
   private final int worldHeight = 800;
   private final int worldZ = 100;
   private final int worldDepth = 800;

   Sphere sphere = new Sphere(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth, 25);
   
   Vector3D planePoint1 = new Vector3D(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth);
   Vector3D planePoint2 = new Vector3D(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth);
   Vector3D planePoint3 = new Vector3D(worldX + Math.random() * worldWidth, worldY + Math.random() * worldHeight, worldZ + Math.random() * worldDepth);

   private GL gl;

   public SpherePlaneTest(){

      canvas.addGLEventListener(this);
      gl = canvas.getGL();

      Animator animator = new FPSAnimator(canvas, 60);
      animator.start();

      JFrame frame = new JFrame("SpherePlaneTest");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.add(canvas, BorderLayout.CENTER);

      frame.setSize(1000, 1000);
      frame.setVisible(true);

      canvas.requestFocusInWindow();
   }


   public void init(GLAutoDrawable drawable) {

   }

   public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
      gl.glEnable(GL.GL_DEPTH_TEST);
      gl.glMatrixMode(GL.GL_MODELVIEW);
      gl.glLoadIdentity();
      gl.glFrustum(-1, 1, -1, 1, 1, 1000);
      gl.glViewport(0, 0, width, height);
   }


   public void display(GLAutoDrawable drawable){

      gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
     
      gl.glColor4d(1, .5, .5, .5);
     
      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_FILL);
      gl.glBegin(GL.GL_TRIANGLES);
      gl.glVertex3d(planePoint1.x, planePoint1.y, -planePoint1.z);
      gl.glVertex3d(planePoint2.x, planePoint2.y, -planePoint2.z);
      gl.glVertex3d(planePoint3.x, planePoint3.y, -planePoint3.z);
      gl.glEnd();

      sphere.step();
      sphere.drawSphere();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -worldZ);
      gl.glVertex3d(worldX+worldWidth, worldY, -worldZ);
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -worldZ);
      gl.glVertex3d(worldX, worldY+worldHeight, -worldZ);
      gl.glEnd();


      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX, worldY, -(worldZ));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ));
      gl.glVertex3d(worldX, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();

      gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
      gl.glColor3f(1f, 1f, 1f);
      gl.glBegin(GL.GL_POLYGON);
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ+worldDepth));
      gl.glVertex3d(worldX+worldWidth, worldY, -(worldZ));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ));
      gl.glVertex3d(worldX+worldWidth, worldY+worldHeight, -(worldZ+worldDepth));
      gl.glEnd();
   }



   public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
   }


   private class Sphere{

      double maxSpeed = 5;
      Vector3D delta = new Vector3D(-maxSpeed+Math.random()*(maxSpeed*2), -maxSpeed+Math.random()*(maxSpeed*2), -maxSpeed+Math.random()*(maxSpeed*2));

      Vector3D centerPoint;

      float radius;

      public Sphere(double x, double y, double z, float radius){
         centerPoint = new Vector3D(x, y, z);
         this.radius = radius;
      }

      public void drawSphere(){
         gl.glColor3d(1, 1, 1);
         gl.glPointSize(radius);
         gl.glBegin(GL.GL_POINTS);
         gl.glVertex3d(centerPoint.x, centerPoint.y, -centerPoint.z);
         gl.glEnd();
      }

      public void step(){
         centerPoint = centerPoint.add(delta);
         
         if(DISTANCE_TO_PLANE < RADIUS){
            bounceOffPoint(POINT_CLOSEST_TO_PLANE);
         }
         
         if(centerPoint.x-radius < worldX){
            bounceOffPoint(new Vector3D(centerPoint.x-radius, centerPoint.y, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.x+radius > worldX+worldWidth){
            bounceOffPoint(new Vector3D(centerPoint.x+radius, centerPoint.y, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.y-radius < worldY){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y-radius, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.y+radius > worldX+worldHeight){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y+radius, centerPoint.z));
            centerPoint = centerPoint.add(delta);
         }

         if(centerPoint.z-radius < worldZ){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y, centerPoint.z-radius));
            centerPoint = centerPoint.add(delta);
         }
         else if(centerPoint.z+radius > worldZ+worldDepth){
            bounceOffPoint(new Vector3D(centerPoint.x, centerPoint.y, centerPoint.z+radius));
            centerPoint = centerPoint.add(delta);
         }
      }

      public void bounceOffPoint(Vector3D point) {

         double deltaX =  point.x - centerPoint.x;
         double deltaY = point.y - centerPoint.y;
         double deltaZ = point.z - centerPoint.z;

         Vector3D around = new Vector3D(deltaX, deltaY, deltaZ).normalize();

         delta = delta.reverse().reflect(around);
      }
   }

   private static class Vector3D{
      private final double x;
      private final double y;
      private final double z;

      public Vector3D(double x, double y, double z){
         this.x = x;
         this.y = y;
         this.z = z;
      }


      public Vector3D add(Vector3D delta) {
         return new Vector3D(x+delta.x, y+delta.y, z+delta.z);
      }

      public Vector3D reflect(Vector3D around) {

         double reflectedX = 2 * this.dotProduct(around) * around.x - this.x;
         double reflectedY = 2 * this.dotProduct(around) * around.y - this.y;
         double reflectedZ = 2 * this.dotProduct(around) * around.z - this.z;

         return new Vector3D(reflectedX, reflectedY, reflectedZ);
      }

      public double dotProduct(Vector3D v2) {
         return (this.x * v2.x + this.y * v2.y + this.z * v2.z);
      }

      public Vector3D normalize(){
         double d = Math.sqrt(x * x + y * y + z * z);

         if (d == 0) {
            return this;
         }
         double normalizedX = x/d;
         double normalizedY = y/d;
         double normalizedZ = z/d;

         return new Vector3D(normalizedX, normalizedY, normalizedZ);
      }

      public Vector3D reverse(){
         return new Vector3D(-x, -y, -z);
      }

      private double distance(Vector3D other) {
         return Math.sqrt((x-other.x)*(x-other.x) + (y-other.y)*(y-other.y) + (z-other.z)*(z-other.z));
      }
   }

   public static void main(String[] args) {
      new SpherePlaneTest();
   }
}


The above program contains a sphere (a point) bouncing around a 3D box, as well as a 3D plane between 3 points. There is currently no interaction between the sphere and the plane, which is what I'm trying to add. Line 147 contains the basic logic I'm planning on using.

I've done a ton of googling on this, but I feel pretty stupid because a lot of it makes no sense to me. I've tried reading up on vector math, but it's been quite some time since I've had linear algebra, so it seems that things other people consider obvious are pretty foreign to me. "Just use the crossproduct to get the normal and use ray tracing to calculate the intersection" might be correct, but I have yet to see a layman's explanation of what any of that means in a real working program.

So I'm hoping somebody can show me how you might add a function that takes 4 3D points: 1 point at the center of the sphere and the other 3 defining a polygon face, and returns the closest point on that polygon face to that center point. I believe I can do the rest from there.

I also want to reiterate that the first part of this (the bouncing sphere) was homework (which I've finished), but the addition of the polygon intersection is outside of the bounds of the class and is mostly for my own curiosity. So nobody is going to be doing my homework for me or anything like that.

As always, I definitely appreciate any insights anybody can offer.
10  Discussions / General Discussions / Re: Should i allow everyone to see my game source code? on: 2014-09-25 15:54:50
My concern would be someone to claim that its their project ( steal from me ), and i college bealive them and i dont graduate.

Then that's a pretty valid concern. I would consult with your teacher to discuss any issues with academic dishonesty. Maybe this is like posting the answers to the final test, which you obviously shouldn't do.

Why *do* you want to release the source? What value do you think people will get out of it?
11  Discussions / General Discussions / Re: Should i allow everyone to see my game source code? on: 2014-09-25 15:45:27
The most likely scenario is that very few people will look at your code, so it really doesn't matter what you do with it. Harsh reality.

A slightly less likely scenario is that your project is of interest to niche academic researchers, and they'll probably want to see your code and probably send you obnoxious emails. I wrote a little Ant Colony Simulation a few years ago and I still get emails from "phd students" doing Ant Colony Optimization (plz sir, help my thesis sir, plzz help plz plz). Although if you're just putting it up on bitbucket, I'm not sure how they'll even find it (I don't really know what bitbucket is).

An even less likely scenario is that your game becomes popular enough to attract the attention of cloners. If it's that popular, you're going to get clones regardless of whether you release your source. However, if you can prove that somebody used your source (and it's not under a license that allows that), then you at least have some way to fight them for copyright infringement.

The point is, I don't really see a downside of releasing the source. Do you have a specific concern?
12  Discussions / Miscellaneous Topics / Re: I'm scared of Unity on: 2014-09-25 13:57:04
My point is just selling something on like the app store doing just SOME advertising, you will sell at least some copies.

I don't disagree. And, in my defense, I do have quite a few finished games available, both on my own site and on Google Play, so it's not like all I have are unfinished projects!

My only point is that it's not all about getting as many games as possible finished as quickly as possible. We already have enough crappy games that were obviously done in Unity or GameMaker (we also have some *great* games done in Unity or GameMaker), so do we all really need to be obsessed with putting games out as quickly as possible?

I would argue that no, there is merit to taking your time and getting into the details because you care about them. I'd rather play a game that took somebody 3 years to build than something that somebody threw together over the course of a month. Do I really need to play another first person cube puzzler because Unity makes that easy? Or would I rather play something *new* built from the ground up?

Like I said, you can do some great things with Unity or GameMaker. But if "getting finished as fast as possible" is your only concern, then you're going to make bad games regardless of what you're using.
13  Discussions / Miscellaneous Topics / Re: I'm scared of Unity on: 2014-09-24 16:08:07
No it's a means to an end.
If I had people programming for me, as I tell them what I need, I would hardly ever program again.

Yeah, that's the other school of thought. I suppose you're more of a "manager" and I'm more of a "code monkey". Different strokes for different folks and all that.

I think it's a slightly depressing outlook.
Making some is actually trivial today if you apply yourself.
And when you are dead, your unfinished projects don't really count for much.

I'm going to try very hard not to be offended by the implication that I don't apply myself and that all I have are unfinished projects, haha. :p

My only point is that if you're only doing game development because you want to make money, you're going to have a bad time no matter what tool you use. That's true of any craft, I suppose.

Life is short. We have a limited time to reach goals and create content.
I appreciate that you enjoy programming/engineering, most of us do on some level. But I love GAMES. I want to create games, stories, characters, dialogues, worlds, maps, scenarios, game play mechanics, conflict, drama, maybe comedy.
Telling a machine what you want is inherently tedious.

This is a valid argument, and I can't disagree that many people think that way. My only goal was to hopefully provide OP with another way to look at the "problem". There are more factors at play than "it's easier to make games in unity than straight Java". It's a tradeoff.
14  Discussions / Miscellaneous Topics / Re: I'm scared of Unity on: 2014-09-24 13:12:41
I think what some people have hinted at is that programming is a process, not just an end-goal.

You say that you're afraid other people will create games faster than you. Well, that's true. That would be true if you were using anything. Somebody out there can probably create a game faster than you, using machine language. Other people might take twice as long, using Unity.

It's a bit like saying "you know, I was enjoying this lovely walk, but look how fast the people in cars are going!"

If you enjoy the process of using Java (or libGDX, or JOGL, or whatever), then that's enough. Face it: most of us (including you, and including the fictitious Unity developers you're jealous of) will never make a cent on any of our games. So why not enjoy the process instead of getting hung up on going as fast as possible?

And even if you are gung-ho on making money off your games, not every artist uses the same tools. Did paintings become irrelevant when sculptures were invented (disclaimer: I am not an art history major so maybe those are reversed, man this is a bad analogy)? Did theater become irrelevant when movies were invented? Did the acoustic guitar become irrelevant when the electric guitar was invented? Stick with something you enjoy and stop worrying about other people.

The one thing that bothers me about things like Unity and Game Maker is that they're way too restrictive. We have an entire generation of "programmers" growing up only knowing Unity or Game Maker, which is fine for making games- but what happens when they want to create a GUI application? (Ever hear game developers complain about not being able to program GUIs?) What happens when they want to program a server?

My school offers a "game development" major to undergrads, but it sorta frustrates me since all they use is Unity. That's extremely restrictive, especially when compared to a "real" computer science degree (which, incidentally, uses Java in most of its classes).
15  Discussions / General Discussions / Re: Are Java applets really "dead" for indie developers? on: 2014-09-24 12:55:51
The sad part about this is that the primary work-around is to convert applets to applications, which run
the same "arbitrary java code".

  "Can't trust applets? Just run the untrusted code directly!"

IMO it's more about Oracle covering its corporate ass than any concern for user's safety.

Before the applet security breach happened, applets were run in a "security sandbox" which meant that they couldn't do anything "dangerous" like access your file system, run other programs, lock the screen, etc. To do any of that stuff, applets had to "leave the sandbox" by presenting you with a warning that you could cancel out of.

After the security breach, applets were able to run outside the sandbox (and therefore do anything they wanted) **without warning you**. That's the dangerous part.

Picture this: during the security breach (or if you're still running a very old version of Java), if the ads on this site allowed me to run arbitrary javascript (not saying ads on this site do, but *many* do), then I could pay the 10 cents to put an add up on the site, then secretly deploy an applet *from the ad* and start accessing your machine *without you knowing it*. You would still be visiting the same sites you always have, not running any weird programs, but I could still get you.

That's how the infamous "the fbi is watching you, give us money to make this message go away" virus was deployed a few years ago.

But you're right, downloading and running a jar isn't any "safer" than purposefully running an applet. But there's the difference: when you download and run a jar, you're "explicitly" running that program. But when an applet runs automatically when the page loads, that applet runs "implicitly" without you having to take any actions. That's the huge difference, and it's why jar files never had to run in a sandbox. Whether that's still a valid distinction today is debatable (especially when you look at how ios and Android does it), but there is at least some amount of logic in the decisions that Oracle has made- now running an applet is an "explicit" action where you have to *take an action* to make it happen, so I can no longer secretly run applets without your knowledge.
16  Game Development / Game Mechanics / Re: Rendering order in a 2d game on: 2014-09-23 14:15:28
Okay thank you sir, I will do that. (But I did not ask this before btw  Smiley)

Huh, right you are. This guy just had the same question as you: http://www.javaprogrammingforums.com/whats-wrong-my-code/39468-tiled-map.html
17  Game Development / Game Mechanics / Re: Rendering order in a 2d game on: 2014-09-23 13:59:57
So my question is how do i calculate in which order the mobs should be rendered?
I thought of sorting the list by y-value using some algorithm, but then I would have to sort everytime a mob moves(which could be up to 60 times a second).
...
That is the way i thought of doing it, but wouldn't that be slow if I have to check the y-positition of every mob several times per render?

We really can't tell you whether it's going to be "slow" on your system with your code. Just try something and see if it works. Sorting using a custom Comparator and seeing what happens will be much faster than waiting for somebody else to explain it to you (especially since I think I saw you ask this question on another forum a couple weeks ago). Then if you notice some performance impact, we can start talking about fancier alternatives.

Get something that works, even if it's slow. Then post that as an MCVE and we can start talking about improvements- if it even needs any.

"Premature optimization is the root of all evil." - Donald Knuth
18  Discussions / General Discussions / Re: Are Java applets really "dead" for indie developers? on: 2014-09-22 21:10:25
That is really what everyone is saying, but I'm kind of skeptical at the moment, because you can't really do all that you can do in native on the browser. But hey, that is just me personally.

Right, it's a tradeoff.

If you have a visualization/app/game that doesn't do anything too fancy, then you can/should probably just use whatever is easiest for your end users. That's something that deploys to the web and runs without the user needing to do anything special. That ain't applets.

However, if you need to do stuff that can't be done via the web, then you move towards a full application that needs to be downloaded or even installed.

The point is, for most things that most end-users do, they expect to be able to do it directly in a browser. Applets don't provide that ease of use anymore, which is why we're saying they're dead.
19  Game Development / Game Mechanics / Re: Rendering order in a 2d game on: 2014-09-22 21:06:52
Isn't it just the bottom of the sprite?

In your picture, the bottom of the tree is below the bottom of the person, so the person gets rendered first. That way you stand "behind" things that are closer to the "camera"?
20  Discussions / Miscellaneous Topics / Re: Whays the story behind your name on: 2014-09-22 18:25:46
My real name is Kev(in)Glass.

Kev

Kev(in)s of the world unite!

And by "world" I mean "this forum" and by "unite" I mean "stay at home and program and drink too much coke". (I'm a diet coke man myself.)
21  Discussions / General Discussions / Re: Are Java applets really "dead" for indie developers? on: 2014-09-22 15:59:21
If Oracle would have taken a more end-user oriented approch (Applets as dedicated Multmediasolution)
Java could still be a big player in online content.
Im thinking more of a "Adobe Flash" type of multimedia plugin - that is beeing controlled by Java bytecode, instead of just sandboxing a complete programming environment
also ment for business backends.

Many people would argue that Flash is dead too.
22  Discussions / General Discussions / Re: Are Java applets really "dead" for indie developers? on: 2014-09-22 14:33:53
I would say GWT is equally dead :-)
It's a beast that even Google abandoned long ago.

Where did they say they abandoned it?

Unless I'm missing something, converting to open-source != abandonment.
23  Discussions / General Discussions / Re: Are Java applets really "dead" for indie developers? on: 2014-09-22 13:11:15
tl;dr: Yes, applets are dead. I would be ecstatic if they were brought back to life through some miracle Frankenstein monster, but I'm not holding my breath. Deploy as a jar or a packaged executable instead.

Shameless self-promotion: I wrote a little blog/tutorial explaining the problem with applets available here: http://staticvoidgames.com/tutorials/deployment/history

But basically, a few years ago people realized that applets contained security problems that would allow badguys to run arbitrary Java code on your computer without your knowledge. This is very bad and actually cost me a reformatting.

Oracle reacted and fixed the problems, then people would find more problems, Oracle would fix them, back and forth for several months. This gave applets, and Java as a whole, a pretty bad name- even though there's nothing wrong with *Java*, just with applets (and those problems are all fixed now anyway). You'll still hear "I heard Java was insecure" from people who don't really know what they're talking about and just remember reading about the original exploit.

Despite the original problems being fixed, Oracle decided to make it pretty much impossible for the problems to come back: now you get a big security warning whenever Java is run (so Java can't run without your permission anymore), and all applets have to be signed. Generally you sign an applet by purchasing a certificate and using that to verify your identity, but you can also sign it using a free certificate- but for that applet to work, your users have to change their Java security settings.

Now end users have heard that Java applets are insecure (even though the problems are fixed) and are faced with big ugly security warnings whenever they run an applet (even though the warning is just telling them that Java is about to run, most end users don't know what that means and think something evil is happening). Now developers either have to buy a certificate (which isn't an option for most people) or walk their users through the process of changing their security settings (which isn't an option for most people).

Couple that with the general clunkiness of applets, especially compared to html5 and javascript. Compare a html5/javascript game or application that "just works" on every system to the Java applet plugin which only works for certain operating systems and browsers, does not work on mobile at all, must be updated and displays warning messages that the user has to read and click through before running anything at all. Which do you think end users prefer?

A few places still use applets. My day job still deploys applets (we have a certificate) and OpenProcessing is still mostly applets (they try to walk users through changing security settings), so you can still see both approaches "in the wild". But it's definitely the minority.
24  Discussions / Miscellaneous Topics / Re: The price of Pizza and Games on: 2014-09-19 17:35:14
Another idea to consider is that when people buy software, they also believe they're buying **a service** and not just **a product**.

In your pizza example: what if when the pizza was delivered, you discovered that it was missing a slice? Or that it had the wrong toppings on it? Chances are you would probably ask for a refund, or at least a replacement pizza. There is some idea of "attached services" even to seemingly one-time things like pizza.

Similarly, if you buy a PS3 game (on a disc, from a store) and then when you get it home it doesn't work, chances are you're going to take it back to the store. Sometimes games don't work because of user error -maybe you bought an xbox game instead- and that can also be straightened out by the clerk at the store.

Traditional game distribution (in boxes, in stores) has a lot of that inherent "service" built into it: you can talk to the person you bought it from, they can talk to the wholesale distributor, they can talk to the manufacturer, they can talk to the company, who can maybe talk to the developers, etc. The president of Sony doesn't have to answer every email from people asking why PS4 games don't work in their PS3. There's a "service layer" for that.

But then along came online distribution- first in the form of downloading a game directly instead of going to the store to buy it. This cuts out all of the above "built in" service mechanisms, which is GREAT for indie developers who can't afford all of that middle-man service layer stuff. But now what happens if the game doesn't work? You're going to get an email from every grandma trying to buy Minecraft for Little Timmy, asking where the any key is. And a week later when her computer crashes, guess who she's going to blame, well the last thing I did was download Minecraft, that must have been it!

And yeah, grandma is wrong- but *she doesn't know she's wrong* and from her perspective, she paid 10 bucks for a product (the game) but also *the built-in layer of assumed SERVICE that comes with every product*. Traditionally she could go to the store and talk to the person who sold it to her, not the developer directly. Traditionally, grandmas all over the world could go to different stores, so no single person has to deal with ALL of them.

But now that we're distributing things online and the product comes directly from the producer (the developer of the game), the producer also absorbs *all of the service-related responsibilities* as well. That's why Notch is constantly getting flack for every change in Minecraft. This is why Cas has to put up with angry teenagers blaming their porn viruses on his games. Is it right? Nope, probably not. Is it fair? Nope, probably not. But from the consumer's perspective it's *natural* based on how we've done business for thousands of years.

And it gets worse- now we also have *downloadable content* and *updates* in every game, the product itself becomes, in a way, a service. Most modern games aren't a one-time product, but a *service* that evolves. So now I pay ten bucks and that gets me *the game itself* and also *the assumed service that comes with every product* but now also *access to every update and new feature for the rest of time* (some of which I might have to pay for, but *the access* is there). So now if the developer releases a new feature but I wanted this other feature, I start to perceive that as *bad service* *that I paid for* and now I'm going to write an angry email telling *the service layer* (who happens to be the one guy who developed the thing) all about that. And multiply that by hundreds, or thousands, or millions of users- and you start to see the kind of stuff that Notch and Cas talk about.
25  Discussions / General Discussions / Re: Microsoft to buy Mojang for $2 billion? on: 2014-09-18 22:30:20
I should have been more specific. I wasn't really talking about thousands of people rushing Notch when he walks down the street. I was more thinking *places he would want to hang out before he was famous* like gamedev expos, hackathons, game jams, etc.

But my central point is that Notch has *the right* to do whatever he wants with his time, including selling *his* product or retiring or whatever. The fact that people in this thread have called him a sellout sorta proves his whole motivation: exhaustion from constantly being criticized for crap that *isn't true* or *doesn't matter*.
26  Discussions / General Discussions / Re: Microsoft to buy Mojang for $2 billion? on: 2014-09-18 18:28:31
I think it's hard to understand the level of fame we're talking about here.

Sure, if it's just your twitter and email overrun with annoying people, fine, we can all probably handle that, and even take some kind of pride in it.

But to go down a hypothetical road, what happens when your girlfriend complains to you that she can't get online without *thousands of disgruntled/bored teenage boys* messaging her, just because they know who you are? What about your parents? Or potential colleagues? What if you *couldn't meet a single person in real life* who hasn't heard something negative about you? And, yeah, okay, "that's what people get for listening to the loud-mouths".. but I bet it gets pretty exhausting to constantly hear whispers and jokes (and flat out accusations) about what a jerk you are, just because you happen to be *good at something*.

What if *everything you touched* was overrun with thousands of "trolls" just because you *happen to be successful*?

It's easy to say "psh, I could handle that" in the same way that we all believe we'd do great in a zombie apocalypse.

"Well just use a fake account and set up secret identities" - glossing over how messed up it is that that's even necessary, it's pretty hard to stay anonymous, especially if you're already famous. Somebody is going to make a connection or figure it out, and then you get flack for "trying to hide" in addition to the normal crap you get. So that's not really an option- plus it misses the whole point of *what if your secret online identity becomes famous*? That's what happens to a lot of the "famous indies", so I'm not sure what the alternative is.

The point is, Notch isn't "selling out", whatever that even means. He's sick of all the crap that comes with fame, *which people in this thread are still giving him*, proving his point even while trying to discredit him for whatever reason. I guess I still just don't really understand the level of vitriol this invokes from people.
27  Discussions / General Discussions / Re: Microsoft to buy Mojang for $2 billion? on: 2014-09-18 16:01:36
The opinions of millions of misinformed strangers trickle through in your personal life, I suspect.

This is an interesting point. It's easy to dismiss famous-people-drama with "of course I could handle anonymous randoms complaining at me on twitter", but then you notice people you meet saying "well I heard that you said X which offended Y, what do you have to say to that?" And you find yourself explaining the same stupid thing over and over again...

Whereas before you were famous, you could just get to know people without them having ideas about you before even meeting you. And how many people now seek you out just to have arguments with you? How many people (who you would like to meet) are now avoiding you because of something they read on the internet?

How exhausting would that be?

Of course, I do not question Nate's toughness. The "famous life spilling over into your personal life" idea just isn't one I had really thought about before now.
28  Java Game APIs & Engines / Android / Re: Hello all on: 2014-09-17 18:54:33
Instead of starting with a solution and trying to work backwards, maybe try it the other way around: can you create an MCVE that demonstrates exactly what you're confused about?

Start from scratch, and if you really want to use code you found from the internet, then take it one small step at a time. Only add as much code as it takes to show us exactly what you're confused about. That way we can copy and paste your code into our own editors to see what's going on.

29  Java Game APIs & Engines / Android / Re: Hello all on: 2014-09-17 17:30:39
I'm not really sure what you're asking. Are you asking how to stop using a snake and to use something more like Pac-Man?
30  Discussions / General Discussions / Re: Microsoft to buy Mojang for $2 billion? on: 2014-09-17 14:33:59
Also, if you own a software, you are more likely to invest time into making is run (install an new JRE, fix drivers)
whereas a free game - that does not work instantly and painlessly - wont get the same effort. "Skip to the next"

There's even a name for this way of thinking. It's called the endowment effect: http://en.wikipedia.org/wiki/Endowment_effect
Pages: [1] 2 3 ... 13
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!