Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Showcase / jCaster - a simple raycaster (almost 3D!)
- - By jahmaican Date 2013-06-16 16:35 Edited 2013-11-27 07:30


jCaster - "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 gamestates

Controls:
WSAD - movement
Mouse - looking
P - pause
Escape - exit

Download:
v0.13 here
Github page
Parent - - By jlnr (dev) Date 2013-06-16 21:50
Wow! Pretty fast, especially considering that you're using TexPlay.

I just have to link to https://github.com/zenkalia/rubystein as related work. :)
Parent - - By Spooner Date 2013-06-17 13:39 Edited 2013-06-17 13:59
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!).
Parent - - By Spooner Date 2013-06-17 14:53
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.
Parent - By jlnr (dev) Date 2013-06-17 20:10 Edited 2013-06-17 20:30
I think that is exactly what Rubystein is doing (or was doing - it seems only there are only forks left on github).
Parent - By Spooner Date 2013-06-17 11:48
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 /
Parent - - By ml Date 2013-08-27 00:38
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!
Parent - By chase4926 Date 2013-08-30 15:48
Nonsense!
This deserves at least 4 thumbs up, and dozens of toes also up.
Parent - By jahmaican Date 2013-09-02 06:51
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.
Parent - - By jahmaican Date 2013-11-20 17:08
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).
Parent - By ml Date 2013-11-23 04:23
I just cd'ed into my jcaster folder and ran "git pull origin" followed by "ruby jcaster.rb". This is wonderful. Awesome awesome awesome.
Parent - - By jahmaican Date 2014-01-28 22:36
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.
Parent - - By jlnr (dev) Date 2014-01-29 21:11
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!! ;)
Parent - By jahmaican Date 2014-01-29 23:12
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!)
Up Topic Gosu / Gosu Showcase / jCaster - a simple raycaster (almost 3D!)

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill