Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Engine-Objekte (vllt auslagern)
  2.  
  3. //->Himmel
  4. function Sky()
  5. {
  6. this.graphicimagepath;
  7. this.old_graphicimagepath;
  8. }
  9.  
  10. Sky.prototype.setgraphic = function(path)
  11. {
  12. this.graphicimagepath = path;
  13. }
  14.  
  15. //------
  16.  
  17. //Allgemein
  18. var framenmbr = 0;
  19.  
  20. //old-Variablen
  21.  
  22. var old_objectcount = 0;
  23. old_sky_graphicimagepath = "";
  24.  
  25. //Objekte
  26. var objectcount = 0;
  27. var object = new Array(500);
  28. var objectchangeclass = new Array(500);
  29. var objectchangeaction = new Array(500);
  30. var objectchangecount = 0;
  31.  
  32. //Landschaft
  33.  
  34. //->Himmel
  35. var sky;
  36. sky = new Sky();
  37.  
  38. //------
  39.  
  40. //label::init
  41.  
  42. function init() //Spiel initialisiern
  43. {
  44. initengine();
  45. setInterval("eachframe()",100);
  46. }
  47.  
  48. function initengine() //Engine initialisiern
  49. {
  50. //Default setzen
  51. sky.setgraphic('../../sky/blue1.jpg');
  52. }
  53.  
  54. //label::objects
  55.  
  56. function registerobject(objectclass)
  57. {
  58. object[objectcount] = objectclass;
  59. objectclass.htmlid = 'obj' + objectcount;
  60. objectclass.code = '<img src="' + objectclass.graphicimagepath + '" style="position: relative; left:' + objectclass.x + 'px;top: ' + objectclass.y + 'px;" alt="Objekt" id="' + objectclass.htmlid + '"/>';
  61. document.getElementById("main").innerHTML = document.getElementById("main").innerHTML + objectclass.code;
  62. objectcount++;
  63. }
  64.  
  65. function setposition(objectclass, posx, posy)
  66. {
  67. objectclass.x = posx;
  68. objectclass.y = posy;
  69. objectchangeclass[objectchangecount] = objectclass;
  70. objectchangeaction[objectchangecount] = "position";
  71. objectchangecount++;
  72. }
  73.  
  74. //label::frames
  75.  
  76. function eachframe() //Was jeden Frame ausgeführt wird
  77. {
  78. update();
  79. framenmbr = framenmbr + 1;
  80. document.getElementById("footer").innerHTML = framenmbr;
  81. }
  82.  
  83. //label::update
  84.  
  85. function update()
  86. {
  87. if (old_sky_graphicimagepath != sky.graphicimagepath)
  88. {
  89. document.getElementById("main").style.backgroundImage = 'url(' + sky.graphicimagepath + ')';
  90. old_sky_graphicimagepath = sky.graphicimagepath;
  91. }
  92.  
  93. while (objectchangecount != 0)
  94. {
  95. var objectchangeindex = objectchangecount;
  96. var tmp_objectchangeclass;
  97. tmp_objectchangeclass = objectchangeclass[objectchangeindex];
  98. if (objectchangeaction[objectchangeindex] == "position")
  99. {
  100. document.getElementById(objectchangeclass[objectchangeindex].htmlid).style.left = objectchangeclass.x;
  101. document.getElementById(objectchangeclass[objectchangeindex].htmlid).style.top = objectchangeclass.y;
  102. alert(objectchangeclass[objectchangeindex].htmlid);
  103. objectchangecount--;
  104. }
  105. }
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement