@@ -9,28 +9,27 @@ use dwemthys::npc::NPC;
99
1010use tcod:: { Console , key_code, Special } ;
1111
12- fn render ( con : & mut Console , objs : & Vec < & mut Updates > ) {
12+ fn render ( con : & mut Console , objs : & Vec < Box < Updates > > ) {
1313 con. clear ( ) ;
1414 for i in objs. iter ( ) {
1515 i. render ( con) ;
1616 }
1717 con. flush ( ) ;
1818}
1919
20- fn update ( objs : & Vec < & mut Updates > , keypress : tcod:: KeyState , game : Game ) {
21- for & mut i in objs. iter ( ) {
20+ fn update ( objs : & mut Vec < Box < Updates > > , keypress : tcod:: KeyState , game : Game ) {
21+ for i in objs. mut_iter ( ) {
2222 i. update ( keypress, game) ;
2323 }
2424}
2525
2626fn main ( ) {
2727 let mut game = Game { exit : false , window_bounds : Bound { min : Point { x : 0 , y : 0 } , max : Point { x : 79 , y : 49 } } } ;
2828 let mut con = Console :: init_root ( game. window_bounds . max . x + 1 , game. window_bounds . max . y + 1 , "libtcod Rust tutorial" , false ) ;
29- let mut c = Character :: new ( 40 , 25 , '@' ) ;
30- let mut d = NPC :: new ( 10 , 10 , 'd' ) ;
31- let objs: Vec < & mut Updates > = vec ! [
32- & mut d as & mut Updates ,
33- & mut c as & mut Updates
29+ let c = box Character :: new ( 40 , 25 , '@' ) as Box < Updates > ;
30+ let d = box NPC :: new ( 10 , 10 , 'd' ) as Box < Updates > ;
31+ let mut objs: Vec < Box < Updates > > = vec ! [
32+ c, d
3433 ] ;
3534
3635 render ( & mut con, & objs) ;
@@ -43,7 +42,7 @@ fn main() {
4342 Special ( key_code:: Escape ) => game. exit = true ,
4443 _ => { }
4544 }
46- update ( & objs, keypress, game) ;
45+ update ( & mut objs, keypress, game) ;
4746
4847 // render
4948 render ( & mut con, & objs) ;
0 commit comments