Add background tiles
This commit is contained in:
parent
e28f257dc9
commit
06fe046d6f
4 changed files with 17 additions and 0 deletions
|
@ -8,5 +8,6 @@ gfx_device_gl = "0.14.1"
|
||||||
piston-ai_behavior = "0.20.0"
|
piston-ai_behavior = "0.20.0"
|
||||||
piston_window = "0.66.0"
|
piston_window = "0.66.0"
|
||||||
piston2d-sprite = "0.36.0"
|
piston2d-sprite = "0.36.0"
|
||||||
|
piston2d-graphics = "0.21.1"
|
||||||
find_folder = "0.3.0"
|
find_folder = "0.3.0"
|
||||||
uuid = "0.1.17"
|
uuid = "0.1.17"
|
||||||
|
|
BIN
assets/bg.png
Normal file
BIN
assets/bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
assets/bg.xcf
Normal file
BIN
assets/bg.xcf
Normal file
Binary file not shown.
16
src/lib.rs
16
src/lib.rs
|
@ -1,6 +1,7 @@
|
||||||
extern crate ai_behavior;
|
extern crate ai_behavior;
|
||||||
extern crate find_folder;
|
extern crate find_folder;
|
||||||
extern crate gfx_device_gl;
|
extern crate gfx_device_gl;
|
||||||
|
extern crate graphics;
|
||||||
extern crate piston_window;
|
extern crate piston_window;
|
||||||
extern crate sprite;
|
extern crate sprite;
|
||||||
extern crate uuid;
|
extern crate uuid;
|
||||||
|
@ -8,6 +9,8 @@ extern crate uuid;
|
||||||
mod object;
|
mod object;
|
||||||
|
|
||||||
use gfx_device_gl::Resources;
|
use gfx_device_gl::Resources;
|
||||||
|
use graphics::Image;
|
||||||
|
use graphics::rectangle::square;
|
||||||
use piston_window::*;
|
use piston_window::*;
|
||||||
use object::Object;
|
use object::Object;
|
||||||
use sprite::*;
|
use sprite::*;
|
||||||
|
@ -53,8 +56,21 @@ impl Game {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_draw(&mut self, e: &Input, _: RenderArgs, w: &mut PistonWindow) {
|
pub fn on_draw(&mut self, e: &Input, _: RenderArgs, w: &mut PistonWindow) {
|
||||||
|
let assets = find_folder::Search::ParentsThenKids(3, 3)
|
||||||
|
.for_folder("assets")
|
||||||
|
.unwrap();
|
||||||
|
let image = Image::new().rect(square(0.0, 0.0, 640.0));
|
||||||
|
let bg = Texture::from_path(&mut w.factory,
|
||||||
|
assets.join("bg.png"),
|
||||||
|
Flip::None,
|
||||||
|
&TextureSettings::new()).unwrap();
|
||||||
w.draw_2d(e, |c, g| {
|
w.draw_2d(e, |c, g| {
|
||||||
clear([1.0, 1.0, 1.0, 1.0], g);
|
clear([1.0, 1.0, 1.0, 1.0], g);
|
||||||
|
for number in 0..100 {
|
||||||
|
let x: f64 = (number % 10 * 64).into();
|
||||||
|
let y: f64 = (number / 10 * 64).into();
|
||||||
|
image.draw(&bg, &Default::default(), c.transform.trans(x, y).zoom(0.1), g);
|
||||||
|
}
|
||||||
self.scene.draw(c.transform, g);
|
self.scene.draw(c.transform, g);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue