Skip to content

Commit

Permalink
Updated game
Browse files Browse the repository at this point in the history
  • Loading branch information
noelking committed Apr 24, 2013
1 parent 7e227b2 commit 981558a
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 36 deletions.
Binary file modified penaltyshootout/.DS_Store
Binary file not shown.
Binary file modified penaltyshootout/007 Scoring and celebrating/.DS_Store
Binary file not shown.
Binary file not shown.
21 changes: 12 additions & 9 deletions penaltyshootout/007 Scoring and celebrating/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>

<div id="computerScoreDiv">
<h3>COMPUTER</h3>
<div id="computerScore">0</div>
</div>
<div id="playerScoreDiv">
<h3>YOU</h3>
<div id="playerScore">0</div>
</div>


<div id="sky">
</div>

Expand Down Expand Up @@ -42,22 +53,14 @@
<img src="roo-fly.png"/>
</div>

<div id="computerScoreDiv">
<h3>COMPUTER</h3>
<span id="computerScore">0</span>
</div>
<div id="playerScoreDiv">
<h3>YOU</h3>
<span id="playerScore">0</span>
</div>

<div id="pitch">
<div id="keepersBox">
</div>

<div id="arrowDiv">
<img id="arrowImage" src="arrowdown.png"/>
</div>

</div>


Expand Down
65 changes: 55 additions & 10 deletions penaltyshootout/007 Scoring and celebrating/penaltyshootout.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ function handleKey(e) {
rooneyStart();
} else if(keyCode == 38) { // up arrow
kickPoint();
rooneyStart();
} else if(keyCode == 40) { //down arrow
kickGoal();
rooneyStart();
}
}



//keeper variables
var keeper;
var keeperWidth=100;
var keeperWidth=120;

var goalWidth;
var leftMovePixels=1;
Expand All @@ -52,6 +52,13 @@ var topStopPoint = goalTop;

var arrowImage;

// Scoring
var computerScore = 0;
var playerScore = 0;
var computerScoreDiv;
var playerScoreDiv;

var rooneyTakingPenalty;

function setup() {

Expand All @@ -72,9 +79,18 @@ function setupVariables() {
rooneyKick = $("#rooneyKick");
arrowImage = $("#arrowImage");
rooneyFly = $("#rooneyCelebrate");
computerScoreDiv = $("#computerScore");
playerScoreDiv = $("#playerScore");
}

function commenceGame() {
rooney.css('display', 'block');
rooneyKick.hide();
rooneyFly.hide();

rooneyKicking = false;

penaltySetup();
setupHtmlPositions();
startKeeper();
}
Expand All @@ -84,7 +100,7 @@ function setupHtmlPositions() {
keeper.css('top','0px');
keeper.css('left','0px');
ball.css('left','175px');

rooneyFly.css('left', '50%');
rooneyFly.css('top',rooney.css('top'));

Expand All @@ -98,7 +114,7 @@ function startKeeper() {

function moveKeeper() {
var currentPosition = parseInt(keeper.css('left'));
console.log(currentPosition);
// console.log(currentPosition);
// new after show problem
var maxRightPosition = goalWidth - keeperWidth;

Expand Down Expand Up @@ -137,10 +153,12 @@ function jumpKeeper() {
}

function rooneyStart() {
rooney.css('display', 'block');

penaltySetup();
rooneyRun();
if(!rooneyKicking) {
rooneyKicking = true;
rooney.css('display', 'block');
rooneyRun();
}
}

function penaltySetup() {
Expand Down Expand Up @@ -215,9 +233,26 @@ function save() {
rooneyKick.hide();
rooneyCelebrate();

if ( isGoal() ) {
playerScore = playerScore + 3; // playerScore += 3;
} else {
playerScore = playerScore + 1; // playerScore += 1;
}

} else {
alert('Saved');
if ( isGoal() ) {
computerScore = computerScore + 3;
} else {
computerScore = computerScore + 1;
}
}
updateScores();
setTimeout(commenceGame,2000);
}

function updateScores() {
computerScoreDiv.html(computerScore);
playerScoreDiv.html(playerScore);
}

function isScored(keeperLeft, keeperRight,
Expand Down Expand Up @@ -275,11 +310,21 @@ function rooneyCelebrate() {
fly();
}

function isGoal() {
if (topStopPoint == goalTop) {
return true;
} else {
return false;
}
}

function fly() {
var rooneyFlyLeft = parseInt(rooneyFly.css('left'));
if(rooneyFlyLeft != 0) {
if(rooneyFlyLeft > 0) {
var newRooneyFlyLeft = rooneyFlyLeft - 5;
rooneyFly.css('left', newRooneyFlyLeft+'px');
setTimeout(fly, 2);
} else {
rooneyFly.hide();
}
}
34 changes: 17 additions & 17 deletions penaltyshootout/007 Scoring and celebrating/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ div#ball {
position: absolute;
top: 500px;
width: 50px;
z-index: 100;
}

img {
Expand Down Expand Up @@ -114,30 +115,29 @@ div#rooneyCelebrate {
position: absolute;
}



#computerScoreDiv{
left: 20px;
text-align: center;
div#computerScoreDiv
{
left: 20px;
text-align: center;
}

#playerScoreDiv
div#playerScoreDiv
{
right: 20px;
text-align: center;
right: 20px;
text-align: center;
}

#computerScoreDiv,#playerScoreDiv
{
position: absolute;
bottom: 20px;
color: #FFF;
width: 200px;
opacity: .8;
font-size: 100px
position: absolute;
bottom: 20px;
color: #FFF;
width: 200px;
opacity: .8;
font-size: 100px;
}

h3 {
margin: 0px;
font-size: 25px;
}
margin: 0px;
font-size: 25px;
}

0 comments on commit 981558a

Please sign in to comment.