auts/isotest/wall.v

72 lines
1.1 KiB
V

module main
struct Wall {
mut:
obj &Obj // Embed
// Map obj
//cx int
//cy int
h int
view &WallView
}
fn new_wall() &Wall {
println("new_wall()")
w := &Wall{
obj: new_obj(),
h: 6, // units/tiles/steps?
view: &WallView(0),
}
return w
}
//fn (mut w Wall) place_at_check(cx, cy int) ?string {
fn (mut w Wall) place_at_check(cx, cy int) ? {
//fn (mut w Wall) place_at_check(cx, cy int) err {
mut c := game.field.get_cell(cx, cy)
if !c.open {
println("return error")
return error("can't place wall: cell is not open: cx: $cx, cy: $cy")
}
w.obj.set_cx(cx)
w.obj.set_cy(cy)
//mut c := &game.field.cells[cx][cy]
//mut c := game.field.get_cell(cx, cy)
c.wall = w
c.open = false
println("return none")
return none
}
fn (mut w Wall) place_at(cx, cy int) {
println("wall place_at: cx: $cx, cy: $cy")
w.place_at_check(cx, cy) or {
println("err:")
println(err)
println(isnil(err))
panic(err)
return
}
}
fn (mut w Wall) spawn() {
println("wall spawn()")
w.view = new_wallview(w)
w.view.spawn()
}
fn (mut w Wall) update(dt f32) {
}