|
|
|
<!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>spring river</title>
|
|
|
|
<link rel="icon" href="imgs/park/tree4.gif"">
|
|
|
|
<link rel="stylesheet" href="spring_river.css">
|
|
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="ground_color" class="invert"></div>
|
|
|
|
|
|
|
|
<div id="groundline" class="invert"></div>
|
|
|
|
|
|
|
|
<div class="army">
|
|
|
|
<div id="player_img" ></div>
|
|
|
|
<img id="fighter1" src="imgs/spring_river/fighter1.gif" height="120px">
|
|
|
|
<img id="fighter2" src="imgs/spring_river/fighter2.gif" height="120px">
|
|
|
|
<img id="fighter3" src="imgs/spring_river/fighter3.gif" height="120px">
|
|
|
|
<img id="fighter4" src="imgs/spring_river/fighter4.gif" height="120px">
|
|
|
|
<img id="fighter5" src="imgs/spring_river/fighter5.gif" height="120px">
|
|
|
|
<img id="fighter6" src="imgs/spring_river/fighter6.gif" height="160px">
|
|
|
|
<img id="fighter7" src="imgs/spring_river/fighter7.gif" height="120px">
|
|
|
|
<img id="fighter8" src="imgs/spring_river/fighter8.gif" height="120px">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="ground">
|
|
|
|
|
|
|
|
<img id="tree1" src="imgs/spring_river/tree4.gif" height="160px">
|
|
|
|
<img id="tree2" src="imgs/spring_river/tree4.gif" height="160px">
|
|
|
|
<img id="tree3" src="imgs/spring_river/tree4.gif" height="160px">
|
|
|
|
<img id="tree4" src="imgs/spring_river/tree4.gif" height="160px">
|
|
|
|
<img id="tree5" src="imgs/spring_river/tree4.gif" height="160px">
|
|
|
|
<img id="tree6" src="imgs/spring_river/tree4.gif" height="160px">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="text_container invert" >
|
|
|
|
|
|
|
|
<div class="message1">
|
|
|
|
You and your army arrived at the Spring River Natural Park.<br>
|
|
|
|
<span class="instructions"><span class="instructions_arrow">→</span> Move with the right arrow to find the children!</span>
|
|
|
|
</div>
|
|
|
|
<div class="message2" style="display: none;">
|
|
|
|
</div>
|
|
|
|
<div class="message3" style="display: none;">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script src="jquery.min.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
// saves game step in the local storage
|
|
|
|
window.onload = function() {
|
|
|
|
window.localStorage.setItem("spring_river","opened");
|
|
|
|
console.log ("spring river:",localStorage.spring_river);
|
|
|
|
}
|
|
|
|
|
|
|
|
//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);
|
|
|
|
|
|
|
|
|
|
|
|
//adjust camera scroll
|
|
|
|
var $div = $('.army');
|
|
|
|
var screenLeftMin = 100;
|
|
|
|
var screenLeftMax = 780;
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//move the character
|
|
|
|
|
|
|
|
$(document).keydown(function(e) {
|
|
|
|
var offset = $div.position();
|
|
|
|
console.log("offset:", offset);
|
|
|
|
|
|
|
|
// change z-index
|
|
|
|
var parent_width = $("#ground").width();
|
|
|
|
var left_val_px = $div.css('left');
|
|
|
|
var left_val_only = parseInt(left_val_px);
|
|
|
|
var left_Percentage = (left_val_only/parent_width) * 100;
|
|
|
|
console.log ("left %", left_Percentage);
|
|
|
|
/*
|
|
|
|
if (top_Percentage > 65) {
|
|
|
|
$div.css ("zIndex", 5)
|
|
|
|
}
|
|
|
|
if (top_Percentage < 55 && top_Percentage > 39) {
|
|
|
|
$div.css ("zIndex", 4)
|
|
|
|
}
|
|
|
|
if (top_Percentage < 39) {
|
|
|
|
$div.css ("zIndex", 1)
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (e.which) {
|
|
|
|
case 37:
|
|
|
|
offset.left -= 20;
|
|
|
|
console.log("left");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 39:
|
|
|
|
offset.left += 20;
|
|
|
|
console.log("right");
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
//check the offset and prevent the character to exceed the screen dimension
|
|
|
|
if (offset.left < 80) {
|
|
|
|
offset.left = 80;
|
|
|
|
}
|
|
|
|
if (offset.left > $("#ground").width() - 250) {
|
|
|
|
offset.left = $("#ground").width() - 250;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$div.css("left", offset.left);
|
|
|
|
$div.css("top", offset.top);
|
|
|
|
e.preventDefault();
|
|
|
|
adjustScroll();
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript" src="index.js" ></script>
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|