annotate src/th06/enemy.rs @ 658:3a9d82a02c88

Add a contructor for enemy, and a new example.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 10 Aug 2019 12:48:01 +0200
parents ff7b6355cdf1
children 31fc0d881105
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 //! Module providing an Enemy struct, to be changed by EclRunner.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 use crate::th06::anm0::Anm0;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 use crate::th06::anm0_vm::{Sprite, AnmRunner};
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 use crate::th06::interpolator::{Interpolator1, Interpolator2};
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 use crate::util::prng::Prng;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 use std::cell::RefCell;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 use std::collections::HashMap;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 use std::rc::{Rc, Weak};
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
11 /// The 2D position of an object in the game.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
12 #[derive(Debug, Clone, Copy, Default)]
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
13 pub struct Position {
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 x: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 y: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
18 /// An offset which can be added to a Position.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
19 #[derive(Debug, Clone, Copy, Default)]
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
20 pub struct Offset {
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 dx: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 dy: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25 impl Position {
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
26 /// Create said position.
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 pub fn new(x: f32, y: f32) -> Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 Position { x, y }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 impl Offset {
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
33 /// Create said offset.
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 pub fn new(dx: f32, dy: f32) -> Offset {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 Offset { dx, dy }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 impl std::ops::Add<Offset> for Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 type Output = Position;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 fn add(self, offset: Offset) -> Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 Position {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 x: self.x + offset.dx,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 y: self.y + offset.dy,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 #[derive(Debug, Clone)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 struct Callback;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 #[derive(Debug, Clone)]
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 struct Laser;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
55 #[derive(Debug, Clone, Default)]
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 struct Process;
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
58 /// God struct of our game.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
59 pub struct Game {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
60 enemies: Vec<Rc<RefCell<Enemy>>>,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
61 anmrunners: Vec<Rc<RefCell<AnmRunner>>>,
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 prng: Rc<RefCell<Prng>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
65 impl Game {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
66 /// Create said god struct.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
67 pub fn new(prng: Rc<RefCell<Prng>>) -> Game {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
68 Game {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
69 enemies: Vec::new(),
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
70 anmrunners: Vec::new(),
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
71 prng,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
72 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
73 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
74
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
75 /// Run the simulation for a single frame.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
76 pub fn run_frame(&mut self) {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
77 /*
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
78 for eclrunner in self.eclrunners {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
79 eclrunner.run_frame();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
80 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
81 */
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
82
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
83 for anmrunner in self.anmrunners.iter() {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
84 let mut anmrunner = anmrunner.borrow_mut();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
85 anmrunner.run_frame();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
86 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
87 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
88
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
89 /// Returns a list of all sprites currently being displayed on screen.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
90 pub fn get_sprites(&self) -> Vec<Rc<RefCell<Sprite>>> {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
91 let mut sprites = vec![];
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
92 for anmrunner in self.anmrunners.iter() {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
93 let anmrunner = anmrunner.borrow();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
94 let sprite = anmrunner.get_sprite();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
95 sprites.push(sprite);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
96 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
97 sprites
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
98 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
99 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
100
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 /// Common to all elements in game.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 struct Element {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 pos: Position,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 removed: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 anmrunner: AnmRunner,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 /// The enemy struct, containing everything pertaining to an enemy.
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
109 #[derive(Default)]
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 pub struct Enemy {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 // Common to all elements in game.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 pos: Position,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 removed: bool,
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
114 anmrunner: Weak<RefCell<AnmRunner>>,
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 // Specific to enemy.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 // Floats.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 z: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 angle: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 speed: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 rotation_speed: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 acceleration: f32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 // Ints.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 type_: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126 bonus_dropped: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 die_score: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 frame: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 life: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130 death_flags: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
131 current_laser_id: u32,
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
132 low_life_trigger: Option<u32>,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
133 timeout: Option<u32>,
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
134 remaining_lives: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
135 bullet_launch_interval: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136 bullet_launch_timer: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
137 death_anim: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138 direction: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139 update_mode: u32,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
140
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
141 // Bools.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
142 visible: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
143 was_visible: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
144 touchable: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
145 collidable: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
146 damageable: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147 boss: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
148 automatic_orientation: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
149 delay_attack: bool,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
150
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
151 // Tuples.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
152 difficulty_coeffs: (f32, f32, u32, u32, u32, u32),
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
153 extended_bullet_attributes: Option<(u32, u32, u32, u32, f32, f32, f32, f32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
154 bullet_attributes: Option<(i16, i16, u32, u32, u32, f32, f32, f32, f32, u32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
155 bullet_launch_offset: Offset,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
156 movement_dependant_sprites: Option<(f32, f32, f32, f32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
157 screen_box: Option<(f32, f32, f32, f32)>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
158
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
159 // Callbacks.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
160 death_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
161 boss_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
162 low_life_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
163 timeout_callback: Option<Callback>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
164
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
165 // Laser.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
166 laser_by_id: HashMap<u32, Laser>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
167
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
168 // Options.
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
169 // TODO: actually a 8 element array.
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
170 options: Vec<Element>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
171
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
172 // Interpolators.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
173 interpolator: Option<Interpolator2<f32>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
174 speed_interpolator: Option<Interpolator1<f32>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
175
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
176 // Misc stuff, do we need them?
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
177 anm0: Weak<RefCell<Anm0>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
178 process: Rc<RefCell<Process>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
179 game: Weak<RefCell<Game>>,
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
180 prng: Weak<RefCell<Prng>>,
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
181 hitbox_half_size: [f32; 2],
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
182 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
183
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
184 impl Enemy {
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
185 /// Create a new enemy.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
186 pub fn new(pos: Position, life: i32, bonus_dropped: u32, die_score: u32, anm0: Weak<RefCell<Anm0>>, game: Weak<RefCell<Game>>) -> Enemy {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
187 Enemy {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
188 pos,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
189 anm0,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
190 game,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
191 visible: true,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
192 bonus_dropped,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
193 die_score,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
194 life: if life < 0 { 1 } else { life as u32 },
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
195 touchable: true,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
196 collidable: true,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
197 damageable: true,
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
198 difficulty_coeffs: (-0.5, 0.5, 0, 0, 0, 0),
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
199 ..Default::default()
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
200 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
201 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
202
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
203 /// Sets the animation to the one indexed by index in the current anm0.
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
204 pub fn set_anim(&mut self, index: u8) {
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
205 let anm0 = self.anm0.upgrade().unwrap();
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
206 let game = self.game.upgrade().unwrap();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
207 let sprite = Rc::new(RefCell::new(Sprite::new()));
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
208 let anmrunner = AnmRunner::new(&*anm0.borrow(), index, sprite, self.prng.clone(), 0);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
209 let anmrunner = Rc::new(RefCell::new(anmrunner));
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
210 self.anmrunner = Rc::downgrade(&anmrunner);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
211 (*game.borrow_mut()).anmrunners.push(anmrunner);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
212 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
213
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
214 /// Sets the hitbox around the enemy.
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
215 pub fn set_hitbox(&mut self, width: f32, height: f32) {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
216 self.hitbox_half_size = [width, height];
657
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
217 }
ff7b6355cdf1 Port the Enemy struct from Python, for now without its methods.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
218 }
658
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
219
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
220 #[cfg(test)]
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
221 mod tests {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
222 use super::*;
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
223 use std::io::{self, Read};
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
224 use std::fs::File;
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
225
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
226 #[test]
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
227 fn enemy() {
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
228 let file = File::open("EoSD/ST/stg1enm.anm").unwrap();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
229 let mut file = io::BufReader::new(file);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
230 let mut buf = vec![];
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
231 file.read_to_end(&mut buf).unwrap();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
232 let anm0 = Anm0::from_slice(&buf).unwrap();
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
233 let anm0 = Rc::new(RefCell::new(anm0));
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
234 let prng = Rc::new(RefCell::new(Prng::new(0)));
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
235 let game = Game::new(prng);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
236 let game = Rc::new(RefCell::new(game));
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
237 let mut enemy = Enemy::new(Position::new(0., 0.), 500, 0, 640, Rc::downgrade(&anm0), Rc::downgrade(&game));
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
238 assert!(enemy.anmrunner.upgrade().is_none());
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
239 enemy.set_anim(0);
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
240 assert!(enemy.anmrunner.upgrade().is_some());
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
241 }
3a9d82a02c88 Add a contructor for enemy, and a new example.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 657
diff changeset
242 }