External Publication
Visit Post

Graphics Development • Re: [OTTD] 2cc Narrow-Gauge in NML - Development

Transport Tycoon Forums - Index page [Unofficial] May 14, 2026
Source

Will you be publishing the source code?

The source code is already on GitHub: https://github.com/althonos/2ccng. I have some of a logic done by macros so maybe not the most straightforward to have, but the gist can be summarized as follow. While previously you would have a "front" and a "back" sprite for the front and back car of an EMU, and select the graphics to use for a dual-headed engine with the 0xC8 variable (the "sprite type") or the "vehicle_is_flipped" property, e.g.

Code:

switch(FEAT_TRAINS, SELF, switch_emu_reversed, var[0xC8]) { 0xFE: emu_back; 0xFF: emu_back; emu_front;}

Now you need to have "forward" and "backward"-driving variants for both cars, and use a switch to select the right one (so that you can adjust e.g. the lights or the pantographs like I did):

Code:

switch(FEAT_TRAINS, PARENT, switch_emu_front, vehicle_is_reversed) { 1: spriteset_emu_front_backward; 0: spriteset_emu_front_forward;}switch(FEAT_TRAINS, PARENT, switch_emu_back, vehicle_is_reversed) { 1: spriteset_emu_back_backward; 0: spriteset_emu_back_forward;}switch(FEAT_TRAINS, SELF, switch_emu_reversed, var[0xC8]) { 0xFE: switch_emu_back; 0xFF: switch_emu_back; switch_emu_front;}

Now, for cars that are perfectly symmetric and that are 8/8 in dimension, then spriteset_emu_front_forward and spriteset_emu_back_backward (resp. spriteset_emu_front_backward and spriteset_emu_back_forward) are the same; therefore you don't need to have new dedicated sprites. But if there is any asymetry you need dedicated sprites or it will look like the car "magically" turns around.

One done you just need to add the new VEHICLE_FLAG_TRAIN_HAS_CAB flags to the extra_flags property of the engine, and you're set!

Statistics: Posted by althonos — 14 May 2026 07:41


Discussion in the ATmosphere

Loading comments...