-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
15 changed files
with
55,069 additions
and
618 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 |
---|---|---|
@@ -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); | ||
}); |
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 |
---|---|---|
@@ -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; | ||
} | ||
} |
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 |
---|---|---|
@@ -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.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.