Giter Site home page Giter Site logo

age-of-steam's People

Contributors

abhijitnandy2011 avatar

Watchers

 avatar  avatar

age-of-steam's Issues

Test with large rakes of upto 100 cars

The biggest train ever has had 682 coaches:

[https://www.google.co.in/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=longest+freight+train+in+the+world]

The record was set on june 21, 2001 in western australia between newman and port headland, a distance of 275km (170 miles) and the train consisted of 682 loaded iron ore wagons and 8 GE AC6000 locomotives giving a gross weight of almost 100,000 tonnes and moved 82,262 tonnes of ore, the train was 7.353 km (4.568 miles) .

We may support at most 25-30 cars in the sim, but we can always test with a lot more and check frame rates. Also we neednt necessarily calculate the position of all coaches as they will not all be visible unless zoomed out a lot.

Even if they are all visible - the positions needn't be accurate - only visually accurate till the player zooms in.

Create a Resource Manager

It should be able to load resources - meshes mostly, also textures asynchronously. It should be able to send an event when done to any subscribers that a resource that was requested is ready. When registering a resource fetch request, the user registers a lambda which can be called back.

The Resource Manager returns a Resource object which can be used to check if the resource has loaded yet. After a resource is loaded the callback will also have this Resource object passed as an argument. The Resource can be used to get to the actual mesh, texture, file etc.

Load Mesh for Loco

We can start with a procedural mesh and schedule loading of a larger mesh asynchronously by requesting the Resource Manager. Once its available at the Resource Manager, we can use it - the Resource Manager needs to inform the client which originated the request - use a lambda function here.

The Resource Manager returns a Resource object immediately after the request is made which can be used to monitor the loading of the resource. The object could also be passed to the the callback lambda.

Create a SimBox within the GameWorld

The SimBox keeps moving within the GameWorld whenever the focussed train reaches near the edge. The world outside the SimBox is unloaded. Whenever the SimBox moves, the Babylon co-ordinates of all objects translate to new co-ordinates based on the new origin of the SimBox within the GameWorld

Create a GameWorld which will manage loading of the game map

The GameWorld is much larger than the usable part of the BabylonJS world. In fact its as large as the creator of a railway needs it to be. For example the GameWorld could be several 100km(thats 100,000 units for the world as our units are meters in the world) wide on each side.

But the complete GameWorld cannot be loaded into the BabylonJS world at one time - there will be precision issues with physics after a few kilometers.

We need maximum precision where the game's current action is, meaning where the currently focused train is. This train is the one being driven(henceforth referred to as only the train). Also maximum precision is available near the BabylonJS origin. So the game's action has to be somehow kept near the BabylonJS origin.

To enable this we separate the GameWorld from the BabylonJS world. An object exists in the GameWorld which is what the author of a railway creates. But for rendering, we need to render the object in BabylonJS co-ordinates which can be different from the GameWorld co-ordinates of the object.

To make this separation possible and manageable we have the concept of a SimBox which is a cuboidal area within the GameWorld. It's axes is aligned with the GameWorld. This SimBox represents the region in the GameWorld where the train currently is. Since the train is moving, the SimBox moves too within the GameWorld. The size of the SimBox is fixed and doesn't change during the sim. All game action thats within the SimBox is rendered, all the rest of the GameWorld and action outside it is ignored. Also, the SimBox ensures that all the action within it is rendered near the BabylonJS origin for maximum precision.

Therefore we need to calculate co-ordinates for each object within the SimBox that we need to render. These co-ordinates need to be BabylonJS co-ordinates of course and as close to the BabylonJS origin as possible.

Lets call the GameWorld co-ordinates henceforth as GW co-ordinates for short
Let the Babylon co-ordinates be called as BJS co-ordinates.

The SimBox is placed in a fixed place in the BabylonJS world at BJS(0,0,0). Therefore the current action in the GameWorld(within the SimBox) will be always centered around the BabylonJS origin and thus have maximum possible precision.

The SimBox center matches with BJS(0,0,0). This center will be the center of the cuboid of the SimBox. In the GameWorld, the SimBox center can start and be anywhere based on the train's current position. Therefore the GW and BJS co-ordinates of the simbox need not match.

For example the train could be at GW(102, 0, 0), within a simbox thats of size (10,10,10).
Let the simbox be at GW(95,0, 0).
Since the simbox is always at BJS(0,0,0), in BJS co-ordinates it extends from (-5,-5,-5) to (5,5,5). Therefore the train is at BJS(2, 0, 0).

Thus if the SimBox is not at GW(0,0,0) then the train will be at different GW co-ordinates than its BJS co-ordinates.

For Version 0.1, the GameWorld and BabylonJS world will match. We will allow larger game worlds from 0.2 onwards.

Create controls for starting and stopping the train

There should be switches to add acceleration and reduce acceleration. This will do till we have a steam engine model. There should also be brake switches. There are no switches for speed directly as an engine works on the basis of force application which accelerates and adds speed.

The following keys can be there:
w - Increase Acceleration
s - Reduce Acceleration
Acceleration is capped at some max at the higher end. Its negative only while braking. Other than at braking we do not allow negative acceleration. Negative acceleration is only during braking deceleration.

We never allow negative velocity or displacement. Negative values would imply reverse movement - this is achieved by reversing the direction of the movement of the train but keeping displacement, velocity and acceleration positive.

Brake switches:
b - Apply normal braking deceleration
Shift + b - release brakes
e - Apply emergency braking deceleration
Shift + e - Release emergency brakes

Add Railway class & a Train class

Add classes to manage a railway & multiple trains in it. The sim will have 1 railway which has multiple trains on different tracks. So there are multiple tracks as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.