- "j" as in "jahmaican", not as in "java" obviously!
So I was bored and I was reading about raycasting here
and I decided to rewrite this in Ruby. There's still room for improvement, but it works as is.
v0.13 added simple gamestatesControls:WSAD
v0.13 hereGithub page
That is using textured quads though, so uses quite a different method of rendering. This raycaster ONLY draws vertical lines, but it is very effective.
EDIT: Oops, yes, it is the same as rubystein. Think that technique might be a bit slow in Ruby though, since you have to read and set pixels, not just draw whole lines (went down from 50 to 3 FPS when I just drew the lines pixel by pixel rather than using a line primative...so not a possibility!).
Actually, thinking about it, doing it efficiently in Gosu would probably involve cropping down to a single vertical line and drawing the whole texture directly on the screen. Maybe I'll have a play with that myself. Curious if it is doable.
I think that is exactly what Rubystein is doing (or was doing - it seems only there are only forks left on github).
I dunno, rayPosX looks a lot more Java than the usual Ruby ray_pos_x :D
I'm really impressed that Texplay worked so fast. I still get 45FPS when I run it at the full 640x480.
If you use:
moveSpeed = 10.0 / fps
rotSpeed = 5.0 / fps
Then the movement speed is no longer dependent on actual FPS.
I'd also recommend using #div and #fdiv rather than forcing to_f and to_i before division with /
Hi, I just tried this out for the first time. As a bonus, everything worked on first attempt, which is usually not the case on my system. :)
This is killer!... It's a like a nice paintball battle arena, all ready to be put into action.
Two thumbs up!
This deserves at least 4 thumbs up, and dozens of toes also up.
Bored at work I was experimenting with texplay :texture parameter. This clearly isn't the result I was hoping for, but I was suprised to find out it has nearly no negative influence on program performance.
I finally managed to get rid of tiled and actually implemented textured walls:
And it works even faster than the recent version - omg so efficient! No time now, but I'll upload it later today (or tomorrow maybe).
I just cd'ed into my jcaster folder and ran "git pull origin" followed by "ruby jcaster.rb". This is wonderful. Awesome awesome awesome.
Now I can put 4 different textures on a wall:
and it has virtually no negative influence on performance, because every piece of wall is still represented by an integer, eg. 0x01020304 means there will be texture 1 put on side 3, texture 2 on side 2, texture 3 on side 1 and texture 4 on side 0 . Proper texture is chosen by only two bitwise operations. And your CPU loves bitwise operations. This kind of representation also introduces a limitation of 255 wall textures per map, but I reckon it's more than enough for a raycasting engine.
On 32-bit platforms, Ruby Fixnums are 30-bit, I think, because some bits are used to represent other values (nil, false, true and probably something else that I forgot). On 64-bit platforms, they're probably 62-bit or something odd like that, so you could even have a "roof" and "ceiling" texture in case the walls are see-through!! ;)
In fact they're 31 and 63 bit. According to this and to the funky way Ruby deals with negative numbers in hex representation that I don't get at all, at current state exceeding a value of 63 (3F) for side 3 (on 32-bit platform) will result in conversion to Bignum which might slow down the process horribly or even destroy the world (on the other hand, there's a possibility it'll be completely fine!)
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill