-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0dfbd8
commit 8750300
Showing
3 changed files
with
156 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [10.x, 12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
# - run: npm install | ||
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | ||
|
||
name: Node.js CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: [10.x, 12.x, 14.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: npm ci | ||
# - run: npm install | ||
- run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
{ | ||
"build": { | ||
"appId": "net.amitoj.flappytoj", | ||
"productName": "Flappytoj" | ||
}, | ||
"name": "flappytoj", | ||
"version": "1.0.0", | ||
"description": "Simple electron based flappybird ripoff", | ||
"files": [ | ||
"./build/**/*", | ||
"./tsdist/**/*", | ||
"./resources/**/*" | ||
], | ||
"main": "./tsdist/main.js", | ||
|
||
"scripts": { | ||
"build": "tsc", | ||
"watch": "tsc -w", | ||
"lint": "eslint -c .eslintrc --ext .ts ./src", | ||
"start": "npm run build && electron ./tsdist/main.js", | ||
"package": "npm run build && electron-builder -mwl --win portable" | ||
}, | ||
"keywords": [ | ||
"Flappy", | ||
"Amitoj" | ||
], | ||
"author": "Amitoj Singh", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/discord-rpc": "^3.0.4", | ||
"electron": "^11.2.3", | ||
"electron-builder": "^22.9.1" | ||
}, | ||
"dependencies": { | ||
"discord-rpc": "^3.2.0" | ||
} | ||
{ | ||
"build": { | ||
"appId": "net.amitoj.flappytoj", | ||
"productName": "Flappytoj" | ||
}, | ||
"name": "flappytoj", | ||
"version": "1.0.1", | ||
"description": "Simple electron based flappybird ripoff", | ||
"files": [ | ||
"./build/**/*", | ||
"./tsdist/**/*", | ||
"./resources/**/*" | ||
], | ||
"main": "./tsdist/main.js", | ||
|
||
"scripts": { | ||
"build": "tsc", | ||
"watch": "tsc -w", | ||
"lint": "eslint -c .eslintrc --ext .ts ./src", | ||
"start": "npm run build && electron ./tsdist/main.js", | ||
"package": "npm run build && electron-builder -mwl --win portable" | ||
}, | ||
"keywords": [ | ||
"Flappy", | ||
"Amitoj" | ||
], | ||
"author": "Amitoj Singh", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/discord-rpc": "^3.0.4", | ||
"electron": "^11.2.3", | ||
"electron-builder": "^22.9.1" | ||
}, | ||
"dependencies": { | ||
"discord-rpc": "^3.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,93 @@ | ||
let c = document.createElement("canvas"); | ||
c.id = "c"; | ||
c.width = 400; | ||
c.height = 400; | ||
document.body.appendChild(c); | ||
let context = c.getContext("2d"); | ||
|
||
const birds = ['./resources/toj.png', './resources/teg.png', './resources/tesh.png', './resources/deep.png'] | ||
|
||
const bird = new Image(); | ||
bird.src = birds[0]; | ||
|
||
let isRandomising = false; | ||
|
||
let birdX = birdDY = score = bestScore = 0; | ||
let interval = birdSize = pipeWidth = topPipeBottomY = 24; | ||
let birdY = pipeGap = 200; | ||
let canvasSize = pipeX = 400; | ||
let paused = false; | ||
|
||
if (localStorage.getItem('bestScore')) { | ||
bestScore = localStorage.getItem('bestScore'); | ||
} | ||
localStorage.setItem("bestScore", bestScore); | ||
|
||
c.onclick = () => (birdDY = 9); | ||
document.body.onkeyup = function(e) { | ||
if (e.keyCode == 32) { | ||
birdDY = 9 | ||
} | ||
if (e.key === "Escape") { | ||
paused = paused ? false : true; | ||
} | ||
} | ||
|
||
let gameloop = setInterval(() => { | ||
if (!paused) { | ||
//bg | ||
context.fillStyle = "skyblue"; | ||
context.fillRect(0, 0, canvasSize, canvasSize); | ||
|
||
//gravity | ||
birdY -= birdDY -= 0.5; | ||
|
||
//bird | ||
context.drawImage(bird, birdX, birdY, birdSize * (524 / 374), birdSize); | ||
|
||
//pipes | ||
context.fillStyle = "green"; | ||
pipeX -= 8; | ||
pipeX < -pipeWidth && | ||
((pipeX = canvasSize), (topPipeBottomY = pipeGap * Math.random())); | ||
context.fillRect(pipeX, 0, pipeWidth, topPipeBottomY); | ||
context.fillRect(pipeX, topPipeBottomY + pipeGap, pipeWidth, canvasSize); | ||
|
||
//scores | ||
score++; | ||
context.fillStyle = "black"; | ||
context.fillText(`Current: ${score}`, 8, 25); | ||
bestScore = bestScore < score ? score : bestScore; | ||
localStorage.setItem('bestScore', bestScore); | ||
context.fillText(`Best: ${bestScore}`, 8, 50); | ||
|
||
//bird death logic | ||
(((birdY < topPipeBottomY || birdY > topPipeBottomY + pipeGap) && pipeX < birdSize * (524 / 374)) || | ||
birdY > canvasSize) && | ||
((birdDY = 0), (birdY = 200), (pipeX = canvasSize), (score = 0)); | ||
|
||
if (score > 10000 && score < 11000) { | ||
if (!isRandomising) { | ||
randomiseBird(); | ||
isRandomising = true; | ||
} | ||
} | ||
} | ||
}, interval); | ||
|
||
|
||
function randomiseBird() { | ||
let interval = setInterval(() => { | ||
if (isRandomising) { | ||
let random = Math.floor(Math.random() * birds.length); | ||
bird.src = birds[random]; | ||
} else { | ||
normaliseBird(); | ||
clearInterval(interval); | ||
} | ||
}, 5000); | ||
} | ||
|
||
function normaliseBird() { | ||
bird.src = birds[0]; | ||
let c = document.createElement("canvas"); | ||
c.id = "c"; | ||
c.width = 400; | ||
c.height = 400; | ||
document.body.appendChild(c); | ||
let context = c.getContext("2d"); | ||
|
||
const birds = ['./resources/toj.png', './resources/teg.png', './resources/tesh.png', './resources/deep.png'] | ||
|
||
const bird = new Image(); | ||
bird.src = birds[0]; | ||
|
||
let isRandomising = false; | ||
|
||
let birdX = birdDY = score = bestScore = 0; | ||
let interval = birdSize = pipeWidth = topPipeBottomY = 24; | ||
let birdY = pipeGap = 200; | ||
let canvasSize = pipeX = 400; | ||
let paused = false; | ||
|
||
if (localStorage.getItem('bestScore')) { | ||
bestScore = localStorage.getItem('bestScore'); | ||
} | ||
localStorage.setItem("bestScore", bestScore); | ||
|
||
c.onclick = () => (birdDY = 9); | ||
document.body.onkeyup = function(e) { | ||
if (e.keyCode == 32) { | ||
birdDY = 9 | ||
} | ||
if (e.key === "Escape") { | ||
paused = paused ? false : true; | ||
} | ||
} | ||
|
||
let gameloop = setInterval(() => { | ||
if (!paused) { | ||
//bg | ||
context.fillStyle = "skyblue"; | ||
context.fillRect(0, 0, canvasSize, canvasSize); | ||
|
||
//gravity | ||
birdY -= birdDY -= 0.5; | ||
|
||
//bird | ||
context.drawImage(bird, birdX, birdY, birdSize * (524 / 374), birdSize); | ||
|
||
//pipes | ||
context.fillStyle = "green"; | ||
pipeX -= 8; | ||
pipeX < -pipeWidth && | ||
((pipeX = canvasSize), (topPipeBottomY = pipeGap * Math.random())); | ||
context.fillRect(pipeX, 0, pipeWidth, topPipeBottomY); | ||
context.fillRect(pipeX, topPipeBottomY + pipeGap, pipeWidth, canvasSize); | ||
|
||
//scores | ||
score++; | ||
context.fillStyle = "black"; | ||
context.fillText(`Current: ${score}`, 8, 25); | ||
bestScore = bestScore < score ? score : bestScore; | ||
localStorage.setItem('bestScore', bestScore); | ||
context.fillText(`Best: ${bestScore}`, 8, 50); | ||
|
||
//bird death logic | ||
(((birdY < topPipeBottomY || birdY > topPipeBottomY + pipeGap) && pipeX < birdSize * (524 / 374)) || | ||
birdY > canvasSize) && | ||
((birdDY = 0), (birdY = 200), (pipeX = canvasSize), (score = 0)); | ||
|
||
if (score > 10000 && score < 11000) { | ||
if (!isRandomising) { | ||
randomiseBird(); | ||
isRandomising = true; | ||
} | ||
} | ||
} | ||
}, interval); | ||
|
||
|
||
function randomiseBird() { | ||
let interval = setInterval(() => { | ||
if (isRandomising) { | ||
let random = Math.floor(Math.random() * birds.length); | ||
bird.src = birds[random]; | ||
} else { | ||
normaliseBird(); | ||
clearInterval(interval); | ||
} | ||
}, 5000); | ||
} | ||
|
||
function normaliseBird() { | ||
bird.src = birds[0]; | ||
} |