Train Simulator

User projects written in or related to FreeBASIC.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Postby oog » Sep 18, 2011 13:49

agamemnus wrote:When I drag out to one of the side-windows, the drag ends and one of the side window drag functions kick in.

Excellent description. Now I got, what you mean. Check V 0.44, dragging is now limited to the view, where you started.
There also has been a bug with the track display, that is fixed. (The new nice track graphics did not have been displayed on a "close track" segment).
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » Sep 19, 2011 0:54

Even though the focus remains now, the main window still doesn't move if I'm dragging outside of it... it should move!!!
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Postby oog » Sep 19, 2011 18:49

agamemnus wrote:... it should move!!!


Let me try to explain, why map movement actually does not work as you expect.

Mouse handling
Earlier version of the train simulator did not have side views. There was just the main view at fullscreen. You could click and drag anywhere.
However, if you move the mouse pointer out of the program window, the FreeBASIC getmouse function always returns x=-1 and y=-1, so there is no control over the mouse position outside of the window. Drag-action naturally ends, if you move the mouse out of the train simulator window. I can't change that.

When implementing the side views, I had to separate the mouse pointer focus for every single view. Actually views are trated like completely independent windows. The view with the mouse focus is printed with a small white border to show, where the mouse is active. You can not click or drag outside of the active view.

Making things better
Actually I'm testing an "endless drag" mode, which can be activated by an init-file switch.

Code: Select all

<endlessdrag=1>

When active, the mouse cursor will be reset to screen center, when reaching the border at 20% distance. You can move the mouse endlessly into one direction and drag the map for a wide distance. That makes map movement intuitive and much easier.
Trains keep driving and you also can change the zoom level while moving the map - very funny.
You can also accelerate map dragging by seting "endlessdrag" to higher values. To allow pixel precise movement, you can set an acceleration level (number of pixel the mouse moved between two frames).
Example:

Code: Select all

  <endlessdrag=3>
  <mouseacclevel=4>


Image
... it should move!!!
(I love that picture from Lachie)

[Update]
Look for Train Simulator V0.45 for download.
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » Sep 25, 2011 2:31

oog wrote:
agamemnus wrote:... it should move!!!


Let me try to explain, why map movement actually does not work as you expect.

Mouse handling
Earlier version of the train simulator did not have side views. There was just the main view at fullscreen. You could click and drag anywhere.
However, if you move the mouse pointer out of the program window, the FreeBASIC getmouse function always returns x=-1 and y=-1, so there is no control over the mouse position outside of the window. Drag-action naturally ends, if you move the mouse out of the train simulator window. I can't change that.

When implementing the side views, I had to separate the mouse pointer focus for every single view. Actually views are treated like completely independent windows. The view with the mouse focus is printed with a small white border to show, where the mouse is active. You can not click or drag outside of the active view.

I see. So you call getmouse 3 times? I'm not really big on the view function.
Well, if you don't want to recode it too much, you can still make one function that figures things out from all 3 getmouse calls.

Actually I'm testing an "endless drag" mode, which can be activated by an init-file switch.

Code: Select all

<endlessdrag=1>

When active, the mouse cursor will be reset to screen center, when reaching the border at 20% distance. You can move the mouse endlessly into one direction and drag the map for a wide distance. That makes map movement intuitive and much easier.

I'm not sure I like this but I'll give it a whirl.

Edit: maybe. But now the cursor should be hidden (when endlessdrag is not 0) because the program resetting the hand cursor at the middle is very distracting!
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Postby oog » Dec 18, 2011 13:38

Train Simulator Version 1.00 has been released.

Image

Version 1.00 of the Train Simulator is available for download at proog.de.

What's new in version 1.00:

The user interface and menu has been revised and simplified.
F4 displays a speed control / tachometer.
F1 displays context-sensitive help pages. You can select a page by pressing a number key '0', '1', '2', ...
F8 opens a configuration menu.
Trains can automatically restart, when stopped within a station.
Some menu buttons now work like switches, showing their state (pressed, released).
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » Dec 18, 2011 17:09

Nice!

Some comments...
Took a while to find the build interface. The track build commands are very confusing. I was somehow able to create two track pieces for a new track, but was unable to replicate. I kept clicking buttons trying to add a new track segment and then the whole thing crashed. :(
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Postby oog » Dec 18, 2011 17:44

agamemnus wrote:Nice!

Some comments...
Took a while to find the build interface. The track build commands are very confusing. I was somehow able to create two track pieces for a new track, but was unable to replicate. I kept clicking buttons trying to add a new track segment and then the whole thing crashed. :(

Thank you for the comments and sorry for the crash - that should not happen.

After start, you can press "Space" to make the menu visible.
Click on the "track" button to flip out the build track menu (the third button).
Then press "F1" and you will see manual page 4, which explains how to build a track.
There is a manual page for every menu, you can also navigate with the number keys through the pages, "Esc" leaves the help pages.
I hope that helps.
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » Dec 18, 2011 18:15

Ah.

* Crashed again upon re-selecting a new track.

* I see that pressing INS creates a new track segment. No button for this? This is the most important function!

* The manual says I need to press INS 5 times to create a forward track. What is a forward track? Nothing special seems to happen when I do this.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Postby oog » Dec 18, 2011 18:28

agamemnus wrote:Ah.

* Crashed again upon re-selecting a new track.

* I see that pressing INS creates a new track segment. No button for this? This is the most important function!

* The manual says I need to press INS 5 times to create a forward track. What is a forward track? Nothing special seems to happen when I do this.


The menu buttons are
"Rail Insert" (green check mark) and
"Rail Remove" (red cross)
On the keyboard you can press "Ins" and "Backspace" instead.

A forward track is a peace of track. Press "+" or "-" to move the cursor on a track and you will see.
The railroad becomes longer in forward direction, when you press "Ins".
You can click on an existing track, to try this out. Maybe you should zoom in a little bit.
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Postby oog » Dec 18, 2011 19:20

I made a small video, where you see, how to build a small demo track with a train and signals.
http://www.youtube.com/watch?v=Wc9u1tpmr28
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Postby agamemnus » Dec 18, 2011 20:48

I see. Qool, qool.

I thought the checkmark and X buttons would either finish or cancel the track (instead of a track segment)...
oog
Posts: 124
Joined: Jul 08, 2011 20:34

Re: Train Simulator

Postby oog » Jan 05, 2012 17:32

There's a small bugfix available. V1.00 did sometimes crash, when removing a turnout.

TrainSimulator has been moved to "TileCity.de".
You can download the V1.01 patch separately (for those, who have V1.00) or as a complete package.
There is also a new video that shows the usage of turnouts.

http://www.tilecity.de/home/index.php/prog/trainsim
agamemnus
Posts: 1842
Joined: Jun 02, 2005 4:48

Re: Train Simulator

Postby agamemnus » Jan 12, 2012 15:49

Perhaps you could stick the train simulator into the tile city...?!?
D.J.Peters
Posts: 7667
Joined: May 28, 2005 3:28

Re: Train Simulator

Postby D.J.Peters » Jul 13, 2016 16:13


Return to “Projects”

Who is online

Users browsing this forum: No registered users and 2 guests