ground
parent
2863cfbb47
commit
bd60946c9f
Binary file not shown.
Binary file not shown.
@ -0,0 +1,218 @@
|
||||
<!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>park_dream</title>
|
||||
<link rel="icon" href="imgs/park/flower2.gif">
|
||||
<link rel="stylesheet" href="park.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div id="groundline"></div>
|
||||
|
||||
<div id="ground">
|
||||
<div id="player_img"></div>
|
||||
<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">
|
||||
<img id="statue" src="imgs/park/statue.gif" height="22%">
|
||||
<img id="tree4" src="imgs/park/tree4.gif" height="25%">
|
||||
<img id="flower6" src="imgs/park/flower1.1.gif" height="5%">
|
||||
<img id="flower7" src="imgs/park/flower3.1.gif" height="6%">
|
||||
<img id="flower8" src="imgs/park/flower3.1.gif" height="6%">
|
||||
<img id="dog" src="imgs/park/dog1.gif" height="12%">
|
||||
<img id="tree5" src="imgs/park/tree1.gif" height="30%">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="text_container">
|
||||
<div class="message1">
|
||||
hello
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script src="jquery.min.js"></script>
|
||||
<script>
|
||||
// player moves
|
||||
|
||||
var $div = $('#player_img');
|
||||
var screenLeftMin = 200;
|
||||
var screenLeftMax = 870;
|
||||
var screenTopMin = 202;
|
||||
var screenTopMax = 450;
|
||||
|
||||
function adjustScroll() {
|
||||
var playerLeft = parseInt($div.css("left"));
|
||||
var scrollLeft = $(document).scrollLeft();
|
||||
var screenLeft = playerLeft - scrollLeft;
|
||||
console.log ("screenleft:", screenLeft);
|
||||
|
||||
var playerTop = parseInt($div.css("top"));
|
||||
var scrollTop = $(document).scrollTop();
|
||||
var screenTop = playerTop - scrollTop;
|
||||
console.log ("screentop:", screenTop);
|
||||
|
||||
|
||||
if (screenLeft > screenLeftMax ) {
|
||||
$(document).scrollLeft(playerLeft - screenLeftMax)
|
||||
}
|
||||
|
||||
if (screenLeft < screenLeftMin ) {
|
||||
$(document).scrollLeft(playerLeft - screenLeftMin)
|
||||
}
|
||||
|
||||
|
||||
if (screenTop > screenTopMax ) {
|
||||
$(document).scrollTop(playerTop - screenTopMax)
|
||||
}
|
||||
|
||||
if (screenTop < screenTopMin ) {
|
||||
$(document).scrollTop(playerTop - screenTopMin)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).keydown(function(e) {
|
||||
switch (e.which) {
|
||||
case 37:
|
||||
$div.css('left', $div.offset().left - 20);
|
||||
e.preventDefault();
|
||||
adjustScroll();
|
||||
break;
|
||||
case 38:
|
||||
$div.css('top', $div.offset().top - 20);
|
||||
break;
|
||||
case 39:
|
||||
$div.css('left', $div.offset().left + 20);
|
||||
e.preventDefault();
|
||||
adjustScroll();
|
||||
break;
|
||||
case 40:
|
||||
$div.css('top', $div.offset().top + 20);
|
||||
break;
|
||||
}
|
||||
})
|
||||
//get player avatar from local storage
|
||||
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;
|
||||
|
||||
//store that you've been in the park
|
||||
window.onload = function() {
|
||||
window.localStorage.setItem("park","opened")
|
||||
console.log ("park:",localStorage.park)
|
||||
}
|
||||
// open newspaper
|
||||
|
||||
$(".open_newspaper_index").click (function(){
|
||||
$("#newspaper, .close").toggle();
|
||||
//saves that u opened the newspaper in the local storage
|
||||
window.localStorage.setItem("newspaper","opened")
|
||||
console.log ("newspaper:",localStorage.newspaper)
|
||||
});
|
||||
|
||||
//newspaper pages
|
||||
|
||||
$("#arrow_go1").click (function(){
|
||||
$(".index, .school1, .message1, .message4 ").hide();
|
||||
$(".school2, .school3, #baloon1, #baloon2, .message2").show();
|
||||
});
|
||||
|
||||
$("#arrow_back1").click (function(){
|
||||
$("#baloon1, #baloon2, #baloon3, #baloon4, .school2,.school3, .message2").hide();
|
||||
$(".index, .school1, .message4").show();
|
||||
|
||||
});
|
||||
|
||||
$("#arrow_go2").click (function(){
|
||||
$(".school2").hide();
|
||||
$(".school3").hide();
|
||||
$("#baloon1").hide();
|
||||
$("#baloon2").hide();
|
||||
$(".message2").hide();
|
||||
$(".school4").show();
|
||||
$(".school5").show();
|
||||
$("#baloon3").show();
|
||||
$("#baloon4").show();
|
||||
$(".message3").show();
|
||||
});
|
||||
|
||||
$("#arrow_back2").click (function(){
|
||||
$(".school4").hide();
|
||||
$(".school5").hide();
|
||||
$("#baloon3").hide();
|
||||
$("#baloon4").hide();
|
||||
$(".message3").hide();
|
||||
$(".school2").show();
|
||||
$(".school3").show();
|
||||
$("#baloon1").show();
|
||||
$("#baloon2").show();
|
||||
$(".message2").show();
|
||||
});
|
||||
$("#wait_for_amanda").click (function(){
|
||||
$(".message3").hide();
|
||||
$(".message1").hide();
|
||||
$(".message4").show();
|
||||
});
|
||||
|
||||
$(".close").click (function(){
|
||||
$("#newspaper").hide();
|
||||
$(".close").hide();
|
||||
$("#baloon1").hide();
|
||||
$("#baloon2").hide();
|
||||
$("#baloon3").hide();
|
||||
$("#baloon4").hide();
|
||||
$(".message1").hide();
|
||||
$(".message2").hide();
|
||||
$(".message3").hide();
|
||||
$(".message4").show();
|
||||
});
|
||||
|
||||
$("#fries").click (function(){
|
||||
$("#newspaper, .message4").hide();
|
||||
$(".message5").show();
|
||||
});
|
||||
|
||||
$("#kiosk").click (function(){
|
||||
$(".chat_fries").toggle();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="index.js" ></script>
|
||||
|
||||
</body>
|
Loading…
Reference in New Issue