Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added co.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions coins.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<html>

<head>
<title>Collect Coins Game</title>
<style>
#container {
width: 1300px;
height: 700px;
position: relative;
background: gray;
}
#player {
width: 100px;
height: 150px;
position: absolute;
background-color: red;
}
#coin1 {
width: 50px;
height: 50px;
position:absolute;
background-color: yellow;
}
#coin2 {
width: 30px;
height: 50px;
position:absolute;
background-color: yellow;
}

</style>

</head>
<body>
<input type="button" id="btn1" value="Play">
<p id="score"></p>

<div id ="container">
<h2 align="center" > Score : <p id="demo">0</p> <h2>
<div id ="player"> </div>
<div id ="coin1"> </div>
<div id ="coin2"> </div>
</div>

<script type="text/javascript" src="coins.js"></script>

</body>
</html>
100 changes: 100 additions & 0 deletions coins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@

var btn=document.getElementById('btn1')

var container = document.getElementById("container");
container.style.width=innerWidth;
container.style.height=innerHeight;


var player = document.getElementById("player");
var coin1 = document.getElementById("coin1");
var coin2 = document.getElementById("coin2");

var score=0;


document.getElementById('demo').innerHTML = score;




//document.getElementById('score').textcontent='gogo'



player.style.top=innerHeight-150+'px';
coin1.style.right=1+'px';
coin1.style.top=innerHeight-200+'px';
coin1.style.height=70+'px';

coin2.style.right=50+'px';

player.style.width=100+'px';



var playerposition=player.style.width; //return string
var ppos='';

var i=0;
while(playerposition[i] != 'p')
{
ppos += playerposition[i]
i++;
}


//console.log('coin width',pcoin1);
console.log("player width ",ppos);
console.log("inner width",innerWidth);

console.log("collision position",innerWidth - ppos )

console.log(score);

var coll=innerWidth - ppos -45
console.log(coll)
var move = function ()
{


var pos =0;
var pos2=0

// var flag=false
var id = setInterval(frame, 3);

function frame()
{
console.log(pos);
console.log(score);


//console.log(coin1.style.right,"coin",innerWidth - player.style.width +"player")
document.getElementById('demo').innerHTML = score;
if (pos == coll) {
clearInterval(id);
//document.getElementById('demo').innerHTML = score;
score++;

pos=0
pos2=0
// alert('b')
id = setInterval(frame, 3);

} else {
pos++;
pos2++;
coin1.style.right=pos + 'px';
coin2.style.right=pos2 + 'px';

}


}

}

btn.addEventListener('click',move);


Binary file added imgs/Thumbs.db
Binary file not shown.
Binary file added imgs/co.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/co.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/ground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/obs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/penguin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions newbegin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#main{
width: 750px;
height: 500px;
position: relative;
margin: auto;
border-width: 5px;
border-style: solid;
overflow: hidden;
size: fixed;

}

.footer{
position: absolute;
/* bottom: 0px;
width: 750px;
height: 70px;*/
z-index: -1;

}

/*#footerdiv2{
right: -750px;
}*/

.obs{
position: absolute;
/* bottom: 30px;
right: -100px;
width: 100px;
height: 100px;*/
z-index: -2;
}

.imgindiv{
width: 100%;
height: 100%;
}
21 changes: 21 additions & 0 deletions newbegin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Keyframe Animation Demo</title>
</head>
<body>
<div id="main">
<h2 align="center" > Score : <p id="demo"></p> <h2>
<h2 align="center" > Player Name : <p id="pname"></p> <h2>
<!-- <div id="footerdiv1" class="footer"><img id="footerimg" class="imgindiv" src="imgs/ground.png"></div>
<div id="footerdiv2" class="footer"><img id="footerimg" class="imgindiv" src="imgs/ground.png"></div> -->
<!-- <div id="obsdiv" class="obs"><img id="obsimg" class="imgindiv" src="imgs/obs.png"></div> -->

</div>

<script type="text/javascript" src="newbegin.js"></script>
<link rel="stylesheet" type="text/css" href="newbegin.css">

</body>
</html>
Loading