Anyone up to a challenge?

BlitzMax Forums/BlitzMax Programming/Anyone up to a challenge?

jalih(Posted 2010) [#1]
Hi all,

I recently wrote a little raycaster in Hollywood

Number keys 1-7 change the drawing mode in demo.

Problem is: Hollywood is not really very well suited for this kind of stuff and some bloke on a local programming forum just shot my implementation down without even seeing the code! He even hinted that porting code to BlitzMax wouldn't make much of an speed difference!

Since learning BlitzMax is still currently on my todo list, anyone here care to prove him wrong?

Porting from Hollywood to BlitzMax should be quite easy as Hollywood has a basic dialect. Code itself has only a very few lines and is very simple with stuff like basic vector addition and basic trigonometry.

I can post the code if someone is interested.


ima747(Posted 2010) [#2]
If you're willing to post it go for it, never know what feedback you'll get :0) if it's short enough and I have time I'll take a stab. If it looks like basic there's a good chance a lot of it will just work, thought I've never seen Hollywood before so can't really promise that... porting math heavy code I find isn't usually that hard as math is usually about the same in every language... With a ray caster I would expect your bottleneck to be in the drawing implementation since pixel by pixel drawing on modern hardware is usually tedious to say the least (opengl and directx are made for bigger things than pixels)


_JIM(Posted 2010) [#3]
I think he can be proved wrong.

However, there might be generic optimizations (algorithm rather than compiler) that can improve speed.

Also, with a bit of luck you can port the more intensive parts to C and include them in your BMax program. If that's not fast enough then swithing to raw opengl might make it a bit faster.

Could be an interesting challenge.


jalih(Posted 2010) [#4]
Thanks for showing some interest!

Here is the Hollywood code


DrDeath(Posted 2010) [#5]
Is this based on this example?


jalih(Posted 2010) [#6]
Yep, that example was the starting point. I 'm gonna send it to Hollywood forums when it's finished as an example for beginners. I kept all the variable names intact, so they can easily follow the original tutorial.

I just added some stuff to guard for zero divides, added simple distance shading and removed some parts that did not seem to affect the end result.


slenkar(Posted 2010) [#7]
i had a crack at it



couldnt work out how to read the pixels into an array because int and double both return error messages,
also i get a divide by zero error with raydiry


Jesse(Posted 2010) [#8]
first time I hear of that CL.

I would try it but that CL don't seem to have proper declaration of variables. I can't tell if the variables are supposed to be integers or floats. I don't know if there is such a thing as "superStrict" for that language. you really need it. I noticed that there are variables being used in a function as part of a calculation and had not been previously declared while others you declared as local at the beginning of the function. That way of programming makes it hard for others to understand or even attempt to understand and translate.
One of the thing I like most about BMax is it's ability to force programmers into a disciplined way of programming.

Anyway, that was just my opinion. I am sure someone has experience in "Hollywood" and BMax and can figure it out with no problems.


jalih(Posted 2010) [#9]
Some info about Hollywood language:

Hollywood only has one 64-bit data type for numbers. It can be used to store signed integers or real numbers.

Variables can be declared anywhere in the code. If you assign a value to a variable for the first time, then this variable will become global if you did not explicitly tell Hollywood that it shall be local by using the Local keyword.

If there is a local variable that has the same name as the global variable, then Hollywood will always use this local variable first.

Local variables are faster and can be easily collected by garbage collector, when they are not needed anymore. Globals must be explicitly set to Nil.


matibee(Posted 2010) [#10]
With a ray caster I would expect your bottleneck to be in the drawing implementation since pixel by pixel drawing on modern hardware is usually tedious to say the least (opengl and directx are made for bigger things than pixels)


We found a solution a while back...
http://www.blitzbasic.com/Community/posts.php?topic=89478#1016434

:)


jalih(Posted 2010) [#11]
Thanks! that does the trick!

I will modify it a bit, add distant shading, floor casting, sprites and what ever else comes to mind...