You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
3.2 KiB
HTML

4 years ago
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>looking for</title>
<link rel="icon" href="imgs/park/flower2.gif">
<link rel="stylesheet" href="park.css">
</head>
<style>
</style>
<body>
<div id="groundline"></div>
4 years ago
<!--<div id="player_img"></div>-->
4 years ago
<div id="ground">
4 years ago
4 years ago
<div id="player_img"></div>
4 years ago
<img id="bench" src="imgs/park/bench1.gif" height="20%">
<img id="tree1" src="imgs/park/tree1.gif" height="30%">
<img id="tree2" src="imgs/park/tree4.gif" height="25%">
<img id="tree3" src="imgs/park/tree4.gif" height="25%">
<img id="newspaperimg" src="imgs/park/newspaper2.gif" height="7%">
<img id="flower1" src="imgs/park/flower1.gif" height="5%">
<img id="flower2" src="imgs/park/flower3.gif" height="7%">
<img id="flower3" src="imgs/park/flower3.1.gif" height="6%">
<img id="flower4" src="imgs/park/flower1.1.gif" height="5%">
<img id="flower5" src="imgs/park/flower1.gif" height="5%">
<img id="grass1" src="imgs/park/grass1.gif" height="75vw">
<img id="grass2" src="imgs/park/grass1.gif" height="75vw">
4 years ago
</div>
4 years ago
<div class="text_container">
move
</div>
<script src="jquery.min.js"></script>
<script>
4 years ago
// player moves
4 years ago
var $div = $('#player_img');
4 years ago
var screenLeftMin = 0;
var screenLeftMax = 870;
function adjustScroll() {
var playerLeft = parseInt($div.css("left"));
var scrollLeft = $(document).scrollLeft();
var screenLeft = playerLeft - scrollLeft;
console.log ("screenleft:", screenLeft);
if (screenLeft > screenLeftMax ) {
$(document).scrollLeft(playerLeft - screenLeftMax)
}
if (screenLeft < screenLeftMin ) {
$(document).scrollLeft(playerLeft - screenLeftMin)
}
}
4 years ago
4 years ago
$(document).keydown(function(e) {
switch (e.which) {
case 37:
4 years ago
$div.css('left', $div.offset().left - 20);
4 years ago
e.preventDefault();
adjustScroll();
4 years ago
break;
case 38:
4 years ago
$div.css('top', $div.offset().top - 20);
4 years ago
break;
case 39:
4 years ago
$div.css('left', $div.offset().left + 20);
4 years ago
e.preventDefault();
adjustScroll();
4 years ago
break;
case 40:
4 years ago
$div.css('top', $div.offset().top + 20);
4 years ago
break;
}
})
4 years ago
// saves game step in the local storage
window.onload = function() {
window.localStorage.setItem("looking_for_N","opened")
console.log ("looking for N:",localStorage.looking_for_N)
}
//get player avatar from local storage
4 years ago
console.log (localStorage.myavatar)
var img = document.createElement("img");
img.src = localStorage.myavatar;
var player_img = document.querySelector("#player_img");
player_img.appendChild(img);
//get player name from local storage
document.querySelector('#player_name').innerHTML =localStorage.playerName;
</script>
<script type="text/javascript" src="index.js" ></script>
</body>