Mercurial > touhou
annotate examples/stagerunner.rs @ 738:817c453b7223
stagerunner: Add a binary able to run multiple enemies.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 28 Dec 2019 23:53:09 +0100 |
parents | |
children | 3555845f8cf4 |
rev | line source |
---|---|
738
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 use luminance::blending::{Equation, Factor}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 use luminance::context::GraphicsContext; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 use luminance::pipeline::BoundTexture; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 use luminance::pixel::NormUnsigned; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 use luminance::render_state::RenderState; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 use luminance::shader::program::{Program, Uniform}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 use luminance::tess::{Mode, TessBuilder}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 use luminance::texture::{Dim2, Flat}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 use luminance_derive::{Semantics, Vertex, UniformInterface}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 use luminance_glfw::{Action, Key, WindowEvent, GlfwSurface, Surface, WindowDim, WindowOpt}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 use touhou::th06::anm0::Anm0; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 use touhou::th06::anm0_vm::Vertex as FakeVertex; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 use touhou::th06::ecl::{Ecl, Rank, MainInstruction}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 use touhou::th06::ecl_vm::EclRunner; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 use touhou::th06::enemy::{Enemy, Game, Position}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 use touhou::util::math::{perspective, setup_camera}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 use touhou::util::prng::Prng; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 use std::cell::RefCell; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 use std::rc::Rc; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
20 use std::env; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
21 use std::path::Path; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
22 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
23 #[path = "common.rs"] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
24 mod common; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
25 use common::{load_file_into_vec, load_anm_image, LoadedTexture}; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
26 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
27 const VS: &str = r#" |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
28 in ivec3 in_position; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
29 in vec2 in_texcoord; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
30 in uvec4 in_color; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
31 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
32 uniform mat4 mvp; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
33 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
34 out vec2 texcoord; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
35 out vec4 color; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
36 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
37 void main() |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
38 { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
39 gl_Position = mvp * vec4(vec3(in_position), 1.0); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
40 texcoord = vec2(in_texcoord); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
41 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
42 // Normalized from the u8 being passed. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
43 color = vec4(in_color) / 255.; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
44 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
45 "#; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
46 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
47 const FS: &str = r#" |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
48 in vec2 texcoord; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
49 in vec4 color; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
50 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
51 uniform sampler2D color_map; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
52 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
53 out vec4 frag_color; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
54 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
55 void main() |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
56 { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
57 frag_color = texture(color_map, texcoord) * color; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
58 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
59 "#; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
60 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
61 #[derive(Clone, Copy, Debug, Eq, PartialEq, Semantics)] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
62 pub enum Semantics { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
63 #[sem(name = "in_position", repr = "[i16; 3]", wrapper = "VertexPosition")] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
64 Position, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
65 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
66 #[sem(name = "in_texcoord", repr = "[f32; 2]", wrapper = "VertexTexcoord")] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
67 Texcoord, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
68 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
69 #[sem(name = "in_color", repr = "[u8; 4]", wrapper = "VertexColor")] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
70 Color, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
71 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
72 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
73 #[repr(C)] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
74 #[derive(Clone, Copy, Debug, PartialEq, Vertex)] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
75 #[vertex(sem = "Semantics")] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
76 struct Vertex { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
77 pos: VertexPosition, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
78 uv: VertexTexcoord, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
79 rgba: VertexColor, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
80 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
81 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
82 #[derive(UniformInterface)] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
83 struct ShaderInterface { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
84 // the 'static lifetime acts as “anything” here |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
85 color_map: Uniform<&'static BoundTexture<'static, Flat, Dim2, NormUnsigned>>, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
86 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
87 #[uniform(name = "mvp")] |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
88 mvp: Uniform<[[f32; 4]; 4]>, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
89 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
90 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
91 fn main() { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
92 // Parse arguments. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
93 let args: Vec<_> = env::args().collect(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
94 if args.len() != 4 { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
95 eprintln!("Usage: {} <ECL file> <ANM file> <easy|normal|hard|lunatic>", args[0]); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
96 return; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
97 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
98 let ecl_filename = Path::new(&args[1]); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
99 let anm_filename = Path::new(&args[2]); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
100 let rank: Rank = args[3].parse().expect("rank"); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
101 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
102 // Open the ECL file. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
103 let buf = load_file_into_vec(ecl_filename); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
104 let (_, ecl) = Ecl::from_slice(&buf).unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
105 assert_eq!(ecl.mains.len(), 1); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
106 let main = ecl.mains[0].clone(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
107 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
108 // Open the ANM file. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
109 let buf = load_file_into_vec(anm_filename); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
110 let (_, mut anms) = Anm0::from_slice(&buf).unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
111 let anm0 = anms.pop().unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
112 let anm0 = Rc::new(RefCell::new(anm0)); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
113 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
114 // Get the time since January 1970 as a seed for the PRNG. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
115 let time = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
116 let prng = Rc::new(RefCell::new(Prng::new(time.subsec_micros() as u16))); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
117 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
118 // Create the Game god object. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
119 let game = Game::new(prng, rank); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
120 let game = Rc::new(RefCell::new(game)); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
121 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
122 assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>()); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
123 let vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() }; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
124 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
125 let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
126 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
127 // Open the image atlas matching this ANM. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
128 let tex = load_anm_image(&mut surface, &anm0.borrow(), anm_filename).expect("image loading"); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
129 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
130 // set the uniform interface to our type so that we can read textures from the shader |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
131 let program = |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
132 Program::<Semantics, (), ShaderInterface>::from_strings(None, VS, None, FS).expect("program creation").ignore_warnings(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
133 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
134 let mut tess = TessBuilder::new(&mut surface) |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
135 .add_vertices(vertices) |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
136 .set_mode(Mode::TriangleFan) |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
137 .build() |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
138 .unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
139 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
140 let mut back_buffer = surface.back_buffer().unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
141 let mut resize = false; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
142 let mut frame = 0; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
143 let mut ecl_runners = vec![]; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
144 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
145 'app: loop { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
146 for event in surface.poll_events() { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
147 match event { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
148 WindowEvent::Close | WindowEvent::Key(Key::Escape, _, Action::Release, _) => break 'app, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
149 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
150 WindowEvent::FramebufferSize(..) => { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
151 resize = true; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
152 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
153 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
154 _ => (), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
155 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
156 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
157 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
158 if resize { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
159 back_buffer = surface.back_buffer().unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
160 resize = false; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
161 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
162 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
163 for call in main.instructions.iter() { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
164 if call.time == frame { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
165 let sub = call.sub; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
166 let instr = call.instr; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
167 let (x, y, _z, life, bonus, score, mirror) = match instr { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
168 MainInstruction::SpawnEnemy(x, y, z, life, bonus, score) => (x, y, z, life, bonus, score, false), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
169 MainInstruction::SpawnEnemyMirrored(x, y, z, life, bonus, score) => (x, y, z, life, bonus, score, true), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
170 MainInstruction::SpawnEnemyRandom(x, y, z, life, bonus, score) => (x, y, z, life, bonus, score, false), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
171 MainInstruction::SpawnEnemyMirroredRandom(x, y, z, life, bonus, score) => (x, y, z, life, bonus, score, true), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
172 _ => continue, |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
173 }; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
174 let enemy = Enemy::new(Position::new(x, y), life, bonus, score, mirror, Rc::downgrade(&anm0), Rc::downgrade(&game)); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
175 let runner = EclRunner::new(&ecl, enemy, sub); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
176 ecl_runners.push(runner); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
177 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
178 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
179 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
180 for runner in ecl_runners.iter_mut() { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
181 runner.run_frame(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
182 let mut enemy = runner.enemy.borrow_mut(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
183 enemy.update(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
184 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
185 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
186 // here, we need to bind the pipeline variable; it will enable us to bind the texture to the GPU |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
187 // and use it in the shader |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
188 surface |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
189 .pipeline_builder() |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
190 .pipeline(&back_buffer, [0., 0., 0., 0.], |pipeline, mut shd_gate| { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
191 // bind our fancy texture to the GPU: it gives us a bound texture we can use with the shader |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
192 let bound_tex = match &tex { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
193 LoadedTexture::Rgb(tex) => pipeline.bind_texture(tex), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
194 LoadedTexture::Rgba(tex) => pipeline.bind_texture(tex), |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
195 }; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
196 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
197 shd_gate.shade(&program, |iface, mut rdr_gate| { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
198 // update the texture; strictly speaking, this update doesn’t do much: it just tells the GPU |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
199 // to use the texture passed as argument (no allocation or copy is performed) |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
200 iface.color_map.update(&bound_tex); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
201 //let mvp = ortho_2d(0., 384., 448., 0.); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
202 let proj = perspective(0.5235987755982988, 384. / 448., 101010101./2010101., 101010101./10101.); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
203 let view = setup_camera(0., 0., 1.); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
204 let mvp = view * proj; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
205 //println!("{:#?}", mvp); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
206 // TODO: check how to pass by reference. |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
207 iface.mvp.update(*mvp.borrow_inner()); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
208 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
209 let render_state = RenderState::default() |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
210 .set_blending((Equation::Additive, Factor::SrcAlpha, Factor::SrcAlphaComplement)); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
211 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
212 rdr_gate.render(render_state, |mut tess_gate| { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
213 let mut game = game.borrow_mut(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
214 game.run_frame(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
215 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
216 for (x, y, z, sprite) in game.get_sprites() { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
217 { |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
218 let mut slice = tess |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
219 .as_slice_mut() |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
220 .unwrap(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
221 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
222 let sprite = sprite.borrow(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
223 let fake_vertices = unsafe { std::mem::transmute::<*mut Vertex, &mut [FakeVertex; 4]>(slice.as_mut_ptr()) }; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
224 sprite.fill_vertices(fake_vertices, x, y, z); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
225 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
226 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
227 // render the tessellation to the surface the regular way and let the vertex shader’s |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
228 // magic do the rest! |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
229 tess_gate.render(&tess); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
230 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
231 }); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
232 }); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
233 }); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
234 |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
235 surface.swap_buffers(); |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
236 frame += 1; |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
237 } |
817c453b7223
stagerunner: Add a binary able to run multiple enemies.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
238 } |