Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Engine-Objekte (vllt auslagern)
- //->Himmel
- function Sky()
- {
- this.graphicimagepath;
- this.old_graphicimagepath;
- }
- Sky.prototype.setgraphic = function(path)
- {
- this.graphicimagepath = path;
- }
- //------
- //Allgemein
- var framenmbr = 0;
- //old-Variablen
- var old_objectcount = 0;
- old_sky_graphicimagepath = "";
- //Objekte
- var objectcount = 0;
- var object = new Array(500);
- var objectchangeclass = new Array(500);
- var objectchangeaction = new Array(500);
- var objectchangecount = 0;
- //Landschaft
- //->Himmel
- var sky;
- sky = new Sky();
- //------
- //label::init
- function init() //Spiel initialisiern
- {
- initengine();
- setInterval("eachframe()",100);
- }
- function initengine() //Engine initialisiern
- {
- //Default setzen
- sky.setgraphic('../../sky/blue1.jpg');
- }
- //label::objects
- function registerobject(objectclass)
- {
- object[objectcount] = objectclass;
- objectclass.htmlid = 'obj' + objectcount;
- objectclass.code = '<img src="' + objectclass.graphicimagepath + '" style="position: relative; left:' + objectclass.x + 'px;top: ' + objectclass.y + 'px;" alt="Objekt" id="' + objectclass.htmlid + '"/>';
- document.getElementById("main").innerHTML = document.getElementById("main").innerHTML + objectclass.code;
- objectcount++;
- }
- function setposition(objectclass, posx, posy)
- {
- objectclass.x = posx;
- objectclass.y = posy;
- objectchangeclass[objectchangecount] = objectclass;
- objectchangeaction[objectchangecount] = "position";
- objectchangecount++;
- }
- //label::frames
- function eachframe() //Was jeden Frame ausgeführt wird
- {
- update();
- framenmbr = framenmbr + 1;
- document.getElementById("footer").innerHTML = framenmbr;
- }
- //label::update
- function update()
- {
- if (old_sky_graphicimagepath != sky.graphicimagepath)
- {
- document.getElementById("main").style.backgroundImage = 'url(' + sky.graphicimagepath + ')';
- old_sky_graphicimagepath = sky.graphicimagepath;
- }
- while (objectchangecount != 0)
- {
- var objectchangeindex = objectchangecount;
- var tmp_objectchangeclass;
- tmp_objectchangeclass = objectchangeclass[objectchangeindex];
- if (objectchangeaction[objectchangeindex] == "position")
- {
- document.getElementById(objectchangeclass[objectchangeindex].htmlid).style.left = objectchangeclass.x;
- document.getElementById(objectchangeclass[objectchangeindex].htmlid).style.top = objectchangeclass.y;
- alert(objectchangeclass[objectchangeindex].htmlid);
- objectchangecount--;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement