Train Simulator

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Train Simulator

Post by oog »

I'm actually working on a train simulator. The simulator uses 2D vector graphics and allows multiple zoom levels.
It's work in progress. There is no user interface. Don't expect too much. It's not more than a simple demo.

Screenshot of Version 0.30

Image

You can download the actual source code and Windows exe-file from proog.de. Pleas click on the flags - proog.de supports google translation (Java-script required).

http://proog.de/joomla/index.php/projekte/62-trains
h4tt3n
Posts: 698
Joined: Oct 22, 2005 21:12
Location: Denmark

Post by h4tt3n »

Hey, that's really awesome! I like the way you've smoothed out the rails. Looking forward to seeing how this develops.

Cheers,
Mike
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Post by agamemnus »

Nice, nice. Keep going...
rugxulo
Posts: 219
Joined: Jun 30, 2006 5:31
Location: Usono (aka, USA)
Contact:

Post by rugxulo »

Impressive!! Nice job!!
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Post by pestery »

Looks good.
Landeel
Posts: 777
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Post by Landeel »

Looks very professional.
Nice job!
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Post by oog »

Thank you for your comments.

Actually I'm trying to get bitmaps as background maps working. I hope to get it stable this weekend.
(Actually no download, just two screenshots)

Image

oog
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Post by kiyotewolf »

How are you managing the keeping the little trains on the little tracks?
What kind of container are you using to dictate where the tracks connect, and maintaining their position to always be on a track?
Or else, they fall off the tracks, then they crash, and grow exponentially larger orange pixels which represent fire.



~Kiyote!
Landeel
Posts: 777
Joined: Jan 25, 2007 10:32
Location: Brazil
Contact:

Post by Landeel »

Or else, they fall off the tracks, then they crash, and grow exponentially larger orange pixels which represent fire.
LOL
Maybe a particles system.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Post by oog »

kiyotewolf wrote:How are you managing the keeping the little trains on the little tracks?
What kind of container are you using to dictate where the tracks connect, and maintaining their position to always be on a track?
Every train just stores it's position related to the track. The position of the train will be calculated from the track's position.
kiyotewolf wrote:Or else, they fall off the tracks, then they crash, and grow exponentially larger orange pixels which represent fire.
That would be pretty cool.
When you run the program, you will find some tracks with an open end (number 9, 10 and 11).
Actually the trains just change the direction.
There is no collision detection at the moment. So you can drive different trains on the same track and let the trains drive over another.

Edit: correcting typos.
Last edited by oog on Jul 14, 2011 20:19, edited 1 time in total.
kiyotewolf
Posts: 1009
Joined: Oct 11, 2008 7:42
Location: ABQ, NM
Contact:

Post by kiyotewolf »

The position of the train is calculated from the track's position.
The UDT for the track's position seems clever & complex, I'm curious how you did it.



~Kiyote!
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Post by oog »

About drawing trains.


I use strings to define vector graphics items like trains and buildungs. The characters of the string stand for graphics commands and parameters.

There are some subroutines, that help building the string similar to graphics commands.

iAddColor(col) for example adds a color(col) command to the string.

There are also Zoom-Commands iAddZoomIn and iAddZoomOut. They are used to show more or less details in different zoom levels.

Example:

w.iBuild(i)= _
iVehicle _
+iAddZoomOut(200) _
+iAddColor(1) _
+iAddLine(-20,-70,20,70) _
+iAddLine(20,-70,-20,70) _
+iAddZoomIn(200) _
+...

Every vector item will be placed on the screen with two pair of coordinates (PointA and PointB).

A coordinate is a 8 bit value. PointA and PointB are located at (-100,0) and (+100,0) within a (-128,-128) - (127,127) grid. For a train, PointA and PointB represent the axis (wheels).


Test for yourself:

You can place a new item at the cursor position by pressing "n" (new item). A Building will appear under the mouse cursor.

Then click with the left mouse button to select the object (use a short click).
There will appear a yellow circle around PointA and a blue one around PointB.

Press + or - to change the item (other building, train, etc.).
Click into a point marker, hold down the mousebutton and drag it. PointA moves the item while PointB change size an direction.

Press "del" to remove the item, or click outside a Point marker to deselect the item.

The next program version will have a more stable drag function, actually you should not move the mouse too fast while dragging.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Post by oog »

There's a new version available for download.

V 0.32a support bitmaps as background images. You can get the "London Maps" extension as a separate download.

Image

London Maps contain seven maps. You can smoothly zoom from London City to South England.

Maps by OpenStreetmap.

I hope, you like it.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Post by oog »

How to use your own bitmap.

For an example, take a screenshot of the FreeBASIC Forum logo and save as "data/fblogo.bmp".

Then edit the "data/trainini.txt" file like in the example.

Code: Select all

groundcolor
  0xd0d0c0

#
# load bitmap
#

loadbmp
  1              # bmp 1
  fblogo.bmp

#
# place map on screen
#

newmap
  1              # place map 1
  logo
  1              # use bmp 1
  1_000_000_000  # position x
  1_000_000_000  # position y
  10_000         # scale, 1 pixel = 10 m
  10             # zoom min
  200_000        # zoom max
After running the trainxxx.exe, press "m" to show the background map.
You will see the logo in the background.

Image

Then you can build your own track. Example for a "horse track"

Image
super_castle
Posts: 289
Joined: Oct 10, 2006 7:19

Post by super_castle »

Jup...., wonderfull the train.....
gruss
Post Reply