Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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 1175 times)
0 Members and 1 Guest are viewing this topic.
Offline Thome

Junior Newbie





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

HI.

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 »

Hi.

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?

Quote
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:
Code:

getAnimationFrame.setDelay(...)

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
right.
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 :
Code:

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 ...you can use the

action method :
Code:
 
if(timer.action(elapsedTime)){
   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  
 
 
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.

trollwarrior1 (31 views)
2014-11-22 12:13:56

xFryIx (72 views)
2014-11-13 12:34:49

digdugdiggy (51 views)
2014-11-12 21:11:50

digdugdiggy (45 views)
2014-11-12 21:10:15

digdugdiggy (39 views)
2014-11-12 21:09:33

kovacsa (63 views)
2014-11-07 19:57:14

TehJavaDev (68 views)
2014-11-03 22:04:50

BurntPizza (66 views)
2014-11-03 18:54:52

moogie (81 views)
2014-11-03 06:22:04

CopyableCougar4 (81 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!