00-Tech_Demo.snuvi 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. event.load("level_reset");
  2. event.load("tile_interact");
  3. event.load("tile_hit");
  4. event.load("auto_tile_interact");
  5. //event.load("entity_spawn");
  6. //sgoto(0, @loop);
  7. @main
  8. wait();
  9. if(event == "level_reset")
  10. {
  11. onLevelReset();
  12. }
  13. elseif(event == "tile_interact")
  14. {
  15. onInteract(tile_x, tile_y, entity);
  16. }
  17. elseif(event == "tile_hit")
  18. {
  19. onTileHit(tile_x, tile_y, entity);
  20. }
  21. elseif(event == "auto_tile_interact")
  22. {
  23. onAutoInteract(tile_x, tile_y, entity);
  24. }
  25. elseif(event == "entity_spawn")
  26. {
  27. print(entity.getType(entity));
  28. }
  29. goto(@main);
  30. //@loop
  31. //light.setPositionSmooth(0, entity.getX(entity.getHero()) + 16, entity.getY(entity.getHero()) + 32);
  32. //sgoto(0, @loop);
  33. //goto(@main);
  34. function onLevelReset()
  35. {
  36. //light.setAmbient(0.0, 0.0, 0.0);
  37. //light.setColor(0, 1.2, 0.9, 0);
  38. //light.setPosition(0, entity.getX(entity.getHero()), entity.getY(entity.getHero()));
  39. //light.setStrength(0, 0.005);
  40. hero = entity.getHero();
  41. x = tile.toTileCoord(entity.getX(hero));
  42. y = tile.toTileCoord(entity.getY(hero));
  43. y -= 1;
  44. x = tile.toLevelCoord(x);
  45. y = tile.toLevelCoord(y);
  46. entity.teleport(hero, x, y);
  47. index = level.getBackgroundIndex();
  48. level.setTile(index, 0, 12, 72);
  49. level.setTile(index, 2, 12, 72);
  50. level.setTile(index, 10, 8, 72);
  51. level.setTile(index, 4, 12, -1);
  52. level.setTile(index, 4, 7, -1);
  53. level.setTile(index, 1, 9, 70);
  54. level.setTile(index, 4, 8, 71);
  55. level.setTile(index, 7, 11, 73);
  56. level.setTile(index, 8, 10, 74);
  57. $platform = platform.spawn(tile.toLevelCoord(4), tile.toLevelCoord(11), 3);
  58. platform.addmove($platform, tile.toLevelCoord(4), tile.toLevelCoord(10), 6, 9, 1);
  59. platform.addmove($platform, tile.toLevelCoord(3), tile.toLevelCoord(6), 6, 9, 1);
  60. entity.spawn(5, tile.toLevelCoord(11), tile.toLevelCoord(4));
  61. }
  62. function onInteract(x, y, ent)
  63. {
  64. if(x == 0 && y == 12)
  65. {
  66. level.setTile(level.getBackgroundIndex(), 4, 12, 3);
  67. level.addMessage("Bla bla, I new block has appeared.");
  68. level.addMessage("This is another page.");
  69. level.addMessage("And another page.");
  70. }
  71. elseif(x == 2 && y == 12)
  72. {
  73. entity.setMotionY(entity.getHero(), -100);
  74. }
  75. elseif(x == 10 && y == 8)
  76. {
  77. entity.spawn(2, tile.toLevelCoord(14), tile.toLevelCoord(4));
  78. }
  79. }
  80. function onTileHit(x, y, ent)
  81. {
  82. if(x == 1 && y == 9)
  83. {
  84. level.addMessage("I'm an info block. ");
  85. }
  86. elseif(x == 4 && y == 8)
  87. {
  88. level.setTile(level.getBackgroundIndex(), 4, 7, 3);
  89. }
  90. }
  91. function onAutoInteract(x, y, ent)
  92. {
  93. if(x == 7 && y == 11)
  94. {
  95. entity.setMotionY(ent, tile.scale(-40));
  96. }
  97. elseif(x == 8 && y == 10)
  98. {
  99. //entity.setMotionY(ent, tile.scale(-80));
  100. //entity.addHealth(entity.getHero(), -1);
  101. }
  102. }