up arrow and spacebar in flappy bird

This commit is contained in:
MonkeyGG2
2023-12-03 20:23:35 -05:00
parent 780b5b10cc
commit 68c6aaa152
5 changed files with 94 additions and 12207 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ gulp.task 'coffee', ->
.pipe gulp.dest 'tmp'
gulp.task 'concat', ->
gulp.src ['bower_components/phaser/phaser.js', 'tmp/index.js']
gulp.src ['bower_components/phaser/build/phaser.js', 'tmp/index.js']
.pipe concat('index.min.js')
.pipe uglify()
.pipe gulp.dest '.'
+12 -6
View File
@@ -45,6 +45,9 @@ githubHtml = """<iframe src="http://ghbtns.com/github-btn.html?user=hyspace&repo
floor = Math.floor
up = null
spacebar = null
main = ->
spawntube = (openPos, flipped) ->
tube = null
@@ -133,12 +136,6 @@ main = ->
# Stop spawning tubes
game.time.events.remove(tubesTimer)
# Make bird reset the game
game.time.events.add 1000, ->
game.input.onTap.addOnce ->
reset()
swooshSnd.play()
hurtSnd.play()
return
@@ -152,6 +149,9 @@ main = ->
tween.onComplete.add ->
bird.body.gravity.y = GRAVITY
flapSnd.play()
if gameOver
reset()
swooshSnd.play()
return
preload = ->
@@ -283,6 +283,12 @@ main = ->
swooshSnd = game.add.audio("swoosh")
# Add controls
up = game.input.keyboard.addKey(Phaser.Keyboard.UP)
spacebar = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR)
# Add listeners
up.onDown.add flap
spacebar.onDown.add flap
game.input.onDown.add flap
# RESET!
+38 -55
View File
@@ -1,58 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async="" src="https://www.googletagmanager.com/gtag/js?id=G-7L02W3ZMS5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-7L02W3ZMS5');
</script>
<title>Flappy Bird HTML5</title>
<meta content="width=device-width" name="viewport"/>
<style>
body{
margin: 0;
padding: 0;
height: 100%;
background: #000;
}
#screen canvas{
margin: 0 auto;
}
#github{
position:absolute;
bottom: 5px;
right:5px;
}
#loading{
position: absolute;
font-family: "Verdana";
width: 100%;
text-align: center;
color: white;
font-size: 24px;
top: 50%;
}
</style>
</head>
<body>
<div id="loading">Loading...</div>
<div id="screen"></div>
<div id="github"></div>
<script src="index.min.js?v=02131824"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
if(document.domain === 'hyspace.io'){
ga('create', 'UA-21699184-3', 'hyspace.io');
ga('send', 'pageview');
}
</script>
</body></html>
<head>
<title>Flappy Bird HTML5</title>
<meta content="width=device-width" name="viewport" />
<style>
body {
margin: 0;
padding: 0;
height: 100%;
background: #000;
}
#screen canvas {
margin: 0 auto;
}
#github {
position: absolute;
bottom: 5px;
right: 5px;
}
#loading {
position: absolute;
font-family: 'Verdana';
width: 100%;
text-align: center;
color: white;
font-size: 24px;
top: 50%;
}
</style>
</head>
<body>
<div id="loading">
Loading...<br />If you are using up arrow please click or press spacebar to enable audio.
</div>
<div id="screen"></div>
<div id="github"></div>
<script src="index.min.js"></script>
</body>
</html>
+13 -12115
View File
File diff suppressed because one or more lines are too long
+30 -30
View File
@@ -1,32 +1,32 @@
{
"name": "flappy",
"version": "0.0.1",
"description": "flappy bird in html5",
"devDependencies": {
"gulp": "~3.5.2",
"coffee-script": "~1.7.1",
"gulp-coffee": "~1.4.1",
"gulp-util": "~2.2.14",
"gulp-connect": "~0.3.1",
"gulp-uglify": "~0.2.1",
"gulp-concat": "~2.1.7"
},
"scripts": {
"start": "./node_modules/.bin/gulp --require coffee-script/register"
},
"repository": {
"type": "git",
"url": "https://github.com/hyspace/flappy"
},
"keywords": [
"game",
"flappy",
"bird"
],
"author": "shan zhou <hyspace@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/hyspace/flappy/issues"
},
"homepage": "https://github.com/hyspace/flappy"
"name": "flappy",
"version": "0.0.1",
"description": "flappy bird in html5",
"devDependencies": {
"gulp": "~3.5.2",
"coffee-script": "~1.7.1",
"gulp-coffee": "~1.4.1",
"gulp-util": "~2.2.14",
"gulp-connect": "~0.3.1",
"gulp-uglify": "~0.2.1",
"gulp-concat": "~2.1.7"
},
"scripts": {
"start": "./node_modules/.bin/gulp --require coffee-script/register"
},
"repository": {
"type": "git",
"url": "https://github.com/hyspace/flappy"
},
"keywords": [
"game",
"flappy",
"bird"
],
"author": "shan zhou <hyspace@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/hyspace/flappy/issues"
},
"homepage": "https://github.com/hyspace/flappy"
}