This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
struct Color | |
{ | |
unsigned char r, g, b; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct File | |
{ | |
uint8* data; | |
uint32 size; | |
}; | |
struct LoadedFile | |
{ | |
bool valid; | |
File file; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.health_bar_texture.map(|t| { | |
Sprite::new_with_texture(t).map(|mut s| { | |
s.set_position(&Vector2f::new(10.,10.)); | |
window.draw(&s); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn load_level(&mut self, filename: ~str) -> ~[~Entity] { | |
let level_json_str = File::open(&Path::new(filename)).read_to_end(); | |
let level_json = match json::from_str(level_json_str.to_str()) { | |
Ok(json) => json, | |
Err(e) => fail!("Failed to load level.") | |
}; | |
let root_json = match level_json { json::Object(~o) => Some(o), _ => None}; | |
let entities_json = root_json.as_ref().map_or(~[], |&j| | |
j.find(&~"entities").as_ref().map_or(~[], |&e| match e { json::List(l) => l, _ => ~[]}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut layers = ~[ | |
~GameLayer::new(&mut resource_store) as ~Layer:, | |
~GuiLayer::new() as ~Layer | |
]; | |
while window.is_open() { | |
let mut new_layers: ~[~Layer:] = ~[]; | |
for layer in layers.iter() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game_layer.rs:34:6: 34:13 error: cannot pack type `~player::Player`, which does | |
not fulfill `Send`, as a trait bounded by Send | |
game_layer.rs:34 ~player as ~Entity, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D:\Dokument\GitHub\rust-sfml\src\rsfml\graphics\render_window.rs:200:32: 200:39 | |
error: instantiating a type parameter with an incompatible type `std::cell::RefC | |
ell<graphics::view::View>`, which does not fulfill `Freeze` | |
D:\Dokument\GitHub\rust-sfml\src\rsfml\graphics\render_window.rs:200 | |
let def_view = Rc::new(RefCell::new(Wrappable::wrap(raw_def_view))); | |
^~~~~~~ | |
D:\Dokument\GitHub\rust-sfml\src\rsfml\graphics\render_window.rs:255:32: 255:39 | |
error: instantiating a type parameter with an incompatible type `std::cell::RefC | |
ell<graphics::view::View>`, which does not fulfill `Freeze` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub trait Entity { | |
// ... some irrelevant functions | |
} | |
impl<'a> AnyRefExt<'a> for &'a ~Entity { | |
#[inline] | |
fn is<T: 'static>(self) -> bool { | |
// Get TypeId of the type this function is instantiated with | |
let t = TypeId::of::<T>(); |
NewerOlder