|
|
@ -35,6 +35,7 @@
|
|
|
|
<img id="sport2" src="imgs/park/fitness2.gif" height="70px">
|
|
|
|
<img id="sport2" src="imgs/park/fitness2.gif" height="70px">
|
|
|
|
<img id="newspaper_seller" src="imgs/park/newspaper_seller.gif" height="120px">
|
|
|
|
<img id="newspaper_seller" src="imgs/park/newspaper_seller.gif" height="120px">
|
|
|
|
<img id="woman" src="imgs/park/woman.gif" height="140px">
|
|
|
|
<img id="woman" src="imgs/park/woman.gif" height="140px">
|
|
|
|
|
|
|
|
<img id="flower9" src="imgs/park/flower1.1.gif" height="30px">
|
|
|
|
<img id="dog" src="imgs/park/dog1.gif" height="90px">
|
|
|
|
<img id="dog" src="imgs/park/dog1.gif" height="90px">
|
|
|
|
<img id="ned" src="imgs/park/ned2.gif" height="120px">
|
|
|
|
<img id="ned" src="imgs/park/ned2.gif" height="120px">
|
|
|
|
<img id="grass2" src="imgs/park/grass1.gif" height="90px">
|
|
|
|
<img id="grass2" src="imgs/park/grass1.gif" height="90px">
|
|
|
@ -67,6 +68,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
// player moves
|
|
|
|
// player moves
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//adjust camera scroll
|
|
|
|
var $div = $('#player_img');
|
|
|
|
var $div = $('#player_img');
|
|
|
|
var screenLeftMin = 200;
|
|
|
|
var screenLeftMin = 200;
|
|
|
|
var screenLeftMax = 870;
|
|
|
|
var screenLeftMax = 870;
|
|
|
@ -89,10 +91,36 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//move the character
|
|
|
|
|
|
|
|
|
|
|
|
$(document).keydown(function(e) {
|
|
|
|
$(document).keydown(function(e) {
|
|
|
|
var offset = $div.position();
|
|
|
|
var offset = $div.position();
|
|
|
|
console.log("offset:", offset);
|
|
|
|
console.log("offset:", offset);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// change z-index
|
|
|
|
|
|
|
|
var parent_height = $("#ground").height();
|
|
|
|
|
|
|
|
var top_val_px = $div.css('top');
|
|
|
|
|
|
|
|
var top_val_only = parseInt(top_val_px);
|
|
|
|
|
|
|
|
var top_Percentage = (top_val_only/parent_height) * 100;
|
|
|
|
|
|
|
|
console.log ("top %", top_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) {
|
|
|
|
switch (e.which) {
|
|
|
|
case 37:
|
|
|
|
case 37:
|
|
|
|
offset.left -= 20;
|
|
|
|
offset.left -= 20;
|
|
|
@ -111,7 +139,7 @@ $(document).keydown(function(e) {
|
|
|
|
console.log("down");
|
|
|
|
console.log("down");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//check the offset
|
|
|
|
//check the offset and prevent the character to exceed the screen dimension
|
|
|
|
if (offset.left < 80) {
|
|
|
|
if (offset.left < 80) {
|
|
|
|
offset.left = 80;
|
|
|
|
offset.left = 80;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -135,6 +163,19 @@ $(document).keydown(function(e) {
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* manipulate the z-index of the character
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var offset_percent = offset
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (offset */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// saves game step in the local storage
|
|
|
|
// saves game step in the local storage
|
|
|
|
window.onload = function() {
|
|
|
|
window.onload = function() {
|
|
|
|