Skip to content

Commit

Permalink
new release
Browse files Browse the repository at this point in the history
  • Loading branch information
amitojsingh366 committed Feb 13, 2021
1 parent e0dfbd8 commit 8750300
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 156 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/node.js.yml
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
72 changes: 36 additions & 36 deletions package.json
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"
}
}
184 changes: 92 additions & 92 deletions resources/flappytoj.js
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];
}

0 comments on commit 8750300

Please sign in to comment.