Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (554)
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: How to check if v-sync is actually enabled on: 2013-10-24 05:57:44
Speaking of V-Sync, Nvidia's recently announced G-Sync technology sounds like a really great idea, if such a tech does ever get standardised and become widely adopted, should be pretty nice for smooth looking games and solve the age old V-Sync/tearing problems properly.
All the advantages of V-sync without all the disadvantages of V-sync? Oh, yes.

Yeah but it would take a loooooooooooong time for wide adoption.

It sounds like most games don't need to do anything special to support g-sync. You just need to purchase a monitor that supports it, then turn it on in your driver options. Of course, most people are still using shitty 60hz monitors, so it's going to take a while for the concept of vsync to disappear...
2  Game Development / Game Play & Game Design / Re: Card Battling System on: 2013-10-23 09:24:46
OK so I thought I get some input here since I honestly I have a small infantile knowledge of the Java language (I'm learning as I go). Without giving out too much info, the game is in short a "Mega Man Chip Challenge" or basically an RPG-Like game that uses cards. I was wonder how I should go about implementing the cards...I believe making a class for the cards is the only way to go about it. Each card knows general info about itself, but in battle they can carry out a wide variety of actions.....I was thinking having a method that can read the cards ID number and thus, using a crap ton of else if statements, perform the required actions. I guess what I want to know is basically if there is an easier way to go about the entire thing. Any suggestions?

You are indeed missing the whole point of OOP design... but this is the perfect problem to help you grasp it. You shouldn't be using conditions to implement each card's behavior, instead...

1.) Make an abstract class called Card which contains all of the code that all cards share in common. Abstract classes cannot be instantiated but they can be extended by other classes.
2.) Now make a class for each type of card you want in your game, and have each one extend the Card class. Your subclasses will inherit all of the implemented methods of the parent "Card" class.
3.) Now, put an abstract method in the Card class, such as "doActions". Notice that this prevents your child classes from compiling... abstract methods must be implemented by child classes.
4.) Have each one of the child classes override "doActions"... this is where you can specify the individual behaviors of each card.

Now, whenever you have a variable of type Card, you can store any of the child classes of Card inside of it. You can even store all of your cards in an ArrayList<Card> (or any other generic container class), no matter which type of card it is.

You can call card.doActions() and it will perform the appropriate actions for whichever type of card it is. Try testing it out with debug messages.
3  Game Development / Game Play & Game Design / Re: 2D vs 3D World Immersion on: 2013-10-21 14:21:57
Have you considered using an isometric perspective? It's a nice compromise between 2d and 3d since it allows for depth and immersion, but doesn't require an unreasonable amount of artwork and engine work.
4  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 14:04:02
Grimmov; the answer is to use a better API.

Java2D has many limitations; its inability to query hardware capabilities is one of the big ones.

This is the most correct answer in the thread... I will do this at some point, but I wanted to get the basics of my game sorted in Java2D before switching to a better API, so that I can understand the differences.

@SHC: as I have explained in depth in this thread, the method you have presented is insufficient for my purposes. Vsync with double buffering is the only way to ensure that each frame is rendered to the screen in sequence without skips, which is the only way to perfectly scroll by the same number of pixels per displayed frame. As I mentioned before, "CPU-sync" has its own limitations.
5  Game Development / Newbie & Debugging Questions / Re: How many tiles should cause lag? [libGDX] on: 2013-10-21 12:09:27
in addition you could also calculate which tiles have to be drawn.

Does this really provide any benefit? Won't objects drawn offscreen take very little time to "draw" since they aren't actually being rendered?
6  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 10:55:43
I've seen it referred to as CPU sync (as opposed to vsync). It clamps framerate to the target interval by waiting to draw each graphics update. I prefer not to use this method, as non-vsync users can actually get a better experience by allowing graphics to update as quickly as possible, even if they are not rendered, as the frame that does get rendered will be more up-to-date this way. It also interferes with vsync because the CPU sync is not perfectly matched to the vsync rate.

I am trying to attain a level of smoothness that goes beyond the typical methods. In the end, I found that the best appearance was achieved by simply using delta-based scrolling combined with rounding the result to the nearest integer. My main problem with this was that extremely high FPS would cause the result to round down to 0. However, I added a check for this and use the non-rounded value when this happens, and all is well. Effectively it is a hybrid of my previous (vsync and non-vsync) approaches that works well regardless of vsync status, however, it only exhibits the actual smooth scrolling effect while vsync is enabled.

If anyone is curious, I've actually gone so far as to use a concurrent rendering thread while waiting for vsync to finish in my quest for smoothness... This basically gives me the benefits of double buffering (every graphics update is pushed to the screen, necessary for smooth scrolling) and triple buffering (game state and certain graphical updates can continue mid-frame) at the same time. Of course, concurrency leads to nightmares, but after a few days studying the concepts I've gotten a handle on it.
7  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 02:42:55
Whether vsync works or not just depends upon the conditions of the computer that's running the program. Some people have vsync forced to off in their graphics driver options; some computers just don't support it under certain circumstances. There's no perfect way to predict or observe the outcome from within the code (using java2d at least). In the end this just amounts to an extra graphics option that I wanted to automatically enable if vsync was detected, but now I'll have to leave that up to the end user.

I am currently using java2d; perhaps LibGDX has better vsync support? I somehow doubt it, but I'd be pleasantly surprised if it were true. I do plan to switch to it at a certain point, anyway.
8  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 02:31:45
You can't just "enable" vsync, you have to create a bufferstrategy and that object internally decides whether to use it or not based on whether it's possible under the current conditions. There seems to be no way to simply ask it whether it's using vsync or not.
9  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 02:20:34
Edit: Modified for clarity.

@zngga: If you want scrolling to be perfectly smooth, simple delta timing isn't good enough. It will result in an inconsistent number of pixels scrolled per frame. Calculating the distance based upon the time delta then flooring/rounding the result works well, but the result is highly dependent upon the current framerate, since it is functionally very similar to scrolling a specified number of pixels per frame (assuming the framerate stays constant). Either way, absolutely smooth scrolling requires moving the same number of pixels per screen refresh; this makes scrolling speed partly to directly proportional to the current framerate while using this technique. And thus, it is only a good idea if the FPS meets four conditions: 1) not too high, 2) not too low, 3) stable, 4) in sync with the monitor's refresh rate to prevent strobe/tearing effects. VSync ensures that all of these conditions are typically true (assuming the framerate does not drop from rendering issues).

This kind of perfectly smooth scrolling is much more apparent in a low-res pixelated 2d game engine, so it isn't much of an issue in higher-res or 3d games. Perhaps you haven't seen just how smooth it can look while using this technique, but it is very impressive. It makes purely delta-based timing look horrible in a side-by-side comparison.

The downside is that if you attempt this kind of scrolling without vsync, it creates an extremely distracting strobe-like effect, in addition to the typical screen tearing issues.

@opiop65: I agree that it is "hackish"... I suppose I will have to give up on detecting actual vsync status since there seems to be no airtight way to do it.

Instead, I will make "smooth scrolling" a graphics option within my game engine, off by default, and recommend its use only if vsync is enabled. Technically illiterate end-users might wind up turning it on without knowing about vsync, and the smooth scrolling effect will have distracting tears and jerks... but if they notice it looks bad, hopefully they will be smart enough to turn it back off.

10  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 01:37:55
You can't "always" enable vsync. Sometimes it is not supported or the graphics drivers override it, and then (it seems) there is no way to notice it's off, other than measuring the current framerate.

My rendering engine uses two different scrolling methods; one if vsync is enabled and one if vsync is disabled. The vsync-enabled method looks much nicer because it scrolls at whole pixel intervals per screen refresh, but this makes the scrolling speed (partially) dependent upon the framerate, and should be disabled if vsync is off.

In the end I've settled on measuring whether the current framerate is within +-5% of the monitor's refresh rate. This technique works well because it reverts to the non-vsync method if the rendering rate falls too far below the refresh rate.
11  Game Development / Newbie & Debugging Questions / Re: How to check if v-sync is actually enabled on: 2013-10-21 00:32:21
Yes, I can tell whether vsync is enabled based on my in-game FPS counter... but making my rendering engine's code depend on the average results of the FPS counter to "guess" whether vsync is enabled seems like a very poor solution. Not to mention, framerate fluctuations could trigger false positives or negatives.
12  Game Development / Newbie & Debugging Questions / How to check if v-sync is actually enabled on: 2013-10-20 22:35:11
I've looked for an answer to this question, but to no avail.

When using a BufferStrategy, how can I check whether VSync is currently enabled? I know that it can be overridden to "off" by graphics driver settings, and some situations may not support it, so I'd like to know when it fails so that I can compensate accordingly within my code.

Bonus question: when using triple buffering, is there any way I can synchronize some logic to the vsync pulse, despite my render thread being able to run at unlimited speed?
13  Game Development / Performance Tuning / Allocation during rendering loop on: 2013-10-16 15:46:38
IN GENERAL, is it considered to be a bad idea to perform allocations (the "new" keyword) during the rendering loop of a game? Would be be a better idea to pool/recycle objects such as vectors and positions, or keep everything in terms of raw x/y coordinates? Or is the performance gain from all of this not worth the decrease in code simplicity/readability? Especially if I have the intention to someday port a game to Android, where less memory would be available. I realize this is perhaps an overly generalized question but I'm curious as to how many people pursue this kind of optimization.
14  Game Development / Newbie & Debugging Questions / Re: animation looping using double buffering on: 2013-10-13 11:48:11
I know what a flag and a boolean are... the problem here is the inarticulate nature of the OP's question. Making assumptions in order to answer him won't help him learn to communicate better.
15  Game Development / Newbie & Debugging Questions / Re: animation looping using double buffering on: 2013-10-13 11:36:56
Your question is very unclear-- can you be more precise about what you want the image to do? Do you want to move it in a circle? I also have no idea what you're talking about with a "flag" to "get the image back".
16  Game Development / Newbie & Debugging Questions / Re: Rendering and game loop method for optimal framerate on: 2013-10-12 05:42:21
I tried out your benchmarking program, and the results were confusing.

While in fullscreen mode, I was unable to make my framerate drop below 60 no matter which settings I used. The balls stopped appearing once I reached ~7000.

While in windowed mode, my framerate was initially 400, and it took 22,000 balls before my framerate was reduced to 60.

If I set the the number of buffers to 2 rather than 3, I still had 120 FPS with over 32,000 balls, so I gave up waiting for it to get slower.

So again, my performance seemed superior in windowed mode. This mirrors the behavior I experienced with my own program.
17  Game Development / Newbie & Debugging Questions / Re: Rendering and game loop method for optimal framerate on: 2013-10-11 20:23:06
philfrei, I do happen to be following all of those suggestions... it seems that I am actually using Java2D correctly, it is just slow.

So, here's an update for anyone with similar issues: it turns out that the laptops were refusing to use video acceleration, I think. As an experiment, I set the following flags at the start of the program:

System.setProperty("sun.java2d.d3d", "false");
System.setProperty("sun.java2d.noddraw", "true");
System.setProperty("sun.java2d.opengl", "true");

This caused the laptops to freeze when the program was launched outside of fullscreen exclusive mode (they most likely cannot use OpenGL in windowed mode), but once I also enabled fullscreen, they started running quite well.

I was able to achieve 143 frames per second on the powerful laptop, and about 57 frames per second on the smaller laptop with integrated graphics (and it actually displayed about that many frames, unlike before).

So, here are my current questions:

1) How the heck can I get the laptops to utilize acceleration under D3D? Is it possible, or even desirable?
2) Why does my desktop render so much faster in windowed mode rather than fullscreen dedicated mode?
3) LibGDX or Slick (or something else)? I have read about the differences, but more opinions are nice.


18  Game Development / Newbie & Debugging Questions / Re: Rendering and game loop method for optimal framerate on: 2013-10-11 19:07:42
I will try out LibJDX and see if it improves the consistency of performance... is the general conclusion simply that Java2D is shit and inconsistent for serious games?

By the way, all three of the laptops are runnings Windows 7 or 8 with i5 processors. The computer and the powerful laptop have similarly powerful nVidia graphics cards. I see no reason for the vast performance disparity unless there's just something very inconsistent happening at a low level.
19  Game Development / Newbie & Debugging Questions / Rendering and game loop method for optimal framerate on: 2013-10-11 18:22:17
I'm working on creating my first serious game in Java... right now, it is relatively simple, and merely displays a few hundred BufferedImages and shapes on the screen. I decided to test various combinations of rendering and game loop methods on each of my three computers...

Method one:
Exclusive fullscreen mode, using a BufferStrategy for page flipping, iterate over elements using an infinite loop with no delay.
Results:
My main desktop computer gets 145 FPS, powerful laptop gets 33 FPS, small laptop gets 11 FPS.

Method two:
Windowed mode, using javax.swing.Timer for timing, iterate over the elements with each expiration.
Results:
Main desktop gets 545 FPS, powerful laptop gets 33 FPS, small laptop gets 31 FPS (but looks laggy like 11 FPS).

Method three:
Windowed mode, using an infinite loop and System.nanoTime() for timing, call repaint() every interval.
Results:
Main desktop gets 850 FPS, powerful laptop gets 31 FPS, small laptop gets 31 FPS (but looks laggy like 11 FPS).


To summarize, my desktop computer gets vastly better performance than either of my laptops. But the larger laptop has its own nvidia graphics card and a CPU even faster than my desktop, so I see no reason there should be a performance disparity. (Yes, I did ensure that the laptops are on performance mode, not power saving mode.)

Furthermore, I am puzzled as to why (on the desktop) windowed modes are so much faster than dedicated fullscreen mode. I was under the impression that the advantage of fullscreen dedicated mode is superior performance.

Any insight into these issues would be appreciated.

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.

TehJavaDev (18 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (70 views)
2014-08-11 02:49:23

BurntPizza (47 views)
2014-08-09 21:09:32

BurntPizza (39 views)
2014-08-08 02:01:56
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!