I tried adapting some raycasting code I found at lodev•org/cgtutor/raycasting•html Unfortunately I have some bugs, the view falls apart when looking from certain angles. Not sure what I did wrong.
It is nothing fancy, very basic. Here is a shot of me trying to debug things. Seems at a certain point it just doesn't see walls anymore. Must be something with stepping from block edge to block edge.
Stewart
It took me about 20 minutes
I copied the .C file to Notepad++ and used REGEX repeatedly to convert it all into SB code
And sent it through PetitModem and it worked immediately
Without VSYNC or WAIT it runs at roughly 30fps
I'll send you guys the code
The only modifications I did were give it GPAGE buffering
The code is the exact same as the websìte, all comments were preserved
I'll send you guys the code so you can use it for whatever
I'm just suprised it uses only GLINE to draw, that could be sped up extremely, by turning it into GFILL, and making the step size > 1
Oh and I just realized
on line 120, VAR RED,GRE,BLU doesn't reset their values to 0
So it should be VAR RED=0,GRE=0,BLU=0 to prevent some blocks from randomly changing color
Thanks!! That was a big help! It looks like my problem was a side distance y that I mistyped as side distance x. Copy paste strikes again.
Now I have a question, is it me, or is the display mirrored?
This is what I think it should look like.
oh wow cool.
i have a question though, is it possible to make a map that builds itself as it goes BUT rebuilds in the same way when going back
see im am working on a map generator which is going well, so it spawns items then it builds itself by deleting the prior map parts and spawning new tiles, but im wondering what i can use to make it biuld back the same way when going back.
It sounds like you are building the map based on a random number generator. Right? I am assuming SmileBasic is using something like a Merssenine twister for it's random number generator. In something like that, the next random number is based on the last one generated. You can however seed the random number generator with any starting value you like with randomize.
So, if you reseed the random number generator with a given seed you should get the same random numbers out each time (assuming nothing else in the game uses them before you get to them). That does mean you have to keep track of a seed per re-creatable area. I wouldn't try it with small of slices.
SmileBasic isn't too memory poor it should be able to generate pretty big worlds.
I would try generating the world into an array then copying things into the bg pages as needed. Then you only have to generate things once. Even without a memory buffer you should be able to fit several screen fulls of data into the bg pages. Then you can use bgofs to scroll around.
LOADING... to answer your question
You need to use either perlin noise or the simplex noise algorithm
You could try building your pen implementation of turning a 1 dimensional number generator into a 2 dimensional one
But why do that, NOISE(X,Y,Z) is already on smilebasicsouce it smooths out the noise too, depending on how small x and y and z change