auts: tile tweaks
This commit is contained in:
parent
8e426fbb60
commit
4d31bc870c
|
@ -4,14 +4,17 @@ struct Field {
|
|||
mut:
|
||||
w int
|
||||
h int
|
||||
tiles_path string
|
||||
cells [][]Cell
|
||||
generated bool
|
||||
|
||||
view &FieldView
|
||||
}
|
||||
|
||||
fn new_field() &Field {
|
||||
println("new_field()")
|
||||
f := &Field{
|
||||
tiles_path: "res/images/tiles/test1",
|
||||
view: &FieldView(0),
|
||||
}
|
||||
return f
|
||||
|
|
|
@ -24,7 +24,8 @@ fn (mut v FieldView) load() {
|
|||
pp(2)
|
||||
}
|
||||
|
||||
path := "res/images/tiles/test1"
|
||||
//path := "res/images/tiles/test1"
|
||||
path := v.m.tiles_path
|
||||
|
||||
for f in os.walk_ext(path, ".png") {
|
||||
println("f: $f")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
module main
|
||||
|
||||
import spytheman.vperlin as perlin
|
||||
import time
|
||||
import rand
|
||||
|
||||
|
@ -22,8 +23,12 @@ fn main() {
|
|||
//mut f := new_field()
|
||||
mut f := game.field
|
||||
|
||||
f.tiles_path = "res/images/tiles/test2"
|
||||
|
||||
//f.generate(4, 4)
|
||||
f.generate(24, 24)
|
||||
//f.generate(24, 24)
|
||||
//f.generate(24, 48)
|
||||
f.generate(32, 96)
|
||||
|
||||
f.cells[1][1].z = 100
|
||||
println("z 0 0: ${f.cells[0][0].z}")
|
||||
|
@ -40,8 +45,36 @@ fn main() {
|
|||
// Randomize tiles
|
||||
for y in 0..f.h {
|
||||
for x in 0..f.w {
|
||||
tile_num := 3
|
||||
n := rand.intn(tile_num)
|
||||
//tile_num := 3
|
||||
tile_num := 5
|
||||
|
||||
mut n := rand.intn(tile_num)
|
||||
|
||||
//scale := 1.0
|
||||
//scale := 0.1
|
||||
//scale := 0.3
|
||||
scale := 0.05
|
||||
mag := f32(tile_num)
|
||||
nv := perlin.noise2d(f32(x) * scale, f32(y) * scale)
|
||||
nv_norm := (nv + 1.0) / 2.0
|
||||
xnv := nv_norm * mag
|
||||
println(xnv)
|
||||
if xnv > tile_num {
|
||||
pp(2)
|
||||
}
|
||||
//mut n := int(xnv)
|
||||
mut noise_n := int(xnv)
|
||||
|
||||
|
||||
|
||||
// Randomize with random
|
||||
//if rand.intn(100) > 80 {
|
||||
if rand.intn(100) > 70 {
|
||||
//if rand.intn(100) > 30 {
|
||||
//n = rand.intn(tile_num)
|
||||
n = noise_n
|
||||
}
|
||||
|
||||
f.cells[x][y].tile_id = n
|
||||
}
|
||||
}
|
||||
|
|
BIN
isotest/res/images/tiles/test2/tile_0_green.png
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_0_green.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_0_green.xcf
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_0_green.xcf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_1_red.png
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_1_red.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_1_red.xcf
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_1_red.xcf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_2_blue.png
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_2_blue.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_3_green1.png
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_3_green1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_3_green1.xcf
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_3_green1.xcf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_4_red1.png
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_4_red1.png
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
isotest/res/images/tiles/test2/tile_4_red1.xcf
(Stored with Git LFS)
Normal file
BIN
isotest/res/images/tiles/test2/tile_4_red1.xcf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in a new issue