Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="area" style="position:relative; width:600px; height:200px; border-bottom:1px solid green;border-top:1px solid green;margin-bottom:5px;">
  <div id="arrow" style="position:absolute;top:90px;left:10px;"><img src="http://pinusart.com/images/content/demo/arrow.png" width="79" height="22" alt="" title="" /></div>
  <div id="target" style="position:relative;top:20px;float:right;width:20px;margin-right:30px;"><img src="http://pinusart.com/images/content/demo/girl.png" width="31" height="100" alt="" title="" /></div>
</div>
<form>
  <input type="button" value="Oyunu Başlat" onclick="startGame();" />
  <input type="button" value="Oku Fırlat" onclick="throwArrow();" /><br />
  <input type="button" value="Yukarı" onclick="move('up');" /><br />
  <input type="button" value="Aşağı" onclick="move('down');" />
</form>
              
            
!

CSS

              
                
              
            
!

JS

              
                function startGame() {
  startOk = 1;
  document.getElementById("target").style.top = randomValue(5, 100) + "px";
  changeLoc = setInterval("setReset()", 5000);
}

function move(dir) {
  if (startOk == 1) {
    var arrowLayer = document.getElementById("arrow");
    currentTop = parseInt(arrowLayer.style.top);

    switch (dir) {
      case "up":
        if (currentTop > 5) {
          arrowLayer.style.top = (currentTop - 5) + "px";
        }
        break;
      case "down":
        if (currentTop < 195) {
          arrowLayer.style.top = (currentTop + 5) + "px";
        }
        break;
    }
  }
}

function throwArrow() {
  if (startOk == 1) {
    var arrowLayer = document.getElementById("arrow");
    arrowLayer.style.left = 510 + "px";
    deadAlive();
  }
}

function deadAlive() {
  var arrow = parseInt(document.getElementById("arrow").style.top);
  var girl = parseInt(document.getElementById("target").style.top);
  var difference = arrow - girl;

  if (difference < 3 && difference > -8) {
    alert("Tam isabet");
    stopGame();
  } else if (difference < -9 || difference > 90) {
    alert("Iskaladınız");
    stopGame();
  } else {
    alert("Geçmişler olsun!!! ");
    stopGame();
  }
}

function stopGame() {
  changeLoc = window.clearInterval(changeLoc);
  document.getElementById("arrow").style.left = 10 + "px";
  startOk = 0;
}

function setReset() {
  document.getElementById("arrow").style.left = 10 + "px";
  document.getElementById("target").style.top = randomValue(5, 100) + "px";
}

function randomValue(start, finish) {
  return Math.floor(Math.random() * (finish - start + 1) + start);
}
              
            
!
999px

Console