Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (526)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
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]
1  Game Development / Newbie & Debugging Questions / Re: Popup Text Effect on: 2014-10-28 20:52:30
I'm not sure I understand what you said, but if you mean how to draw each popup, make a render method and while you update the popuplist, also call that render method with a started valid sprite batch. Libgdx confuses updating and rendering anyway...
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: What engine/library shoud I use for 3D game development? on: 2014-10-28 20:49:26
About the networking, I use box2D both on client and server. This makes everything run more smoothly for the client. I interpolate the position from the server to the local position. Server having total priority of course.

I'll work on jmonkey for now... but I'm very interested in this new ardor. I'm quite a fan of using libraries more than editors. I can handle the things missing with libraries of my own, or libs around the web. Just that tutorial and docs I think its essential.
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: What engine/library shoud I use for 3D game development? on: 2014-10-28 15:31:44
Nice man!
I have a libgdx expansion that I coded. Its a entity manager that handles networking for some cases. It is based on valve's article https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking and the API is very simple.

I used kryonet to do that. And some other things. It handles box2d synchronization too, making it quite easy to write multiplayer games. The deal breaker is that I'm fighting some issues with the amount of data you can pass between server and client. Also box2d doesn't like setPosition methods... But soon enought I'll release it.

Though networking is not part of 3D engines, is usually associated with them as they grow larger since most of modern games have some networking.

Anyway, thanks for the support.

I took a look at ardor3D but I can't seem to find good documentation... JMonkey seems like a good option too. I'll explore both.
4  Game Development / Newbie & Debugging Questions / Re: Popup Text Effect on: 2014-10-28 15:11:16
I'll not code it for you now because I'm not at home but I'll explain what you need to do:

You need a textpopup class to hold the string and an x,y. This class will also have an update method that increments the y coordinate (or decrements it) moving it up or down the way you want it.

Then you'll probably want a static list of textpopups. When you call your text("thing",x,y), you'll add an instance of textpopup with those parameters to your list. Then you add an FX.update static method to update your list (you iterate through each element and call update on them).

With this you handled adding and moving your text popups. You still have to handle deleting them or fading them out. To do that you can add an internal timer to each popup element and counting them out. And also have a active state to each popup that you use to remove them from the popuplist.

Or you can use another algorithm in the FX update method... Thats up to you. If you need some code to understand this, tell me and I'll help you =)
5  Java Game APIs & Engines / Engines, Libraries and Tools / Re: What engine/library shoud I use for 3D game development? on: 2014-10-28 14:49:43
I got all you have, Springrbua. I have a running example with jbullet, a custom shader, some ray picking experiments and other things. The deal breaker is that I'll have to code a map format that supports jbullet, static models, uv mapping (with custom settings for texture correction)... I'll also have to code networking and a map editor. There are more things that I'll have to tackle, but the ones listed are difficult enough.

Also I don't rush coding, I follow a standart with complete java-doc and using design patterns where I can, and at least calling out possible optimizations in the comments. This makes things slow, and as you said dealing with this 3D basics in a slow pace, makes you feel unconfortable and sad.

gouessej, awesome comment. I'll certainly have a look at JogAmp's Ardor3D! I'll come back here also to tell my experiences with it and contribute where I can.
6  Java Game APIs & Engines / Engines, Libraries and Tools / Re: What engine/library shoud I use for 3D game development? on: 2014-10-27 21:18:43
I do that for all my work. I try to code what I can do by hand and use a few libraries on the way. I wrote 3 2D ""engines"" before I started using one.

The deal breaker is that the jump from 2D to 3D is quite big. I want to be able to start projects now, for fun, but keep developing them up to commercial state. Sticking to the same technology is something I find very important.

All this ramble involving commercial is because I'm almost finishing my computer science graduation and I'd like to have something to work on, a project of mine, before it is ended. I have so many ideas and gamemodes that I wrote that could be turned into nice games, I just lack the right technology to stick to. I love source engine and the LUA API in garrysmod is amazing, but I cannot live coding there, it is too confortable and wont give me a dimme.
7  Java Game APIs & Engines / Engines, Libraries and Tools / What engine/library shoud I use for 3D game development? on: 2014-10-27 20:55:09
Ok, I know this might be the wrong board, if so I'm sorry. This one seems to fit my question.

Here is the deal... Its been a long time now that I'm developing java stuff. Things from 2d games, processing frameworks and even some 2D library (small engines). And now I'd like to start making 3D games but the thing is, I can't seem to find a place to start it right.

I have a good experience in high-level 3D game programming, I used to be a addon/gamemode developer in Garrysmod. Its more like modding, but still is almost the same process as using an big engine (the LUA code that is use to script gamemodes is quite similar to UDK4 c++ in structure).

The main problem that I find in all the avaliable options is that if I want more starting content to focus my work on the game it self, I need to use a messy C++ engine way bigger than what I actually need... But if I go the other way, as I'm trying to, I need to code loads of 'basic' things.

I tried using UDK4 but the C++ documentation and support is quite terrible. The syntax UDK requires is messy and quite ugly and intellisense makes my skin crawl. Unity is too expensive to go commercial and too big, and some of my friends that work with it say it is too problematic. Than I started coding stuff in libgdx (which I used before to make 2D games and things) but the 3D API is too little. I mean, most of the things I need are there, but binding it all together is now looking too much effort.

The problems I'm facing with libgdx as my library are fighting with bullet (the default kinematic character controler seems problematic). Also, the default uber shader is vertex lit only and since it needs compatibility with many devices, doesn't offer much. I'm using the test version uber-shader that is pixel lit, but still doesn't seem to be working. I'm sorry about all this mumbling (all developers mumble, cmon), but I'd like to know if the effort of learning shader code, fighting bullet, and coding tons of things that already exist in other engines worth. I mean, shouldn't I be focusing more on the game code it self?

What you guys think? What engines you guys use? I'd like to hear some of your histories when ou, if you faced the same thing. Thanks for surviving all the mumbling until here.


And I mean, I did my homework. I know most of the alternatives and what similar questions landed on this forum. Still, I'm more focused on your histories and how you handled this question than on finding a good engine. Your opinions on the stuff you worked with.

Lets also raise some questions:

http://www.jpct.net/ - this one have enought support? I heard very little about it.

http://jmonkeyengine.org/ - When I used it, it seemed good but some how felt very messy. It has a big community but the showcase only has few and buggy examples. I might be terribly wrong about it but many advised me against it before. (This also http://www.java-gaming.org/topics/why-don-t-many-of-you-use-jmonkey-engine/29474/msg/270626/view.html#msg270626)

https://www.unrealengine.com/blog/welcome-to-unreal-engine-4 - I'd like to stick to java and enjoy good clean code... but this one has tons of features. Not so expensive (I already have the editor) and can get commercial very easily. The code though will require much time reading infinite documentation since there is no propper getting started and the documentations is quite problematic.

http://polycode.org/ - Not java too, but has a LUA binding and I must say I love lua. Seems quite powerful but is still in development and  has no binary releases (I'd need to build it every time).

Ardor3D just stopped beeing developed. (http://blog.renanse.com/)
8  Game Development / Newbie & Debugging Questions / Re: Top Down Shooter Multiplayer and Box2D questions on: 2013-12-19 02:32:44
I'll help you, since you are a nice guy.
It could mean Tower Defence Software... or Tower Defence Super! Even Tower Defence Sexy!
9  Game Development / Newbie & Debugging Questions / Re: Top Down Shooter Multiplayer and Box2D questions on: 2013-12-19 01:52:39
TDS = Top Down Shooter.
Isn't meant to be simple, I wont be coding this alone.

As for server side only collisions, 65k is right. An alternative would be doing client box2d as a low priority 'visual' physics while the client waits for the server snapshot. When the snapshot comes, the client then compares the simulations and if necessary, interpolates to server positions.
10  Game Development / Newbie & Debugging Questions / Re: Top Down Shooter Multiplayer and Box2D questions on: 2013-12-18 20:17:29
I could do that, totally... the AABB version... but I think I'm able to get it working with Box2D.
Simulate all physics server side, and on the clients only interpolate.
Using the same principle I'm using now, clients send input and process input locally. Client receive snapshot,
interpolate all entities to their 'server positions' (if they are far from the position).
I just don't get what would be the problem here... everything is simulated on the server. Client only renders and interpolates.

I mean, writing a GRID or QuadTree for broad... that is quite easy.
Collisions would be entirely serverside, handeling and all. The only thing the client do is send input.
I shouldn't even need a collision message. The server handle states of the entities, even simulates their animations.
11  Game Development / Newbie & Debugging Questions / Top Down Shooter Multiplayer and Box2D questions on: 2013-12-18 17:59:43
Hey guys! Its me again, the cockdefenders guy!

I'm so thankful for the help I got here the last time, when I managed to make a multiplayer 'game-prototype' that mimics valve networking protocol...
This time I've got some other questions. Its about a TDS that I'm planning, and I want to make it right. The game will be multiplayer with customizable ships
and Box2D if possible.

hmmm... lets get to the questions then!
  • 1- In my previous networking 'prototype' I synchronized about three events per entity, creation, update, deletion. That was done manually with a individual message for each.
    I thought though that I could automate that probably with an interface and a manager, so that I don't have to code sync code for each new entity. This way I can code only if the
    entity has other atributes that need sync. The question is, has anyone done that before? Any tips or cool desings for those?
    Just to help out understanding, my last design was:
    Client send input changes to server.
    Server simulates everything.
    Each 33ms server sends a snapshot to all clients containing world entities, a timestamp, and removed entities.
  • 2- As I said, I want to use Box2D for nice physics. I've got some questions about that. The first question is how I'm I going to code bullets? Does Box2D support bullets?
  • 3- And ho about laser beams? Do I use Box2D to check intersection between line and poligon? Does Box2D have methods for that (handling rotated poligons)?
12  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-15 21:36:53
I'm back here just to say thanks again. Seeing this working is a total dream of mine.
Multiplayer means much to me..
I've added the rest of the game to the server now and it is just amazing seeing that I've coded
that and it is not crashing nor flickering nor nothing actually. Is just amazing.
I'll study now how to generalize this architecture a bit and try to provide either a tutorial or
library (on top of kryonet) to make that super easy for people starting into games. Just like the libs I'm using
made that easy for me.
Something like 'extends LiveEntity' with a few '@ID and @Sync' annotations, a 'client.processLastSnapshot()'....
<a href="http://www.youtube.com/v/pA_sJwbLeoA?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/pA_sJwbLeoA?version=3&amp;hl=en_US&amp;start=</a>
13  Game Development / Newbie & Debugging Questions / Re: Open License on: 2013-11-14 01:29:52
OMG Nate replied! *.* You are a hero!

Does new BSD force the 'users' to stay opensource?
14  Game Development / Newbie & Debugging Questions / Re: Open License on: 2013-11-13 19:58:34
If I create a license like "MY CODE IS PROVIDED AS IS, GET IT AND RUB ALL OVER YOU! JUST SAY MY NAME SOMEWHERE." (just an example), I could use it? Who makes this licenses a legal thing? Is there a entity that controls this kind of stuff?
15  Game Development / Newbie & Debugging Questions / Open License on: 2013-11-13 19:49:43
What is the best 'do what ever you want to with my code, just remember me' license?  Grin
BSD, GPL, Copyleft?
16  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-13 03:56:45
Yeah, that or he just want to stick with paint tool sai forever, and will never touch photoshop =P

Well, thanks for the help. I'll code a framework for this kind of sync and if everything goes ok, I'll post and teach about it XD
17  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-13 03:06:29
My 'artist' friend doesn't know the meaning of .png
18  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-12 23:06:07
ORGASM.
<a href="http://www.youtube.com/v/oZai73uc4g8?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/oZai73uc4g8?version=3&amp;hl=en_US&amp;start=</a>

Success! Now I can proceed to implement a framework XD.
19  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-12 18:58:00
I see now!  Grin
So in your game the client pull server updates... I think I'm going for the server pushing snapshots.
I also understood that the messages of input should be "fireShip" instead of "mouseButton1".
nice.

I'll try to sync a throw-away prototype that I have...
20  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-12 16:34:39
Something like this?

21  Game Development / Networking & Multiplayer / Re: Server game loop and syncronization questions on: 2013-11-12 16:21:38
Many thanks!!

Let me see if I got it:
The server will have its own thread, that run endlesly.
The server will then have its own FPS.
The player should send messages like "mouseButton1Down" "mouseButton1Up" and only when the state changes.
All messaging will be TCP.

If that is good then I'm a happy dev and you deserve TONs of good coffe, with cookies.

The server snapshots have a timestamp?
The thing that stills bother me is that the server have its own fps...
imagine that the client is running at a framerate of 60, and the ship travels 100 pixels,
then the server sends an update, but there the fps is 200 and the ship travelled 350.2 pixels...
(I compute the position using RK4 integrations but still... this sync thing is hard to grasp)
22  Game Development / Networking & Multiplayer / Server game loop and syncronization questions on: 2013-11-12 14:54:29
Hello! I'm studying how to make multiplayer games and I came across something I don't understand how to do correctly: The game loop on the server side.
I'm thinking about a space top down shooter now, just to limit the scope. In my case, it is a kryonet application with LIBGDX. What I have planned for the multiplayer follows:
Client sends spawn message TCP.
Server handles the message, spawning the client ship.
Server responds the message with a snapshot TCP.

--> if there are more than two players
Server sends a start game message TCP (for UI) and starts the game (spawning of aliens).
During game:
Client streams player input through UDP.
Server process the input simulating all players.
Server sends snapshots TCP/UDP? to players each server tick.

--> if game over condition is met
Server sends end game message TCP.

I have several questions though....
Q1 - How will the server run by it self? I though of making a separate thread that calls the methods for sending stuff to the client (the snapshots).
Q2 - How much time a server tick should have? Wouldn't this depend on the clients game loop delay?
Q3 - I currently sync the spawning of bullets to the ship firing animation... is that going to be a problem since the rendering is client side?
Q4 - Valve's article says in source that object positions are processed both locally and server side, with interpolation to always use the server over the client. Can that be
applied to shooting?
Q5 - Should the player send a input message each game loop tick? Or should I sample the input with time intervals?
Q6 - Should the server snapshots be sent over UDP or TCP?
Q7 - What calls the server update loop? Won't the server simulation run without sync with the client?

Thanks so much for taking your time to read all this!
If there is any good article about this, or a example game, even books, send me the names! =)
23  Game Development / Shared Code / Re: Java Quadtree Implementation on: 2013-05-06 21:33:05
Grids are very good for handeling objects the same size. But when size varies quadtrees can do a bit better.
24  Game Development / Shared Code / Re: Java Quadtree Implementation on: 2013-05-06 20:21:50
People people, I'm here to solve all the problems with my google-fu:
http://gamedev.tutsplus.com/tutorials/implementation/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space/

S2 all of you =)
25  Game Development / Game Play & Game Design / Re: Destructible/deformable terrain help on: 2013-05-06 10:29:59
Is that polygon based? Maybe he is generating and averaging points around his mouse, and making the poly from them....
anyway, seems good for collision detection =)
26  Game Development / Game Play & Game Design / Re: Destructible/deformable terrain help on: 2013-05-06 08:45:52
Hey guys! I'm fairly new here but I code java for a long while now and I know a tip about this... If you learn how to render good quadtrees (the datastructure) you can generate points where you explode stuff. Worms use quadtrees to make those awesome smooth maps and the results are better than using pixel-perfect. Also pixel perfect consume a lot of time to process compared to quadtree operations.

This video ilustrates quad tree usage for 2d terrain with awesome results:
<a href="http://www.youtube.com/v/NdHhwXzRfR4?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/NdHhwXzRfR4?version=3&amp;hl=en_US&amp;start=</a>

And here an awesome blog post on terrain rendering:
http://chrisbunner.wordpress.com/2011/01/23/terrain-rendering/

Also,
http://chrisbunner.wordpress.com/2011/01/23/deformable-terrain/

I wish I could help you with a tutorial but for that I would have to code the renderer my self and I'm too lazy now. Also I would probably make something ineficient and some godlike coder here would hit me with a bazooka. But if you need help with quad tree's PM me.
27  Game Development / Newbie & Debugging Questions / Re: Overriding a method question. on: 2010-04-19 17:18:13
MAN! I LUV YOU! Thank you so much!
28  Game Development / Newbie & Debugging Questions / Re: Overriding a method question. on: 2010-04-18 22:04:17
Well, thats all my code so far... I'm running(calling) the Game class where I extend the base class.
29  Game Development / Newbie & Debugging Questions / Overriding a method question. on: 2010-04-18 19:48:20
Hello, and thanks for reading this.
I'm pretty new to Java development and i caught myself here in this AWESOME  Grin site were things seems to work better than trying every thing all alone.
I am trying to use a game base engine that i found here in the tutorial section but for some reason i can't override any class. I create the base class and a Game main class to place the game code separately, than i extended the Game class to the base class this way i could override the update method and the render method. For some weird reason none of those are accepting my overrides Cry .

The code:

---------------------The (modified) Base class

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  
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.image.BufferStrategy;

import javax.swing.JFrame;
import javax.swing.JPanel;


public class Base implements Runnable{
   
   int WIDTH = 1024;
   int HEIGHT = 768;
   
   JFrame frame;
   Canvas canvas;
   BufferStrategy bufferStrategy;
   
   private GraphicsDevice  gd;
   private DisplayMode defaultDM;
   
   public static final DisplayMode DefaultDisplaySet[]={
      //640x480
      new DisplayMode(640,480,32,0),
      new DisplayMode(640,480,16,0),
      //800x600
      new DisplayMode(800,600,32,0),
      new DisplayMode(800,600,16,0),
      //1024x768
      new DisplayMode(1024,768,32,0),
      new DisplayMode(1024,768,16,0),
      //1440x900
      new DisplayMode(1440,900,32,0),
      new DisplayMode(1440,900,16,0)
   };
   
   public Base(){
      GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      gd = env.getDefaultScreenDevice();
      defaultDM = gd.getDisplayMode();
     
      frame = new JFrame("Basic Game");
      frame.setUndecorated(true);
        gd.setFullScreenWindow(frame);
        if (gd.isDisplayChangeSupported())
        {
            gd.setDisplayMode(checkCompatibleMode(DefaultDisplaySet[7]));
            this.WIDTH = gd.getDisplayMode().getWidth();
            this.HEIGHT = gd.getDisplayMode().getHeight();
        }
         
      JPanel panel = (JPanel) frame.getContentPane();
      panel.setPreferredSize(new Dimension(WIDTH, HEIGHT));
      panel.setLayout(null);
     
      canvas = new Canvas();
      canvas.setBounds(0, 0, WIDTH, HEIGHT);
      canvas.setIgnoreRepaint(true);
     
      panel.add(canvas);
     
      canvas.addMouseListener(new MouseControl());
     
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.pack();
      frame.setResizable(false);
      frame.setVisible(true);
     
      initialize();
     
      canvas.createBufferStrategy(2);
      bufferStrategy = canvas.getBufferStrategy();
     
      canvas.requestFocus();
   }
   
   //diplay mode handlers
   public DisplayMode[] getCompatibleDisplayModes(){
      return gd.getDisplayModes();
   }
   
   public DisplayMode checkCompatibleMode(DisplayMode mode){
      DisplayMode goodModes[] = getCompatibleDisplayModes();
         for(int j=0;j<goodModes.length;j++){
            if (DisplayModesMatch(mode,goodModes[j])){
               return mode;
            }
      }
      return null;
   }
   
   //compara displaymodes
   public boolean DisplayModesMatch(DisplayMode d1, DisplayMode d2){
      if(d1.getWidth() != d2.getWidth() || d1.getHeight() != d2.getHeight()){
         return false;
      }
      if(d1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && d2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && d1.getBitDepth() != d2.getBitDepth()){
         return false;
      }
      if(d1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && d2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && d1.getRefreshRate() != d2.getRefreshRate()){
         return false;
      }
     
      return true;
   }
   
   
   //initialize - override
   
   protected void initialize(){}
   
   //the keyInput for shutting down
   
   private class KeyInputHandler extends KeyAdapter
   {
                   public void keyPressed(KeyEvent e)
                   {
                           if(e.getKeyCode()==27)
                   {
                                   gd.setDisplayMode(defaultDM);
                                   gd.setFullScreenWindow(null);
                           System.exit(0);
                   }
                   }
                 
                   public void keyReleased(KeyEvent e)
                   {
                         
                   }
   }
   
   //the mouse listeners
   
   private class MouseControl extends MouseAdapter{
     
   }
   
   long desiredFPS = 100;
    long desiredDeltaLoop = (1000*1000*1000)/desiredFPS;
   
   boolean running = true;
   
   //the separate thread func
   
   public void run(){
     
      long beginLoopTime;
      long endLoopTime;
      long currentUpdateTime = System.nanoTime();
      long lastUpdateTime;
      long deltaLoop;
     
      while(running){
         beginLoopTime = System.nanoTime();
         
         render();
         
         lastUpdateTime = currentUpdateTime;
         currentUpdateTime = System.nanoTime();
         update((int) ((currentUpdateTime - lastUpdateTime)/(1000*1000)));
         
         endLoopTime = System.nanoTime();
         deltaLoop = endLoopTime - beginLoopTime;
           
           if(deltaLoop > desiredDeltaLoop){
               //Do nothing. We are already late.
           }else{
               try{
                   Thread.sleep((desiredDeltaLoop - deltaLoop)/(1000*1000));
               }catch(InterruptedException e){
                   //Do nothing
               }
           }
      }
   }
   
   //rendering
   
   private void render() {
      Graphics2D g = (Graphics2D) bufferStrategy.getDrawGraphics();
      g.clearRect(0, 0, WIDTH, HEIGHT);
      render(g);
      g.dispose();
      bufferStrategy.show();
   }

   int counter = 0;
   
   //updating - overriding
   
   public void update(int deltaTime){
   }
   
   //rendering - overriding
   
   public void render(Graphics2D g){
      g.setColor(Color.black);
      g.fillRect(0, 0, this.WIDTH, this.HEIGHT);
   }
   
   //main thread func
   
   public static void main(String [] args){
      Base ex = new Base();
      new Thread(ex).start();
   }
   
}


---------------------The Main Game Class

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  
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

public class Game extends Base{
   
   BufferedImage bg = null;
   int counter = 0;
   
   protected void initialize(){
   try {
       bg = ImageIO.read(new File("bg.png"));
   } catch (IOException e) {}
   }
   
   public void update(int deltaTime){
      counter++;
      if (counter > 100){
         counter = 0;
         JOptionPane.showMessageDialog(null, "UPDATE FUNCIONANDO."); //NOT WORKING
      }
   }
   public void render(Graphics2D g){
      g.setColor(Color.blue);
      g.fillRect(0, 0, 1024, 768); //NOT WORKING EITHER
      //g.drawImage(bg, 0, 0, canvas);
   }

}
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (73 views)
2014-11-26 15:22:04

toopeicgaming1999 (62 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (27 views)
2014-11-24 19:59:16

trollwarrior1 (40 views)
2014-11-22 12:13:56

xFryIx (78 views)
2014-11-13 12:34:49

digdugdiggy (56 views)
2014-11-12 21:11:50
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

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
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!