Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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 / Shared Code / Re: [RFC] GarbageBin on: 2003-03-10 10:25:20
Does that mean, that the less memory available the more the GC runs.  For example, if 32k is being occupied with objects, the GC runs half as many times as it would if 64K were being taken up?  Does this mean it is best to handle garbage as a normal application, but force GC to run when convient as well?

Stu
2  Game Development / Shared Code / [RFC] GarbageBin on: 2003-03-10 09:44:18
In an attempt to better control the collection of garbage, I decided it is (I think) advantageous to not nullify objects.  Instead, it makes sense to pass them to an 'storage' class that can be easily emptied and the System.gc() called.  This should limit (I think) the volume of work the garbage collector has to do, and allows you to collect garbage when it suits you, (i.e. between levels or whatever).  I don't know if the code is anygood, just wondering if anyone could comment on its usefulness.  Ohh, and if it is useful, feel free to use it Smiley

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  
/*
GarbageBin is designed for situations where generating garbage
will affect the performance of the program.  It prevents garbage
collection by maintaining references to Object's until the
programmer emptys the bin by nullifying all references and calling
the garbage collector using System.gc()

Usage Example:

      GarbageBin bin = new GarbageBin(20);
      String forBinning = "This string should be binned";
      forBinning = bin.add(forBinning);
      ...
      bin.empty();
*/


public class GarbageBin {
     
      // The bin is simply an array of object refrences
      private Object[] theBin;
     
      // We need to know how many items of garbage are in the bin
      private int garbageItems;
     
      // Create a new bin to throw garbage in
      public GarbageBin() { this(15);}
      public GarbageBin(int size) {
            theBin = new Object[size];
            garbageItems = 0;
      }
     
      // Adds garbage to the bin.  If the bin is full, what should I do???
      public Object add(Object garbage) {
            if (garbageItems < theBin.length)
                  theBin[garbageItems] = garbage;
            else
                  return garbage; // ATM just return the object to itself?
            return null;
      }
     
      // Empty the bin
      public void empty() {
            for (int i = 0; i < garbageItems; i++)
                  theBin[i] = null;
            System.gc();
      }
}
3  Java Game APIs & Engines / Java 2D / Re: Framerate-independent movement on: 2003-02-11 18:33:05
Well, I am using this in a game I am writing, and it is not far off from being accurate enough, check the shared code section for information on more accurate timers!

Stu
4  Java Game APIs & Engines / Java 2D / Re: Framerate-independent movement on: 2003-02-11 17:56:13
The way to do it goes something like this (pseudo-code)

1.  When game is loaded grab and store the time, and render the screen.
2. At the start of the next frame grab the time again and work out the time since the last grab of the time. Store the new time.
3.  Distance moved = the speed (a constant of your choice for a nice speed) * the time.

For example, you load the game and call System.currentTimeMillis().  You store this in a long variable called lastTime.  You render the scene.  Get the time again and calculate the difference since the first time, multiplying this time by the speed, say for example the speed is 10 and 0.1secs have passed, you move the paddle 10*0.1 = 1 pixel.  You then store the new time into the lastTime variable and repeat?

Hope that is a start, try coding it now Smiley

Stu
5  Java Game APIs & Engines / Java 2D / Re: *.jpg/gif file as a background for VolatileIma on: 2003-02-11 17:17:31
You should be able to use drawImage on the Graphics object returned from the VolatileImage.  You can either draw on the image, or you could create a method to tile it over the entire image

I think Smiley

Stu
6  Java Game APIs & Engines / Java 2D / Re: Terrain on: 2003-02-11 10:15:49
Sorry I can't help, but good luck with it Smiley

Maybe you could post some screenshots when you are further into it Smiley

Stu
7  Java Game APIs & Engines / OpenGL Development / First Post :) on: 2003-02-10 14:11:37
yay  Grin
8  Java Game APIs & Engines / Java 2D / Re: Terrain on: 2003-02-10 13:06:47
Do you mean like C&C Tiberian Sun, where they had faked 3D terrain by having shaded tiles that looked kind of sloped, and by moving the unit 'up' the slope in addition to they way they were moving already (if you catch my drift).  If so then I have no idea how to do it, maybe someone else will Smiley

Stu
9  Discussions / Business and Project Management Discussions / Re: Internal document from Sun on: 2003-02-10 13:03:01
I think it is because it is such a convienient language.  It is very readable, and it kinda feels nice.  Can't quite explain it!  Also I think everyone on this board wants to prove the point that it can be done, and everyone is very persistent.  I suspect Sun is going to pull the finger out soon (hopefully), because at the moment I can see C# becoming more successful than Java, unless Sun do something!  Lets hope they make the right decision Smiley

Stu
10  Discussions / Business and Project Management Discussions / Re: Internal document from Sun on: 2003-02-10 12:49:43
Hmm, me thinks that is already too late!!!  Its on /.    Smiley

Stu
11  Java Game APIs & Engines / Java 2D / Re: Drawing to off-screen buffer on: 2003-02-09 00:37:39
The reason (I think) you are getting a white rectangle is because you are calling getGraphics() twice.  The first one returns a Graphics object and you set its draw color to red.  Then you get another  Graphics object, whose default colour is white which you actually draw to screen.  To fix this try:

1  
2  
3  
Graphics g = myImage.getGraphics();
g.setColor(Color.RED);
g.fillRect(0, 0, 16, 16);


I hope that is correct and makes sense to you Smiley

Stu
12  Discussions / General Discussions / Re: Demos & Tutorials on: 2003-02-05 23:03:10
I believe that is currently being planned, and hopefully implemented soon.  Hopefully soon JavaGaming.org will become even better  Cheesy

Stu
13  Games Center / Archived Projects / Re: My First Game (Uncompleted) on: 2003-02-04 16:12:28
Stupid thing won't let me upload my jnlp file, says it is an invalid file.  Anyone got any ideas?

Stuart
14  Games Center / Archived Projects / Re: My First Game (Uncompleted) on: 2003-02-04 16:00:28
Geocities it is then (and I swore YEARS ago I would never use geocities  Sad )

Thanks,

Stu
15  Games Center / Archived Projects / Re: My First Game (Uncompleted) on: 2003-02-04 14:40:06
I don't think btinternet.com supports the mime type for jnlp, so I cannot get web start working, can anyone suggest some where I can get free web space that supports this?

Thanks in advance

Stuart
16  Games Center / Archived Projects / Re: My First Game (Uncompleted) on: 2003-02-04 13:01:32
NOT WORKING YET

I have added Web Start support Smiley

http://www.btinternet.com/~stustill/GravityWars.jnlp

That should work I haven't tested yet

Stuart
17  Games Center / Archived Projects / Re: My First Game (Uncompleted) on: 2003-02-03 16:28:13
Thanks!

I have been trying to implement collision detection but haven't gotten very far with it at all.  I am worried that when implementing collision detection, because the ship is drawn on the fly, whether or not creating a bitmask is going to slow the game down.  I suppose it only really needs to generate a bitmask when it is close to the walls, so it might not be a big concern.

When I get the basic game going, I am going to start producing levels and programming different modes for the game.  One thing that I am unsure on is whether or not the way I am implement the levels is a good idea (ie each level is a class that implements GravityWarsLevel) or whether I should have large gifs /pngs for the levels?

Regards

Stuart
18  Java Game APIs & Engines / Java 2D / Re: Help Me: I don't know whats wrong with my code on: 2003-02-02 23:06:55
You set it in A correct place (you can call it anytime)!  I am just surprised that it hasn't disabled repaint(), maybe it allows the user to call repaint() manually

Stuart
19  Java Game APIs & Engines / Java 2D / Re: Help Me: I don't know whats wrong with my code on: 2003-02-02 21:40:12
repaint() shouldn't work because you are ignoring repaint calls (setIgnoreRepaint(true))!  Correct me if I am wrong Smiley

Stuart
20  Games Center / Archived Projects / My First Game (Uncompleted) on: 2003-02-02 21:22:41
Hi

This is the start of my very first game, it is not by any means complete, but I am stumped as to what I should do next, and how nicely it is coded so far.  Any suggests, comments or criticisms would be greatly appreciated.  It is available for download from http://www.btinternet.com/~stustill/GravityWars.zip.  The source code is provided (but not commented), and the main class is GravityWars.class.  I hope no one thinks it is too bad and can come up with some suggestions for how I continue.

The buttons are the arrow keys, left and right for rotation and up for thrust.  Exit quits the current game, and it doesn't detect collisions or anything, the second ship is not controllable (yet).

Please note: Only select death match, nothing else works at the moment.

I hope you enjoy what I have so far Smiley

Stuart
21  Java Game APIs & Engines / Java 2D / Re: Help Me: I don't know whats wrong with my code on: 2003-02-02 21:12:08
You aren't trying to draw to the JPanel, you are drawing the image to the buffer and not doing anything to the displayed JPanel.  To fix, try doing this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public void run()
 {
  offscreen= createImage(400,400);
    Graphics buff = offscreen.getGraphics();
    buff.setColor(Color.black);
    buff.fillRect(0,0,400,400);

  try
  {
   while (running)
   {
    buff.drawImage(images[currentImage].getImage(), X, Y, this);
    images[currentImage].paintIcon(this, buff, X, Y);
    buff.drawString("TEST", 30, 30);
    currentImage = (++currentImage) % TOTAL_IMAGES;
    paint(this.getGraphics());
    Thread.sleep(30);
   }
  }
  catch (Exception e) {}
 }


This works because it gets the Graphics object for the JPanel, and therefore renders it to something the user can see, rather than the buffer.  I think that should work, sorry if it does't Smiley

Stuart
22  Java Game APIs & Engines / Java 2D / Re: Transparency on: 2003-01-23 07:55:09
It is okay, I have figured it out, I just used the SrcOut AlphaComposite rule and it worked!  Anyone know where I can find detailed information about all of the JDK classes involving image operations, ie rasters, transparency, affine transforms, because I don't really know what I am doing as far as that goes Sad

Stu
23  Java Game APIs & Engines / Java 2D / Transparency on: 2003-01-23 07:06:09
Help!

I am currently writing my first game, and it is coming along (kinda) nicely.  I have some of the important physics in place, but I haven't dealt with collisions or nice level creation.

Anyway, it is a gravity game, where you place a ship with a big thruster on the back, and you have to fly around doing things.  Things include deathmatch (hopefully), racing and CTF with other human opponents.  That is going to come later, I need to get the basics working first.  Anyway, my ship is just a filled GeneralPath onto a BufferedImage.  The buffered image supports Transparency.BITMASK, but when this is turned on, anti-aliasing won't work, and the ship just looks like a jagged mess!

Does anyone know how I can get the transparency to work, but still allow me to anti-alias the image?

Thanks in advance,

Stu
24  Java Game APIs & Engines / Java 2D / Re: converting applet to application on: 2003-01-22 12:57:57
Just add a main method, i.e.:

1  
2  
3  
4  
5  
6  
7  
8  
9  
public static void main(String[] args) {
   JFrame applicationWindow = new JFrame("Applet");
   AppletClass myApplet = new AppletClass();
   myApplet.init();
   myApplet.start();
   applicationWindow.getContentPane().add(myApplet);
   applicationWindow.setSize(300, 300);
   applicationWindow.setVisible(true);
}


I believe that should work Smiley

Stu
25  Discussions / General Discussions / Time Zones on: 2003-01-18 10:24:26
I don't know if this is possible, but all of the times displayed in the forums, i.e current times and times of posting, could they perhaps be localized to the time zone of the users computer.

I am Scottish, so I am 5 hours ahead of what I presume is the mass of users on the forum, and I find it really confusing as to what was posted when  Smiley

Maybe I am just stupid but it would be great if that could be fixed up

Stu
26  Game Development / Networking & Multiplayer / Re: some xp users to test my web start deployment on: 2003-01-18 09:54:24
dito, looks very funky, just annoyed I didn't get to try the game  Wink
27  Java Game APIs & Engines / Java 2D / Re: Some Java2D/FullScreen questions on: 2003-01-13 09:08:58
Here goes:

Using Java2D with an ATI card under 1.4.0 there were major problems, and I believe for version 1.4.1_01 they disabled some of the performance settings to make it slower but function across the board.

On linux I believe it is probably slower, it can't make as good use of hardware acceleration (yet).

LWJGL cannot be ditributed using Web Start.  It runs using the Java Native Interface (JNI) to speak to C/C++ code.  That means it is unsigned and unless you can get Sun to sign it for you, Web Start won't be an option.  As far as multiple platforms go, LWJGL is available for linux (and maybe solaris) but it is a separate download because they all use JNI and therefore require OS specific code.

Don't take my word as gospel, but that information is hopefuly accurate Smiley

Stu
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.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (21 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57: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

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!