moogie
|
 |
«
Posted
2006-01-29 06:51:11 » |
|
 I have not really programmed many games using java, or recently in general, due to work and life commitments but have always wanted to try my hand at a the 4k competition. So using jojoh's template 4k game class as a base i thought i would try to make a game this time. Currently the game is in a "working" pre-pre-pre alpha stage  that is, you are able to move around however there is no collision detection or opponents. There are two versions: a windowed and fullscreen version. Currently the fullscreen version makes the game co -over the 4k limit. However i have not yet optimised the code (as seen on the web site) I am also thinking of changing the storage of the maps to a much smaller footprint and embedding it in with the class. So feel free to test it out. and report and "interesting" features ;P Mac or linux uses are espeically wanted as I do not have access to such systems. The inital concept version can be found at http://www.geocities.com/budgetanime/rally4k.html
|
Java4k RIP 2014
|
|
|
moogie
|
 |
«
Reply #1 - Posted
2006-01-29 06:55:08 » |
|
Mac OS 10.4.4 Java 5 (1.5.0_06) 40 fps in windowed mode.
The car had a yellow fringe around it that I wasn't sure about. Maybe it is a bug I should report to Apple (they've had issues with some image formats and alpha blending before), or if that's just the way it is for everyone. Yep, that is a bug, the yellow areas are set transparent in the game using the following code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| img1=ImageIO.read(loader.getResource("a")); int transparentColour=img1.getRGB(0,0); for (i=300;i<660;i++) { images[i]=new BufferedImage(65, 65, 2); g=(Graphics2D) images[i].getGraphics();
g.rotate (degToRad*(i-300),33,33); g.drawImage(img1,10,20,null); g.dispose(); for (j=0;j<65;j++) { for (int k=0;k<65;k++) { if (images[i].getRGB(j,k)==transparentColour) images[i].setRGB(j,k,0); } } }
|
|
Java4k RIP 2014
|
|
|
moogie
|
 |
«
Reply #2 - Posted
2006-01-29 07:20:48 » |
|
Oop, i forgot to mention the controls: The keys are currently: arrow left, rotate left arrow right, rotate right arrow up, accelerate arrow down, decerate space bar, change to red/blue car and drastically slow down. My goal for this 4k entry is to simulate (or at least approximate) physical forces on the cars so that you can drift around corners and even do burnouts  With such a system in place the different road types have different frictional force, i.e. the tarmac has more than the gravel which has more than the dirt/mud. This allows for different driving characteristic depending on the road surface. I also hope to add opponents with some simple AI, though i think i might have to let them cheat to actually be challenging.
|
Java4k RIP 2014
|
|
|
Games published by our own members! Check 'em out!
|
|
moogie
|
 |
«
Reply #3 - Posted
2006-01-29 08:26:20 » |
|
The car had a yellow fringe around it that I wasn't sure about. Maybe it is a bug I should report to Apple (they've had issues with some image formats and alpha blending before), or if that's just the way it is for everyone. I had to peform this step (and waste precious bytes) as a work around due to a bug in the jvm... when the image was a transparent gif, the ImageIO loader created unwanted grey bar near the top of the sprite. This gray bar was not present when image was a normal gif. Maybe the java gif loader cannot handle 4bit gifs with transparency?
|
Java4k RIP 2014
|
|
|
Alan_W
|
 |
«
Reply #4 - Posted
2006-01-29 09:24:58 » |
|
Works on OS X 10.4  The graphics detail is excellent for 4k, especially the car. Alan
|
Time flies like a bird. Fruit flies like a banana.
|
|
|
moogie
|
 |
«
Reply #5 - Posted
2006-01-29 10:15:52 » |
|
Works on OS X 10.4  The graphics detail is excellent for 4k, especially the car. Alan Glad to hear it is working for you on the mac... Do you have the same problems as swpalmer with the transparency issues? i.e. yellow around the car? The car takes 426 bytes after I reduced the bit depth to 4 I am using a freely availble user greated car sprite initally designed for GTA2. The rest of the graphics are created on the fly. I may change the random speckle of the grass to a procedual pattern to make it look better. Does any one know of an GIF optimiser? like PNG crush or similar?
|
Java4k RIP 2014
|
|
|
Alan_W
|
 |
«
Reply #6 - Posted
2006-01-29 10:27:44 » |
|
There is a slight yellow halo around the car, but it's very subtle and doesn't detract from the game really 
|
Time flies like a bird. Fruit flies like a banana.
|
|
|
moogie
|
 |
«
Reply #7 - Posted
2006-01-29 11:00:52 » |
|
can you post a screen capture? there should not be any halo at all  or if you are really keen  try the version (just uploaded) which used only the transparency in the gif... maybe the JVM error i get on windows is not present on the mac.... /me crossed his fingers.
|
Java4k RIP 2014
|
|
|
Alan_W
|
 |
«
Reply #8 - Posted
2006-02-01 08:01:48 » |
|
The transparency version works ok on OS X 10.4 but I still get the yellow halo. It is 0-1 bits wide and varies with car rotation. If it's a Mac only problem it might a result of antialiasing, since the Mac has that switched on by default, while the PC tends to go for nearest neighbour by default. However, as I said before, the effect is very minor.
Alan
|
Time flies like a bird. Fruit flies like a banana.
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #9 - Posted
2006-02-01 10:47:41 » |
|
4 fps here
and it doesn't run in full screen (I only get a grey screen)
oh and I'm running Linux
|
|
|
|
Games published by our own members! Check 'em out!
|
|
moogie
|
 |
«
Reply #10 - Posted
2006-02-01 12:39:48 » |
|
4 fps here
and it doesn't run in full screen (I only get a grey screen)
oh and I'm running Linux
hmm... that is not good at all. It makes me wonder if the bufferedimages are being accelerated at all. I am afraid i have no experience in addressing linux based java issues... maybe someone who is more knowledgable in this area may suggest a solution? or a hint in where to start looking ? 
|
Java4k RIP 2014
|
|
|
moogie
|
 |
«
Reply #11 - Posted
2006-02-01 12:53:44 » |
|
I have uploaded a new version which uses embedded graphics instead of an external gif. Is the yellow halo still present on the Macs and is the game more playable under Linux?
The start-up time has unfortunetly been increased, but i have now four colours for the car (red,yellow, black and blue) These extra colours will be for the opponents.
|
Java4k RIP 2014
|
|
|
x30ice
Senior Newbie 
|
 |
«
Reply #12 - Posted
2006-02-01 13:21:58 » |
|
Runs at 90 aprox. fps on my computer without any halos at all.
I think the car gets too much speed so a limit earlier than it have now would be better and maybe it would be needed some kind of limits outside the circuit with straw, tires or anything. And to pass to the 'R' gear I think it would be better the car was stopped, so if you brake it makes reduce speed to 0 then have to release key and press it again to get it. If possible, make the grass reduce the car speed too.
|
|
|
|
moogie
|
 |
«
Reply #13 - Posted
2006-02-01 23:00:58 » |
|
Runs at 90 aprox. fps on my computer without any halos at all.
I think the car gets too much speed so a limit earlier than it have now would be better and maybe it would be needed some kind of limits outside the circuit with straw, tires or anything. And to pass to the 'R' gear I think it would be better the car was stopped, so if you brake it makes reduce speed to 0 then have to release key and press it again to get it. If possible, make the grass reduce the car speed too.
Thanks for testing, what computer and os do you have? This version is just a concept tech test atm, the current control system will not be used in the actual game.
|
Java4k RIP 2014
|
|
|
x30ice
Senior Newbie 
|
 |
«
Reply #14 - Posted
2006-02-01 23:07:33 » |
|
Runs at 90 aprox. fps on my computer without any halos at all.
I think the car gets too much speed so a limit earlier than it have now would be better and maybe it would be needed some kind of limits outside the circuit with straw, tires or anything. And to pass to the 'R' gear I think it would be better the car was stopped, so if you brake it makes reduce speed to 0 then have to release key and press it again to get it. If possible, make the grass reduce the car speed too.
Thanks for testing, what computer and os do you have? This version is just a concept tech test atm, the current control system will not be used in the actual game. XP @3200 with win xp pro sp 2, 1 gig ram and radeon 9200 128 meg and jre 1.5
|
|
|
|
swpalmer
|
 |
«
Reply #15 - Posted
2006-02-03 14:15:35 » |
|
I have uploaded a new version which uses embedded graphics instead of an external gif. Is the yellow halo still present on the Macs and is the game more playable under Linux? Halo on Mac is now cyan instead of yellow  ... this very well could be a bug in the handling of the image format used. In fact testing shows that it IS an Apple thing... that I can't discuss because I'm running a developer preview.. I will report a bug to Apple, can I send them the jar for testing?
|
|
|
|
swpalmer
|
 |
«
Reply #16 - Posted
2006-02-03 14:26:20 » |
|
Yep, that is a bug, the yellow areas are set transparent in the game using the following code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Â Â Â Â Â Â Â Â Â img1=ImageIO.read(loader.getResource("a")); Â Â Â Â int transparentColour=img1.getRGB(0,0); Â Â Â Â Â Â Â Â Â Â Â Â for (i=300;i<660;i++) Â Â Â Â { Â Â Â Â Â Â images[i]=new BufferedImage(65, 65, 2); Â Â Â Â Â Â g=(Graphics2D) images[i].getGraphics();
      g.rotate (degToRad*(i-300),33,33);       g.drawImage(img1,10,20,null);       g.dispose();             for (j=0;j<65;j++)       {         for (int k=0;k<65;k++)         {           if (images[i].getRGB(j,k)==transparentColour) images[i].setRGB(j,k,0);         }       }     }
|
Wait a sec! Why are you trying to set the transparent colour AFTER rotating the image? Shouldn't you do that to the car image once after loading it, then make rotated copies of the image that has the transparency already set? Also note that when you make an image on Mac that you get a TRANSLUCENT image not a BITMASK image, if you don't specify, simply specifying the type of transparency that you expect may fix it. I think somehow the check you have for the transparent colour using "==" fails near the edges because of this.
|
|
|
|
arne
Senior Devvie   
money is the worst drug- we should not let it rule
|
 |
«
Reply #17 - Posted
2006-02-03 15:43:50 » |
|
still 4 fps 1,8 Mhz Radeon 9000 512mb ram
|
|
|
|
moogie
|
 |
«
Reply #18 - Posted
2006-02-04 05:51:18 » |
|
I have uploaded a new version which uses embedded graphics instead of an external gif. Is the yellow halo still present on the Macs and is the game more playable under Linux? Halo on Mac is now cyan instead of yellow  ... this very well could be a bug in the handling of the image format used. In fact testing shows that it IS an Apple thing... that I can't discuss because I'm running a developer preview.. I will report a bug to Apple, can I send them the jar for testing? I changed the transparent colour to cyan so i could create a yellow palettized version of the car  If you want you can submit the jar. The source is still the old source however and does not reflect the new version.
|
Java4k RIP 2014
|
|
|
moogie
|
 |
«
Reply #19 - Posted
2006-02-04 05:58:58 » |
|
still 4 fps 1,8 Mhz Radeon 9000 512mb ram
I am at a loss... as i have said earlier, the only thing i can think of is that it is not accelerating the images. Does java for linux come with the command line options to use openGL for AWT?
|
Java4k RIP 2014
|
|
|
Anon666
Junior Devvie  
aka Abuse/AbU5e/TehJumpingJawa
|
 |
«
Reply #20 - Posted
2006-02-04 06:09:50 » |
|
I have uploaded a new version which uses embedded graphics instead of an external gif. Is the yellow halo still present on the Macs and is the game more playable under Linux? Halo on Mac is now cyan instead of yellow  ... this very well could be a bug in the handling of the image format used. In fact testing shows that it IS an Apple thing... that I can't discuss because I'm running a developer preview.. I will report a bug to Apple, can I send them the jar for testing? I changed the transparent colour to cyan so i could create a yellow palettized version of the car  If you want you can submit the jar. The source is still the old source however and does not reflect the new version. I'm abit confused, why are you adding the transparency once the image is loaded? What is wrong with having the transparency defined in the palette for the image itself?
|
|
|
|
moogie
|
 |
«
Reply #21 - Posted
2006-02-04 06:53:15 » |
|
Wait a sec! Why are you trying to set the transparent colour AFTER rotating the image? Shouldn't you do that to the car image once after loading it, then make rotated copies of the image that has the transparency already set? Also note that when you make an image on Mac that you get a TRANSLUCENT image not a BITMASK image, if you don't specify, simply specifying the type of transparency that you expect may fix it. I think somehow the check you have for the transparent colour using "==" fails near the edges because of this. For some reason i am getting a black/grey bar at the top of the rotated images if i set the transparency before rotating... I know it is stupid but if i change the transparency after the rotatiing this bar is not present. however since i now create an image from embedded data instead of loading an external gif this problem of the bar appearing on the rotated images may no longer occur. I am specifiing a BITMASK image on this line: 1
| images[i]=new BufferedImage(65, 65, 2); |
the 2 represents a bitmasked image.
|
Java4k RIP 2014
|
|
|
swpalmer
|
 |
«
Reply #22 - Posted
2006-02-04 17:19:47 » |
|
I am specifiing a BITMASK image on this line: 1
| images[i]=new BufferedImage(65, 65, 2); |
the 2 represents a bitmasked image. Hmm.. img1 returned from the ImageIO.read() will be 32 bit probably. The way the Mac graphics pipeline does the rotated blit it will likely get anti-aliasing. I did test on Mac with Sun's graphics pipeline (only possible with recent developer previews) and the halo went away.
|
|
|
|
moogie
|
 |
«
Reply #23 - Posted
2006-02-04 22:28:56 » |
|
I am specifiing a BITMASK image on this line: 1
| images[i]=new BufferedImage(65, 65, 2); |
the 2 represents a bitmasked image. Hmm.. img1 returned from the ImageIO.read() will be 32 bit probably. The way the Mac graphics pipeline does the rotated blit it will likely get anti-aliasing. I did test on Mac with Sun's graphics pipeline (only possible with recent developer previews) and the halo went away. good to know... but not really helpful for this competition due to the 1.4.2 restriction. Cheers tho,
|
Java4k RIP 2014
|
|
|
moogie
|
 |
«
Reply #24 - Posted
2006-02-05 02:43:54 » |
|
New Update: Now using both embedded graphics and embedded maps for tracksI am now able to use pre-generated transparency making the code foot print for the car graphic generation smaller. This should also get rid of the haloing for Mac users... i hope. The embedded tracks are stored in a stream format rather than as a bit map. This was done for two reasons: 1. it is likely that track tiles which are connected to each other will be identical and so it helps compression to keep them together. 2. the tile stream is stored in order of the track should be completed when racing. This will help keep the AI opponents going the correct direction. However I am currently running low on bytes with the current version when kzipped gives 3924 bytes giving only 172 bytes to code in AI opponents and some crappy physic model for sliding around corners... It is going to be interesting  I may have to remove some graphics. I have uploaded the new JARs and source code. Can some one suggest an area or a trick where i might be able to save some bytes for the AI code? Cheers
|
Java4k RIP 2014
|
|
|
swpalmer
|
 |
«
Reply #25 - Posted
2006-02-05 20:20:41 » |
|
I can confirm that the halo effect on Mac OS has been fixed.
|
|
|
|
moogie
|
 |
«
Reply #26 - Posted
2006-02-06 06:04:55 » |
|
I can confirm that the halo effect on Mac OS has been fixed.
Great! thats a relief! I am going to see whether i can make some simple AI for opponent vehicles with in the next few days. I think i will need to get creative to get it to all fit in 4096 btyes.
|
Java4k RIP 2014
|
|
|
stephencarmody
Senior Newbie 
Java games rock!
|
 |
«
Reply #27 - Posted
2006-02-07 03:02:10 » |
|
OMG! Nice one moogie. This game is almost exactly like what i've been working on. Though I started with the physics first and your car looks a lot better than mine. A very old (i.e. 5+ weeks ago) version is avaliable at http://stephencarmody.wikispaces.com/Racer4kI'm very interested to see where both our games end up. As your've mentioned, your current control setup is only for development. You'll find when the physics are in, using one hand to accelerate, brake and turn is a little too hard. Now i'm cursing myself I didn't pull my finger out early and actually post something before you. What you see posted on my wiki is very out of date now, since that version i've been completely redoing to graphics. My screen now pans and zooms in and out a little depending on the speed of the car. Good luck on trying to get opponents implemented. I gave up early on that. Anyway, now I've got some extremely close competition to bet. Goodluck!
|
|
|
|
moogie
|
 |
«
Reply #28 - Posted
2006-02-07 03:37:43 » |
|
LOL! great minds think alike  My game is tile based so panning and zooming is out of the question (tho would be nice!) I think i will no longer go with a "proper" physics for the car and instead go with a heuristic psuedo-realistic physics model for the car so you version will probably be better in that aspect  My game will definetly have opponnents (I have a very simple AI semi-working at the moment) tho whether they will be a challenge is to be seen. The car graphic takes quite a bit of room, but I think it really adds to the game so I am trying desperately to keep it in. I cannot access your game at work so I will fire it up at home. I look forward to your completed racing game, you are correct: it will be interesting to see where both games end up. 
|
Java4k RIP 2014
|
|
|
stephencarmody
Senior Newbie 
Java games rock!
|
 |
«
Reply #29 - Posted
2006-02-07 05:48:09 » |
|
OMG!!!!!!!!!
Your from Australia!
I thought i recognised the name moogie. When you said your still at work, I though oh ok similar timezones to me. Peter posted his buggy game not 4 or so days ago. He sits like across from me at work. I remembered someone answer south australia to his anyone from australia question.
Ok this is officially freaky now.
Shit!!!!!!!! I'm competing with a similar game to someone else in australia on a little know international java games comp.
I'm going to kick your butt!!!!!!!!!!!!!
|
|
|
|
|