Page 1 of 1

Crear un mapper e inicializarlo

Posted: Thu Oct 21, 2021 2:50 pm
by efraimsangil

Code: Select all

class Mapper implements GL_Program
{
	properties:
		mapper = null;
		
	virtual Start()
	{
		_mapper = NewMapper("map");
		mapper = _mapper;
		
		_ts = _mapper.AddTileSet("tiles.tga", 16, 16);
		
		_layer = _mapper.AddLayer(100, 100);
		
		for(j=0; j<100; j++)
		{
			for (i=0; i<100; i++)
			{
				_layer.Set(i, j, _ts, Rand(0,31));
			}
		}
		
		_pad = NewPad("pad");
		_pad.SetPreset("CURSORS");
		
		_controller = NewController("contr");
		_controller.SetPad(_pad);
		_controller.SetUpdateCallback(this, "OnController");
	}
	
	function OnController(_controller)
	{
		mapper.SetOffset(_controller.GetX(), _controller.GetY());
	}
}
El archivo "tiles.tga" serĂ­a este:
Image
Requiere build >= 20440