Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (757)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (844)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to drive on a road?  (Read 2188 times)
0 Members and 1 Guest are viewing this topic.
Offline Thome

Junior Newbie

« Posted 2006-01-12 15:59:14 »


I have problem finding out how to program my carsimulator.
The game should be very simple. You sit in the car and therefor only see the road as a triangle from the bottom of the screen to the horizont. When you stear with the arrows on the keyboard the triangle (road) should move. When the road moves the center of the road moves to the sides.

That shouldn't be hard to do. But what do I need? Should I use java3D?

The hard thing with the road is the stripes in the middle of the road that makes us undrstand that we are moving forward. How do I do this? On each side of the road there is going to be short sticks that also make you see that we are moving forward on the road.

Please help me get started. What I want to know is what ways there is to do this.
Offline Grand Poeba

Junior Devvie

« Reply #1 - Posted 2006-01-12 17:12:31 »

think java 2d is just easiest thing to use here
and the just pain the stripes in a different place every thing to give impresseion you drive forward
Offline Thome

Junior Newbie

« Reply #2 - Posted 2006-01-12 17:25:49 »

Should I make the stripes like 2D objekts that appears at the horizon, grows and disapears out of frame?
And pinpoint them to the road object so the stripes always is in the middle of the road. Somehow?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Thome

Junior Newbie

« Reply #3 - Posted 2006-01-13 23:16:43 »


I have got some help in another forum.

Where someone wrote the following:
Can someone please comment if it seams like the way to do it?

Hi Thome, welcome abroad...

I'm no expert but I have an idea to solve your problem..
what you need is AnimatedSprite class or AdvanceSprite class from GTGE for the road...
oh my bro solar, don't scare us with 3D stuff here Laughing , there you go you scared Thomas already...Laughing

yes the road basically is just like a triangle, in my mind there are minimum 6 frame for the road
animation. (the more frame the road has, the more smooth the animation)

the first 2 frame is for the straight road, called it A1 & A2
the different between A1 & A2 is the size & the position of the short stick & the center stripes you
mentioned, so if you animate it , the car just like moving forward. use this method in GTGE:


with this mehotd you can set the car is going fast or slow. It only update the animation for the road

more faster or slower.
the 3rd & 4rd frame, called it A3 & A4 , is turn left road, just make the 2 curve line to the left so
it appear like a road, and give short stick & center stripes with different size & position, the more
it appear closer offcourse the more big the size of the short stick & the center stripe, so when you
animate it the car just like moving forward.
you can quest the last 2 frame right... it just like the 3rd & the 4rd frame, but only curve to the
using AnimatedSprite or AdvanceSprite you may choose for the turn left or turn right behaviour you
like, between moving the road sprite or just simply moving the car sprite.
also you can manage the colision between the car with boundary(short sticks)
with AnimatedSprite class you can set which frame is currently active using method :

setAnimationFrame(0, 1) //straight road
setAnimationFrame(2, 3) //turn left road
setAnimationFrame(4, 5) //turn right road

say it you are using Timer class to manage when the road going to turn left or right can use the

action method :
   setAnimationFrame(2, 3)

there you go the simple way to create car simulator in 2D
if you don't understand or confuse with my explanation, please don't be hesitate to ask.
and for anyone who understand what I'm talking about, especially solar Razz , please help me for explaining more detail.
Pages: [1]
  ignore  |  Print  

EgonOlsen (73 views)
2018-06-10 19:43:48

EgonOlsen (54 views)
2018-06-10 19:43:44

EgonOlsen (73 views)
2018-06-10 19:43:20

DesertCoockie (253 views)
2018-05-13 18:23:11

nelsongames (154 views)
2018-04-24 18:15:36

nelsongames (154 views)
2018-04-24 18:14:32

ivj94 (895 views)
2018-03-24 14:47:39

ivj94 (156 views)
2018-03-24 14:46:31

ivj94 (808 views)
2018-03-24 14:43:53

Solater (172 views)
2018-03-17 05:04:08
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!