auts: place tiles

This commit is contained in:
coaljoe 2020-08-22 17:01:22 +03:00
parent 210d5376eb
commit 9c4a9ade7d

View file

@ -17,6 +17,14 @@ fn new_hud() &Hud {
return h
}
fn (mut h Hud) place_tile(tile_id int, cx, cy int) {
f := game.field
if cx < 0 || cx > f.w-1 || cy < 0 || cy > f.h-1 {
return
}
game.field.cells[cx][cy].tile_id = tile_id
}
fn (mut h Hud) draw() {
s := "mx: $h.mx, my: $h.my"
@ -61,4 +69,12 @@ fn (mut h Hud) update(dt f32) {
h.mcx = mcx
h.mcy = mcy
// Draw tiles
key := C.SDLK_SPACE
if ctx.app.is_key_pressed(key) {
// Place tile
h.place_tile(2, h.mcx, h.mcy)
}
}