This file contains 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>(); |
This file contains 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 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 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 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 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 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 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 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
# propagates error of |v2 - v1| where v2 and v1 are vectors and parameters are in celestial coordinates | |
def celestial_magnitude_of_velocity_difference_error( | |
ra1_deg, dec1_deg, r1, | |
ra1_error_deg, dec1_error_deg, r1_error, | |
pmra1_deg_per_s, pmdec1_deg_per_s, rv1, | |
pmra1_error_deg_per_s, pmdec1_error_deg_per_s, rv1_error, | |
ra2_deg, dec2_deg, r2, | |
ra2_error_deg, dec2_error_deg, r2_error, | |
pmra2_deg_per_s, pmdec2_deg_per_s, rv2, | |
pmra2_error_deg_per_s, pmdec2_error_deg_per_s, rv2_error): |
This file contains 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
# Linearly propagates the error of a velocity given in celestial coordinates to cartesian via the | |
# formulas identical to the ones in function cartesian_velocity_from_celestial. | |
def celestial_coords_to_cartesian_error( | |
ra, dec, r, | |
ra_error, dec_error, r_error, | |
pmra, pmdec, rv, | |
pmra_error, pmdec_error, rv_error): | |
dvx_dra = -cos(dec)*sin(ra)*rv + r*cos(dec)*cos(ra)*pmra - r*sin(dec)*sin(ra)*pmdec | |
dvx_ddec = -sin(dec)*cos(ra)*rv - r*sin(dec)*sin(ra)*pmra + r*cos(dec)*cos(ra)*pmdec | |
dvx_dr = cos(dec)*sin(ra)*pmra + sin(dec)*cos(ra)*pmdec |
OlderNewer