Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (427)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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] 2 3 ... 67
1  Game Development / Newbie & Debugging Questions / Re: moving a generalPath on: 2014-04-20 00:31:38
Graphics.translate(x,y) or Graphics2D.translate(tx,ty)

The latter being equivalent to Graphics2D.setTransform(AffineTransform.getTranslateInstance(tx,ty))
2  Game Development / Newbie & Debugging Questions / Re: Can you randomly bitwise shift an integer left or right? on: 2014-04-13 13:31:31
Shifts are defined for all inputs

Just not what you might expect* Grin
*right-hand operand is truncated to 5 bits(for an int shift) or 6 bits (for a long shift).

I came a cropper of this behaviour some time ago.
3  Game Development / Newbie & Debugging Questions / Re: Advice on a faster way to check every pixel in an image. on: 2014-04-12 20:04:50

Not when you're loading 10~ of these sheets (depending on the spritesheet it needs to grab) about 300~ times... /snip

You're reloading the same image multiple times?
4  Game Development / Newbie & Debugging Questions / Re: Gradient fill a BufferedImage on: 2014-04-12 19:54:37
You googled for it?
http://lmgtfy.com/?q=gradient+fill+java
5  Game Development / Performance Tuning / Re: Pixel Array Manipulation vs. Multiple DrawImage Calls on: 2014-04-07 14:10:09
The answer to the question depends on where the images are being drawn to.

... and from.
6  Game Development / Newbie & Debugging Questions / Re: My most inefficient way of implementing running texts. How to optimize? on: 2014-04-06 00:22:10
Thanks. I see a lot of unfamiliar classes being used, but the font setup and attributes portion looks easy to understand.

What is Inset? What does it do?

Insets
7  Game Development / Newbie & Debugging Questions / Re: Why a NaN variable is not equal to Double.NaN? on: 2014-04-02 12:54:25
autoboxing + NaN = potential for much pain
8  Game Development / Newbie & Debugging Questions / Re: Parse a string to a *packed* Integer. (0xFFFFFFFF) on: 2014-04-02 02:27:35
Wow, that decode() behaviour really is a nasty gotcha.
First bug reported against it...... 15 years ago.  Undecided

Even worse are Integer's parseInt & valueOf methods, as they make no mention of any special behaviour or limitation relating to integer values >0x7FFFFFFF.
9  Discussions / Miscellaneous Topics / Re: new computer purchase advice on: 2014-04-01 10:09:08
I'd just like to reiterate how invaluable having an SSD is, especially in a development environment.

The sweet spot at the moment is 256GB, which if you hunt around for a good price, can be had for ~£75.
10  Game Development / Newbie & Debugging Questions / FilterOutputStream the most useless class in the JDK? on: 2014-03-27 13:54:59
I fell into the exact same trap as Riven did (here).

What is the point of this class existing if the default method implementations are so stupid :/

FilterInputStream is similarly flawed in that read(byte[]) invokes read(byte[],offset,len), resulting in it invoking your subclass implementation potentially causing unintended behaviour.
There's a hint in the javadoc that this flawed behaviour is to compensate for a stupid implementation in FilterInputStream's known subclasses:
Quote
It is important that it does
     * <i>not</i> do <code>in.read(b)</code> instead;
     * certain subclasses of  <code>FilterInputStream</code>
     * depend on the implementation strategy actually
     * used.

These Filter classes should be such trivial wrapper implementations it boggles my mind how they ended up having such convoluted & downright broken behaviour.

They should both be deprecated, and flagged with a big "DO NOT USE THESE CLASSES, THEY'RE FUNCTIONALLY USELESS/BROKEN" warning.
11  Game Development / Networking & Multiplayer / Re: Good latency proxy? (TMnetsim causing stream corruption!) on: 2014-03-24 03:42:29
What does it mean for the code to be "bytecode injecteD"? Sounds painfull Wink

bytecode instrumentation / code weaving.
12  Discussions / General Discussions / Re: How to make a JFrame's background transparent? on: 2014-03-23 20:30:57
Google is your friend:

http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html

:edit:

Looks like Oracle made a booboo; the jnlp link for the 3rd example (ShapedWindow) is wrong.
13  Discussions / General Discussions / Re: 30 vs 60 vs 120 FPS on: 2014-03-23 20:30:12
I think if one day we'll have VR with working eye-tracking, high frame-rates will be a lot less computationally demanding. Even at proper resolutions for VR (like 4K or even 8K).

Your eyes only see sharply at just about 2 degrees. Outside of that it all quickly becomes a blur. You brain does the rest to make you think it's all sharp.

At a 100 degrees FoV at 8K resolution, that's like 88*88 pixels per eye that need the best quality rendering, and that's with 8K resolution (i.e. 7680*4320) .
Outside of those 88*88 pixels, you can increasingly (and quickly) drop resolution, AA, texture resolution, shader quality etc.
This might be a bit of an oversimplification, but I suppose even today's PCs should be able to handle that at at least 60fps.
But good eye-tracking will be key here.

I doubt that will ever happen.
Besides the obvious problem of what to do when you have multiple observers, you'd also need absolutely insane response times for the eye not to register the low resolution/quality peripherial areas when moving focal point.

Bypassing the eye entirely & patching into the optic nerve is the next logical step IMO, though I can't even begin to imagine how that would feel to the user.
14  Game Development / Networking & Multiplayer / Good latency proxy? (TMnetsim causing stream corruption!) on: 2014-03-23 16:22:49
I'm currently writing an unofficial multiplayer mod for the game Starsector. (great game btw! and a bargain for $10)

For simplicity* I'm making the game simulation(and fp) deterministic, syncing the peers, and transmitting just user-originated events using a lock-step model, with input delay appropriate to the latency between peers.
*(simplicity is of paramount importance because the entire mod is going to be bytecode injected, meaning there are practical limitations upon how much of the codebase I can interact with.)

To this end I created a prototype to test how well the lock-step model handles at various latencies. (using the tool TMnetsim as a latency proxy)
It seemed to work fine with low latencies, but exhibited weird data corruption at higher latencies.
After much hair pulling I determined it couldn't possibly be my code, and wrote the below code as a sanity test to confirm TMnetsim is a useless piece of crap.

So 2 questions:

1) The below code should work perfectly, right? (obviously with the relevant ports redirected)
2) As TMnetsim appears to be a piece of unreliable crap, can anyone suggest a good tool for introducing semi-realistic latency between connections? (I could of course write one... but given the plethora of multiplayer games surely such tools already exist?!)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
import java.io.IOException;
import java.net.Socket;

public class Client {

   public static void main(String[] args) throws IOException {
      Socket s = new Socket("localhost", 9665);

      new Thread(new SocketReader(s)).start();

      new Thread(new SocketWriter(s)).start();
   }

}

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
   public static void main(String[] args) throws IOException {
      Socket s = new ServerSocket(9765).accept();

      new Thread(new SocketReader(s)).start();

      new Thread(new SocketWriter(s)).start();
   }

}

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  
import java.io.DataInputStream;
import java.io.IOException;
import java.net.Socket;

class SocketReader implements Runnable {

   Socket s;

   public SocketReader(Socket s) {
      this.s = s;
   }

   @Override
   public void run() {
      try {
         DataInputStream dis = new DataInputStream(s.getInputStream());
         int counter = 0;

         while (true) {
            int val = dis.readInt();
            if (val != counter) {
               throw new RuntimeException("stream corruption! Expected: " + counter + " received: " + val);
            }
            counter++;
         }
      } catch (IOException e) {
         // TODO Auto-generated catch block
        e.printStackTrace();
      }
   }

}

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  
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

class SocketWriter implements Runnable {

   Socket s;

   public SocketWriter(Socket s) {
      this.s = s;
   }

   @Override
   public void run() {

      try {
         DataOutputStream dos = new DataOutputStream(s.getOutputStream());
         int counter = 0;
         
         while (true) {
            dos.writeInt(counter);
            counter++;
         }
      } catch (IOException e) {
         // TODO Auto-generated catch block
        e.printStackTrace();
      }
   }

}
15  Discussions / Java Gaming Wiki / Re: Anonymous/Local/Inner class gotchas on: 2014-03-11 08:57:04
Why would anyone do that :/
16  Game Development / Newbie & Debugging Questions / Re: [Solved] Smooth transition between angles on: 2014-03-10 04:15:25
If you kept everything as vectors, it'd be a lot neater.
You'd just examine the sign of the determinant (cross product) of the 2 vectors to know if one is to the left, or right of the other.

pseudo code something like:
1  
2  
3  
4  
determinant = (b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x);
if(determinant>0) turnLeft();
else if(determinant<0) turnRight();
else fire();
17  Discussions / General Discussions / Re: Someone brought up an interesting topic regarding the new JDK8 default methods. on: 2014-02-08 12:48:11
That example that turns the Comparator interface into a Builder feels.... misguided.

Wouldn't it be better to simply add a separate ComparatorBuilder library class?

If the main purpose of default methods is so that existing interfaces can be expanded without breaking binary compatibility, then I feel it's somewhat pointless as most interfaces shouldn't be able to provide a meaningful default implementation.
It'll just result in messy interface bodged with empty implementations and warning comments.
18  Discussions / Miscellaneous Topics / Re: I had an idea involving .gifs! on: 2014-01-07 04:23:17
.mng would be a better choice.
19  Games Center / 4K Game Competition - 2014 / Re: In The Dark 4K on: 2014-01-04 02:10:11
Very impressive, though I can't help thinking free look/aim with the mouse would make it a lot more playable.
20  Game Development / Newbie & Debugging Questions / Re: JFrame dimensions? on: 2013-12-31 04:08:14
getInsets().

Though it's less work (and probably more reliable) to draw onto a child Component (JPanel for instance), rather than directly onto the top-level Window.
21  Game Development / Shared Code / Re: Simple mouse coordinate code on: 2013-12-15 01:02:18
I remember seeing one post where they 'discovered' this. Mind was blown.

Discovered Math.min and Math.max, or discovered how to clamp values in general? Huh

I imagine the mind blowing discovery was finding that an API existed for directly querying the mouse position.
I certainly didn't know it existed.

Though I can't really see too many useful applications for it.
I suppose MouseInfo.getNumberOfButtons() is a useful feature.

I'd have preferred the API exposed direct querying of HID devices, so support for multiple mice/keyboards/etc was possible (without 3rd party APIs)
22  Game Development / Performance Tuning / Re: Which is faster? :P on: 2013-12-05 11:41:15
Could you guyz stop giving the stupid advice like "reuse the random object"
I will now try to re-make my question.
Which way would it be faster to do it, if we have 10000 actions to check?

The answer is the same; you shouldn't care which is faster, you should be writing your code so that it's readable & maintainable.

Case in point; for 10000 actions, a switch statement with sequential case values would be fastest.... and simultaneously the least maintainable.

For 10k actions I'd consider determining the commonality of the actions, and making it data-driven.
23  Game Development / Performance Tuning / Re: Which is faster? :P on: 2013-12-05 11:03:08
A is much faster; it requires nothing more than a conditional branch.

B's implementation on the other hand ( array[index].method() ) requires:

if(array == null) throw NullPointerException
if(index >=array.length) throw ArrayIndexOutOfBoundsException
if(array[index] == null) throw NullPointerException
Method call using invokeinterface (which requires a search of the method table, creation of a stack frame, etc etc).

Though as previously said; you shouldn't be considering performance at this level, simply write your code in the clearest way possible.
24  Games Center / 4K Game Competition - 2014 / Re: GameInceptionGames on: 2013-12-04 17:01:27
Ticception is a work of genius.
Original idea, or a clone of someone else's invention?

Pongception is hard, breakception is insane, but I don't feel either adds anything to their respective vanilla games.
25  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-29 14:56:35
Looking great!

I wouldn't worry about prettifying it until it's functionally complete; you can waste loads of time dicking around with L&F.

26  Game Development / Newbie & Debugging Questions / Re: Collision response on two axis on: 2013-11-24 18:53:52
Going back to the OP's original code; your 'getting stuck' problem is that you're checking for collision using the object's present coordinates.
You should be testing for collision with the coordinates that you intend to move into; the object's future coordinates.

I won't confuse the matter by touching on how complex proper collision detection & response is to do, as it clearly isn't applicable to what you're trying to achieve.
27  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-17 14:35:08
I'm completely opposed to using source file size limitations, as it demands the creation of illegible code.

While the 4KB binary limitation might not result in the most structurally sound of code bases, it's perfectly possible to write verbose and readable code that compiles down to optimal byte code.

The expected competition start date is so close, I'm doubtful that any changes to the rules that requires significant framework development are going to take place this year.
For the elimination of doubt, I suggest we settle on the status quo.

The issue of Applet compatibility & usability going forward can be addressed retrospectively with wrappers & byte code weaving, if the demand arises.
28  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-11-16 11:52:05
There's so much setup bloat with Android apps, could you even do a hello world app in 4KB?
29  Discussions / General Discussions / Re: Java's built in Scripting engine on: 2013-11-13 18:07:17
I suppose a small plug for Starsector (formerly Starfarer) would not be entirely inappropriate here, given its use of Janino in its scripting & extensive modding support.

I don't know if Alex (the game's creator) frequents these forums, but he could undoubtedly cast some valuable light upon the usability & security of using Janino in this scenario.
30  Game Development / Newbie & Debugging Questions / Re: Movement based on FPS on: 2013-11-12 23:14:31
Sampling inputs as often as possible is a very good idea.

However there's little to gain from rendering more frequently than the monitor's refresh period.
Pages: [1] 2 3 ... 67
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (76 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (66 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!