Browse Source

Merge branch 'master' of git.indy.io:indy/tetris

master
Inderjit Gill 1 year ago
parent
commit
42268beba1
3 changed files with 15 additions and 13 deletions
  1. +6
    -4
      src/game.rs
  2. +5
    -5
      src/lib.rs
  3. +4
    -4
      web/js/index.js

+ 6
- 4
src/game.rs View File

@@ -259,17 +259,19 @@ impl Game {
geometry.push(0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0);
render_board(geometry, &self.board, &self.board_offset);

let x = 21;
let y = 16;
if let Ok(c) = get_colour_from_hsl(0.0,
self.colour_saturation,
self.colour_lightness) {
render_score(geometry, self.score, Block2D { x: 19, y: 24 }, c);
render_level(geometry, self.level, Block2D { x: 19, y: 20 }, c);
render_lines(geometry, self.lines, Block2D { x: 19, y: 16 }, c);
render_score(geometry, self.score, Block2D { x, y: y + 8 }, c);
render_level(geometry, self.level, Block2D { x, y: y + 4 }, c);
render_lines(geometry, self.lines, Block2D { x, y }, c);
}
if let Some(shape) = self.shapes.get(&self.next_piece_shape) {
render_next_shape(geometry,
&shape,
Block2D { x: 19, y: 10 },
Block2D { x, y: y - 6 },
self.next_piece_colour);
}
}

+ 5
- 5
src/lib.rs View File

@@ -83,17 +83,17 @@ impl Config {
#[wasm_bindgen(constructor)]
pub fn new() -> Config {
Config {
canvas_width: 480,
canvas_height: 480,
block_size: 30,
canvas_width: 512,
canvas_height: 512,
block_size: 32,
tileset_texture_width: 0, // tileset texture width
tileset_texture_height: 0, // tileset texture height
sprite_width: 16,
sprite_height: 16,
colour_saturation: 99.0,
colour_lightness: 50.0,
board_offset_x: 5,
board_offset_y: 5,
board_offset_x: 7,
board_offset_y: 6,
default_cooldown: 100.0,
board_width: 10,
board_height: 20,

+ 4
- 4
web/js/index.js View File

@@ -57,10 +57,10 @@ window.reconfigure = reconfigure;
window.config = gState.config;

function main() {
gState.config.canvas_width = 480;
gState.config.canvas_height = 480;
gState.config.block_size = 30; // how many blocks fit along a dimension
// 480 / 30 = 16 (the size of each block in pixels)
gState.config.canvas_width = 512;
gState.config.canvas_height = 512;
gState.config.block_size = 32; // how many blocks fit along a dimension
// 512 / 32 = 16 (the size of each block in pixels)

// the size of each sprite in the tileset (in pixels)
gState.config.sprite_width = 16;

Loading…
Cancel
Save