Rally 4k (title to be confrimed)


http://img96.imageshack.us/img96/3591/screenshot0me.th.jpg

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 :wink: 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 :stuck_out_tongue_winking_eye:

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

Yep, that is a bug, the yellow areas are set transparent in the game using the following code:

///////// blue car
  
        // load the car graphic
        img1=ImageIO.read(loader.getResource("a"));
        int transparentColour=img1.getRGB(0,0);
        
        // create rotational images of the car
        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);
                }
            }
        }

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 :wink:

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.

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?

Works on OS X 10.4 :slight_smile:

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?

There is a slight yellow halo around the car, but it’s very subtle and doesn’t detract from the game really ;D

can you post a screen capture? there should not be any halo at all :frowning:

or if you are really keen :slight_smile: 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.

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

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 ? :slight_smile:

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.

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

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?

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.

still 4 fps
1,8 Mhz
Radeon 9000
512mb ram

I changed the transparent colour to cyan so i could create a yellow palettized version of the car :slight_smile:

If you want you can submit the jar.

The source is still the old source however and does not reflect the new version.

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?