Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <link rel="icon" href="miniatura.png">
- <title>Fat Runner</title>
- <style type="text/css">
- #pAContainer{
- width:1000px;
- height:800px;
- border:1px solid black;
- position:relative;
- top:10px;
- }
- #pASky{
- position:relative;
- height:38em;
- background:#aad2f1;
- overflow:hidden;
- }
- #pACh{
- position:absolute;
- height:32px;
- width:20px;
- bottom:0px;
- display:block;
- z-index:9;
- }
- #pAGround{
- position:relative;
- height:12em;
- top:0%;
- background:#99d299;
- overflow:hidden;
- }
- #pACloudArea{
- position:relative;
- clear:both;
- height:400px;
- width:100%;
- overflow:hidden;
- }
- *{
- margin:0;
- padding:0;
- }
- #gMenu{
- opacity:1;
- z-index:10;
- position:absolute;
- height:100%;
- width:100%;
- background-image: url('bG.png');
- text-align:center;
- }
- .gMOption{
- height:10%;
- font-size:75px;
- margin-left:auto;
- margin-right:auto;
- width:30%;
- margin-top:5%;
- border:1px solid black;
- padding:20px;
- box-shadow:4px 4px 10px black;
- }
- .gMOption:hover{
- cursor:pointer;
- background-color:rgba(255,255,255,0.3);
- transition-duration:1s;
- }
- #gH2Pwindow{
- display:none;
- position:relative;
- top:-155px;
- left:600px;
- height:250%;
- width:80%;
- background-color: rgba(255, 255, 255, 0.5);
- padding:2px;
- }
- #gH2P:hover > #gH2Pwindow{
- display:block;
- box-shadow:4px 4px 10px black;
- font-size:21px;
- }
- #logoBar{
- height:210px;
- width:840px;
- position:relative;
- margin-left:auto;
- margin-right:auto;
- top:10px;
- }
- #logoBar:hover{
- cursor:pointer;
- }
- </style>
- </head>
- <body>
- <!-- MENU -->
- <div id='gMenu'>
- <a href="#"><img src='logoV2.png' id='logoBar'/></a>
- <div id='gAButon' class='gMOption' onclick='menu();game();'>Graj</div>
- <div id='gH2P' class='gMOption'>Jak grać?
- <div id='gH2Pwindow'>W <font color="#79e279">Fat Runner</font> <span style="vertical-align:super;font-size:15px;">®</span> wczuwasz się w gnębionego przez szkolnych kolegów grubasa.
- Twoim zadaniem jest unikać głów swoich prześladowców spadających z nieba.<br>
- <strong>Sterowanie:</strong><br>
- A lub strzałka w lewo - <strong>Poruszanie w lewo </strong><br>
- D lub strzałka w prawo - <strong>Poruszanie w prawo</strong>
- </div>
- </div>
- <div id='qGame' class='gMOption' onclick='quitGame()'>Wyjdź z gry</div>
- </div>
- <!-- POLE GRY -->
- <div id="pAContainer" style="margin-left:300px;">
- <div id="pASky">
- <div id="pACloudArea">
- </div>
- <img src="char01.png" id="pACh" >
- </div>
- <div id="pAGround">
- </div>
- </div>
- <script>
- function quitGame(){
- if(confirm('Jesteś pewny?')){
- window.close();
- }
- }
- function menu(){
- document.getElementById('gMenu').style.opacity = '0';
- document.getElementById('gMenu').style.transitionDuration = '1s';
- setTimeout('document.getElementById("gMenu").style.display = "none";',1000)
- }
- //////////////////CHARACTER CONTROL/////////////////////
- var poziomo = 480;
- var x = document.getElementById('pACh');
- document.body.onkeydown = function lol(e){
- if((e.keyCode == 68 || e.keyCode == 39) && (x.style.left != '980px')){
- poziomo += 10;
- x.style.left = poziomo + 'px';
- x.src='char02rdir01.png';
- if(poziomo%20==0){
- x.src='char03rdir0201.png';
- }
- }
- if((e.keyCode == 65 || e.keyCode == 37) && (x.style.left != '0px')){
- poziomo -= 10;
- x.style.left = poziomo + 'px';
- x.src='char02ldir01.png';
- if(poziomo%20==0){
- x.src='char03ldir0201.png';
- }
- }
- }
- document.getElementById('pACh').style.left = poziomo + 'px';
- ////////////////////GENERATE ENVIRONMENT/////////////////////////////////
- //var pos_x = Math.floor((Math.random()*1000)+301);
- //var pos_y = Math.floor((Math.random()*400)+1);
- //alert(pos_x + ':' + pos_y);
- window.onload = chmurki;
- function chmurki(){
- var clouds = Math.floor((Math.random()*10)+1);
- for(var i = 0; i<clouds;i++){
- var pos_x = Math.floor((Math.random()*1000)-130);
- var pos_y = Math.floor((Math.random()*300)+1);
- var ccount = document.createElement('IMG');
- ccount.src = 'clouds.png';
- ccount.style.height = '100px';
- ccount.style.width= '150px';
- ccount.style.position = 'absolute';
- ccount.style.display = 'block';
- ccount.style.zIndex = '3';
- ccount.setAttribute('class', 'chmury');
- ccount.style.left = pos_x + 'px';
- ccount.style.top = pos_y + 'px';
- document.getElementById('pACloudArea').appendChild(ccount);
- }
- kamykiitrawa();
- }
- function kamykiitrawa(){
- var stones = Math.floor((Math.random()*3)+1);
- var thots = Math.floor((Math.random()*14)+1);
- for(var i = 0; i<stones;i++){
- var pos_x = Math.floor((Math.random()*1000)-130);
- var pos_y = Math.floor((Math.random()*190)+1);
- var kcount = document.createElement('IMG');
- kcount.src = 'stone.png';
- kcount.id = 'kamien' + i;
- kcount.style.height = '50px';
- kcount.style.width= '90px';
- kcount.style.position = 'absolute';
- kcount.style.zIndex = '2';
- kcount.style.display = 'block';
- kcount.style.left = pos_x + 'px';
- kcount.style.top = pos_y + 'px';
- document.getElementById('pAGround').appendChild(kcount);
- var kamyk = document.getElementById('kamien' + i);
- }
- for(var i = 0; i<thots;i++){
- var pos_x = Math.floor((Math.random()*1000)-130);
- var pos_y = Math.floor((Math.random()*190)-10);
- var tcount = document.createElement('IMG');
- tcount.src = 'tuft.png';
- tcount.id='trawa' + i;
- tcount.setAttribute('class' , 'grass');
- tcount.style.height = '75px';
- tcount.style.zIndex = '1';
- tcount.style.width= '55px';
- tcount.style.position = 'absolute';
- tcount.style.display = 'block';
- tcount.style.left = pos_x + 'px';
- tcount.style.top = pos_y + 'px';
- document.getElementById('pAGround').appendChild(tcount);
- var trawka = document.getElementById('trawa' + i);
- }
- if(trawka.style.top < kamyk.style.top){
- tcount.style.zIndex = '2';
- kcount.style.zIndex = '1';
- }
- falowanie();
- }
- var wavePoint = 0;
- function falowanie(){
- wavePoint+=1;
- setTimeout('falowanie()', 500);
- var z = document.getElementsByClassName('chmury');
- var x = document.getElementsByClassName('grass');
- var y = x.length;
- var w = z.length;
- for(var i = 0; i<y;i++){
- if(i%2==0){
- if(x[i].style.transform == 'rotateY(15deg)'){
- x[i].style.transform = 'rotateY(-25deg)';
- }
- else{x[i].style.transform = 'rotateY(15deg)';};
- }
- else{
- if(x[i].style.transform == 'rotateY(-25deg)'){
- x[i].style.transform = 'rotateY(15deg)';
- }
- else{x[i].style.transform = 'rotateY(-25deg)';}
- }
- }
- for(var i=0; i<w;i++){
- if(i%2==0){
- if(z[i].style.transform == 'rotateX(0deg)'){
- z[i].style.transform = 'rotateX(-15deg)';
- }
- else{z[i].style.transform = 'rotateX(0deg)';};
- }
- else{
- if(z[i].style.transform == 'rotateX(-15deg)'){
- z[i].style.transform = 'rotateX(0deg)';
- }
- else{z[i].style.transform = 'rotateX(-15deg)';}
- }
- }
- }
- //////////////////////////GAME MECHANISMS/////////////////////////////
- var poziom = 1;
- var eCount = poziom * 10;
- var pos_y = 600;
- function game(){
- document.getElementById('gAButon').onclick = '';
- for(var i=0;i<eCount;i++){
- var pos_x = Math.floor((Math.random()*(100)+0))*10;
- var enemyFace = document.createElement('IMG');
- var faceNumber = Math.floor((Math.random()*6)+1);
- enemyFace.src = 'face' + faceNumber+'.jpg';
- enemyFace.style.position = 'absolute';
- enemyFace.style.display = 'block';
- enemyFace.style.height = '20px';
- enemyFace.style.width = '20px';
- enemyFace.setAttribute('class' , 'enemies');
- enemyFace.style.left = pos_x + 'px';
- enemyFace.style.bottom = pos_y + 'px';
- document.getElementById('pASky').appendChild(enemyFace);
- }
- setTimeout(function(){
- var elo = 0;
- var chX = document.getElementById('pACh').style;
- var x = document.getElementsByClassName('enemies');
- var z = x.length;
- for(var i = z-1;i>0;i--){ //problem dotyczy tej pętli.
- //tworzenie zdjęć i ich wysokosci
- if(x[i].style.bottom > '0px'){ //
- x[i].style.transitionDuration = '0.3s';
- x[i].id = 'fejs'+i;
- x[i].style.bottom = pos_y+elo+'px';
- elo-=20;
- //document.querySelector('#fejs'+i).style.bottom = pos_y+elo + 'px';
- //document.getElementById('pASky').childNodes[i].style.bottom = elo+'px';
- }
- //
- //zderzenie z graczem - koniec gry ;d
- if((chX.left==x[i].style.left)&&(x[i].style.bottom=='0px')){
- alert('siema');
- }
- //spadnięcie na ziemię
- if(x[i].style.bottom<='0px'){ //
- if(x[i] && x[i].parentElement){
- x[i].parentElement.removeChild(x[i]);
- }
- }
- } //
- game();
- },300);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement