00-Tech_Demo.snuvi 2.7 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(3), tile.toLevelCoord(3), 3);
  58. platform.addmove($platform, tile.toLevelCoord(0), tile.toLevelCoord(9), 1, 2, 50);
  59. platform.addmove($platform, tile.toLevelCoord(3), tile.toLevelCoord(3), 1, 2, 50);
  60. }
  61. function onInteract(x, y, ent)
  62. {
  63. if(x == 0 && y == 12)
  64. {
  65. level.setTile(level.getBackgroundIndex(), 4, 12, 3);
  66. level.addMessage("Bla bla, I new block has appeared.");
  67. level.addMessage("This is another page.");
  68. level.addMessage("And another page.");
  69. }
  70. elseif(x == 2 && y == 12)
  71. {
  72. entity.setMotionY(entity.getHero(), -100);
  73. }
  74. elseif(x == 10 && y == 8)
  75. {
  76. entity.spawn(2, tile.toLevelCoord(14), tile.toLevelCoord(4));
  77. }
  78. }
  79. function onTileHit(x, y, ent)
  80. {
  81. if(x == 1 && y == 9)
  82. {
  83. level.addMessage("I'm an info block. ");
  84. }
  85. elseif(x == 4 && y == 8)
  86. {
  87. level.setTile(level.getBackgroundIndex(), 4, 7, 3);
  88. }
  89. }
  90. function onAutoInteract(x, y, ent)
  91. {
  92. if(x == 7 && y == 11)
  93. {
  94. entity.setMotionY(ent, tile.scale(-40));
  95. }
  96. elseif(x == 8 && y == 10)
  97. {
  98. //entity.setMotionY(ent, tile.scale(-80));
  99. //entity.addHealth(entity.getHero(), -1);
  100. }
  101. }