Updated player to now use the camera and better animation.
This commit is contained in:
+4
-6
@@ -2,7 +2,6 @@ package game
|
||||
|
||||
import rl "vendor:raylib"
|
||||
|
||||
PLAYER_SPEED :: 180
|
||||
Direction :: enum { LEFT, RIGHT }
|
||||
Player_State :: enum { IDLE, WALK, ATTACK }
|
||||
|
||||
@@ -15,7 +14,8 @@ Player :: struct {
|
||||
|
||||
player_init :: proc(assets: ^Player_Assets) -> Player {
|
||||
player := Player{}
|
||||
player.pos = {(WINDOW_WIDTH / 2 - 16 * 4), (WINDOW_HEIGHT / 2 - 16 * 4)}
|
||||
// center for now not really needed
|
||||
player.pos = {(WINDOW_WIDTH / 2), (WINDOW_HEIGHT / 2)}
|
||||
player.state = .IDLE
|
||||
animation_play(&player.ani_state, &assets.clips[.IDLE])
|
||||
|
||||
@@ -46,8 +46,6 @@ update_player :: proc(player: ^Player, assets: ^Player_Assets) {
|
||||
animation_update(&player.ani_state, dt)
|
||||
}
|
||||
|
||||
// temp, remove once camera/zoom is in
|
||||
SPRITE_SCALE :: 4
|
||||
renderer_draw_player :: proc(player: ^Player) {
|
||||
clip := player.ani_state.clip
|
||||
src_rect := animation_frame_rect(&player.ani_state)
|
||||
@@ -59,8 +57,8 @@ renderer_draw_player :: proc(player: ^Player) {
|
||||
dst_rect := rl.Rectangle{
|
||||
x = player.pos.x,
|
||||
y = player.pos.y,
|
||||
width = f32(clip.frame_width) * SPRITE_SCALE,
|
||||
height = f32(clip.frame_height) * SPRITE_SCALE,
|
||||
width = f32(clip.frame_width),
|
||||
height = f32(clip.frame_height),
|
||||
}
|
||||
|
||||
rl.DrawTexturePro(clip.texture, src_rect, dst_rect, rl.Vector2{}, 0, rl.WHITE)
|
||||
|
||||
Reference in New Issue
Block a user