Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(4 edits)

13 days left

Today I spent some time thinking about the themes. I'll go for a game involving trains or steamy locomotives. Never made a train game before although I'm a pretty big train lover. You Are The Last Hope & Kill It With Fire are looking like nice secondary themes for my game but I'll need to figure out what kind of gameplay I want: Action? Strategy? Management? Survival? ... I'll figure that out soon. So I went ahead and got working.

There are four core elements in my implementation:

  • Rail nodes form the connections between rails. They have a position (x, y) and a list of rails connecting to them.
  • Rails are the edges between nodes. They have a "from node", a "to node", a length and an identifier for the type: straight or curved rail (quadrant 1-4).
  • Waggons are standing on one rail and have a position on that rail: the distance from the "from-node" on that rail. They also have a facing value (1, -1) which will used for the graphical representation (facing one of the two nodes).  Of course real waggons have two axis connected by the waggon on top of them but I figured to simplify that to a single point instead.
  • Trains are a collection of waggons belonging together.

When I want to move a train I always pull the train. For that I'll figure out the first waggon which needs to move. Whenever a moved waggon crossed either the "from" or the "to" node its rail and position have to get updated. Only the first pulling waggon decides the route to go, all other waggons behind are following the one in front of them. Important was to only look at valid rails when choosing the next rail of the leading waggon at a node: Basically only tangent rails which are on the opposite side of the node must be considered. It got a little bit tricky figuring out how to go about the movement direction because of different facings and orientations of rails e.g. two "from" nodes of rails ending at the same node which resulted  in sign switching. There also could be two instead of one rails between two waggons, depending on minimum rail and maximum waggon length so I also couldn't simply just use the previous waggon's rail.

With some hardcoding of rail placements I already got a train with some waggons moving in both directions with direction switching without going crazy. Pretty good for a day 1 imo.

Next up:

  • Train sprites with proper rotation
  • Basic tile sprites
  • Calculate waggon position on curves (instead of lerping diagonals)
  • Camera movement