Java-Gaming.org Hi !
Featured games (86)
games approved by the League of Dukes
Games in Showcase (649)
Games in Android Showcase (181)
games submitted by our members
Games in WIP (699)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 ... 8 9 [10]
 91 
 on: 2016-02-02 08:58:34 
Started by mike_bike_kite - Last post by Oskuro
- I can't speak exact numbers because of Valve's NDA

There's an NDA on the money you make selling your own games on their platform?  Stare

 92 
 on: 2016-02-02 04:23:22 
Started by k0sar - Last post by DrZoidberg
I tried to improve the code some more. I defined a class that represents a virtual camera. To move the player around you just have to move the camera, which means your current position is the position of the camera.
Btw. the camera always looks in the direction of the negative z axis (because that's the default in opengl). So moving foward means to move towards -z.

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  
import com.jogamp.opengl.*;
import com.jogamp.opengl.awt.*;
import com.jogamp.opengl.util.*;
import com.jogamp.opengl.util.gl2.GLUT;
import com.jogamp.opengl.glu.*;
import com.jogamp.opengl.math.*;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

class Camera {
  private float[] pos = {0, 0, 0};
  private Quaternion orientation = new Quaternion();
 
  void moveTo(float[] pos) {
    this.pos[0] = pos[0];
    this.pos[1] = pos[1];
    this.pos[2] = pos[2];
  }
 
  void move(float[] dv) {
    this.pos[0] += dv[0];
    this.pos[1] += dv[1];
    this.pos[2] += dv[2];
  }
 
  void setOrientation(Quaternion q) {
    orientation.set(q);
    orientation.normalize();
  }
 
  void rotateAbs(Quaternion q) {
    Quaternion temp = new Quaternion();
    temp.set(orientation);
    orientation.set(q);
    orientation.mult(temp);
  }
 
  void rotateRel(Quaternion q) {
    orientation.mult(q);
  }
 
  void rotateXRel(float radians) {
    Quaternion q = new Quaternion();
    q.rotateByAngleX(radians);
    orientation.mult(q);
  }
 
  void rotateYRel(float radians) {
    Quaternion q = new Quaternion();
    q.rotateByAngleY(radians);
    orientation.mult(q);
  }
 
  void rotateZRel(float radians) {
    Quaternion q = new Quaternion();
    q.rotateByAngleZ(radians);
    orientation.mult(q);
  }
 
  void lookAtPos(float[] target, float[] up) {
    float[] direction = new float[3];
    VectorUtil.subVec3(direction, pos, target);
    orientation.setLookAt(direction, up, new float[3], new float[3], new float[3]);
  }
 
  void moveBack(float x) {
    float[] zAxis = orientation.copyMatrixColumn(2, new float[3], 0);
    pos[0] += zAxis[0] * x;
    pos[1] += zAxis[1] * x;
    pos[2] += zAxis[2] * x;
  }
 
  void moveForward(float x) {
    moveBack(-x);
  }
 
  void moveRight(float x) {
    float[] xAxis = orientation.copyMatrixColumn(0, new float[3], 0);
    pos[0] += xAxis[0] * x;
    pos[1] += xAxis[1] * x;
    pos[2] += xAxis[2] * x;
  }
 
  void moveLeft(float x) {
    moveRight(-x);
  }
 
  void prepareGL(GL2 gl) {
    float[] axis = new float[3];
    float angle = orientation.toAngleAxis(axis);
    gl.glRotated(-Math.toDegrees(angle), axis[0], axis[1], axis[2]);
    gl.glTranslated(-pos[0], -pos[1], -pos[2]);
  }
}

public class Rotation2 extends JFrame implements GLEventListener, KeyListener
{
    GLCanvas canvas = null;
    Animator an;
   
    public Rotation2()
    {
        canvas=new GLCanvas();
        an=new Animator(canvas);
        add(canvas);
        canvas.addGLEventListener(this);
        canvas.addKeyListener(this);
        setSize(1280,900);
        setVisible(true);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        an.start();
        requestFocus();
       
    }
   
    Camera cam = new Camera();
   
    float red = 0;
    float green = 0;
    float blue = 1;
   
    public void init(GLAutoDrawable drawable)
    {  
        GL2 gl = drawable.getGL().getGL2();
        GLU glu = new GLU();
        gl.glMatrixMode(GL2.GL_PROJECTION);
        gl.glLoadIdentity();
       
        double w = drawable.getSurfaceWidth();
        double h = drawable.getSurfaceHeight();
        double aspect = w/h;
        glu.gluPerspective(60.0, aspect, 2.0, 200.0);
        cam.moveBack(30);
       
    }
   
    public void display(GLAutoDrawable drawable)
    {
        GL2 gl=drawable.getGL().getGL2();
        GLU glu = new GLU();
        GLUT glut = new GLUT();
       
        gl.glMatrixMode(GL2.GL_MODELVIEW);
        gl.glLoadIdentity();
       
        gl.glClearColor(0f,0f,0f,0f);
       
        cam.prepareGL(gl);
       
        gl.glClear(GL2.GL_COLOR_BUFFER_BIT);
       
        gl.glColor3f(1, 1, 1);
        gl.glBegin(GL2.GL_QUADS);
        gl.glVertex3i(0, 100, -500);
        gl.glVertex3i(0, 100, 0);
        gl.glVertex3i(500, 100, 0);
        gl.glVertex3i(500, 100, -500);
        gl.glEnd();
       
        red = 0.0f;
        green = 0.0f;
        blue = 0.9f;
        gl.glColor3f(red, green, blue);
//transforming the place the next shape
//will be drawn.
        gl.glTranslated(2, 0, 2);
//We use wire here because default
//lighting is not good enough to
//use when rendering the solid version
        glut.glutWireIcosahedron();
//more shapes to navigate through
        gl.glTranslated(-4, 0, 0);
        glut.glutWireIcosahedron();
        red = 0.0f;
        green = 0.9f;
        blue = 0.1f;
        gl.glColor3f(red, green, blue);
        gl.glTranslated(4, 0, 4);
        glut.glutWireIcosahedron();
        gl.glTranslated(-4, 0, 0);
        glut.glutWireIcosahedron();
        red = 0.9f;
        green = 0.0f;
        blue = 0.1f;
        gl.glColor3f(red, green, blue);
        gl.glTranslated(4, 0, 4);
        glut.glutWireIcosahedron();
        gl.glTranslated(-4, 0, 0);
        glut.glutWireIcosahedron();
        red = 0.9f;
        green = 0.0f;
        blue = 0.9f;
        gl.glColor3f(red, green, blue);
        gl.glTranslated(4, 0, 4);
        glut.glutWireIcosahedron();
        gl.glTranslated(-4, 0, 0);
        glut.glutSolidIcosahedron();
       
        gl.glBegin(GL2.GL_QUADS);
        // Right-face
        gl.glColor3f(100.0f, 0.0f, 100.0f); // violet
        gl.glVertex3f(100.0f, 100.0f, -100.0f);
        gl.glVertex3f(100.0f, 100.0f, 100.0f);
        gl.glVertex3f(100.0f, -100.0f, 100.0f);
        gl.glVertex3f(100.0f, -100.0f, -100.0f);
       
        gl.glEnd();
       
    }
   
    public void reshape(GLAutoDrawable drawable,int x,int y,int width,int height)
    {}
    public void dispose(GLAutoDrawable drawable)
    {}
   
   
    public static void main(String[] ar)
    {
        new Rotation2();
    }
   
    @Override
    public void keyTyped(KeyEvent e) {
    }
   
    @Override
    public void keyPressed(KeyEvent e) {
        if (e.getKeyCode() == KeyEvent.VK_W) {
          cam.moveForward(1);
        }
        else if (e.getKeyCode() == KeyEvent.VK_S) {
          cam.moveBack(1);
        }
        else if(e.getKeyCode() == KeyEvent.VK_A) {
          cam.moveLeft(1);
        }
        else if (e.getKeyCode() == KeyEvent.VK_D) {
          cam.moveRight(1);
        }
        if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
          cam.rotateYRel((float)Math.toRadians(-5));
        }
        else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
          cam.rotateYRel((float)Math.toRadians(5));
        }
        else if (e.getKeyCode() == KeyEvent.VK_UP) {
          cam.rotateXRel((float)Math.toRadians(5));
        }
        else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
          cam.rotateXRel((float)Math.toRadians(-5));
        }
       
        canvas.repaint();
    }
   
    @Override
    public void keyReleased(KeyEvent e) {
       
    }
}

 93 
 on: 2016-02-01 21:18:08 
Started by ags1 - Last post by ags1
I use two threads per CPU core, this seems to be the optimum number for Windows (not optimal for Linux, sorry Linux). There are 10,000 one-hectare cells and these are shared out between the threads in a thread-safe order.

Rergarding A* etc pathfinding, I'm just not very interested in it. It's expensive and beeline works ok. For indoors movement I will need to have some logic to the movement, as in pathfinding with only a small number of nodes (doorways) to consider. But for outdoors movement I will keep it simple. The complexity in outdoors movement comes from including hazard avoidance, stealthy movement, grouping behavior (so citizens travelling between settlements do not travel dangerous roads alone)...

Most of the objects in the game are small, convex and reasonably spaced, so going in straight lines and sliding to the right around obstacles works for 99% of the cases. For the rarer cases where an entity gets stuck, it simply scatters randomly and tries again. This covers most the remaining cases. It only fails for very large or irregular/concave objects, and for these I will provide local waypoints to guide the entities without the need for global pathfinding.

 94 
 on: 2016-02-01 21:11:26 
Started by mike_bike_kite - Last post by Rayvolution
   Is that a bad thing?
- No! Write more games. Tongue

   Am I being a bit unrealistic expecting money for this stuff?
- Yes and no. To make money, you need a ton of polish. Even a high quality game (mechanics wise) will be almost unsellable without decentish graphics. There are some out liners on Steam (Not-GTAV, or that retarded "Shower With Your Dad Simulator" for example) but generally speaking if you don't have graphics/polish, you won't make money.

   Does anyone have any experience of putting Java games onto steam?
- My games Java, on Steam, and it's no problem what so ever.

   Do PC arcade games actually sell well (or at all)?
- "yes" (see my second bullet point way down in the next section). My game is my day job now, but it isn't an arcade game.

   Is it easy to integrate a Java game into steam?
- Cakewalk!

   Is it straightforward to use their achievements, leader boards and cloud facilities?
- Also a cakewalk. Smiley

   If you have experience of releasing on steam - can I ask how you did? (a PM is fine and I promise not to repeat any info)
- I can't speak exact numbers because of Valve's NDA, but I make enough to pay all my bills/living expenses and still put money in savings. My wife works, but only because she wants to. We don't use her income.

   Is it mostly luck or is there a good formula to follow?
- There is of course some luck with everything in life. But generally no, making a successful game is not about luck. If you make a good, interesting game that grabs people's attention and is unique to the genre you picked, they will come. You just have to do a LOT of legwork marketing the game. You can't expect them to show up out of no where.




My 2 cents of what I think makes or breaks an indiedev:
1. Keep in touch with everyone all the time constantly. Social media is half the battle.

2. Don't just clone a game then add your special twist to it, reinvent the idea the game sets forward. For example, don't make "Pacman with a random level generator". Figure out why pacman is fun, and reinvent pacman itself entirely.
(Example: Shatter, a re-imagining of breakout.)
(Example: Pacman Championship Edition)
(Example: Kingdom Rush (Now a lot of TDs clone their mechanic though, but they were the first to do what they did to the genre))

What sets these games apart is they don't feel like clones anymore. They feel like something totally new.

3. Polish the ever bloody hell out of it. If you're not a good artist, become one. You will most likely fail if you can't polish your product.

4. Be unforgiving to yourself. Nothing you do is ever perfect. Never be satisfied. Obviously you need to release that game sometime, but don't just accept your limitations. Don't know how to do something, and you think the game will benefit from it? Learn!

5. Always act professionally in the public eye. Even if you have something hard to say, say it like a well spoken professional. Don't let the trolls get to you (they'll try) and don't let angry customers piss you off (because they'll try too!). If you get a fanbase, your fans will take care of the insulting idiots for you, and you won't have to look like the bad guy (Read comments starting from page 8, if you're crazy enough).

6. Remember that everything wrong is your fault. Figure out why it's your fault, and fix it. Smiley

7. Market, market, market, market, market, market, market, market, market, market, market.

8. Repeat 1 through 7 50 million times, and cry yourself to sleep once you realize your 6 month project is actually a 2 year project. But keep trucking forward anyway and someday release that game.

 95 
 on: 2016-02-01 20:48:10 
Started by ags1 - Last post by J0
So have you implemented multithreading with your entity logic?
One thread for each entity! Roll Eyes

 96 
 on: 2016-02-01 19:54:53 
Started by ags1 - Last post by Emmsii
This means that logic updates can be done in parallel as long as each cell being updated is separate from other cells being updated concurrently by two intervening cells in all directions.

So have you implemented multithreading with your entity logic?

 97 
 on: 2016-02-01 15:06:50 
Started by k0sar - Last post by k0sar
Thank you for your help, I tried your code and it does what I want it to do but I have a new problem and that's how can I now my current position? I want to setup a wall that the player can't go through, I want set something like a boundary but I don't know which numbers to work with.

 98 
 on: 2016-02-01 15:03:31 
Started by k0sar - Last post by k0sar
Why don't I need glulookAt()? I need to move the screen instead?

 99 
 on: 2016-02-01 14:24:09 
Started by BurntPizza - Last post by KaiHH
Here is a video of yesterday's three hours worth of work plus two today:
<a href="http://www.youtube.com/v/413acCqDsIM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/413acCqDsIM?version=3&amp;hl=en_US&amp;start=</a>
Scene shows the HUD of the player with marker around "bogey" position/distance and marker around intercept shot direction as well as "velocity compass".

EDIT: Executable jar download: https://www.dropbox.com/s/engh0nt1gkwuqqh/spaceshooter.jar?dl=1 (requires at least OpenGL 2.0 and Java 1.6)
Standard output gives instructions how to fly.

 100 
 on: 2016-02-01 13:44:16 
Started by Xolitude - Last post by Oskuro
You essentially need to decide how to partition and store your map data.

Minecraft, for example, divides the game map into 16 x 16 x 256 tile "chunks" which are loaded based on proximity to the player, and unloaded as the player moves away.

My guess is that Minecraft's strategy is to store the chunks in a List of sorts, which can be accessed like a 2d matrix, since individual chunks contain all the possible vertical space.

As for content generation, the chunks are generated procedurally at first, but they are then saved to disk, and loaded from there in subsequent visits.

I'd go for something like this:

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  
public class Chunk
{
   public static final int WIDTH  = 10;
   public static final int HEIGHT = 10;

   protected Tiles[] data;

   public Chunk()
   {
      data = new Tiles[WIDTH * HEIGHT];
   }

   public Tiles getTile(int x, int y)
   {
      return data[(y * WIDTH) + x];
   }

   public Tiles setTile(int x, int y, Tile tile)
   {
      data[(y * WIDTH) + x] = tile;
   }

   public Tiles[] getTiles()
   {
      return new ArrayList(data);
   }

  //TODO: Whatever else you need
}

public class ChunkyMap
{
   HashMap<int, Chunk> chunks;

   protected int height;
   protected int width;

   public ChunkyMap(int width, int height)
   {
      chunks = new HashMap<int, Chunk>();  
      this.height = height;
      this.width = width;
   }

   public Tiles[] getMap(int x, int y, int chunk_radius)
   {
        int chunk_x = x/Chunk.WIDTH;
        int chunk_y = y/Chunk.HEIGHT;

       //TODO: Check if coordinates are out of the map (or do something clever to get infinite maps)

        List<Tiles> retMap = new List<Tiles>();

        int startY = chunk_y - chunk_radius;
        int startX = chunk_x - chunk_radius;
        int endY = chunk_y + chunk_radius;
        int endX = chunk_x + chunk_radius;

        for(int index = (startY * width) + startX; index < (endY * width) + endX) //Note: This is quite possibly wrong...
        {
              if(chunks.containsKey(index))
              {
                    retMap.add(chunks.get(index).getTiles());
              }
              else
             {
                    Chunk newChunk = generateChunkAt(index); //TODO: You know, implement this...
                    chunks.put(index, newChunk);
                    retMap.add(newChunk.getTiles());
             }
         }

         return retMap.toArray();
   }
 
}


Anyway, just a rough idea, I've personally never implemented something like this, so keep your grain-of-salt-grabbing pincers handy Wink


Edit: Fixed some things with the code that were bothering me, but it is still pretty flawed

Pages: 1 ... 8 9 [10]
 
KaiHH (57 views)
2016-01-31 23:15:29

sci4me (86 views)
2016-01-23 21:47:05

sci4me (74 views)
2016-01-23 21:46:58

KaiHH (107 views)
2016-01-19 13:26:42

theagentd (188 views)
2016-01-05 17:10:00

ClaasJG (207 views)
2016-01-03 16:58:36

chrisdalke (196 views)
2015-12-28 06:31:21

Guerra2442 (226 views)
2015-12-25 03:42:55

Guerra2442 (225 views)
2015-12-25 03:27:21

theagentd (261 views)
2015-12-21 14:43:24
List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48
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!