Skip to content

Commit 13dfba9

Browse files
committed
vectors are now cloneables, update ContextSettings class, there is now an default static method and update the pong example.
1 parent 6dca54b commit 13dfba9

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

src/examples/pong/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn main () -> () {
3535
let ballRadius : f32 = 10.;
3636

3737
// Create the window of the application
38-
let setting: ContextSettings = ContextSettings{depthBits: 10, stencilBits: 10, antialiasingLevel: 1, majorVersion: 0, minorVersion: 1};
38+
let setting : ContextSettings = ContextSettings::default();
3939
let mut window : RenderWindow = match RenderWindow::new(VideoMode::new_init(gameWidth, gameHeight, 32), ~"SFML Pong", sfClose, &setting) {
4040
Some(window) => window,
4141
None => fail!("Cannot create a new Render Window.")
@@ -178,7 +178,7 @@ fn main () -> () {
178178
179179
// Move the ball
180180
let factor = ballSpeed * deltaTime;
181-
ball.move(~Vector2f::new(ballAngle.cos() * factor, ballAngle.cos() * factor));
181+
ball.move(~Vector2f::new(ballAngle.cos() * factor, ballAngle.sin() * factor));
182182
183183
// Check collisions between the ball and the screen
184184
if ball.get_position().x - ballRadius < 0. {

src/rsfml/system/vector2.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub use std::libc::{c_uint, c_int, c_float};
3434
/**
3535
* Implemention of Vector2i
3636
*/
37+
#[deriving(Clone)]
3738
pub struct Vector2i {
3839
x : i32,
3940
y : i32
@@ -42,6 +43,7 @@ pub struct Vector2i {
4243
/**
4344
* Implemention of Vector2u
4445
*/
46+
#[deriving(Clone)]
4547
pub struct Vector2u {
4648
x : u32,
4749
y : u32
@@ -50,6 +52,7 @@ pub struct Vector2u {
5052
/**
5153
* Implemention of Vector2f
5254
*/
55+
#[deriving(Clone)]
5356
pub struct Vector2f {
5457
x : f32,
5558
y : f32

src/rsfml/system/vector3.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
pub use std::libc::{c_float};
3333

34+
#[deriving(Clone)]
3435
pub struct Vector3f {
3536
x : f32,
3637
y : f32,

src/rsfml/window/context_settings.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,21 @@
3131

3232

3333
pub struct ContextSettings {
34-
depthBits: uint,
35-
stencilBits: uint,
36-
antialiasingLevel: uint,
37-
majorVersion: uint,
38-
minorVersion: uint
34+
depth_bits: uint,
35+
stencil_bits: uint,
36+
antialiasing_level: uint,
37+
major_version: uint,
38+
minor_version: uint
39+
}
40+
41+
impl ContextSettings {
42+
pub fn default() -> ContextSettings {
43+
ContextSettings {
44+
depth_bits : 0,
45+
stencil_bits : 0,
46+
antialiasing_level : 0,
47+
major_version : 2,
48+
minor_version : 0
49+
}
50+
}
3951
}

0 commit comments

Comments
 (0)