Hi !
Featured games (87)
games approved by the League of Dukes
Games in Showcase (669)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (727)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  java race game  (Read 6951 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja

Medals: 16
Projects: 4
Exp: 14 years


« Reply #30 - Posted 2003-05-19 10:00:53 »

You could use BufferedImage.getRGB(int x, int y) to get the color of a certain pixel in a BufferedImage, but then you'll make everything depending on the color of the background. It could be a quick, simple and dirty solution, but it depends on how you plan to create your tracks and IMHO it won't be a good solution if you want your game to look good and be flexible.

You might want to make the background tiled (made up of small square images) so you have to check which tile your car is on to decide how to behave instead of checking for pixel colors.

I'm sure a couple of folks will jump in here now to plug their tile based libraries.  Smiley


Offline jbanes

JGO Coder

Projects: 1

"Java Games? Incredible! Mr. Incredible, that is!"

« Reply #31 - Posted 2003-05-19 12:31:21 »

Check out my response here:;action=display;num=1052919932;start=5

Not sure if that's what you need, but it would work.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline blahblahblahh

JGO Coder

Medals: 1

« Reply #32 - Posted 2003-05-19 12:51:08 »

wow, didn't expect so much replies  Shocked
Anyway thx for tips. Meanwhile we have been able to make an applet that lets a car move over a certain field. The problem is now the collisions. How should we let the car folow a a circuit. Is there something like pixel recognition, pixelgrabber ? eg. the car should drive normal on tarmac ( grey) and should slow down or stop on gras, mud ...
what do you guys suggest ?

You will pretty much end up having two maps - the "visual" one which you draw to the screen and the "virtual" one, which just differentiates between different terrains. This way, the visual one can be really pretty - even texture-mapped - and the virtual one is just for collision detection etc.

If I interpreted the GAGE posts correctly, it uses a virtual map made of 16x16 pixel squares? EDIT: I stand corrected - it can use arbitrary precision (which is obviously a very good thing, and shows how you can get better features out of a purpose-built API like GAGE rather than a generic one like J2D)

Personally, for the virtual map I'd use Java2D Shapes and Areas to define the different parts of your map (e.g. one Area for "tarmac" a different Area for each separate chunk of grass, etc). This gives you arbitrarily fine detail, and it's easy to use, built in to the standard libraries, and works. (I'm not suggesting you DON'T use GAGE or etc, just that personally I'd do it that way since I already know j2d, and have never used GAGE before).

Then you create a rectangle to represent each of your cars, and use the intersects() tests you were originally attempting to use Smiley.

malloc will be first against the wall when the revolution comes...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jbanes

JGO Coder

Projects: 1

"Java Games? Incredible! Mr. Incredible, that is!"

« Reply #33 - Posted 2003-05-19 13:06:50 »

>  If I interpreted the GAGE posts correctly, it uses a virtual map made of 16x16 pixel squares?

Err, no. The idea is that the collision map can be as fine as you need it, right down to the pixel level. You'd tend to use a larger collision map for something like Pac-Man, where you have relatively large tiles. Also, the CollisionMap is a standalone piece of code I haven't yet folded into GAGE. It doesn't have any dependencies.

Given a collision map, the drag formula is:

distance += speed - getCollision(x, y)

In that case, zero would be road, while non-zero would introduce drag (e.g. 1 for grass, 2 for sand, etc). When collision value == speed, you'll hit a wall. When collision value > speed, you'll bounce off (like a tire-bumper wall).

Java Game Console Project
Last Journal Entry: 12/17/04
Offline gizfcb

Junior Newbie

Java games rock!

« Reply #34 - Posted 2003-05-21 08:06:46 »

Thank you very much everybody for your help.

We had to show our project today, it was really basic but it was a carGame.

the communication didn't work but they sai too that communication between two cars is not so basic.

One week before we had to finish it we were almost hopeless but with the goed hints we had a basicgame.

When I have more time I'll try to improve it and matbe I'll start with something easier Smiley.

See you later
Pages: 1 [2]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

IanParcs (34 views)
2016-04-18 14:18:53

KaiHH (34 views)
2016-04-18 08:35:41

KaiHH (66 views)
2016-04-15 12:43:58

theagentd (64 views)
2016-04-14 02:16:17

theagentd (72 views)
2016-04-14 02:15:43

IanParcs (66 views)
2016-04-12 03:51:16

IanParcs (35 views)
2016-04-12 03:50:03

IanParcs (32 views)
2016-04-12 03:49:54

IanParcs (27 views)
2016-04-12 03:49:52

IanParcs (36 views)
2016-04-12 03:49:52
Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30 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‑
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!