Recent

Author Topic: Big Metro - real-time metro building game  (Read 7378 times)

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Big Metro - real-time metro building game
« on: November 24, 2017, 11:26:40 pm »
Project homepage: https://app.zdechov.net/BigMetro

This is first release of somehow unfinished but playable game inspired by Mini Metro game  https://dinopoloclub.com/minimetro/. The original idea was just for fun to re-implement that game in Pascal and to extend it in various ways. Its kind of fun to build metro lines and watch trains going back and forth transporting passengers :) In real world you don't want to rebuild tube every time when a new station appears somewhere. But here it costs nothing to move and reorganize all lines. So you can always optimize your metro system for better throughput.

Its also interesting to implement zoom-able map with various moving elements as software rendering and achieve lower CPU load. There are not many nice complex fully featured games created in Lazarus/FPC yet. There is a long way for Lazarus to be simply usable for game development. Even simple native multi-platform Windows/Linux/Mac sound system for games is not there. But still we can try to push things forward.
« Last Edit: February 17, 2023, 04:21:03 pm by Chronos »

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Big Metro - real-time metro building game
« Reply #1 on: November 25, 2017, 11:51:50 am »
Cool indeed.  :)

Anyway I don't agree with you in this statement:
There are not many nice complex fully featured games created in Lazarus/FPC yet. There is a long way for Lazarus to be simply usable for game development. Even simple native multi-platform Windows/Linux/Mac sound system for games is not there. But still we can try to push things forward.
Actually there are a collection of libraries and engines for game development with FPC.  May be some are old but we (including myself) are working in new stuff as ZenGL, Allegro.pas, Luna Game Pascal, MinGRo and Castle Engine among others, as well as nice experiments like DelphiDoom, Thyandyr's Voxel Engine and Lua Game Library.  I would agree that there are not a lot of games lately though.

May be you should join Pascal Game Development not just to get information but also to help us change how the gamedev community sees Pascal.
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9754
  • Debugger - SynEdit - and more
    • wiki
Re: Big Metro - real-time metro building game
« Reply #2 on: November 25, 2017, 12:07:42 pm »
Div by zero

in UGeometric.pas
function LineIntersect(LineAP1, LineAP2, LineBP1, LineBP2: TPoint): TPoint;

Line 113
  LDetDivInv := 1 / ((LDiffLA.X * LDiffLB.Y) - (LDiffLA.Y * LDiffLB.X));

LDiffLB = (0,0)

Code: Pascal  [Select][+][-]
  1. ~"#0  0x00440c41 in LINEINTERSECT (LINEAP1=..., LINEAP2=..., LINEBP1=..., LINEBP2=..., result=...) at UGeometric.pas:113\n"
  2. ~"#1  0x0043d0ee in TENGINE__SHIFTTRACKPOINTS (this=0x2f9c50) at UEngine.pas:1814\n"
  3. ~"#2  0x00438587 in TMETROLINE__CONNECTSTATION (STATION=0x24e398, LINESTATIONDOWN=0x313970, LINESTATIONUP=0x313eb0, this=0x23ef58) at UEngine.pas:888\n"
  4. ~"#3  0x0043e1c7 in TENGINE__MOUSEMOVE (POSITION=..., this=0x2f9c50) at UEngine.pas:2028\n"
  5. ~"#4  0x004361bd in TFORMMAIN__PAINTBOX1MOUSEMOVE (SENDER=0x26a930, SHIFT=..., X=485, Y=451, this=0x269a60) at ./Forms/UFormMain.pas:90\n"
  6. ~"#5  0x0052f23c in MOUSEMOVE (this=0x26a930, SHIFT=..., X=485, Y=451) at include/control.inc:4425\n"
  7. ~"#6  0x0052ef6d in WMMOUSEMOVE (this=0x26a930, MESSAGE=...) at include/control.inc:4384\n"
  8.  


LINEAP1={X = 498, Y = 538}
LINEAP2={X = 515, Y = 555}
LINEBP1={X = 515, Y = 555}
LINEBP2={X = 515, Y = 555}
RESULT=0x262f7b4
LDETLINEA=-680
LDETLINEB=0
LDETDIVINV=1.1945305291614955e+103
LDIFFLA={X = -17, Y = -17}
LDIFFLB={X = 0, Y = 0}
LINEINTERSECT=0x262f7b4
« Last Edit: November 25, 2017, 12:10:22 pm by Martin_fr »

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Re: Big Metro - real-time metro building game
« Reply #3 on: February 03, 2018, 09:09:04 pm »
Version 1.0.1 (2018-02-03)
==========================

* Modified: High DPI support under Windows.
* Fixed: Zooming by mouse wheel was inverted. Not worked correctly with touch screen.
* Fixed: Avoid division by zero in line intersection calculation.

Download: https://app.zdechov.net/BigMetro
« Last Edit: December 18, 2018, 11:41:03 pm by Chronos »

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Big Metro - real-time metro building game
« Reply #4 on: September 05, 2020, 10:10:45 pm »
This app works well on the Mac, too, when being compiled from source code.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Big Metro - real-time metro building game
« Reply #5 on: September 06, 2020, 05:26:42 am »
Too well... I'm addicted :)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Big Metro - real-time metro building game
« Reply #6 on: September 09, 2020, 03:00:10 pm »
Having "researched" the game play for several days and having attained a high score of 3,755 passengers being transported over 72 days I have a few comments for improvements :)

o A High Score facility (saved to a file?) so I don't need pen and paper.
o The number of days that have passed being displayed under the clock would be a nice touch.
o Once a certain number of stations have been added, it becomes increasingly hard to find the latest one because sometimes it is placed on an existing line (but not connected) and sometimes it is hard to spot where the latest one has appeared until you notice the number of passengers growing at it.
o Sometimes the type of passenger that starts waiting at station/s appears before the matching type of station appears which leads to overcrowding and my eventual firing.

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Re: Big Metro - real-time metro building game
« Reply #7 on: December 01, 2020, 12:28:12 pm »
A new version was released with some improvements:

Quote
Version 1.1.0 (2020-11-28)
==========================

* Added: Show highest score on game over.
* Added: Support for dark mode.
* Added: Top left back button to exit from game to game menu. Allow to restart game and continue with playing.
* Added: Support for Escape key for exiting game and menu.
* Added: Support for full screen mode. Can be changed in options and by hitting F11 key.
* Added: Remember form dimensions between application restarts.
* Added: Multi-language support. Supported English and Czech languages.
* Added: Main game menu with options section.
* Modified: Use InnoSetup 6 with modern style.
* Modified: Update project web links.
* Fixed: Canvas width and height is not updated correctly on Windows. Use additional CanvasSize parameter in drawing methods.
* Fixed: Correct vertical position of game over text.
* Fixed: Show correct application icon and removed version from name in Windows installed application item.

Download: https://app.zdechov.net/BigMetro

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Big Metro - real-time metro building game
« Reply #8 on: December 02, 2020, 05:47:14 am »
Compiling for Intel 64 bit macOS results in:

Quote
Free Pascal Compiler version 3.3.1 [2020/10/25] for x86_64
Copyright (c) 1993-2020 by Florian Klaempfl and others
(1002) Target OS: Darwin for x86_64
(3104) Compiling Common.pas
(3104) Compiling UCommon.pas
/Users/trev/Documents/Programming/LAZPROJECTS/BigMetro2/Packages/Common/UCommon.pas(292,19) Warning: (5093) Function result variable of a managed type does not seem to be initialized
/Users/trev/Documents/Programming/LAZPROJECTS/BigMetro2/Packages/Common/UCommon.pas(344,9) Error: (5000) Identifier not found "UtsName"
/Users/trev/Documents/Programming/LAZPROJECTS/BigMetro2/Packages/Common/UCommon.pas(344,16) Error: (5007) Error in type definition
/Users/trev/Documents/Programming/LAZPROJECTS/BigMetro2/Packages/Common/UCommon.pas(346,3) Error: (5000) Identifier not found "fpuname"
/Users/trev/Documents/Programming/LAZPROJECTS/BigMetro2/Packages/Common/UCommon.pas(347,18) Error: (3205) Illegal qualifier
/Users/trev/Documents/Programming/LAZPROJECTS/BigMetro2/Packages/Common/UCommon.pas(505,19) Warning: (5093) Function result variable of a managed type does not seem to be initialized
UCommon.pas(682) Fatal: (10026) There were 4 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: Big Metro - real-time metro building game
« Reply #9 on: December 02, 2020, 08:47:26 am »
Compiling for Intel 64 bit macOS results in:

Quote
...
Error: /usr/local/bin/ppcx64 returned an error exitcode

The previous version from September 2020 compiled seamlessly on the Mac. The bug(s) seem(s) to have been introduced afterwards.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Re: Big Metro - real-time metro building game
« Reply #10 on: December 02, 2020, 09:45:45 am »
I don't have any MacOS installation right now so I can't test such build. I wanted to install MacOS into VirtualBox so I can test applications with Mac and create packages but OS was crashing VirtualBox at that time.

It would be really nice if we would be able to build windows and mac applications directly from linux. But currently it is too complicated even to build i386 linux app from 64-bit linux.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Big Metro - real-time metro building game
« Reply #11 on: December 02, 2020, 10:35:46 am »
I can provide command line access via ssh to either an M1 Mac mini or an Intel Mac mini or there's the  https://www.macincloud.com service from $1/hour.

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Re: Big Metro - real-time metro building game
« Reply #12 on: October 26, 2022, 05:50:56 pm »
A new version was released with further improvements:

Quote
Version 1.3.0 (2022-10-04)
==========================

* Added: Show train direction before placement on track.
* Added: Terminals as selectable user improvement on every week.
* Added: New game mode career where user needs to play existing cities and gradually unlock them by reaching expected transported number of passengers.
* Added: Show dialog about new train every start of new week.
* Added: Support for train carriages.
* Added: French and German translation.
* Modified: Improved trains placement behavior by mouse drag and drop.
* Modified: Do not change view zoom if new station is already visible.
* Modified: Use by default black background color to avoid flashing on light desktop theme.
* Modified: Build with Lazarus 2.2.4.
* Modified: Use core22 for snap package.
* Modified: Code cleanup.
* Fixed: Redrawing scene during paused game.
* Fixed: Disable controls during game over.
* Fixed: Line icon normalized.
* Fixed: Normalized images quality and on screen placement.
* Fixed: Night and day state in clock.
* Fixed: Translation of short days of weeks names.
* Fixed: Calculation of tracks end.
* Fixed: Wrong train drawing position if track points distance close to zero.

Version 1.2.0 (2021-08-19)
==========================

* Added: Control icons for Pause, Play and Fast forward.
* Added: Detect language files in different system location on Linux.
* Modified: Allow to start new track from already connected station.
* Modified: Image buttons changed to custom TImage control with Enabled property supported.
* Fixed: Missing parallel track line ending shift.
* Fixed: Colors inversion of used images if dark mode active.
* Fixed: Back button arrow drawn as image instead of font. Left arrow was not supported under Ubuntu.

https://app.zdechov.net/BigMetro

kupferstecher

  • Hero Member
  • *****
  • Posts: 583
Re: Big Metro - real-time metro building game
« Reply #13 on: October 27, 2022, 01:11:29 pm »
Hi, thanks for sharing!

I got an access violation when I moved a track in the moment a train was in the station.

Chronos

  • Full Member
  • ***
  • Posts: 240
    • PascalClassLibrary
Re: Big Metro - real-time metro building game
« Reply #14 on: October 27, 2022, 03:26:20 pm »
That should be already fixed. How you install or run the game and on what platform?

 

TinyPortal © 2005-2018