1
0
Fork 0

auts: work on world

This commit is contained in:
coaljoe 2020-04-30 12:32:03 +03:00
parent 0adc284a9d
commit 7ff3a55cd1
3 changed files with 64 additions and 0 deletions

17
elems.v
View File

@ -1,8 +1,25 @@
module main
enum ElemType {
none_, // None/Empty
//// Primary form
wood, sand, stone, coal, clay,
// Liquid
water, oil,
// Gas(?)
vapour, methane,
// Extra(?)
biomass,
//// Secondary form
glass, concrete, brick
}
struct Elem {
mut:
name string
elem_type ElemType
density int // XXX per bit?
flameable bool

19
main.v
View File

@ -5,6 +5,7 @@ fn main() {
mut e := new_elem()
e.name = "wood"
e.elem_type = .wood
e.density = 100
e.flameable = true
_ = e
@ -13,16 +14,19 @@ fn main() {
mut e2 := new_elem()
e2.name = "sand"
e2.elem_type = .sand
e2.density = 2000
println("e2: ${e2}")
mut e3 := new_elem()
e3.name = "glass"
e3.elem_type = .glass
e3.density = 2200
mut e4 := new_elem()
e4.name = "stone"
e4.elem_type = .stone
e4.density = 8000
//
@ -91,5 +95,20 @@ fn main() {
//ob.elem.generic_processor0.process(ob)
//e4.generic_processor0.process(ob)
//
// World
//
w := new_world()
b1 := Bit{
elem_type: .wood,
}
w.bits[0][0] = b1
println("w b1: ${w.bits[0][0]}")
println("w 1 0: ${w.bits[1][0]}")
println("done")
}

28
world.v Normal file
View File

@ -0,0 +1,28 @@
module main
// World bit
// size: 50x50x50cm (?)
struct Bit {
mut:
elem_type ElemType
}
struct CompoundBit {
mut:
elem1_type ElemType
elem1_amt i8
elem2_type ElemType
elem2_amt i8
}
struct World {
mut:
//bits [][][]Bit
//bits [10][10][10]Bit
bits [10][10]Bit // 2d (only surface bits)
}
fn new_world() &World {
w := &World{}
return w
}