40 lines
572 B
V
40 lines
572 B
V
module main
|
|
|
|
struct Obj {
|
|
mut:
|
|
name string
|
|
x int
|
|
y int
|
|
}
|
|
|
|
fn new_obj() &Obj {
|
|
o := &Obj{}
|
|
|
|
return o
|
|
}
|
|
|
|
fn (o &Obj) cx() int {
|
|
return o.x / c_cell_w
|
|
}
|
|
|
|
fn (mut o Obj) set_cx(cx int) {
|
|
//o.x = cx * c_cell_w
|
|
//x1, y1 := cell_to_world_pos(cx, o.cy())
|
|
x1, y1 := cell_to_world_pos_center(cx, o.cy())
|
|
o.x = x1 // XXX fixme?
|
|
o.y = y1
|
|
}
|
|
|
|
fn (o &Obj) cy() int {
|
|
return o.y / c_cell_h
|
|
}
|
|
|
|
fn (mut o Obj) set_cy(cy int) {
|
|
//o.y = cy * c_cell_h
|
|
//x1, y1 := cell_to_world_pos(o.cx(), cy)
|
|
x1, y1 := cell_to_world_pos_center(o.cx(), cy)
|
|
o.x = x1 // XXX fixme?
|
|
o.y = y1
|
|
}
|
|
|