summaryrefslogtreecommitdiff
path: root/src/player.rs
blob: 66e7d28e575539832300729f37dd9719e2c6a637 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use ggez::graphics::{spritebatch::SpriteBatch, DrawParam};
use ggez::nalgebra::{Point2, Vector2};

use crate::constants;
use crate::tileset::Tileset;

pub struct Player {
    pub position: Point2<f32>,
}

impl Player {
    pub fn new() -> Player {
        Player {
            position: Point2::new(0.0, 0.0),
        }
    }

    pub fn draw(&self, spritebatch: &mut SpriteBatch, tileset: &Tileset) {
        let draw_param = DrawParam::default()
            .src(tileset.tiles[1])
            .dest(self.position)
            .scale(Vector2::new(constants::TILE_SCALE, constants::TILE_SCALE));

        spritebatch.add(draw_param);
    }
}