Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Texture(i32);
- struct Game<'s> {
- priv textures : ~[~Texture],
- priv sprites : ~[Sprite<'s>]
- }
- struct Sprite<'s> {
- tex : &'s Texture,
- }
- impl<'s> Game<'s> {
- fn run(&mut self) {
- self.init();
- self.draw(); //should be in loop
- }
- fn draw(&mut self) {
- //draw each sprite, etc.
- }
- fn init(&mut self) {
- self.textures.push(~Texture(1));
- self.sprites.push(Sprite {tex: self.textures[0]});
- }
- fn new() -> Game {
- return Game {
- sprites: ~[],
- textures: ~[]
- };
- }
- }
- fn main() {
- let mut game = Game::new();
- game.run();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement