Add validation position char, active img with url
This commit is contained in:
parent
1139e4f39c
commit
94cc78de19
0
._.DS_Store
Executable file → Normal file
0
._.DS_Store
Executable file → Normal file
2
css/style.css
Executable file → Normal file
2
css/style.css
Executable file → Normal file
@ -8,8 +8,6 @@
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------Icon CSS high-resolution-------------------------------------*/
|
||||
|
||||
|
||||
/*-----------------------Character CSS high-resolution--------------------------------*/
|
||||
|
||||
|
0
fonts/ARCADE.TTF
Executable file → Normal file
0
fonts/ARCADE.TTF
Executable file → Normal file
0
fonts/monaco.ttf
Executable file → Normal file
0
fonts/monaco.ttf
Executable file → Normal file
0
icons/.DS_Store
vendored
Executable file → Normal file
0
icons/.DS_Store
vendored
Executable file → Normal file
0
icons/._.DS_Store
Executable file → Normal file
0
icons/._.DS_Store
Executable file → Normal file
2
index.html
Executable file → Normal file
2
index.html
Executable file → Normal file
@ -15,7 +15,7 @@
|
||||
<body>
|
||||
<h1>PLAY && LEARN</h1>
|
||||
<div id="game-container"></div>
|
||||
<a href="page1.html" class="active">
|
||||
<a href="page1.html" class="not-active">
|
||||
<div id="police-building" class="building"><img src="img/006-police.png"></div>
|
||||
</a>
|
||||
<a href="page1.html" class="active">
|
||||
|
19
js/script.js
Executable file → Normal file
19
js/script.js
Executable file → Normal file
@ -13,6 +13,24 @@ $(document).ready(function() {
|
||||
$("#char-pupil-right").attr('id','char-pupil-right-move');
|
||||
$("#char-arm-left").attr('id','char-arm-left-up');
|
||||
$("#char-arm-right").attr('id','char-arm-right-up');
|
||||
var positionCharXCornerLeft = $('#char-container').offset().left;
|
||||
var positionCharYCornerLeft = $('#char-container').offset().top;
|
||||
var positionCharXRightCorner = $('#char-container').offset().left + $('#char-container').innerWidth();
|
||||
var positionCharYRightCorner = $('#char-container').offset().top + $('#char-container').innerHeight();
|
||||
|
||||
//https://stackoverflow.com/questions/8872578/if-element-is-over-another-element
|
||||
//uproscic kod(funkcje/zmienne);
|
||||
var positionXPoliceBuildingCornerLeft = $('#police-building').offset().left;
|
||||
var positionYPoliceBuildingCornerLeft = $('#police-building').offset().top;
|
||||
var positionXPoliceBuildingCornerRight = $('#police-building').offset().left + $('#police-building').innerWidth();
|
||||
var positionYPoliceBuildingCornerRight = $('#police-building').offset().top + $('#police-building').innerHeight();
|
||||
if(positionXPoliceBuildingCornerRight>positionCharXCornerLeft && positionYPoliceBuildingCornerRight>positionCharYCornerLeft &&
|
||||
positionXPoliceBuildingCornerLeft<positionCharXRightCorner &&
|
||||
positionYPoliceBuildingCornerLeft<positionCharYRightCorner){
|
||||
console.log('jestem na policji');
|
||||
$('#police-building').parent().attr('class', 'active');
|
||||
}
|
||||
|
||||
}
|
||||
if(e.which == 38){
|
||||
$("#char-arm-left-up").attr('id','char-arm-left');
|
||||
@ -46,4 +64,5 @@ $(document).ready(function() {
|
||||
$("#char-arm-right").attr('id','char-arm-right-up');
|
||||
}
|
||||
})
|
||||
|
||||
});
|
Loading…
Reference in New Issue
Block a user