Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (499)
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 5170 times)
0 Members and 1 Guest are viewing this topic.
Offline erikd

JGO Ninja


Medals: 15
Projects: 4
Exp: 14 years


Maximumisness


« Reply #30 - Posted 2003-05-19 12: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

Erik

Offline jbanes

JGO Coder


Projects: 1


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


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

Check out my response here:

http://www.JavaGaming.org/cgi-bin/JGOForums/YaBB.cgi?board=2D;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
Online blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


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

Quote
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 15: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 10: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (46 views)
2014-04-15 18:08:23

BurntPizza (42 views)
2014-04-15 03:46:01

UprightPath (58 views)
2014-04-14 17:39:50

UprightPath (40 views)
2014-04-14 17:35:47

Porlus (56 views)
2014-04-14 15:48:38

tom_mai78101 (79 views)
2014-04-10 04:04:31

BurntPizza (138 views)
2014-04-08 23:06:04

tom_mai78101 (238 views)
2014-04-05 13:34:39

trollwarrior1 (199 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!