Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (603)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (652)
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?

//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 "" 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
   Date startTime = new Date();
   Date previousRepaint = startTime;
   Date currentTime = startTime;

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

      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:
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) {
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
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..
Graphics2D g = (Graphics2D)strategy.getDrawGraphics();

When we finished drawing, we release all the used resources, by finishing the flip-book page

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

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):
for(Entity e : entities) {

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

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


Pages: [1]
SHC (17 views)
2015-08-01 03:58:20

Jesse (17 views)
2015-07-29 04:35:27

Riven (38 views)
2015-07-27 16:38:00

Riven (20 views)
2015-07-27 15:35:20

Riven (22 views)
2015-07-27 12:26:13

Riven (13 views)
2015-07-27 12:23:39

BurntPizza (32 views)
2015-07-25 00:14:37

BurntPizza (44 views)
2015-07-24 22:06:39

BurntPizza (25 views)
2015-07-24 06:06:53

NoxInc (33 views)
2015-07-22 22:16:53
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

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