Mercurial > touhou
comparison examples/eclrenderer.rs @ 660:31fc0d881105
Make ecl_vm compile, and use it in eclrenderer (doesn’t render yet).
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 10 Aug 2019 14:41:30 +0200 |
parents | 3a9d82a02c88 |
children | 598f3125cbac |
comparison
equal
deleted
inserted
replaced
659:53786d834444 | 660:31fc0d881105 |
---|---|
11 use luminance_glfw::event::{Action, Key, WindowEvent}; | 11 use luminance_glfw::event::{Action, Key, WindowEvent}; |
12 use luminance_glfw::surface::{GlfwSurface, Surface, WindowDim, WindowOpt}; | 12 use luminance_glfw::surface::{GlfwSurface, Surface, WindowDim, WindowOpt}; |
13 use touhou::th06::anm0::Anm0; | 13 use touhou::th06::anm0::Anm0; |
14 use touhou::th06::anm0_vm::{Sprite, Vertex as FakeVertex}; | 14 use touhou::th06::anm0_vm::{Sprite, Vertex as FakeVertex}; |
15 use touhou::th06::ecl::Ecl; | 15 use touhou::th06::ecl::Ecl; |
16 use touhou::th06::ecl_vm::EclRunner; | |
16 use touhou::th06::enemy::{Enemy, Game, Position}; | 17 use touhou::th06::enemy::{Enemy, Game, Position}; |
17 use touhou::util::math::{perspective, setup_camera}; | 18 use touhou::util::math::{perspective, setup_camera}; |
18 use touhou::util::prng::Prng; | 19 use touhou::util::prng::Prng; |
19 use std::cell::RefCell; | 20 use std::cell::RefCell; |
20 use std::fs::File; | 21 use std::fs::File; |
125 // Create the Game god object. | 126 // Create the Game god object. |
126 let game = Game::new(prng); | 127 let game = Game::new(prng); |
127 let game = Rc::new(RefCell::new(game)); | 128 let game = Rc::new(RefCell::new(game)); |
128 | 129 |
129 // And the enemy object. | 130 // And the enemy object. |
130 let mut enemy = Enemy::new(Position::new(0., 0.), 500, 0, 640, Rc::downgrade(&anm0), Rc::downgrade(&game)); | 131 let enemy = Enemy::new(Position::new(0., 0.), 500, 0, 640, Rc::downgrade(&anm0), Rc::downgrade(&game)); |
131 enemy.set_anim(0); | 132 let mut ecl_runner = EclRunner::new(&ecl, enemy.clone(), 0); |
132 | 133 |
133 assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>()); | 134 assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>()); |
134 let vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() }; | 135 let vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() }; |
135 | 136 |
136 let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap(); | 137 let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap(); |
172 { | 173 { |
173 let mut slice = tess | 174 let mut slice = tess |
174 .as_slice_mut() | 175 .as_slice_mut() |
175 .unwrap(); | 176 .unwrap(); |
176 | 177 |
178 ecl_runner.run_frame(); | |
177 let mut game = game.borrow_mut(); | 179 let mut game = game.borrow_mut(); |
178 game.run_frame(); | 180 game.run_frame(); |
179 let sprites = game.get_sprites(); | 181 let sprites = game.get_sprites(); |
180 fill_vertices_ptr(sprites, slice.as_mut_ptr()); | 182 fill_vertices_ptr(sprites, slice.as_mut_ptr()); |
181 } | 183 } |