Skip to content

Commit

Permalink
Fail
Browse files Browse the repository at this point in the history
  • Loading branch information
xvk-64 committed Oct 17, 2020
1 parent b617dd7 commit a55824c
Show file tree
Hide file tree
Showing 15 changed files with 55,069 additions and 618 deletions.
17 changes: 17 additions & 0 deletions dist/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Express = require('express');
const Http = require('http');
const Path = require('path');
const app = Express();
const server = Http.createServer(app);
const APP_PORT = process.env.PORT || 5000;
app.use('/static', Express.static(Path.join(__dirname, 'public')));
app.set('port', APP_PORT);
// Routing
app.get('/', function (request, response) {
response.sendFile(Path.join(__dirname, '/public/index.html'));
});
// Starts the server.
server.listen(APP_PORT, function () {
console.log();
console.log('Starting server on port ' + APP_PORT);
});
37 changes: 37 additions & 0 deletions dist/public/func.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
export class PieceGenerator {
constructor() {
this.pieces = ['I', 'J', 'L', 'O', 'S', 'T', 'Z'];
this.order = [];
this.pool = this.pieces.concat(this.pieces, this.pieces, this.pieces, this.pieces);
}
nextPiece() {
if (!history.length) {
// First piece special conditions
let firstPiece = ['I', 'J', 'L', 'T'][Math.floor(Math.random() * 4)];
this.pieceHistory = ['S', 'Z', 'S', firstPiece];
return firstPiece;
}
let i;
let piece;
// Roll For piece
for (let roll = 0; roll < 6; ++roll) {
i = Math.floor(Math.random() * 35);
piece = this.pool[i];
if (!this.pieceHistory.indexOf(piece) || roll == 5) {
break;
}
if (this.order.length)
this.pool[i] = this.order[0];
}
// Update piece order
if (!this.order.indexOf(piece)) {
this.order.splice(this.order.indexOf(piece), 1);
}
this.order.push(piece);
this.pool[i] = this.order[0];
// Update history
this.pieceHistory.shift();
this.pieceHistory[3] = piece;
return piece;
}
}
26 changes: 26 additions & 0 deletions dist/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<script src="/static/jquery-3.4.1.min.js"></script>
<script type="module" src="/static/math.js"></script>
<script type="module" src="/static/func.js"></script>
<script type="module" src="/static/tetris.js"></script>
<div id="tetrisContainer"></div>
<script type="module">
import {Tetris} from "/static/tetris.js"

jQuery(() => {
for (let i = 0; i < 1; i++) {
new Tetris(false, 1, true);
}
})

</script>
<style>
#tetrisContainer {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.tetris {
margin: 5px;
}

</style>
File renamed without changes.
52,838 changes: 52,838 additions & 0 deletions dist/public/math.js

Large diffs are not rendered by default.

Loading

0 comments on commit a55824c

Please sign in to comment.