Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. struct Texture(i32);
  2.  
  3. struct Game<'s> {
  4. priv textures : ~[~Texture],
  5. priv sprites : ~[Sprite<'s>]
  6. }
  7.  
  8. struct Sprite<'s> {
  9. tex : &'s Texture,
  10. }
  11.  
  12. impl<'s> Game<'s> {
  13. fn run(&mut self) {
  14. self.init();
  15. self.draw(); //should be in loop
  16. }
  17.  
  18. fn draw(&mut self) {
  19. //draw each sprite, etc.
  20. }
  21.  
  22. fn init(&mut self) {
  23. self.textures.push(~Texture(1));
  24. self.sprites.push(Sprite {tex: self.textures[0]});
  25. }
  26.  
  27. fn new() -> Game {
  28. return Game {
  29. sprites: ~[],
  30. textures: ~[]
  31. };
  32. }
  33. }
  34.  
  35. fn main() {
  36. let mut game = Game::new();
  37. game.run();
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement