Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
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  Java Game APIs & Engines / JOGL Development / Re: Skinnable GUI framework? on: 2003-12-02 16:45:01
Sounds great, I'd be very interested in you GUI framework.

from,
Stefan
2  Java Game APIs & Engines / JOGL Development / Skinnable GUI framework? on: 2003-12-01 15:20:00
Is there any free (liscence could be GPL, BSD, etc.), clean, and object-oriented GUI framework which can run in JOGLE and is skinnable?

Since Swing doesn't work on hardware yet, I can't use that.  Also, I'd like to be able to define my own skins for the GUI.

Thanks,
Stefan
3  Java Game APIs & Engines / JOGL Development / Re: Offscreen rendering: doing a little better on: 2003-11-29 08:18:42
The way to get arbitrarily sized textures on top of a pow-2 graphics card is to make a big pow-2 texture and to pack several (to save space) non pow-2 textures into it.

Search the web for "light map packing".  This link may be of some help: http://www.blackpawn.com/texts/lightmaps/default.html.  I have implemented a similar scheme (in C++ DirectX, sorry).

Since you are dealing with a tree data structure, it can clutter code a bit.  It is best to encapsulate this texture packing scheme so that you don't have to worry about it after implementing it once.

from,
Stefan
4  Games Center / Archived Projects / Re: Alpha test Boom (Breakout Clone) on: 2003-03-26 03:55:12
Thanks, those will be the next things on my agenda:
+ Fixing the timing and framerate.
+ Writing the paddle and ball physics.

from, Stefan
5  Games Center / Archived Projects / Alpha test Boom (Breakout Clone) on: 2003-03-23 14:49:49
Now that I've finally got my JAR working, I have released the first beta/tech demo of my Breakout clone, called Boom.  I know, it's not incredibly original, but it is my first real Java applet game.  The levels are not very playable at the moment (I'm not a very good artist or level designer Wink), but you can try the different powerups, check out the different types of bricks, and get a general feel for how things are working.  By the way, it runs on Java 1.2.

So please try it out at: http://folk.uio.no/stefanha/Boom/Play.html.

I would be interested in the performance and, of course, any obvious problems.

Known issues:
+ On slow machines, collision detection may sometimes mess up.  I think I can fix it by sub-dividing the frame time and running more update cycles on it.

Thanks and have fun,
Stefan
6  Java Game APIs & Engines / Tools Discussion / Re: Stupid JAR Question on: 2003-03-20 13:09:26
Somebody please answer: it's so frustrating to have a game ready, but not be able to release it on the internet!

Anyway, if anyone can just describe in general how you can JAR an applet whose class is in a package, and run it from a browser, please answer...

from, Stefan
7  Java Game APIs & Engines / Tools Discussion / Re: Stupid JAR Question on: 2003-03-18 07:23:18
Okay, what I've done now, after checking out the -C option, is to just copy all my class files to the same location, and to JAR that.  It works, BUT I'm having trouble accessing the applet.

My HTML file looks like this:
1  
2  
3  
4  
5  
<html>
<body>
<applet archive="Boom.jar" code="Boom.class" width=320 height=200></applet>
</body>
</html>


I get an error - the VM can't load/find the class.  So I guess that means I need to use its full packaged name, com.stefanha.boom.Boom, but that doesn't work either.

What is the correct way to run an applet from a JAR file when it is in a package?

from, Stefan
8  Java Game APIs & Engines / Tools Discussion / Stupid JAR Question on: 2003-03-15 14:40:36
I can't get JAR files to work with my (applet) game.  I have compiled my game.  The class belong to two packages: com.stefanha.games.boom and com.stefanha.games.util.  Now I want to make one JAR file containing all of the classes (from both packages) plus a directory with graphics (GIF images).

I have managed to make a JAR file, but the paths were absolute paths (as in "C:\My Documents\Boom\").  Can someone explain the process of creating one JAR file containing all my classes and images, and then making an HTML file that starts the applet from the JAR file?

Thanks, Stefan
9  Java Game APIs & Engines / Java 2D / Re: copyArea == drawImage? on: 2002-12-28 05:07:16
Okay, cool thanks.
10  Game Development / Shared Code / Re: Pixel perfect collision detection on: 2002-12-25 15:28:57
I posted my pixel-perfect collision detection routines.  The differences to zparticle's are mainly that I use Java 1.2 and that I keep the mask in a one-dimensional array.

I tried to optimize my code so that only simple operations (+, -, <<, >>>) would be performed in the loops.  I don't need any multiplications to index ints in the collision masks because I keep an offset, which gets incremented appropriately as the loop executes.

I know it's kind of messy, but it is fairly low-level bitmanipulation code.  Also, my optimization strategy was basically just intuition.  I didn't think too much about it, especially in the context of Java.  So if you see some obvious problem/optimization/simplification please tell me.

I tested this code for quite a bit today, so I am fairly confident that there are no bugs.  Again, feel free to prove me wrong.

from, Stefan
11  Game Development / Shared Code / Re: Pixel perfect collision detection on: 2002-12-25 15:21:04
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  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
class CollisionMask
{
      int width, height, maskWidth;
      int mask[];

      public CollisionMask ( Image image, int width, int height )
      {
            this ( image, 0, 0, width, height );
      }
     
      public CollisionMask ( Image image, int x, int y, int width, int height )
      {
            this.width = width;
            this.height = height;
            maskWidth = ( width >> 5 ) + ( ( width % 32 == 0 ) ? 0 : 1 );
           
            mask = new int[ maskWidth * height ];
           
            int pixels[] = new int[ width * height ];
            PixelGrabber pixelGrabber = new PixelGrabber ( image, x, y, width, height, pixels, 0, width );

            try
            {
                  pixelGrabber.grabPixels ( );
            }
            catch ( InterruptedException e )
            {
                  throw new RuntimeException ( "Error grabbing pixels!" );
            }
           
            if ( ( pixelGrabber.getStatus ( ) & ImageObserver.ABORT ) != 0 )
            {
                  throw new RuntimeException ( "Error grabbing pixels!" );
            }
           
            for ( int i = 0; i < height; i++ )
            {
                  for ( int j = 0; j < width; j++ )
                  {
                        if ( ( pixels[ j + ( i * width ) ] & 0xFF000000 ) != 0 )
                        {
                              mask[ ( j >> 5 ) + ( i * maskWidth ) ] |= 0x80000000 >>> ( j % 32 );
                        }
                  }
            }
      }
     
      public boolean collidesWith ( CollisionMask b, int x1, int y1, int x2, int y2 )
      {
            // Check if the masks even overlap
            if ( ( x1 >= x2 + b.width ) || ( x1 + width <= x2 ) ||
                   ( y1 >= y2 + b.height ) || ( y1 + height <= y2 ) )
            {
                  return false;
            }
           
            int ax, ay, bx, by;
           
            if ( y1 < y2 )
            {
                  ay = y2 - y1;
                  by = 0;
            }
            else
            {
                  ay = 0;
                  by = y1 - y2;
            }
           
            if ( x1 < x2 )
            {
                  int dx = x2 - x1;
                  int aStart = dx >> 5;
                  int shift = dx % 32;
                  int aOffset = aStart + ( ay * maskWidth );
                  int bOffset = by * b.maskWidth;
                 
                  if ( shift == 0 )      // Masks are aligned, we do not need to shift pixels
                  {                  
                        while ( ( ay < height ) && ( by < b.height ) )
                        {
                              ax = aStart;
                              bx = 0;
                                                           
                              while ( ( ax < maskWidth ) && ( bx < b.maskWidth ) )
                              {
                                    if ( ( mask[ aOffset ] & b.mask[ bOffset ] ) != 0 )
                                    {
                                          return true;
                                    }
                                   
                                    aOffset++;
                                    bOffset++;
                                    ax++;
                                    bx++;
                              }

                              aOffset += maskWidth - ( ax - 1 ) + aStart - 1;
                              bOffset += b.maskWidth - ( bx - 1 ) - 1;
                              ay++;
                              by++;
                        }
                  }
                  else                  // Masks are not aligned, we need to shift pixels
                  {
                        int invShift = 32 - shift;
                 
                        while ( ( ay < height ) && ( by < b.height ) )
                        {
                              ax = aStart;
                              bx = 0;
                             
                              while ( bx < b.maskWidth )
                              {
                                    if ( ax < maskWidth - 1 )
                                    {
                                          if ( ( ( ( mask[ aOffset ] << shift ) |
                                                       ( mask[ aOffset + 1 ] >>> invShift ) ) &
                                                   b.mask[ bOffset ] ) != 0 )
                                          {
                                                return true;
                                          }
                                    }
                                    else
                                    {
                                          if ( ( ( mask[ aOffset ] << shift ) & b.mask[ bOffset ] ) != 0 )
                                          {
                                                return true;
                                          }

                                          aOffset++;
                                          bOffset++;
                                          ax++;
                                          bx++;

                                          break;
                                    }
                                   
                                    aOffset++;
                                    bOffset++;
                                    ax++;
                                    bx++;
                              }
                             
                              aOffset += maskWidth - ( ax - 1 ) + aStart - 1;
                              bOffset += b.maskWidth - ( bx - 1 ) - 1;
                              ay++;
                              by++;
                        }
                  }
            }
            else
            {
                  int dx = x1 - x2;
                  int bStart = dx >> 5;
                  int shift = dx % 32;
                  int aOffset = ay * maskWidth;
                  int bOffset = bStart + ( by * b.maskWidth );
                 
                  if ( shift == 0 )      // Masks are aligned, we do not need to shift pixels
                  {
                        while ( ( ay < height ) && ( by < b.height ) )
                        {
                              ax = 0;
                              bx = bStart;
                             
                              while ( ( ax < maskWidth ) && ( bx < b.maskWidth ) )
                              {
                                    if ( ( mask[ aOffset ] & b.mask[ bOffset ] ) != 0 )
                                    {
                                          return true;
                                    }
                                   
                                    aOffset++;
                                    bOffset++;
                                    ax++;
                                    bx++;
                              }
                             
                              aOffset += maskWidth - ( ax - 1 ) - 1;
                              bOffset += b.maskWidth - ( bx - 1 ) + bStart - 1;
                              ay++;
                              by++;
                        }
                  }
                  else                        // Masks are not aligned, we need to shift pixels
                  {
                        int invShift = 32 - shift;
                 
                        while ( ( ay < height ) && ( by < b.height ) )
                        {
                              ax = 0;
                              bx = bStart;
                             
                              while ( ax < maskWidth )
                              {
                                    if ( bx < b.maskWidth - 1 )
                                    {
                                          if ( ( ( ( b.mask[ bOffset ] << shift ) |
                                                       ( b.mask[ bOffset + 1 ] >>> invShift ) ) &
                                                   mask[ aOffset ] ) != 0 )
                                          {
                                                return true;
                                          }
                                    }
                                    else
                                    {
                                          if ( ( mask[ aOffset ] & ( b.mask[ bOffset ] << shift ) ) != 0 )
                                          {
                                                return true;
                                          }
                                         
                                          aOffset++;
                                          bOffset++;
                                          ax++;
                                          bx++;
                                         
                                          break;
                                    }

                                    aOffset++;
                                    bOffset++;
                                    ax++;
                                    bx++;
                              }

                              aOffset += maskWidth - ( ax - 1 ) - 1;
                              bOffset += b.maskWidth - ( bx - 1 ) + bStart - 1;
                              ay++;
                              by++;
                        }
                  }
            }
           
        return false;
      }
}
12  Game Development / Performance Tuning / Re: Fastest way to draw only a part of an image on: 2002-12-24 04:19:20
Okay, I've done some testing and figured out the fastest way to do it.  Both the scaled drawImage() and g.create() are not the fastest.  The best way to do it is:
1  
2  
3  
4  
5  
6  
7  
paint (Graphics g)
{
Shape oldClip = g.getClip ();
g.setClip (x, y, width, height);
g.drawImage (sx, sy, x - sx, y - sy, null );
g.setClip (oldClip);
}


The cool thing about this approach is that if you have a loop that renders several pieces from different images, you can take the "Shape oldClip = g.getClip()" and "g.setClip (oldClip)" out of the loop and only call them once the loop is done, saving yourself some processor cycles.

from, Stefan
13  Java Game APIs & Engines / Java 2D / copyArea == drawImage? on: 2002-12-22 11:42:37
I'm wondering if Graphics.copyArea() is equivalent, performance-wise, to Graphics.drawImage().  I guess that drawImage() may be slower if the two Images have different pixel formats, because the pixel format will always be the same in copyArea() since it copies from itself.  However, if I create both Images myself, can't I reasonably expect their formats to be the same?  Does anyone know if drawImage() and copyArea() have equal execution times?

Thanks,
Stefan
14  Game Development / Performance Tuning / Fastest way to draw only a part of an image on: 2002-12-21 04:14:52
I'm wondering what the fastest way to draw only a portion of an Image is.  Right now I am using g.drawImage ( Image image, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, ImageObserver observer ).  However, this function can also do scaling, so I'm not sure if it is optimized to deal with the case when no scaling has to be done.

The other way I know is to do g.setClip (...) and then g.drawImage().  But then I have create a compatible Graphics object from g, as to not screw up the original clipping area.  I think that might slow things down...

Which way is faster?

from, Stefan
15  Games Center / Archived Projects / Runescape on: 2002-11-29 15:14:10
I'm sure many of you have seen Runescape (http://www.runescape.com) by now.  All I can say is WOW!  When I started the game, by jaw dropped.  I couldn't believe a 3D/iso Java applet MMORPG running like that.

Now of course I wanted to take a look at how it works, but there's no info on the web.  For those who are going to decompile it, don't bother, it is obfusticated.  It is a large game, so reverse-engineering all that obfusticated code would take a long time.  Additionally, the company that made it, Jagex, lives off this software and their engine technology, so it wouldn't be a nice thing to do.  So if you guys would like to speculate about how the game works, I'd be very interested.

It seems the world is based on a kind of heightmap, in which each square has a height and a color.  Then houses and objects are put on top of that.  Characters are not full 3D, as the graphics switch only when you rotate ~45°, as they did in old raycasting games (Wolfenstein, Doom).  Most objects (fires, mushrooms, etc.) are only flat shaded (ie. no textures).  However, houses are texture mapped.  Some GUI components are alpha blended.

I'd say their doing a lot of rendering every frame, unless they've found a really clever way to optimize things and avoid redrawing the majority of a frame.

from, Stefan
16  Game Development / Networking & Multiplayer / Thanks guys on: 2002-10-24 04:42:14
Okay, thanks.  I just want to try to stay away from a server, because I don't have one Wink.  Well if you use encryption, you will at least make it a lot harder for the client to cheat (and obfusticate your class files, of course).

from,
Stefan
17  Java Game APIs & Engines / Java 2D / Re: 2D Map question on: 2002-10-20 05:33:49
Check out the games Warp and Urbanoids on http://www.javaonthebrain.com.  They describe the way their scrolling algorithms work and have source code.

In general, you need to search for "scrolling maps", "tiles", and maybe "isometric".  I'm sure you'll be able to find some tutorials, even if they are for C or C++...

from, Stefan
18  Game Development / Networking & Multiplayer / Cookies?  Preferences?  Persistance? on: 2002-10-19 11:35:37
In an online game where you don't want to keep every person's save game data (especially if they just show up once and try the game out, never to return again) on the server, what options are there to store data on the client?

Cookies?
Some Preferences API (I think I read about it)?

I don't think cookies are supported, but combined with CGI scripts you can empower your applet to do cookies.  I think it should be possible with JavaScript on the page as well.  The applet would call the JavaScript functions to read and write cookies.  However, I don't think this is supported on many browsers?  Hopefully I am wrong...

Thanks for answering my newbie questions Wink
from, Stefan
19  Game Development / Performance Tuning / Applet main loop on: 2002-10-18 11:08:54
I know this must have been covered in various places in the past.  However, I would be interested in your opinions and alternatives for the "Applet main loop" problem; How to structure the main loop of a real-time applet?

I think we all more or less agree on:
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  
public class RealTimeApplet extends Applet implements Runnable
{
Thread thread; // Runner thread

public void start () {
thread = new Thread ( this );
}

public void stop () {
thread = null;
}

public void run ()
{
while ( thread != null )
{
// run main loop
}
}

public void update ( Graphics g )
{ // override because origional cleared screen
paint ( g );
}
}


Now comes the interesting part.  How do we update logic and then repaint in the main loop.  These are some ideas/approaches I've seen:

1. Just grab the Applet's Graphics context and use it however you like (bypassing the paint() function).  This is not very friendly, and I'm not sure have supported it is by various AWT implementations.
2. In the main loop, wait() after calling repaint().  The paint() function then calls notifyAll() when it is done.  When running on a fast computer, the applet can eat up too many resources (ie. freeze the system by taking almost all time).  This means some performance manager must be implemented to avoid this :(.
3. Just use Thread.sleep (1L) at the end of the main loop.  This is kind of a hack :(.  It avoids eating too many resources though.

I would like to know what other approaches there are, because these all have some drawback(s) which I don't like.

Also, who uses ToolKit.vsync () and where should it be used.  Who uses Thread.yield () and where should it be used.

You see I have many questions ;).  Sorry guys, but I'm looking to sort this out once and for all.

Thanks.
from, Stefan
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.

rwatson462 (33 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (51 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (58 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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