Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (491)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
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 / Networking & Multiplayer / Re: Good guide for network programming on: 2005-04-27 10:23:48
Looks like you need to join in order to view the information.
2  Game Development / Networking & Multiplayer / How to check if a client has closed a socket. on: 2005-04-27 00:46:40
Hey everyone,

I've got a problem in which if a client calls socket.close(), the server never receives an Exception.  The server will only receive an Exception if the client actually quits out -- as in System.exit(0).

I've also done socket.shutdownInput() & socket.shutdownOutput() on the client end, but to no avail.

On the server end, I'm still able to write to the OutputStream without getting any sort of Exception.  Why would an Exception not be thrown if I'm writing to an OutputStream that is supposedly closed at the other end?  Any thoughts?
3  Game Development / Newbie & Debugging Questions / Discerning Primitive Types on: 2005-04-14 09:54:52
Hey everyone,

I've been programming in Java for a good many years now, but this sort of problem has never come up before.

You can tell what type of class a reference is by doing

if (obj instanceof java.lang.String)
System.out.println("It's a string!");

But how can you discern between primitives?  Is there a reserved word for it, or is there some other special trick?

Thanks!
4  Java Game APIs & Engines / Java 3D / Re: Removing Children on: 2005-03-29 22:49:25
Ah, okay.  Smiley

So, hypothetically, if I had a scene where 40 laser blasts were shot, and I wanted them all removed, they would have to have been under a BranchGroup -- with the proper capability bits set, of course.
5  Java Game APIs & Engines / Java 3D / Removing Children on: 2005-03-28 19:59:38
Hey Everyone,

I've gotten the basic hang of Java3D, but one thing that still puzzles me is how to remove a child from a group after it becomes live / compiled.  Once a node is added as a child to a Group, and becomes live, can it never be removed?

For instance, I might have laser blasts in a game, and instead of recycling, say I'd want to destroy them after they've performed their duty.  Instead of being cheap and setting their transparency to zero, conceptually, how might I be rid of them?

Thanks.  Smiley
6  Game Development / Networking & Multiplayer / Closing A Socket on: 2004-12-21 12:02:03
Hey everyone,

I haven't quite figured out yet how to completely close down a socket -- other than having the client quit their program.

Why doesn't socket.close() get the job done?

Thanks!
7  Game Development / Networking & Multiplayer / Re: Sludge-Like Network Performance on: 2004-11-19 02:25:48
Alright, here's an update on the situation.  Smiley

Instead of passing various objects back and forth, I switched to encoding Strings into bytes, and passing that along with a BufferedWriter.

The ping times went down from a spikey average of 240 down to 15 milliseconds.

16x Faster Smiley

Thanks!
8  Game Development / Networking & Multiplayer / Re: Sludge-Like Network Performance on: 2004-11-17 16:32:43
Now here's the thing.  How can ObjectOutputStream be so slow?  I wrote my object states to the hard drive, and they're incredibly small!

These are the only objects being passed back and forth:

GameData: 635 bytes, done once every 1 - 10 seconds
KeyStroke: 47 bytes, done 5 - 8 times a second
Position: 560 bytes, matches KeyStroke

The campus network here is certainly more than capable of sustaining 5 kb/s.

9  Game Development / Networking & Multiplayer / Re: Sludge-Like Network Performance on: 2004-11-17 11:28:42
Thanks for the replies.  I'll definitely take a look at RMI.  Smiley

Using the ObjectOutputStreams, on a somewhat moderate campus network, the reaction time between the client rotating a piece and actually seeing the result felt like 0.33 - 0.5 seconds.  I'm curious to see what it'll look like on a high-performance, low-latency home LAN.

There are two points I'm curious about, and I'm wondering if anyone knows off hand:

- Which is faster?  Sending five objects, each in succession, or sending all five objects encapsulated within a single array?  (5 sends vs. 1 send)

- Is calling ObjectOutputStream.reset() after writing out the data a good / bad idea?
10  Game Development / Networking & Multiplayer / Sludge-Like Network Performance on: 2004-11-17 02:18:27
Hey everyone, so I've tried to program a two-player version of Tetris.  Essentially, the server runs the game, the client sends move/rotate commands, and then the server sends back the board and piece data.

I'm using ObjectInputStreams and ObjectOutputStreams in TCP/IP.  I'd do something like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
Socket client;
ServerSocket ss;
ObjectOutputStream oos;
ObjectInputStream ois;
Transmitter transmitter;
Receiver receiver;

client = ss.accept();
                        
                        oos = new ObjectOutputStream(client.getOutputStream());
                        ois = new ObjectInputStream(client.getInputStream());

                        transmitter = new Transmitter(oos);
                        receiver = new Receiver(ois);


Transmitter 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  
package tetris.net;

import java.io.*;
import java.net.*;
import java.util.*;

public class Transmitter implements Runnable
{
      ObjectOutputStream oos;

      Vector<Object> vec;

      public boolean running;

      Thread th;

      public Transmitter (ObjectOutputStream oos)
      {
            this.oos = oos;

            vec = new Vector<Object>(50,10);

            running = true;

            th = new Thread(this);
            th.start();
      }

      public void run ()
      {
            while (running)
            {
                  while (!vec.isEmpty())
                  {
                        Object object = vec.get(0);

                        writeOut(object);

                        vec.remove(0);
                  }

                  try
                  {
                        th.sleep(15);
                  }

                  catch (InterruptedException ie) {}
            }
      }

      private void writeOut (Object object)
      {
            try
            {
                  oos.writeObject(object);
                  oos.reset();
            }

            catch (Exception e)
            {
                  System.out.println("Error on transmitter");
                  running = false;
            }
      }

      public void add (Object object)
      {
            vec.add(object);
      }

      public int getSize ()
      {
            return vec.size();
      }
}


Receiver 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  
package tetris.net;

import java.io.*;
import java.net.*;
import java.util.*;

public class Receiver implements Runnable
{
      ObjectInputStream ois;

      Vector<Object> vec;

      public boolean running;

      Thread th;

      public Receiver (ObjectInputStream ois)
      {
            this.ois = ois;

            vec = new Vector<Object>(50,10);

            running = true;

            th = new Thread(this);
            th.start();
      }

      public void run ()
      {
            while (running)
            {
                  readIn();
            }
      }

      private void readIn ()
      {
            Object object;

            try
            {
                  object = ois.readObject();
            }

            catch (Exception e)
            {
                  System.out.println("Error on receiver");
                  running = false;
                  return;
            }

            vec.add(object);      
      }

      public int getSize ()
      {
            return vec.size();
      }

      public Object extract ()
      {
            if (vec.size() == 0)
                  return null;

            Object object = vec.get(0);
            vec.remove(0);
            
            return object;
      }
}



Essentially, if the client were to tell the server to move its piece one unit to the left, it would add a serialized integer to the transmitter.

Now, am I correct in assuming that using ObjectStreams won't bring about decent network play?  Is there something that I'm doing wrong here?

Thanks!
11  Game Development / Newbie & Debugging Questions / Source / Target flag Compiling on: 2004-10-29 01:35:05
Hey Everyone,

Right now I've got Java 1.5 SDK on my computer.  I wanted to compile for 1.3, so I did this:

javac -source 1.3 -target 1.3 *.java

It successfully compiled without giving any errors.

However, the program didn't run.  Why?

Because I called the String.contains(String) method, which wasn't introduced until 1.4.

Why doesn't it catch this?

Thanks.
12  Game Development / Newbie & Debugging Questions / Re: Swing Components Blocking on: 2004-08-27 15:52:14
Whoops!  Grin

As sure as I was yesterday that the I/O operation was being done on a totally separate thread, it turns out that I was wrong about that.

Thanks for the help, though.  That repaint(0) call will definitely come in handy.

Anyway, I was making a program which writes the absolute pathname of each and every single file and folder inside a given directory to a specified text file.  Works now.
13  Game Development / Newbie & Debugging Questions / Re: Swing Components Blocking on: 2004-08-27 15:36:11
There is no interaction with the UI whatsoever.  What the I/O is doing is reading in a list of files and writing their absolute pathnames to a text file.  It is on a completely separate thread from the GUI.

The thread that is running responsible for painting in the JFrame may make a call during the I/O operation like:

System.out.println(System.currentTimeMillis());

And that will work; but, for some reason, the painting functions will not.  The JFrame stays blank until the I/O operation ceases.
14  Game Development / Newbie & Debugging Questions / Swing Components Blocking on: 2004-08-26 19:24:00
Hey everyone,

Now I've been programming for nearly two years in Java, but this one little tidbit has got me stumped.

I've got two separate threads running.  One doing painting in a JFrame, and the other performing I/O work.

For some odd reason, when the I/O thread is doing its thing, the components refuse to paint in the JFrame.  Even if I try calling repaint(), it will ignore the call until the I/O has finished.

Any ideas?
15  Java Game APIs & Engines / Java Sound & OpenAL / Re: Java Sound Chapter Online on: 2004-04-19 23:49:42
These are the greatest... and just in time too, for the sound section, because I needed something non-perplexing to learn from!  Thanks so much for putting the time into making these chapters.  Smiley
16  Java Game APIs & Engines / Java 2D / Re: Page Flipping with Buffer Strategy on: 2003-07-17 12:41:17
I am such an idiot!  Cheesy Cheesy Cheesy

Know what I did with the flags?  I put them after Java MyProgram.   Wink

Now the game runs just as fast as it did in the first place!  Thanks very much for the help.  Now that I've got everything technologically speaking, I can finally buckle down and concentrate on the game itself.  Grin
17  Java Game APIs & Engines / Java 2D / Re: Page Flipping with Buffer Strategy on: 2003-07-17 00:52:03
I tried it.  I loaded the .png image through the ImageIO and then brought it over to a BufferedImage via createCompatibleImage.  I set both flags to true.  One rocketship didn't seem to do that much damage to the framerate.  But a few more certainly did.  Sad



When all I used was update() and paint(), I could get 60+ fps on a PIII 750mhz with this many rocketships on the screen.  (Same level of transparency.)

Now, even with accelerated BufferedImages, I barely get 3 fps on a PIV 2.4ghz in the same situation.

You'd think that if hardware mode wasn't faster than software, it'd be at least within the ballpark.  Wink


So a buffered image created with createCompatibleImage is automatically sent to VRAM if ImageCapabilities.isAccelerated() returns true?
18  Java Game APIs & Engines / Java 2D / Re: Page Flipping with Buffer Strategy on: 2003-07-16 14:39:34
Seems like I've run into a totally different snag now.   Wink

I implemented the BufferStrategy as opposed to the old update() and paint() methods, and now my .png graphics -- which make extensive use of an alpha channel and partial transparency -- slow the game down considerably.  The more of them there are on the screen, the worse it is.

Before, without using strategy.show(), the performance was as quick as the Gingerbread Man, no matter how many of them I had on the screen at any given time.

I'd hate to have to go back to high-speed ripping and tearing, but I love my large corona effects.

Does anyone know what it is about using BufferStrategy that significantly downgrades the performance of images that utilize the alpha channel?
19  Java Game APIs & Engines / Java 2D / Re: Page Flipping with Buffer Strategy on: 2003-07-16 13:13:08
Whew!  Thanks everyone!   Grin Grin Grin

The setIgnoreRepaint(true) did the trick.  Now everything runs perfectly in fullscreen and without a single tear effect.
20  Java Game APIs & Engines / Java 2D / Re: Page Flipping with Buffer Strategy on: 2003-07-16 12:42:24
I'm still wondering about that flashing effect that's going on.  I've noticed that the more buffers I use -- createBufferStrategy(numBuffers) --  the slower the frequency of the flash.

I'm doing something wrong here to cause this flashing effect.  It is definitely the background color that's doing it.  When the background is set to red, it'll flash red, etc.  Leaving it alone will flash white.

Red--Blue--Red flashing looks pretty cool and seizure-inducing, but it's not what I wanted for the game, exactly.  Wink

I'll try experimenting with a few other ideas I have, but so far, no luck.
21  Java Game APIs & Engines / Java 2D / Re: Page Flipping with Buffer Strategy on: 2003-07-16 12:16:23
Ah, thanks.  Looks like it's working.  Multi-buffer and page-flipping both return as true.

However, there's horrible full-screen flickering now.  I can tell that there's no more tearing, but the whole screen flashes with the background color.  It isn't exactly the "flickering" that you'd see in the old days when you didn't use the old-fashioned double-buffering, but it's more of a flashing.

The background itself doesn't clear out the area; I have to do a setColor(Color.blue) and fillRect(0,0,640,480), otherwise you get that effect like in Doom when you walk out of the walls.


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  
import java.awt.event.*;
import java.awt.image.*;
import java.awt.geom.*;
import java.applet.*;
import java.util.*;
import java.net.*;
import java.applet.Applet;
import javax.swing.*;
import java.io.*;


public class Gamer extends Frame implements KeyListener, MouseListener, MouseMotionListener
{
      BufferStrategy strategy;
      BufferCapabilities bufCap;

      GraphicsDevice device;
      GraphicsConfiguration gc;
      boolean inFullScreen;

      DisplayMode newDisplayMode;
      DisplayMode oldDisplayMode;

      public Gamer (String title, GraphicsDevice device)
      {
            super(device.getDefaultConfiguration());
                   this.device = device;

            oldDisplayMode = device.getDisplayMode();

            boolean isFullScreen = device.isFullScreenSupported();
              setUndecorated(isFullScreen);
              setResizable(!isFullScreen);

              if (isFullScreen)
            {
                        device.setFullScreenWindow(this);
                       validate();
                  inFullScreen = true;
                   }
           
            else
            {
                        pack();
                        setVisible(true);
                  inFullScreen = false;
              }

           

            newDisplayMode = new DisplayMode(640, 480, 32, 60);
            device.setDisplayMode(newDisplayMode);
            gc = device.getDefaultConfiguration();
            bufCap = gc.getBufferCapabilities();

            createBufferStrategy(3);
            strategy = getBufferStrategy();

            setBackground(Color.blue);

            while (true)
            {
                  if (loaded)
                  {
                        runningUpdate();
                        render();
                  }

                  try
                  {
                        Thread.sleep(20);
                  }

                  catch (InterruptedException e) {}
            }            
      }

      public void render ()
      {
            Graphics g1 = strategy.getDrawGraphics();

            Graphics2D g = (Graphics2D) g1;

            g.setColor(Color.blue);
            g.fillRect(0,0,640,480);

            // DRAWING

            g.dispose();
            strategy.show();
      }
           
      public static void main (String[] args)
      {
            GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice myDevice = env.getDefaultScreenDevice();

            Gamer gamer = new Gamer("Gamer", myDevice);
            gamer.setSize(640, 480);
            gamer.setVisible(true);
      }
}



Could someone please tell me what I'm doing wrong here?  That's all the code relevant to the graphical aspect of my program.
22  Java Game APIs & Engines / Java 2D / Page Flipping with Buffer Strategy on: 2003-07-16 01:05:11
First time poster here.  Smiley


Ever since I managed to get full-screen exclusive mode working, I've noticed that the faster moving objects tear like crazy.  I've scoured the net for one decent example of a simple page-flipping code and came up with nothing.  Everyone keeps linking to the "examples"   Roll Eyes on Sun's site, but there is no code whatsoever demonstrating the use of page-flipping.

Having a couple of words and pictures doesn't do it for this programmer.  Wish it did, but it doesn't.  Wink

I would be very grateful if any kind soul here could point me in the right direction -- that one, single example!
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.

Nickropheliac (15 views)
2014-08-31 22:59:12

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

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

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

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

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

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

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

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

BurntPizza (48 views)
2014-08-09 21:09:32
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!