snipplets.dev/projects/V/Game/draw.v

43 lines
1.6 KiB
Coq
Raw Normal View History

2023-07-02 21:16:14 +03:00
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
2024-05-11 21:12:26 +03:00
game.gg.draw_image(game.player.pos_x, game.player.pos_y, game.player.image.width,
2023-07-02 21:16:14 +03:00
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)
}
}
}