main.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This script is the main entry point of the game
  2. require("AtomicGame");
  3. Atomic.game.init(start, update);
  4. // called at the start of play
  5. function start() {
  6. var game = Atomic.game;
  7. // create a 2D scene
  8. game.createScene3D();
  9. var scene = game.scene;
  10. // zone
  11. var zoneNode = scene.createChild("Zone")
  12. var zone = zoneNode.createComponent("Zone");
  13. zone.boundingBox = [-1000, -1000, -1000, 1000, 1000 , 1000];
  14. zone.ambientColor = [0.35, 0.35, 0.35];
  15. zone.fogColor = [0.1, 0.1, 0.1, 1.0];
  16. zone.fogStart = 10;
  17. zone.fogEnd = 100;
  18. game.cameraNode.position = [0, 2.5, -6];
  19. game.cameraNode.pitch(20);
  20. var lightNode = scene.createChild("Directional Light");
  21. lightNode.direction = [0.6, -1.0, 0.8];
  22. var light = lightNode.createComponent("Light")
  23. light.lightType = Atomic.LIGHT_DIRECTIONAL;
  24. light.castShadows = true;
  25. // If we're running on android tweak the shadows
  26. if (Atomic.platform == "Android") {
  27. light.setShadowCascade(20.0, 50.0, 200.0, 0.0, 0.9);
  28. light.shadowIntensity = 0.33;
  29. } else {
  30. light.setShadowCascade(10.0, 50.0, 200.0, 0.0, 0.8);
  31. }
  32. light.setShadowBias(0.00025, 0.5);
  33. light.specularIntensity = 8;
  34. // create the game component
  35. var node = game.scene.createChild("Roboman");
  36. TheRoboman = node.createJSComponent("Roboman");
  37. var ui = game.scene.createChild("UI");
  38. ui.createJSComponent("UI");
  39. }
  40. // called per frame
  41. function update(timeStep) {
  42. }