Hi !
Featured games (88)
games approved by the League of Dukes
Games in Showcase (679)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (734)
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
1  Game Development / Networking & Multiplayer / closing SocketChannel asynchronously on: 2006-11-22 23:12:56
Another NIO beginner's question Smiley

If I close a SocketChannel from some other thread than the selector thread, it causes several exceptions after next Selector::select() operation. Some selection keys gets invalidated, so readyOps() throws CancelledKeyException and  SocketChannel::read()  throws  AsynchronousCloseException. I know why it happens, but I'm not sure what is the best way to handle it.

- should I simply catch and ignore these exceptions?
- should I try to avoid them by only closing a SocketChannel in selector thread?
- any other idea?

thank you
2  Discussions / General Discussions / Re: 3D graphics in Runescape - how? on: 2006-10-22 10:45:02
I'm very impressed with your game
glad you like it Smiley
Some things I was wondering:
How long did it take you to make ?
around 2 years Sad
Is it compatible with the microsoft VM?
it is
How many frames per second does it run at?
there is 25 fps throttle.
How much can I buy your code for? 
At the moment I don't consider selling it (and anyway not many people could afford to buy 2 years of my work)
3  Discussions / General Discussions / Re: 3D graphics in Runescape - how? on: 2006-10-20 06:49:42
It's really not that hard (if you are good at math, and you know something about code optimization). I have created an engine similar to runescape, and I also created the "mmorpg" part - it is online, multiplayer, it has all elementary features like picking/droping object, chat, combat, etc.
You can see it here:   

Sadly, then I realized that without funding and some dedicated artists I have no chance to create reasonable content, so I moved to a simpler project and I put this one on hold (it hasn't changed since a half year or so).
4  Java Game APIs & Engines / Tools Discussion / Re: Eclipse 3.2 where did my console go? on: 2006-10-01 21:11:38
Happened to me few times as well. I suspect it happens when you start the Eclipse, and you hit "run" too soon, before some internal Eclipse stuff initializes.
5  Game Development / Newbie & Debugging Questions / Re: Runtime.exec() problem on: 2006-09-13 05:30:29
I had similar (?) problem some time ago. I was writing an eclipse plugin, and I needed to launch an external program from it. In fact I needed to launch a batch file (".bat"), containing just a line like:

java -jar something.jar

I launched it like this:
Process process = Runtime.getRuntime().exec("...something...", null, dir);

It always simple froze, and I have no idea why. I AGREE that there are better ways to do same thing, but still I don't understand why it didn't work.
6  Game Development / Networking & Multiplayer / Re: Applet Failing After First Load on: 2006-08-20 15:26:10
That is really wierd, I thought applets ran in their own VM & so static variables are not shared?

A web browser creates only one VM (at least IE and Firefox do it this way). Thus you need to be very careful when same applet runs twice in same web browser. Both instances will share static fields.
7  Game Development / Networking & Multiplayer / Re: Is FTP an option? on: 2006-08-20 15:15:02
There's an extension to Java called JavaMail that is specifically for working with email.

With JavaMail you will need a mail server.  (Windows XP has built-in mail server). But I doubt this is what you are looking for. You should explain what exactly do you need.
8  Discussions / Miscellaneous Topics / Re: Free dungeon and textures on: 2006-05-04 09:44:40
not available anymore Sad
9  Discussions / Community & Volunteer Projects / Re: !!!Team needed 4 Applet-Based MMORPG!!! on: 2005-12-07 09:54:28
there is nothing wrong about using snes sprites during development. Programming is much more important than graphics. Once you have alpha version of your engine (after at least one year of hard work) you can start worry about better graphics.
10  Discussions / General Discussions / Re: Java Applets for Games? on: 2005-11-28 20:20:12
According to Sun, those people are officially a small minority

He maybe means The Sun newspaper  Grin
11  Discussions / General Discussions / Re: Java Applets for Games? on: 2005-11-28 10:43:20
According to Sun, those people are officially a small minority

Have they released some official statistics? Where can we find it?
12  Games Center / Archived Projects / Re: 3D Engine and Demo with some nice effects on: 2005-11-17 17:21:31
Nice Smiley Runs at 60 fps here  (2.4GHz Celeron / FX-5500 / WinXp)
13  Games Center / Archived Projects / Re: Cyberion - 2D Shooter Game! on: 2005-11-03 20:23:47
Damn, how many levels it has? I finally made it to lvl 6

Recently it became my favourite casual game Smiley I play it when I'm too tired for programming Smiley Are you still working on it? It's really great and entertaining game, but:

- since level 4 it starts to be way too hard. Often it takes too much luck to not be hit
- hyperspace level 5 contains some very nasty obstacles, can they all be dodged?
- level 6 is simply impossible

The problem is that it takes too long to get to lvl 6, and then I just die too fast. It would need something like save/load - or some codes/passwords so you can start in some higher level. Otherwise, really great game and good work
14  Game Development / Game Mechanics / Re: Need help with quarternions -> transformation Matrix on: 2005-10-28 11:23:35
It's unbelievable, the bug is still there, it was reported in 2002!

Got a link by any chance?  This would be a rather large problem.
I also remember that there was an explanation of this bug, but the shortfuze site is still down. But looking at the Fuze3d source code, I think that original version (not working due to bug) was:
bone.getTransformMatrix ().transform (v);

which he worked around to:
CalCoreBone.transform (v, bone.getRotationBoneSpace ());

he introduced new method CalCoreBode::transform
public static void transform (Vector3f v, Quat4f q)
        Quat4f qq = new Quat4f (-q.x, -q.y, -q.z, q.w);
        mul (qq, v);
        qq.mul (q);
        v.x = qq.x;
        v.y = qq.y;
        v.z = qq.z;

I don't understand why it works, but it works
15  Discussions / Miscellaneous Topics / Re: I've been accused of something horrendous on: 2005-10-17 08:51:46
1. Eclipse really IS a Godsend Smiley
2. Your friends should also try some other IDE, and if they find it more comfortable they should stick to it. You have right to have your own opinion and to gospel it Smiley
16  Game Development / Networking & Multiplayer / Re: NIO beginners corner :) on: 2005-09-26 09:55:57
However, what you're doing is wrong, and buggy , unless you can absolutely guarantee that all requests will always fit within your buffer.
yes, that was the case. The messages had limited size and would always fit within the buffer. Anyway, it's history. Since I switched to NIO I have separated buffer for each connection (there is no other possibility with NIO)

At the hardware level, when something happens tehre's an interrupt. This interrupt allows the CPU to stop what it's doing and handle the interrupt. Ultimately, if the OS is coded well and the libs are coded well, that interrupt can filter up to the thread that's blocked on select without any polling at all.
Ok, if it's possible to register socket "observers" at operating system level and jvm can be notified without polling, then ... it's good.
17  Game Development / Networking & Multiplayer / Re: NIO beginners corner :) on: 2005-09-24 21:26:33
btw do you find it useful/reasonable that NIO writes non-fatal messages to stderr? (It writes a message each time a connection is broken). I was used to write all my internal error messages to stderr and redirect its output to file. Now it's all polluted with not-very-useful messages from NIO. Is there a way to turn it off?
18  Java Game APIs & Engines / Java 3D / low polygon character animation - how to? on: 2005-08-27 11:40:27

I would like to animate very simple "extremely-low-polygon" character models (they will be rendered using custom software renderer). In other words, I need something very similar to what Runescape 2 has ( please don't stop reading:) )

I don't want to re-invent the wheel so I think that the best way to achieve it is to model and animate the characters in some existing modeler, store the animation in some popular format, and then convert it to my internal format.

The question is, which modeler (and file format) would you use? I'm not very familiar with character modeling software (and file formats which support bone animation), but my current ideas are:

- to use quake 3 file format. I believe that there exist many editors which can edit these models (if you know some good and suitable for my purpose please mention it)
- I saw software named Poser, it seems to be able to edit & animate characters and export them to various format
- probably almost every major commercial 3d software has some support for character modeling (though I'm not sure whether it is suitable for my purposes)

any other suggestion regarding file format & editor (which supports bone character animation) ?

thank you
19  Game Development / Artificial Intelligence / Re: Guide for DAN on: 2005-08-15 15:08:31
Please tells your spammer friends to get off this forum and do something more productive with their life.

actually, I've got feeling that this forum *needs* to be spammed more and harder. Only then will moderators take some real action about it (they could at least start deleting spam)
20  Game Development / Networking & Multiplayer / Re: Best approach for networking a board game? on: 2005-08-08 19:24:40
I have already created exactly same games as you are planning to do (see the site in my signature)

- it has client / server architecture, it communicates through TCP
- the server is java application. But Jeff's suggestion is good. If I had to start again from scratch I would consider servlets
- at the beginning I used old java IO for both server and client, but I encountered very annoying problems, so I re-worked the server to use NIO. It works great now. The clients (applets)  still use old java IO, for clients it's ok
21  Game Development / Networking & Multiplayer / Re: NIO: using same ByteBuffer concurrently? on: 2005-08-02 07:46:04
Jumping back to the original topic.

Be VERY careful if yo uarent going to use duplicate.
Your topic says "concurrently".  Actually trying to use the same Buffer object concurrently from two different threads is likely to cause nasty race conditions.

I'm not using threads. Each connection keeps a list of messages queued for sending (same message may exist in several queues). The connections are *sequentialy* asked (from same thread) to flush their queues. Each connection also maintains current "write position" for the buffer which is currently being sent. This position is restored before channel::write is called, and stored after it. It is possible that it takes several iterations until whole message is sent, and different connections may have different current write-position for same buffer.

So far it seems to work . Do you think there is some conceptual problem?

<edit> I guess that exactly same thing happens when duplicate()  is called. Two objects reffer to same byte array. I just maintain write positions myself  - and this way I don't have to allocate new objects. I'm not really sure if it was worth it, but I was always a bit touchy and paranoid when it comes to unnecessary object allocation Smiley
22  Game Development / Networking & Multiplayer / Re: NIO: using same ByteBuffer concurrently? on: 2005-07-31 10:14:29
In the end I decided to not use duplicate(), but the approach I mentioned in my first post  - exactly same buffer may be shared by many connections, but each connection remembers current write-position. It seems to work well.

The reason is that I maintain a pool of  re-usable ByteBuffers (not really plain ByteBuffers, they are wrapped in "Message" class with additional functionality) and I wanted to have unified way to get/release a Message. When a message is queued into some connection its internal reference-counter is incremented. When a connection succesfuly sents a message the counter is decremented. When it reaches zero the message is automaticaly "recycled" (returned back to pool)

That's also because don't like to create new instance of any class, when it's not really necessary.
23  Game Development / Performance Tuning / Re: Casting Objects on: 2005-07-26 12:44:47
The point being that should only use type casts where you *have* to? Not that surpising.

Well, you *never* have to. You can always make some crazy not-very-OO construction (or at least replace collections with arrays). The point was to find out whether it's worth it.
24  Game Development / Performance Tuning / Re: Casting Objects on: 2005-07-26 10:08:04
I also wondered how expensive typecast is. Following code displays:
~ 200 ms WITHOUT typecast
~ 1000 ms WITH typecast

My interpretation is:   typecast takes four times longer to execute, THAN method invocation + integer divide  (at least in this case). I'm not sure if it's correct interpretation though

public class Test {

   private static final int COUNT         = 50000000;
   private static Test object1 = new Test();
   private static Object object2 = new Test();
   public static void main(String[] args) {
      long startTime = System.currentTimeMillis();
      long diff = System.currentTimeMillis() - startTime;
      System.out.println("Without typecast: " + diff);

      startTime = System.currentTimeMillis();
      diff = System.currentTimeMillis() - startTime;
      System.out.println("With typecast: " + diff);

   private static void test()
      for (int i=0; i<COUNT; i++)

   private static void test2()
      for (int i=0; i<COUNT; i++)
         ((Test) object2).testMethod();
         ((Test) object2).testMethod();
         ((Test) object2).testMethod();
         ((Test) object2).testMethod();
         ((Test) object2).testMethod();

   public void testMethod()
      int i = 10 / 3;
25  Games Center / Archived Projects / Re: Isometric Engine (RCT style) on: 2005-07-26 09:20:23
same exception here, I hope it's not 1.5 only
26  Game Development / Networking & Multiplayer / AIO4J = better NIO? on: 2005-07-24 21:18:05
there is one thing which I did not like about NIO since very beginning. Its interface is too cumbersome when you want to use it for game programming. I guess that most people need fire&forget. You want to create a message and call one method, which will post it. You don't want to bother with waiting till the socket is ready for writing, and then bother with checking whether it was really sent or not.

Searching on internet I found that there is "competitive" implementation - AIO4J from IBM. I haven't seen their interface yet, but they say it uses different paradigm to achieve same thing. Anybody tried it by any chance? Smiley

Interesting link:
Interesting quote:
As others have pointed out, this is not a replacement for NIO. It actually seems to be an implementation of (at least portions of) JSR 203. In pattern speak, NIO enables the Reactor pattern, while asynchronous IO enables the Proactor pattern. See POSA2. JSR 203 was originally supposed to be part of JDK 1.5, but did not make it. It will be part of a future implementation.
As Bruce points out above, AIO is a different paradigm to NIO (which is multiplexed non-blocking serial IO). The platform support for AIO in many operating systems enables scalability beyond that afforded by NIO for handling thousands of simultaneous connections with low thread count.

AIO is not intended to usurp NIO. AIO4J is regular Java and JNI code that will run on any compliant 1.4 JVM.
27  Game Development / Networking & Multiplayer / Re: NIO: using same ByteBuffer concurrently? on: 2005-07-24 20:57:39
that's exactly what I needed, that you Smiley
28  Game Development / Networking & Multiplayer / NIO: using same ByteBuffer concurrently? on: 2005-07-24 18:39:55
one more principal question:

I need quite often to broadcast *exactly* same message to many connected clients. So "intuitive" solution is to create ByteBuffer, populate it with data - and write it to several SocketChannel-s. Of course it will *not* work, because each SocketChannel::write will change buffer's read-position to unpredictable value. (Also it may happen that SocketChannel::write has to be called several times, before buffer's whole content is sent)

Second solution is: simply create as many buffers as necessary, and fill them all with same data. No problem, but it is sure very ineffective.

Would it be possible to have just one ByteBuffer shared by many Channels, and remember/restore current write position according to current SocketChannel? Isn't it too crazy idea? Roughly something like:

class Connection {
     private SocketChannel channel;
     private ByteBuffer buffer;          // shared by more Connection-s
     private pos;

     public send() {
           pos = buffer.position();

Or have do you broadcast same messages?
29  Game Development / Networking & Multiplayer / Re: bug in writing to socket???! on: 2005-07-24 18:15:08
Maybe the holding time it the same as the system dependant TCP timeout?

I programmed some code which measures the length of this "delay". For some reason it is always *exactly* 1080 seconds (18 minutes). So I guess you are right, it probably has to do something with system TCP timeout. I'm not sure whether it is bug or feature, but it is very annoying in any case Sad
Maybe I could create some "guard" thread which will notice when the main thread freezes, and closes the socket which caused it. Not sure if it's going to help (if it stops blocking immediately)
I have really no idea what's the reason of it all, it happens so infrequently Sad

Sadly, it is the only single issue I have with old java IO. If I don't fix it somehow I'll have to rewrite the whole server from scratch (using NIO), currently  it is too tightly coupled with old IO Sad
30  Game Development / Shared Code / Re: Scale2X Java Source on: 2005-07-24 08:22:43
very impressive Smiley I see it's also used in WinUAE, I'm going to try it Smiley Had no time to play with emulators recently Sad
Pages: [1] 2
DarkCart (16 views)
2016-05-29 02:30:33

Hydroque (34 views)
2016-05-26 14:45:46

Mac70 (45 views)
2016-05-24 21:16:33

theagentd (49 views)
2016-05-14 18:38:35

theagentd (84 views)
2016-05-10 22:37:41

theagentd (89 views)
2016-05-10 22:33:46

IanParcs (117 views)
2016-04-18 14:18:53

KaiHH (114 views)
2016-04-18 08:35:41

KaiHH (135 views)
2016-04-15 12:43:58

theagentd (141 views)
2016-04-14 02:16:17
FPS Camera Tutorial
by Hydroque
2016-05-22 05:40:58

Website offering 3D Models specifically for games for free
by vusman
2016-05-18 17:23:09

Website offering 3D Models specifically for games for free
by vusman
2016-05-09 08:50:56

Website offering 3D Models specifically for games for free
by vusman
2016-05-06 11:10:21

Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50 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!