added scythe
This commit is contained in:
parent
6993054d63
commit
9504812ed5
10 changed files with 305 additions and 116 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package game
|
||||
|
||||
import t "../tween"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
pickup_sound_data: []u8 : #load("../assets/sounds/pickup_sound.mp3")
|
||||
|
|
@ -11,6 +12,21 @@ sell_button_sprite: []u8 : #load("../assets/sell_button.png")
|
|||
background_sprite: []u8 : #load("../assets/background.png")
|
||||
tile_dirt_dry_sprite: []u8 : #load("../assets/tile_dirt_dry.png")
|
||||
tile_dirt_wet_sprite: []u8 : #load("../assets/tile_dirt_wet.png")
|
||||
hoe_sprite: []u8 : #load("../assets/hoe.png")
|
||||
scythe_sprite: []u8 : #load("../assets/scythe.png")
|
||||
|
||||
pickup_sound: rl.Sound
|
||||
|
||||
sell_button_texture: rl.Texture2D
|
||||
background_texture: rl.Texture2D
|
||||
tile_dirt_dry_texture: rl.Texture2D
|
||||
tile_dirt_wet_texture: rl.Texture2D
|
||||
tomato_texture: rl.Texture2D
|
||||
hoe_texture: rl.Texture2D
|
||||
scythe_texture: rl.Texture2D
|
||||
|
||||
player_animation: Animation
|
||||
tomato_animation: Animation
|
||||
|
||||
load_texture_from_memory :: proc(data: []u8) -> (texture: rl.Texture2D) {
|
||||
img := rl.LoadImageFromMemory(".png", raw_data(data), auto_cast len(data))
|
||||
|
|
@ -31,13 +47,63 @@ load_sound_from_memory :: proc(
|
|||
return
|
||||
}
|
||||
|
||||
pickup_sound: rl.Sound
|
||||
|
||||
sell_button_texture: rl.Texture2D
|
||||
background_texture: rl.Texture2D
|
||||
tile_dirt_dry_texture: rl.Texture2D
|
||||
tile_dirt_wet_texture: rl.Texture2D
|
||||
tomato_texture: rl.Texture2D
|
||||
load_resources :: proc() {
|
||||
tween_ctx_f32 = t.context_init(f32)
|
||||
tween_ctx_vec2 = t.context_init([2]f32)
|
||||
|
||||
player_animation: Animation
|
||||
tomato_animation: Animation
|
||||
game_render_buffer = rl.LoadRenderTexture(
|
||||
auto_cast GAME_SCREEN_WIDTH,
|
||||
auto_cast GAME_SCREEN_HEIGHT,
|
||||
)
|
||||
rl.SetTextureFilter(game_render_buffer.texture, rl.TextureFilter.POINT) // Texture scale filter to use
|
||||
|
||||
player_animation = Animation {
|
||||
texture = load_texture_from_memory(player_spritesheet_sprite),
|
||||
num_frames = 2,
|
||||
frame_length = 0.5,
|
||||
loop = true,
|
||||
}
|
||||
tomato_animation = Animation {
|
||||
texture = load_texture_from_memory(tomato_spritesheet_sprite),
|
||||
num_frames = 4,
|
||||
frame_length = 0.1,
|
||||
loop = false,
|
||||
offset = {TILE_SIZE / 2, TILE_SIZE},
|
||||
}
|
||||
|
||||
tomato_texture = load_texture_from_memory(tomato_item_sprite)
|
||||
sell_button_texture = load_texture_from_memory(sell_button_sprite)
|
||||
background_texture = load_texture_from_memory(background_sprite)
|
||||
tile_dirt_dry_texture = load_texture_from_memory(tile_dirt_dry_sprite)
|
||||
tile_dirt_wet_texture = load_texture_from_memory(tile_dirt_wet_sprite)
|
||||
hoe_texture = load_texture_from_memory(hoe_sprite)
|
||||
scythe_texture = load_texture_from_memory(scythe_sprite)
|
||||
|
||||
pickup_sound = load_sound_from_memory(pickup_sound_data)
|
||||
rl.SetSoundVolume(pickup_sound, 0.1)
|
||||
|
||||
e := create_entity(
|
||||
Entity {
|
||||
pos = {GAME_SCREEN_WIDTH / 2, GAME_SCREEN_HEIGHT / 2},
|
||||
kind = .Player,
|
||||
data = PlayerData{animation = player_animation},
|
||||
},
|
||||
)
|
||||
player_handle = entity_to_handle(e^)
|
||||
}
|
||||
|
||||
free_resources :: proc() {
|
||||
t.context_destroy(tween_ctx_f32)
|
||||
t.context_destroy(tween_ctx_vec2)
|
||||
|
||||
rl.UnloadSound(pickup_sound)
|
||||
|
||||
rl.UnloadTexture(tomato_texture)
|
||||
rl.UnloadTexture(sell_button_texture)
|
||||
rl.UnloadTexture(background_texture)
|
||||
rl.UnloadTexture(tile_dirt_dry_texture)
|
||||
rl.UnloadTexture(tile_dirt_wet_texture)
|
||||
|
||||
rl.UnloadRenderTexture(game_render_buffer) // Unload render texture
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue