Skip to content

Commit 1c192a4

Browse files
Start only on enter, update seed and add paddings (#14)
* chore: start game on enter press * increase seed, add padding, fix gameId generation
1 parent 8484e27 commit 1c192a4

File tree

7 files changed

+11
-8
lines changed

7 files changed

+11
-8
lines changed

client/game/attractMode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class AttractMode extends EventSource implements IGameState {
3434
update(step: number) {
3535
this.currentMode.update(step);
3636

37-
if (Key.isAnyPressed()) {
37+
if (Key.isEnterPressed()) {
3838
if (!this.isStarting) {
3939
this.isStarting = true;
4040
startGame()

client/game/comets.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class Comets {
6464
};
6565

6666
this.attractMode.on("done", () => {
67-
console.log("Done with Attract Mode");
67+
console.log("Start Game");
6868
setGameMode();
6969
});
7070
}

client/game/draw.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ export class Draw {
347347
}
348348

349349
pushStart() {
350-
this.screen.draw.text3("push start", this.screen.font.xlarge, (width) => {
350+
this.screen.draw.text3("Press Enter", this.screen.font.xlarge, (width) => {
351351
return {
352352
x: this.screen.width2 - width / 2,
353353
y: this.screen.height / 8,

client/game/keys.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ export class _Key {
108108
return this.keys[key];
109109
}
110110

111-
isAnyPressed() {
112-
return !!Object.values(this.keys).filter((pressed) => pressed).length;
111+
isEnterPressed() {
112+
return this.keys[13];
113113
}
114114

115115
isRotateLeft() {

client/game/util.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// We use a fixed seed for deterministic behavior
2-
const SEED = 0.69;
2+
const SEED = 0.8;
33

44
export function random(start: number, end: number): number {
55
return Math.floor(SEED * (end - start + 1)) + start;

client/style.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ body {
88
width: 100vw;
99
height: 100vh;
1010
margin: 0;
11-
background-color: #000000;
11+
display: flex;
12+
justify-content: center;
13+
align-items: center;
14+
background-color: #525252;
1215
}
1316

1417
canvas {

rollup/stackr/transitions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type ValidateGameInput = {
1717
const startGame: STF<AppState, ValidateGameInput> = {
1818
handler: ({ state, msgSender, block, emit }) => {
1919
const gameId = hashMessage(
20-
`${msgSender}::${block.timestamp}::${state.games}`
20+
`${msgSender}::${block.timestamp}::${state.games.length}`
2121
);
2222

2323
state.games[gameId] = {

0 commit comments

Comments
 (0)