Skip to content

Commit c1238f0

Browse files
scoreboard init
1 parent 6a5446e commit c1238f0

File tree

3 files changed

+127
-11
lines changed

3 files changed

+127
-11
lines changed

flappyBids.js

+21-11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var endGamePullEndTween;
3939
var endGameCurrentScoreText;
4040
var endGameCurrentBestScoreText;
4141
var canClick = true;
42+
var scoreBoardButton;
4243

4344
var startInfoText;
4445

@@ -56,6 +57,7 @@ function preload() {
5657
game.load.image('click','click_flat.png');
5758
game.load.image('logo','logo.png');
5859
game.load.image('endgame','endgame.png');
60+
game.load.image('sumbit','submit.png');
5961
game.load.audio('s_wall', ['wall.mp3', 'wall.ogg']);
6062
game.load.audio('s_gate', ['gate.mp3', 'gate.ogg']);
6163
game.load.audio('s_jump', ['jump.mp3', 'jump.ogg']);
@@ -105,8 +107,6 @@ function create() {
105107
//walls
106108
gateGroup = game.add.group();
107109

108-
109-
110110
// marvin
111111
marvin = game.add.sprite(0,0,"marvin_gfx");
112112
marvin.anchor.setTo(0.5,0.5);
@@ -132,18 +132,18 @@ function create() {
132132
startInfoText.x = game.width/2;
133133
startInfoText.y = game.height/2;
134134

135-
var title_logo = game.add.sprite(gaps/2+45,gaps/2,"logo");
135+
var title_logo = game.add.sprite(gaps/2+30,gaps/2,"logo");
136136
title_logo.anchor.setTo(0.5,0.5);
137137

138138
var titleStyle = { font: "24px Arial", fill: "#686B7A", align: "left" };
139-
var title_text = game.add.text(100+45,gaps/2,"FLAPPY BIDS",titleStyle);
139+
var title_text = game.add.text(100+10,gaps/2,"FLAPPY BIDS",titleStyle);
140140
title_text.anchor.setTo(0,0.5);
141141

142-
var scoreCounterStyle = { font: "42px Arial", fill: "#00CFB5", align: "center" };
142+
var scoreCounterStyle = { font: "27px Arial", fill: "#00CFB5", align: "center" };
143143
scoreCounter = game.add.text(100+45,gaps/2,"0",scoreCounterStyle);
144144
scoreCounter.x = game.width/2;
145145
scoreCounter.anchor.setTo(0.5,0.5);
146-
scoreCounter.y = 150;
146+
scoreCounter.y = 130;
147147

148148
endGameBannerGroup = game.add.group();
149149
//endGameBannerGroup.anchor.setTo(0.5,0.5);
@@ -154,18 +154,25 @@ function create() {
154154
endGameBannerGroup.add(endGameBanner);
155155

156156
var endGameScoreTextStyle = { font: "18px Arial", fill: "#00CFB5", align: "center" };
157-
endGameCurrentScoreText = game.add.text(0,0,"Current bid: $0.0",endGameScoreTextStyle);
158-
endGameCurrentBestScoreText = game.add.text(0,25,"Highest bid: $0.0",endGameScoreTextStyle);
157+
endGameCurrentScoreText = game.add.text(0,-30,"Current: $0.0",endGameScoreTextStyle);
158+
endGameCurrentBestScoreText = game.add.text(0,-5,"Highest: $0.0",endGameScoreTextStyle);
159159
endGameCurrentScoreText.anchor.setTo(0.5,0.5);
160160
endGameCurrentBestScoreText.anchor.setTo(0.5,0.5);
161161
endGameBannerGroup.add(endGameCurrentScoreText);
162162
endGameBannerGroup.add(endGameCurrentBestScoreText);
163163

164+
scoreBoardButton = game.add.button(0, 35, 'sumbit', onClickScoreboard, this, 0, 0, 0);
165+
scoreBoardButton.anchor.setTo(0.5,0.5);
166+
endGameBannerGroup.add(scoreBoardButton);
164167

165168
resetGame();
166169

167170
}
168171

172+
function onClickScoreboard(){
173+
window.location.href = "/scoreboard.html?s=" + scoreStringFromScore(score);
174+
}
175+
169176
function generateWalls(){
170177

171178
var oldPairs = gatePairs;
@@ -250,14 +257,17 @@ function setScore(_score){
250257
}
251258

252259
scoreCounter.setText(scoreStringFromScore(score));
253-
endGameCurrentScoreText.setText("Current bid: "+scoreStringFromScore(score));
254-
endGameCurrentBestScoreText.setText("Highest bid: "+scoreStringFromScore(bestScore));
260+
endGameCurrentScoreText.setText("Current "+scoreStringFromScore(score));
261+
endGameCurrentBestScoreText.setText("Highest "+scoreStringFromScore(bestScore));
255262
}
256263

257264
function scoreStringFromScore(_score){
258265

266+
//var s = _score+"%";
267+
//return s;
268+
259269
var s = _score/10;
260-
return "$ "+s+(s%1==0?".0":"");
270+
return "ROI: "+s+(s%1==0?".0":"")+"x";
261271
}
262272

263273
function resetMarvin(){

scoreboard.html

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<head>
4+
<title>Flappy Bids!</title>
5+
<style>
6+
body {
7+
margin: 0;
8+
padding: 0;
9+
background-color: #000000;
10+
color:#eee;
11+
font-family:Helvetica, Arial, sans-serif;
12+
}
13+
.btns {
14+
height: 60px;
15+
width:320px;
16+
overflow: hidden;
17+
}
18+
19+
.btns a{
20+
height: 60px;
21+
width: 160px;
22+
float: left;
23+
}
24+
25+
.fb-btn {
26+
background: #999;
27+
}
28+
29+
.tw-btn {
30+
background: #888;
31+
}
32+
33+
.btns-i {
34+
width:400px;
35+
}
36+
37+
</style>
38+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
39+
40+
</head>
41+
<body>
42+
<a href="index.html">Back to Game</a>
43+
<div id="score"></div>
44+
<div class="btns">
45+
<div class="btns-i">
46+
<a class="fb-btn" href="javascript:void(0);"></a>
47+
<a class="tw-btn" href="javascript:void(0);"></a>
48+
</div>
49+
</div>
50+
<div class="stream">
51+
<a class="twitter-timeline" href="https://twitter.com/search?q=%23flappybids" data-widget-id="435820094212435968">Tweets about "#flappybids"</a>
52+
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
53+
</div>
54+
55+
<script type="text/javascript">
56+
function getScore() {
57+
var url = window.location.href;
58+
if(url.indexOf('?s=') >= 0) {
59+
score = url.split('?s=')[1];
60+
document.getElementById('score').innerHTML = 'Your Score: ' + score;
61+
}
62+
}
63+
64+
function bindBtns() {
65+
$(document).on('click', '.tw-btn', function() {
66+
window.open('https://twitter.com/share?url=https%3A%2F%2Fdev.twitter.com%2Fpages%2Ftweet-button', 'TweetWin', 'outerWidth=600,width=500,innerWidth=400,resizable,scrollbars,status');
67+
return false;
68+
});
69+
70+
$(document).on('click', '.fb-btn', function() {
71+
FB.ui(
72+
{
73+
method: 'feed',
74+
name: 'Facebook Dialogs',
75+
link: 'https://developers.facebook.com/docs/dialogs/',
76+
picture: 'http://fbrell.com/f8.jpg',
77+
caption: 'Reference Documentation',
78+
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.'
79+
},
80+
function(response) {
81+
if (response && response.post_id) {
82+
alert('Post was published.');
83+
} else {
84+
alert('Post was not published.');
85+
}
86+
}
87+
);
88+
return false;
89+
});
90+
}
91+
92+
$(document).ready(function() {
93+
bindBtns();
94+
});
95+
96+
getScore();
97+
</script>
98+
<script type="text/javascript">
99+
(function(d){
100+
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
101+
js = d.createElement('script'); js.id = id; js.async = true;
102+
js.src = "//connect.facebook.net/es_LA/all.js";
103+
d.getElementsByTagName('head')[0].appendChild(js);
104+
}(document));</script>
105+
</body>
106+
</html>

submit.png

115 KB
Loading

0 commit comments

Comments
 (0)