Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Code you wrote [Part II]

Name: Anonymous 2014-09-18 3:37

All I've worked on tonight is this dumb raycaster: http://hastebin.com/iyerililov.rs

I screwed up the projection something awful and I have no idea how, but otherwise it sort of works.

To compile: Install a recent Rust+Cargo nightly, save this file http://hastebin.com/huyobaripa.toml as "Cargo.toml," put the Rust source in "src/ray.rs," and type "cargo run." It will automatically download and build the dependencies.

Name: Anonymous 2014-09-19 1:42

let dest = self.player.pos + if self.keys[0] {
self.player.dir * walk_speed
} else if self.keys[1] {
self.player.dir * walk_speed * -0.5f64
} else if self.keys[2] {
self.right * walk_speed
} else if self.keys[3] {
self.right * walk_speed * -1.0f64
} else {
Vec2 { x: 0.0f64, y: 0.0 }
};


This could do with a match statement:

let dest = match self.keys {
[true,_,_,_, _,_,_,_] => self.player.dir * walk_speed,
[_,true,_,_, _,_,_,_] => ...,
...
}


Something similar in the playpen to prove it works:http://play.rust-lang.org/?code=%0A%0Afn%20main()%20%7B%0A%20%20%20%20let%20keys%20%3D%20%5Bfalse%2C%20true%2C%20false%2C%20true%5D%3B%0A%20%20%20%20let%20state%20%3D%2010f32%3B%0A%20%20%20%20let%20add%20%3D%200.5f32%3B%0A%20%20%20%20%0A%20%20%20%20let%20newstate%20%3D%20match%20keys%20%7B%0A%20%20%20%20%20%20%20%20%5Btrue%2C_%2C_%2C_%5D%20%3D%3E%20state%20%2B%20add%2C%0A%20%20%20%20%20%20%20%20%5B_%2Ctrue%2C_%2C_%5D%20%3D%3E%20state%20-%20add%2C%0A%20%20%20%20%20%20%20%20_%20%3D%3E%200f32%2C%20%2F%2F%20you%20get%20the%20idea%0A%20%20%20%20%7D%3B%0A%20%20%20%20%0A%20%20%20%20println!(%22%7B%7D%22%2C%20newstate)%3B%0A%7D

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List