whar?
This commit is contained in:
parent
1c29cce71b
commit
d34b072fcd
|
@ -282,7 +282,10 @@ void main() async {
|
|||
int rot = 0;
|
||||
bool spinWasLastMove = false;
|
||||
Coords coords = Coords(3, 21);
|
||||
double gravityBucket = 0.00000000000000;
|
||||
double lockDelay = 30; // frames
|
||||
int lockResets = 15;
|
||||
bool floored = false;
|
||||
double gravityBucket = 1.0;
|
||||
|
||||
developer.log("Seed is ${replay.stats[0][0].seed}, first bag is $queue");
|
||||
Tetromino current = queue.removeAt(0);
|
||||
|
@ -305,6 +308,10 @@ void main() async {
|
|||
}
|
||||
//developer.log("Next queue is $queue");
|
||||
rot = 0;
|
||||
lockResets = 15;
|
||||
lockDelay = 30;
|
||||
floored = false;
|
||||
gravityBucket = 1.0;
|
||||
return queue.removeAt(0);
|
||||
}
|
||||
|
||||
|
@ -322,77 +329,7 @@ void main() async {
|
|||
return false;
|
||||
}
|
||||
|
||||
void handleGravity(double frames){
|
||||
if (frames == 0) return;
|
||||
gravityBucket += settings != null ? (handling!.sdfActive ? settings.g! * settings.handling!.sdf : settings.g!) * frames : 0;
|
||||
int gravityImpact = 0;
|
||||
if (gravityBucket >= 1.0){
|
||||
gravityImpact = gravityBucket.truncate();
|
||||
gravityBucket -= gravityBucket.truncate();
|
||||
}
|
||||
while (gravityImpact > 0){
|
||||
if (board.positionIsValid(current, Coords(coords.x, coords.y-1), rot)) coords.y -= 1;
|
||||
gravityImpact--;
|
||||
}
|
||||
}
|
||||
|
||||
void handleMovement(double frames){
|
||||
if (frames == 0 || handling == null) return;
|
||||
int movement = handling.processMovenent(frames);
|
||||
while (movement.abs() > 0){
|
||||
if (board.positionIsValid(current, Coords(movement.isNegative ? coords.x-1 : coords.x+1, coords.y), rot)) movement.isNegative ? coords.x-- : coords.x++;
|
||||
movement.isNegative ? movement++ : movement--;
|
||||
}
|
||||
}
|
||||
|
||||
coords += spawnPositionFixes[current.index];
|
||||
for (currentFrame; currentFrame <= replay.roundLengths[0]; currentFrame++){
|
||||
handleMovement(1-subframesWent);
|
||||
handleGravity(1-subframesWent);
|
||||
subframesWent = 0;
|
||||
|
||||
if (settings?.handling?.sdf == 41) coords.y = sonicDrop();
|
||||
print("$currentFrame: $current at $coords\n$board");
|
||||
//print(stats.combo);
|
||||
if (currentFrame == nextEvent.frame){
|
||||
while (currentFrame == nextEvent.frame){
|
||||
print("Processing $nextEvent");
|
||||
switch (nextEvent.type){
|
||||
case EventType.start:
|
||||
developer.log("go");
|
||||
break;
|
||||
case EventType.full:
|
||||
settings = (nextEvent as EventFull).data.options;
|
||||
handling = HandlingHandler(settings!.handling!.das.toDouble(), settings.handling!.arr.toDouble());
|
||||
print(handling);
|
||||
break;
|
||||
case EventType.keydown:
|
||||
nextEvent as EventKeyPress;
|
||||
double subframesDiff = nextEvent.data.subframe - subframesWent;
|
||||
subframesWent += subframesDiff;
|
||||
handleMovement(subframesDiff);
|
||||
handleGravity(subframesDiff);
|
||||
//activeKeypresses[nextEvent.data.key] = nextEvent;
|
||||
switch (nextEvent.data.key){
|
||||
case KeyType.rotateCCW:
|
||||
handleRotation(-1);
|
||||
break;
|
||||
case KeyType.rotateCW:
|
||||
handleRotation(1);
|
||||
break;
|
||||
case KeyType.rotate180:
|
||||
handleRotation(2);
|
||||
break;
|
||||
case KeyType.moveLeft:
|
||||
case KeyType.moveRight:
|
||||
int pontencialMovement = handling!.movementKeyPressed(nextEvent.data.key == KeyType.moveLeft, nextEvent.data.key == KeyType.moveRight, nextEvent.data.subframe);
|
||||
if (board.positionIsValid(current, Coords(coords.x+pontencialMovement, coords.y), rot)) coords.x += pontencialMovement;
|
||||
break;
|
||||
case KeyType.softDrop:
|
||||
handling!.sdfActive = true;
|
||||
break;
|
||||
case KeyType.hardDrop:
|
||||
coords.y = sonicDrop();
|
||||
void handleHardDrop(){
|
||||
board.writeToBoard(current, coords, rot);
|
||||
bool tspin = board.wasATSpin(current, coords, rot);
|
||||
LineClearResult lineClear = stats.processLineClear(board.clearFullLines(), current, coords, spinWasLastMove, tspin);
|
||||
|
@ -430,6 +367,86 @@ void main() async {
|
|||
}
|
||||
current = getNewOne();
|
||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||
}
|
||||
|
||||
void handleGravity(double frames){
|
||||
if (frames == 0) return;
|
||||
gravityBucket += settings != null ? (handling!.sdfActive ? max(settings.g! * settings.handling!.sdf, 0.05 * settings.handling!.sdf) : settings.g!) * frames : 0;
|
||||
int gravityImpact = 0;
|
||||
if (gravityBucket >= 1.0){
|
||||
gravityImpact = gravityBucket.truncate();
|
||||
gravityBucket -= gravityBucket.truncate();
|
||||
}
|
||||
while (gravityImpact > 0){
|
||||
if (board.positionIsValid(current, Coords(coords.x, coords.y-1), rot)) {coords.y -= 1; floored = false;}
|
||||
else floored = true;
|
||||
gravityImpact--;
|
||||
}
|
||||
if (floored) lockDelay -= frames;
|
||||
if (lockDelay <= 0 && floored){
|
||||
handleHardDrop();
|
||||
}
|
||||
}
|
||||
|
||||
void handleMovement(double frames){
|
||||
if (frames == 0 || handling == null) return;
|
||||
int movement = handling.processMovenent(frames);
|
||||
while (movement.abs() > 0){
|
||||
if (board.positionIsValid(current, Coords(movement.isNegative ? coords.x-1 : coords.x+1, coords.y), rot)) movement.isNegative ? coords.x-- : coords.x++;
|
||||
movement.isNegative ? movement++ : movement--;
|
||||
}
|
||||
}
|
||||
|
||||
coords += spawnPositionFixes[current.index];
|
||||
for (currentFrame; currentFrame <= replay.roundLengths[0]; currentFrame++){
|
||||
handleMovement(1-subframesWent);
|
||||
handleGravity(1-subframesWent);
|
||||
subframesWent = 0;
|
||||
|
||||
if (settings?.handling?.sdf == 41) coords.y = sonicDrop();
|
||||
print("$currentFrame: $current at $coords\n$board");
|
||||
//print(stats.combo);
|
||||
if (currentFrame == nextEvent.frame){
|
||||
while (currentFrame == nextEvent.frame){
|
||||
print("Processing $nextEvent");
|
||||
switch (nextEvent.type){
|
||||
case EventType.start:
|
||||
developer.log("go");
|
||||
break;
|
||||
case EventType.full:
|
||||
settings = (nextEvent as EventFull).data.options;
|
||||
handling = HandlingHandler(settings!.handling!.das.toDouble(), settings.handling!.arr.toDouble());
|
||||
lockDelay = settings.locktime!.toDouble();
|
||||
lockResets = settings.lockresets!;
|
||||
break;
|
||||
case EventType.keydown:
|
||||
nextEvent as EventKeyPress;
|
||||
double subframesDiff = nextEvent.data.subframe - subframesWent;
|
||||
subframesWent += subframesDiff;
|
||||
handleMovement(subframesDiff);
|
||||
handleGravity(subframesDiff);
|
||||
//activeKeypresses[nextEvent.data.key] = nextEvent;
|
||||
switch (nextEvent.data.key){
|
||||
case KeyType.rotateCCW:
|
||||
handleRotation(-1);
|
||||
break;
|
||||
case KeyType.rotateCW:
|
||||
handleRotation(1);
|
||||
break;
|
||||
case KeyType.rotate180:
|
||||
handleRotation(2);
|
||||
break;
|
||||
case KeyType.moveLeft:
|
||||
case KeyType.moveRight:
|
||||
int pontencialMovement = handling!.movementKeyPressed(nextEvent.data.key == KeyType.moveLeft, nextEvent.data.key == KeyType.moveRight, nextEvent.data.subframe);
|
||||
if (board.positionIsValid(current, Coords(coords.x+pontencialMovement, coords.y), rot)) coords.x += pontencialMovement;
|
||||
break;
|
||||
case KeyType.softDrop:
|
||||
handling!.sdfActive = true;
|
||||
break;
|
||||
case KeyType.hardDrop:
|
||||
coords.y = sonicDrop();
|
||||
handleHardDrop();
|
||||
case KeyType.hold:
|
||||
switch (hold){
|
||||
case null:
|
||||
|
@ -441,10 +458,14 @@ void main() async {
|
|||
temp = hold;
|
||||
hold = current;
|
||||
current = temp;
|
||||
rot = 0;
|
||||
lockResets = 15;
|
||||
lockDelay = 30;
|
||||
gravityBucket = 1.0;
|
||||
floored = false;
|
||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||
break;
|
||||
}
|
||||
rot = 0;
|
||||
coords = Coords(3, 21) + spawnPositionFixes[current.index];
|
||||
break;
|
||||
case KeyType.chat:
|
||||
// TODO: Handle this case.
|
||||
|
|
|
@ -80,6 +80,9 @@
|
|||
font-weight: 500;
|
||||
font-style: normal;
|
||||
}
|
||||
a{
|
||||
color: aqua;
|
||||
}
|
||||
#preloader{
|
||||
display: flex;
|
||||
width: fit-content;
|
||||
|
@ -111,6 +114,15 @@
|
|||
padding-top: 8px;
|
||||
animation: 1s cubic-bezier(.46,.03,.52,.96) infinite alternate breathing;
|
||||
}
|
||||
.error{
|
||||
color: red;
|
||||
}
|
||||
#tip{
|
||||
position: absolute;
|
||||
bottom: 5%;
|
||||
color: gray;
|
||||
text-align: center;
|
||||
}
|
||||
@media (max-width: 502px){
|
||||
#preloader{
|
||||
flex-direction: column;
|
||||
|
@ -130,10 +142,25 @@
|
|||
<p id="progress">Loading...</p>
|
||||
</div>
|
||||
</div>
|
||||
<p id="tip"></p>
|
||||
<script>
|
||||
window.addEventListener('load', function(ev) {
|
||||
let progress = document.querySelector("#progress");
|
||||
let preloader = document.querySelector("#preloader");
|
||||
let tip = document.querySelector("#tip");
|
||||
const tips = [
|
||||
// Promoting Tetra Stats "native"
|
||||
"Want a better perfomance?<br><a href=\"ya.ru\">Try out Tetra Stats Native</a>",
|
||||
"Imagine a world, where Tetra Stats was written in JS",
|
||||
"Welcome to fullscreen canvas",
|
||||
|
||||
// An actual tips
|
||||
"You can interact with most objects that have an accent color",
|
||||
"Like Sheetbot graphs? Go to three dots menu → Settings → Customization",
|
||||
"Click and hold on line chart graph, then start dragging to zoom in"
|
||||
];
|
||||
tip.innerHTML = tips[Math.floor(Math.random() * tips.length)];
|
||||
try{
|
||||
// Download main.dart.js
|
||||
_flutter.loader.loadEntrypoint({
|
||||
serviceWorker: {
|
||||
|
@ -141,12 +168,17 @@
|
|||
},
|
||||
onEntrypointLoaded: async function(engineInitializer) {
|
||||
console.log(serviceWorkerVersion);
|
||||
let appRunner = await engineInitializer.initializeEngine();
|
||||
progress.innerHTML = "Booting...";
|
||||
let appRunner = await engineInitializer.initializeEngine();
|
||||
await appRunner.runApp();
|
||||
preloader.classList.add("hidden");
|
||||
}
|
||||
});
|
||||
} catch (e){
|
||||
progress.classList.add("error");
|
||||
document.getAnimations()[0].cancel();
|
||||
progress.innerHTML = "fuck: "+e;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue