create basic paint tile type and some controls for creating paint.

This commit is contained in:
HyperOnion 2023-06-24 12:03:08 +02:00 committed by transoptimal
parent 204075465c
commit 9fd2b0e21b
2 changed files with 19 additions and 1 deletions

View File

@ -45,6 +45,11 @@ export function draw_world (box, start_x = 0, start_y = 0, scale = BASE_SCALE) {
draw_world(tile.box, start_x + visual_x, start_y + visual_y, scale / world.BOX_SIZE);
break;
}
case "paint": {
graphics.set_color(tile.color);
draw_tile(start_x + visual_x, start_y + visual_y, scale);
break;
}
}
});

View File

@ -4,7 +4,7 @@ import * as entity from "./entity.mjs";
const player = entity.create(world.get_root(), 2, 1, "#0f0");
const player = entity.create(world.get_root(), 2, 1, "#080");
@ -35,3 +35,16 @@ on_press(" ", _ => {
export function get_player_box () {
return player.box;
}
function set_painting_key (key, color) {
on_press(key, _ => {
world.set_tile(player.box, player.x, player.y, {
type: "paint",
color,
});
});
}
set_painting_key("q", "#f00");
set_painting_key("w", "#0f0");
set_painting_key("e", "#00f");