PHP gevorderde |
|
Oké, hier komtiern[code]htmlrnheadrntitleTiteltitlernSCRIPT LANGUAGE='JavaScript'rn!--rnvar move=false;rnrnfunction rechts() {rn player.style.posLeft+=2; rn}rnfunction omlaag() {rn player.style.posTop+=2;rn}rnfunction omhoog() {rn player.style.posTop-=2;rn}rnfunction links() {rn player.style.posLeft-=2;rn}rnrnfunction checkArrows (field, evt) {rn var keyCode = rn document.layers evt.which rn document.all event.keyCode rn document.getElementById evt.keyCode 0;rn if (keyCode == 39){ rechtsrn if (move==false) {rn playerint=setInterval('rechts()',1); onUnLoad=clearInterval;rn move=true;rn }rn }rn else if (keyCode == 40){ omlaagrn if (move==false) {rn playerint=setInterval('omlaag()',1); onUnLoad=clearInterval;rn move=true;rn }rn }rn else if (keyCode == 38){ omhoogrn if (move==false) {rn playerint=setInterval('omhoog()',1); onUnLoad=clearInterval;rn move=true;rn }rn }rn else if (keyCode == 37){ linksrn if (move==false) {rn playerint=setInterval('links()',1); onUnLoad=clearInterval;rn move=true;rn }rn }rn return true;rn}rnrnfunction stop() {rn move=false;rn clearInterval(playerint);rn}rnwindow.status = 'Titel';rn--rnSCRIPTrnHEADrnBODY ONKEYDOWN='return checkArrows(this, event)' ONKEYUP='stop()'rndivimg id='player' src='pacman.gif' style='positionabsolute; left20; top20;'divrndivimg id='wall' src='wall.gif' style='positionabsolute; left200; top200;'divrnbodyhtml[code]rnDit script laat het divje 'player' bewegen op de pijltjestoetsen.rnMaar nu wil ik hebben dat je niet kan bewegen als er het divje 'muur' voor staat. Logisch, tochp |