Java-Gaming.org Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (564)
Games in Android Showcase (151)
games submitted by our members
Games in WIP (605)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3 ... 10
 1 
 on: 2015-03-28 18:59:41 
Started by jakethesnake - Last post by wxwsk8er
If I understand you correctly, my advice would be to load all the possible actions/'event ids' into a hashmap<Integer, Button/ButtonEvent> and go through that everytime instead of a switch...

Just my ramblings  Grin

 2 
 on: 2015-03-28 18:36:28 
Started by Fairy Tailz - Last post by Fairy Tailz
I'm trying to make rendering VBOs a simpler task. I have this Drawer class with code to render a VBO quad each frame.

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  
public class Drawer {
   static int vboVertexHandle;
   static int vertices;
   static int vertexSize;
   
   public static void drawQuad( int width, int height )
   {
      boolean initialized = false;
      if(!initialized)
      {
         final int vertices = 6;
         final int vertexSize = 6;
         
         FloatBuffer vertexData = BufferUtils.createFloatBuffer(vertices * vertexSize);
         vertexData.put(new float[]{0, 0, 0, width, 0, 0, width, height, 0, 0, height, 0});
         vertexData.flip();
         
         vboVertexHandle = glGenBuffers();
         glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
         glBufferData(GL_ARRAY_BUFFER, vertexData, GL_DYNAMIC_DRAW);
         glBindBuffer(GL_ARRAY_BUFFER, 0);
         System.out.println("boolean...do you work?");
         initialized = true;
      }
     
      glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
      glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);
     
      glEnableClientState(GL_VERTEX_ARRAY);
      glDrawArrays(GL_TRIANGLES, 0, vertices);
      glDisableClientState(GL_VERTEX_ARRAY);
     
     
   }
}


I have that boolean there in hopes it wont initialize the VBOs each frame. When I call
1  
Drawer.drawQuad(20, 20);
nothing appears. Why isn't it working?

 3 
 on: 2015-03-28 18:18:35 
Started by BurntPizza - Last post by lcass
Finally finished A* path finding. Here is a little test.
Click to Play

 4 
 on: 2015-03-28 17:29:33 
Started by jakethesnake - Last post by jakethesnake
So, I'm building a GUI for my game from scratch and the further I've progressed, the harder it gets.

So far, I've used the following method:

I've got a button class, which represents a button. It can be hovered, clicked and rendered to the screen. My strategy has been to assign an integer to each button and when I click it, if it's hovered, it returns this integer. I then use the integer in the parent class and perform actions in regards to it (like a switch statement with different methods, or assigning the index to arrays and such).

1  
2  
3  
4  
5  
6  
7  
8  
9  
   private final int PLAY = 100;
   private final int SETTINGS = 101;
   private final int INFO = 102;
   private final int EXIT = 103;
   private final int SAVE = 104;
   private final int RESET = 105;
   private final int MAIN = 106;
   private final int SETTINGS2 = 107;
   private final int MESSAGE = 108;


... construct the buttons, passing a particular int from above. Once a mouse event occurs I then iterate through the buttons and get the code from that which was pressed. I then do something like:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
      switch(code){
      case -1:
         break;
      case PLAY: exit(true);
         break;
      case SETTINGS: resetSetts(); pageNr = 1;
         break;
      case INFO:
         break;
      case EXIT: exit(false);
         break;
      case SAVE: uSure = false; saveSetts(); pageNr = 0;
         break;
      case RESET: uSure = false; resetSetts();
         break;
      case MAIN: pageNr = 0; resetSetts();
         break;
      case SETTINGS2:
         break;
      case MESSAGE: uSure = true;
      }


Now, to say the least, this is messy and I feel I can't do the advanced stuff I want without confusing myself. I've now figured out another solution:

1  
2  
3  
4  
5  
6  
   button.addClickAction(new CLICK_ACTION() {
         @Override
         public void action() {
            exit(false);
         }
      });


This way I don't need to keep track of all the integers and what they do, but the logic of the button is encapsulated in the button itself. My only question is whether this is good design?

E.g. Let's say I have the gamecore - class. This class controls whether the game runs or not, obviously. Now, the gamecore is the root of the class hierarchy and imagine that at the end of the hierarchy three, there is a guiclass, which holds a button which is supposed to exit the game. With my new method, I'll be able to call the exit method directly in that button, as in apposed to before when I had to return a particular int back to the core. But I feel like I'm violating something... I want to keep to a MVC model as much as I can. What are your thoughts on it?

 5 
 on: 2015-03-28 17:00:54 
Started by BurntPizza - Last post by SHC
My MiniLD #58 entry SurvivorPong is now complete. It is my attempt at remaking Pong by adding a bit of challenge. The idea is you have to stop a deer from running into leopards which are hiding under leaves, and the score is how much time you can survive.



The game needs a GPU which supports OpenGL 3.3 or higher, and Java 8 runtime. By the way, this is just my second real game, so please give me constructive criticism if I have done anything in a wrong way.

LudumDare Post
LudumDare MiniLD entry
Executable JAR download (4.67 MB, needs Java 8 to run)

Please play once and tell me your opinions on how should I improve. I want to learn from any mistakes that I would have made. Also I'll be participating in the main LD event too this time.

 6 
 on: 2015-03-28 15:50:06 
Started by RKJ - Last post by skys0ldier
just divide delta through 17 and you have your update factor.
For example:

player speed is 10. if delta is 17 (optimum) you calc:

player.position += 10 * 17 / 17

so plus ten. if your game sleeps longer for example delta = 34,
delta / 17 is 2 and your player would move twice as fast in this frame.

 7 
 on: 2015-03-28 15:48:16 
Started by RKJ - Last post by skys0ldier
actually it is okay, but you have to factor the delta value in your update() method.

 8 
 on: 2015-03-28 15:39:08 
Started by Stranger - Last post by Stranger
They could make "System-and Application-Specific Heuristics", for example.  Smiley

 9 
 on: 2015-03-28 15:38:58 
Started by ii8 - Last post by atombrot
How do you start your game with spring framework?

If you want to understand how LibGDX is structured it's probably best you create a project with the libgdx setup and try to fiddle around with it a bit.

When you generate your libgdx project, you have one main project containing your game code and you have separate projects for each target environment (desktop, android, web etc.). You can find *Launcher.java files in the target projects.

This is the startup code from my DesktopLauncher.java

1  
2  
3  
4  
   LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
   config.width = 800;
   config.height = 600;
   new LwjglApplication(new Matcher(), config);


In this case Matcher is my main class extending ApplicationAdapter. I think this should be what you need to start your LibGDX application.

Just one thing to consider if you want to use spring. I am not 100% sure but I could imagine that it won't work (or will be a pain to port) with android and web projects. If you don't care about these platforms then you should be fine, otherwise I would investigate if you can even use it and if yes how hard it will be. Could save you some time in the long run.

 10 
 on: 2015-03-28 15:29:05 
Started by Stranger - Last post by Longarmx
What's so weird with those? All they are doing is describing the paper like a title should. If you want more names like this, look up patents Pointing

Pages: [1] 2 3 ... 10
 
theagentd (9 views)
2015-03-27 23:08:20

wxwsk8er (52 views)
2015-03-20 15:39:46

Fairy Tailz (45 views)
2015-03-15 21:52:20

Olo (28 views)
2015-03-13 17:51:59

Olo (30 views)
2015-03-13 17:50:51

Olo (35 views)
2015-03-13 17:50:16

Olo (41 views)
2015-03-13 17:47:07

ClaasJG (40 views)
2015-03-10 11:36:42

ClaasJG (39 views)
2015-03-10 11:33:01

Pippogeek (47 views)
2015-03-05 14:36:23
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27
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!