Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (494)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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: timer, Time keeping help on: 2009-03-17 22:47:20
If you don't display the timer, what about this?

1  
2  
3  
4  
5  
6  
7  
8  
9  
//on start:
long gameStartTime = System.currentTimeMillis();

while(gameRunning) {
// ... game loop with logic and more
}

//this shall be executed when the game has finished
long playedTime = System.currentTimeMillis() - gameStartTime;
2  Game Development / Performance Tuning / Re: How can I make this simple game loop better? on: 2009-03-09 07:39:08
That maxes the CPU on my Linux box. I think in general nanoSleep is the best solution, assuming availability of Java 1.5.

Yes, it maxes the CPU, but other Threads are able to do their work even with that. Using Thread.sleep(long ms, long ns) isn't accurate, too, afaik.
3  Discussions / General Discussions / Re: Hide forum E-Mail address? on: 2009-03-06 14:33:17
Thanks Wildern. I didn't know that I see my own E-Mail always.  Grin
4  Discussions / General Discussions / Hide forum E-Mail address? on: 2009-03-05 23:49:42
After changing my E-Mail address in the Account Related Settings-section of the profile from "damaxxed" to "damaxxed@---.de" it appears next to each of my posts.
It doesn't matter if Hide email address from public? is checked or not, the email link is always visible since I changed the E-Mail address..

I don't mind getting mails from you guys, but I don't want my email to be collected by harvesters  Roll Eyes

Anybody with the same problem or even a solution?  Wink
5  Game Development / Performance Tuning / Re: How can I make this simple game loop better? on: 2009-03-05 23:09:07
1  
2  
3  
   Date startTime = new Date();
   Date previousRepaint = startTime;
   Date currentTime = startTime;

Why are you using Date? Isn't a long for each timestamp enough? Use
1  
   long startTime = System.getCurrentMillis(); //can be System.nanoTime() if you need higher precision




1  
2  
3  
      if(delta <= redrawsPerSecond) {
         try { Thread.sleep(10); } catch(Exception e) { /* pass */ }
      }

I dislike Thread.sleep() because it's very unprecise on my Windows XP machine.. I prefer solutions like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
final long LOOPTIME = 1000/60; //for 60 FPS in 1000ms
long nextLoop;

while(true) {
    nextLoop = System.currentTimeMillis() + LOOPTIME;

    //do logic and repaint stuff

    while(System.currentTimeMillis() < nextLoop) {
        Thread.yield();
    }
}
6  Game Development / Newbie & Debugging Questions / Re: Game graphics on: 2009-03-05 22:47:47
Here comes some dummy explanation, which I would've needed at my beginnings..

You can compare the graphic stuff of the game excellently to a flip-book..

First we have to create a digital flip-book, which will display our game gfx: use a JPanel or Canvas for this.

Now we say, that we always use 2 pages of the flip-book at the same time:
One that the video game player is seeing on the screen and the one behind it, that is invisible as long as we draw all the bullets, explosions, ... on it. It would really look strange if the player would see how all the effects are drawn on the screen Wink
1  
2  
createBufferStrategy(2);  //our strategy for a fluid motion: display 1 page and draw on another page => 2 pages
strategy = getBufferStrategy();


Now we create a Graphics2D object, which we can draw on. This is our invisible next page.
By calling g.drawXXX you can draw shapes and images on it..
1  
Graphics2D g = (Graphics2D)strategy.getDrawGraphics();


When we finished drawing, we release all the used resources, by finishing the flip-book page
1  
g.dispose();


Finally, we show the next page of our flip-book to the player(the one that we have been drawing on) and everything starts from the beginning.
1  
strategy.show();
7  Game Development / Newbie & Debugging Questions / Re: aiming? could call it homing missiled I guess on: 2009-03-05 22:27:17
A solution WITHOUT Vectors, I used in a 2D game of mine:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
int diffX; //the distance in X-direction from the bullet to the enemy
int diffY; //the distance in Y-direction
double maxDistance; //the maximum air-line way the bullet is allowed to travel in this frame (e.g. timedelta * 100 pixel/millisec)
double distance = Math.sqrt(distX*distX + distY*distY); //the exact, air-line distance (calculated with Pythagoras' theorem)

double goX = diffX*distance/maxDistance; //the x-way which the bullet travels in this fram
double goY = diffY*distance/maxDistance; //the y-way

this.x += goX;
this.y += goY;

8  Game Development / Game Mechanics / Re: Simple question (time based movement) on: 2009-03-05 22:12:04
This doesn't really make sense to me. No matter what, in a single thread program I wont be able to do that in a good way. If the program is sequential, the logic will always be limited by the rendering method, as they must be part of the same loop.
You're right, in a single threaded application that's true, but multi-threading makes sense here.. Why would you stick to one thread?

But really, from your posts I find multiplying the deltavalue each time the best solution. What would you do to pass this value to almost every class in your program? Singleton approach or just a simple static class?
Speaking from my experience: I always have a foreach-loop like this in my logic-thread (or in the logic-party of the main thread):
1  
2  
3  
for(Entity e : entities) {
    e.doLogic();
}

Where entities is an ArrayList or something similar with all the objects, players, enemies, units, buildings, (they extend Entity).. and doLogic() recalculates positions, does the enemy AI, determines building times, ...
9  Discussions / Miscellaneous Topics / Re: Worst OS ever? on: 2009-03-05 21:39:46
My vote: Symbian!

I (luckily) didn't develop anything for Symbian, ever, but I have to use it on my W950i.. I never, never experienced such a slow and unstable OS before  Lips Sealed
10  Game Development / Newbie & Debugging Questions / Re: Pin to desktop? on: 2008-12-10 23:29:17
Sorry, I didn't specify my question enough..

I was asking for a way to make a Window with the same properties as the desktop (is always behind any other window, but displayed when the desktop is brought to front [WIN+D])

Take the PIN TO DESKTOP mode of Samurize as example
11  Game Development / Newbie & Debugging Questions / Pin to desktop? on: 2008-12-10 20:42:34
Hi

is there a way to pin a Window or any other Container on the desktop?

Thanks,

Max
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.

Dwinin (21 views)
2014-09-12 09:08:26

Norakomi (55 views)
2014-09-10 13:57:51

TehJavaDev (66 views)
2014-09-10 06:39:09

Tekkerue (33 views)
2014-09-09 02:24:56

mitcheeb (54 views)
2014-09-08 06:06:29

BurntPizza (38 views)
2014-09-07 01:13:42

Longarmx (24 views)
2014-09-07 01:12:14

Longarmx (30 views)
2014-09-07 01:11:22

Longarmx (28 views)
2014-09-07 01:10:19

mitcheeb (37 views)
2014-09-04 23:08:59
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!