I need some tutorial material on the animation loop and use of RenderScript, SetRenderScript and SetUpdateScript functions I can't get the RenderLines() code to work. I keep getting either a missing ; or ) syntax error. Line(x1, y1, x2, y2, color) works when values are inserted but the line runs through my stakes rather than behind them. I'm starting to wonder about using LineSeries, PointSeries and Surface objects. I'm looking through Sphere code but have not found some example code yet.
The code below using SetTile(x,y, layer, tile_index)) draws three sets of lines at a decent speed with wait(100) but is jerky at wait(500). I tried putting it into a RenderLines() function but I got "Map engine not running" problems or missing } syntax errors.
I also have tried putting in code for the tractor sprite movement. With AttachInput() it works ok but I want it to move by itself. When I add GetTileWidth() *5; it just runs off the screen instead of stopping after the fifth tile and I could not get it to synchonize with the lines very well but a speed of 5 was close. I have since revised the code by adding the move command between each line set loop and it looks good enough but is very linear, clunky coding. I need to learn more about the QueuePersonScript and QueuePersonCommand functions and where to put them in my code.
// Show all stakes in untilled field - zoom out
DetachCamera();
// Set view to show stakes on both sides
SetCameraX(600);
SetCameraY(300);
// Zoom view out to see all stakes
SetLayerScaleFactorX(0, 0.5);
SetLayerScaleFactorY(0, 0.5);
SetLayerScaleFactorX(1, 0.5);
SetLayerScaleFactorY(1, 0.5);
SetLayerScaleFactorX(2, 0.5);
SetLayerScaleFactorY(2, 0.5);
SetLayerScaleFactorX(3, 0.5);
SetLayerScaleFactorY(3, 0.5);
SetLayerScaleFactorX(4, 0.5);
SetLayerScaleFactorY(4, 0.5);
// Show desired layers - 0 is base soil, 3 is stakes, 4 is tractor
SetLayerVisible(0, true);
SetLayerVisible(1, false);
SetLayerVisible(2, false);
SetLayerVisible(3, true);
SetLayerVisible(4, true);
SetLayerVisible(5, false);
RenderMap();
FlipScreen();
wait(5000);
FadeOut(1000);
// Show marking of aisles/paths in field with tractor
DetachCamera();
CreatePerson("George",'TopTractor.rss',true);
SetPersonLayer("George", 4);
SetPersonDirection("George","east");
SetPersonVisible("George", true);
SetPersonX("George", 50);
SetPersonY("George", 600);
SetLayerScaleFactorX(0, 0.5);
SetLayerScaleFactorY(0, 0.5);
SetLayerScaleFactorX(1, 0.5);
SetLayerScaleFactorY(1, 0.5);
SetLayerScaleFactorX(2, 0.5);
SetLayerScaleFactorY(2, 0.5);
SetLayerScaleFactorX(3, 0.5);
SetLayerScaleFactorY(3, 0.5);
SetLayerScaleFactorX(4, 0.5);
SetLayerScaleFactorY(4, 0.5);
//RenderLines();
RenderMap();
FlipScreen();
wait(500)
// Change map line tiles as sprite moves to right
// Line(100, 600, 500, 600, black);
CreatePerson("GeorgeEast2",'TopTractor.rss',true);
SetPersonLayer("GeorgeEast2", 4);
SetPersonDirection("GeorgeEast2","west");
SetPersonX("GeorgeEast2", 50);
SetPersonY("GeorgeEast2", 152);
SetPersonVisible("GeorgeEast2", false);
CreatePerson("GeorgeWest",'TopTractor.rss',true);
SetPersonLayer("GeorgeWest", 4);
SetPersonDirection("GeorgeWest","west");
SetPersonX("GeorgeWest", 700);
SetPersonY("GeorgeWest", 376);
SetPersonVisible("GeorgeWest", false);
for (i= 3; i< 46; i++) {
SetTile(i, 37, 1, 26);
SetTile(i, 38, 1, 25);
SetPersonSpeed("George", 16);
SetPersonDirection("George", "east");
QueuePersonCommand("George", COMMAND_MOVE_EAST, true);
// SetTile(3, 37, 1, 26) - first tile of upper line for first range as example
// Tile positions for all lines
// Bottom Lines: (3.37) to (46,37) and (3,38) to (46,38)
// Middle Lines: (3,23) to (46,23) and (3,24) to (46,24)
// Top Lines: (3,9) to (46,9) and (3,10) to (46,10)
SetLayerVisible(0, true);
SetLayerVisible(1, true);
SetLayerVisible(2, false);
SetLayerVisible(3, true);
SetLayerVisible(4, true);
RenderMap();
FlipScreen();
wait(100);
}
SetPersonVisible("George", false);
for (k= 46; k> 3; k--) {
SetTile(k, 23, 1, 26);
SetTile(k, 24, 1, 25);
SetPersonVisible("GeorgeWest", true);
SetPersonSpeed("GeorgeWest", 17);
QueuePersonCommand("GeorgeWest", COMMAND_MOVE_WEST, true);
RenderMap();
FlipScreen();
wait(100);
}
SetPersonVisible("GeorgeWest", false);
for (k= 3; k< 46; k++) {
SetTile(k, 9, 1, 26);
SetTile(k, 10, 1, 25);
SetPersonVisible("GeorgeEast2", true);
SetPersonSpeed("GeorgeEast2", 16);
SetPersonDirection("GeorgeEast2", "east");
QueuePersonCommand("GeorgeEast2", COMMAND_MOVE_EAST, true);
RenderMap();
FlipScreen();
wait(100);
}
SetPersonVisible("GeorgeEast2", false);
wait(1000)
SetLayerVisible(3, false);
RenderMap();
FlipScreen();
wait(1000);