create basic paint tile type and some controls for creating paint.
This commit is contained in:
parent
204075465c
commit
9fd2b0e21b
|
@ -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);
|
draw_world(tile.box, start_x + visual_x, start_y + visual_y, scale / world.BOX_SIZE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "paint": {
|
||||||
|
graphics.set_color(tile.color);
|
||||||
|
draw_tile(start_x + visual_x, start_y + visual_y, scale);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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 () {
|
export function get_player_box () {
|
||||||
return 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");
|
||||||
|
|
Loading…
Reference in New Issue