123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- event.load("level_reset");
- event.load("tile_interact");
- event.load("tile_hit");
- event.load("auto_tile_interact");
- //event.load("entity_spawn");
- sgoto(0, @loop);
- @main
- wait();
- if(event == "level_reset")
- {
- onLevelReset();
- }
- elseif(event == "tile_interact")
- {
- onInteract(tile_x, tile_y, entity);
- }
- elseif(event == "tile_hit")
- {
- onTileHit(tile_x, tile_y, entity);
- }
- elseif(event == "auto_tile_interact")
- {
- onAutoInteract(tile_x, tile_y, entity);
- }
- elseif(event == "entity_spawn")
- {
- print(entity.getType(entity));
- }
- goto(@main);
- @loop
- light.setPositionSmooth(0, entity.getX(entity.getHero()) + 16, entity.getY(entity.getHero()) + 32);
- sgoto(0, @loop);
- goto(@main);
- function onLevelReset()
- {
- light.setAmbient(0.0, 0.0, 0.0);
- light.setColor(0, 1.2, 0.9, 0);
- light.setPosition(0, entity.getX(entity.getHero()), entity.getY(entity.getHero()));
- light.setStrength(0, 0.005);
-
- hero = entity.getHero();
- x = tile.toTileCoord(entity.getX(hero));
- y = tile.toTileCoord(entity.getY(hero));
- y -= 1;
- x = tile.toLevelCoord(x);
- y = tile.toLevelCoord(y);
- entity.teleport(hero, x, y);
- index = level.getBackgroundIndex();
-
- level.setTile(index, 0, 12, 72);
- level.setTile(index, 2, 12, 72);
- level.setTile(index, 10, 8, 72);
-
- level.setTile(index, 4, 12, -1);
- level.setTile(index, 4, 7, -1);
-
- level.setTile(index, 1, 9, 70);
- level.setTile(index, 4, 8, 71);
-
- level.setTile(index, 7, 11, 73);
- level.setTile(index, 8, 10, 74);
-
- $platform = platform.spawn(tile.toLevelCoord(3), tile.toLevelCoord(3), 3);
- platform.addmove($platform, tile.toLevelCoord(0), tile.toLevelCoord(9), 1, 2, 50);
- platform.addmove($platform, tile.toLevelCoord(3), tile.toLevelCoord(3), 1, 2, 50);
- }
- function onInteract(x, y, ent)
- {
- if(x == 0 && y == 12)
- {
- level.setTile(level.getBackgroundIndex(), 4, 12, 3);
- level.addMessage("Bla bla, I new block has appeared.");
- level.addMessage("This is another page.");
- level.addMessage("And another page.");
- }
- elseif(x == 2 && y == 12)
- {
- entity.setMotionY(entity.getHero(), -100);
- }
- elseif(x == 10 && y == 8)
- {
- entity.spawn(2, tile.toLevelCoord(14), tile.toLevelCoord(4));
- }
- }
- function onTileHit(x, y, ent)
- {
- if(x == 1 && y == 9)
- {
- level.addMessage("I'm an info block. ");
- }
- elseif(x == 4 && y == 8)
- {
- level.setTile(level.getBackgroundIndex(), 4, 7, 3);
- }
- }
- function onAutoInteract(x, y, ent)
- {
- if(x == 7 && y == 11)
- {
- entity.setMotionY(ent, tile.scale(-40));
- }
- elseif(x == 8 && y == 10)
- {
- //entity.setMotionY(ent, tile.scale(-80));
- entity.addHealth(entity.getHero(), -1);
- }
- }
|