Organize project

This commit is contained in:
Stefan Stefanov 2024-12-31 13:27:36 +02:00
parent d6143951d8
commit 6993054d63
7 changed files with 368 additions and 327 deletions

34
src/tile.odin Normal file
View file

@ -0,0 +1,34 @@
package game
import "core:math"
import rl "vendor:raylib"
Tile :: struct {
id: int,
pos: rl.Vector2,
animation: Animation,
}
spawn_tile_under_mouse :: proc() {
tile_position := get_tile_position(world_mouse)
old_tile: bool
for e in entities {
if .Allocated not_in e.flags {continue}
if e.kind == .Tile && e.pos == tile_position {
old_tile = true
}
}
if !old_tile {
create_entity(
Entity {
pos = tile_position,
kind = .Tile,
data = TileData{has_plant = true, plant_id = 0, animation = tomato_animation},
},
)
}
}
get_tile_position :: proc(wpos: rl.Vector2) -> rl.Vector2 {
return {math.floor(wpos.x / TILE_SIZE) * TILE_SIZE, math.floor(wpos.y / TILE_SIZE) * TILE_SIZE}
}