snipplets.dev/code/V/example_window/draw.v
2023-09-26 22:05:13 +03:00

43 lines
1.6 KiB
V

import gg
import gx
fn (game &Game) draw() {
game.gg.begin()
// draw filled texture
game.draw_bg_texture()
// draw ui
game.draw_text(gg.window_size().width - 10, 0, 'Lives: ${game.player.lives}', 36,
gx.white, 'right', 'top', true)
// draw image
game.gg.draw_image(0, game.gg.window_size().height - game.player.image.height, game.player.image.width,
game.player.image.height, game.player.image)
game.gg.end()
}
fn (game &Game) draw_bg_texture() {
game.gg.draw_image(game.bg_texture.pos_x - game.bg_texture.image.width, game.bg_texture.pos_y,
game.bg_texture.image.width, game.bg_texture.image.height, game.bg_texture.image)
for x in 0 .. gg.window_size().width / game.bg_texture.image.width + 3 {
game.gg.draw_image(x * game.bg_texture.image.width + game.bg_texture.pos_x, game.bg_texture.pos_y - game.bg_texture.image.height,
game.bg_texture.image.width, game.bg_texture.image.height, game.bg_texture.image)
game.gg.draw_image(game.bg_texture.pos_x - game.bg_texture.image.width, game.bg_texture.pos_y - game.bg_texture.image.height,
game.bg_texture.image.width, game.bg_texture.image.height, game.bg_texture.image)
for y in 0 .. gg.window_size().height / game.bg_texture.image.height + 3 {
game.gg.draw_image(x * game.bg_texture.image.width + game.bg_texture.pos_x,
y * game.bg_texture.image.height + game.bg_texture.pos_y, game.bg_texture.image.width,
game.bg_texture.image.height, game.bg_texture.image)
game.gg.draw_image(game.bg_texture.pos_x - game.bg_texture.image.width,
y * game.bg_texture.image.height + game.bg_texture.pos_y, game.bg_texture.image.width,
game.bg_texture.image.height, game.bg_texture.image)
}
}
}