Testing world/screen space functions
This commit is contained in:
+14
-8
@@ -41,15 +41,21 @@ update_player :: proc(player: ^Player, assets: ^Player_Assets, camera: rl.Camera
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rl.IsMouseButtonPressed(.LEFT) {
|
if rl.IsMouseButtonPressed(.LEFT) {
|
||||||
pixel_pos := rl.GetMousePosition()
|
// TESTING
|
||||||
//convert to render size
|
mouse_pos := rl.GetMousePosition()
|
||||||
pixel_pos.x = pixel_pos.x / (WINDOW_WIDTH / GAME_WIDTH)
|
screen_space := window_to_screen(mouse_pos)
|
||||||
pixel_pos.y = pixel_pos.y / (WINDOW_HEIGHT / GAME_HEIGHT)
|
|
||||||
|
|
||||||
grid_space := world_to_grid(pixel_pos, camera)
|
x := screen_to_world(screen_space, camera)
|
||||||
fmt.printf("GRID SPACE: %v\n", grid_space)
|
fmt.printf("Mouse pos -> world pos: %v\n", x)
|
||||||
world_space := grid_to_world(grid_space[0], grid_space[1])
|
|
||||||
fmt.printf("WORLD SPACE: %v\n", world_space)
|
v := world_to_screen(x, camera)
|
||||||
|
fmt.printf("world pos -> screen pos: %v\n", v)
|
||||||
|
|
||||||
|
y := world_to_grid(x)
|
||||||
|
fmt.printf("Mouse pos -> grid coord: %v\n", y)
|
||||||
|
|
||||||
|
z := grid_to_world(y[0], y[1])
|
||||||
|
fmt.printf("grid pos -> world pos: %v\n", z)
|
||||||
}
|
}
|
||||||
|
|
||||||
player.state = moving ? .WALK : .IDLE
|
player.state = moving ? .WALK : .IDLE
|
||||||
|
|||||||
Reference in New Issue
Block a user