comparison examples/anmrenderer.rs @ 646:7d92730bf543

Add a PRNG and use it for anm0 instruction 16.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2019 23:30:15 +0200
parents f983a4c98410
children 967627181a76
comparison
equal deleted inserted replaced
645:7bde50132735 646:7d92730bf543
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::{AnmRunner, Sprite, Vertex as FakeVertex}; 14 use touhou::th06::anm0_vm::{AnmRunner, Sprite, Vertex as FakeVertex};
15 use touhou::util::math::{perspective, setup_camera}; 15 use touhou::util::math::{perspective, setup_camera};
16 use touhou::util::prng::Prng;
16 use std::cell::RefCell; 17 use std::cell::RefCell;
17 use std::fs::File; 18 use std::fs::File;
18 use std::io::{BufReader, Read}; 19 use std::io::{BufReader, Read};
19 use std::rc::Rc; 20 use std::rc::Rc;
20 use std::env; 21 use std::env;
108 } 109 }
109 110
110 // Create the sprite. 111 // Create the sprite.
111 let sprite = Rc::new(RefCell::new(Sprite::new(0., 0.))); 112 let sprite = Rc::new(RefCell::new(Sprite::new(0., 0.)));
112 113
114 // TODO: seed this PRNG with a valid seed.
115 let prng = Rc::new(RefCell::new(Prng::new(0)));
116
113 // Create the AnmRunner from the ANM and the sprite. 117 // Create the AnmRunner from the ANM and the sprite.
114 let mut anm_runner = AnmRunner::new(&anm0, script, sprite.clone(), 0); 118 let mut anm_runner = AnmRunner::new(&anm0, script, sprite.clone(), Rc::downgrade(&prng), 0);
115 119
116 assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>()); 120 assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>());
117 let mut vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() }; 121 let mut vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() };
118 fill_vertices(sprite.clone(), &mut vertices); 122 fill_vertices(sprite.clone(), &mut vertices);
119 123