Show Posts
|
|
Pages: [1]
|
|
1
|
Game Development / Shared Code / Re: [RFC] GarbageBin
|
on: 2003-03-10 11: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 10: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  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
|
public class GarbageBin { private Object[] theBin; private int garbageItems; public GarbageBin() { this(15);} public GarbageBin(int size) { theBin = new Object[size]; garbageItems = 0; } public Object add(Object garbage) { if (garbageItems < theBin.length) theBin[garbageItems] = garbage; else return garbage; return null; } public void empty() { for (int i = 0; i < garbageItems; i++) theBin[i] = null; System.gc(); } }
|
|
|
|
|
|
4
|
Java Game APIs & Engines / Java 2D / Re: Framerate-independent movement
|
on: 2003-02-11 18: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  Stu
|
|
|
|
|
8
|
Java Game APIs & Engines / Java 2D / Re: Terrain
|
on: 2003-02-10 14: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  Stu
|
|
|
|
|
9
|
Discussions / Business and Project Discussions / Re: Internal document from Sun
|
on: 2003-02-10 14: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  Stu
|
|
|
|
|
11
|
Java Game APIs & Engines / Java 2D / Re: Drawing to off-screen buffer
|
on: 2003-02-09 01: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  Stu
|
|
|
|
|
17
|
Games Center / Archived Projects / Re: My First Game (Uncompleted)
|
on: 2003-02-03 17: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
|
|
|
|
|
20
|
Games Center / Archived Projects / My First Game (Uncompleted)
|
on: 2003-02-02 22: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  Stuart
|
|
|
|
|
21
|
Java Game APIs & Engines / Java 2D / Re: Help Me: I don't know whats wrong with my code
|
on: 2003-02-02 22: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  Stuart
|
|
|
|
|
22
|
Java Game APIs & Engines / Java 2D / Re: Transparency
|
on: 2003-01-23 08: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  Stu
|
|
|
|
|
23
|
Java Game APIs & Engines / Java 2D / Transparency
|
on: 2003-01-23 08: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 13: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  Stu
|
|
|
|
|
25
|
Discussions / General Discussions / Time Zones
|
on: 2003-01-18 11: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  Maybe I am just stupid but it would be great if that could be fixed up Stu
|
|
|
|
|
27
|
Java Game APIs & Engines / Java 2D / Re: Some Java2D/FullScreen questions
|
on: 2003-01-13 10: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  Stu
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|