Here is again the newer version of the raycasting library
with wall, floor and ceilig rendering an many more functions.
It has its own fast pixel-rendering routines.
I hope that some of the coders here can use it.
Library and examples:
Code: Select all
InitSprite()
InitKeyboard();
Enumeration
#Buffer1
#Tex
EndEnumeration
Declare Render16( a,b, c, d, e)
WndScrID = OpenScreen(640, 480,16, "")
SetFrameRate(60)
CreateSprite(#Buffer1, 320,200,#PB_Sprite_Memory) ;//screenbuffer
LoadSprite(#Tex,"texd.bmp",#PB_Sprite_Memory ) ;//texture
StartDrawing(SpriteOutput(#Buffer1))
buffer1= DrawingBuffer() ;screenmemory
StopDrawing()
StartDrawing(SpriteOutput(#Tex))
tex= DrawingBuffer() ; texturememory
StopDrawing()
Repeat
;draw the wall with perspective
For a = 1 To 64 ; texture is 64 pixel large
Render16(buffer1,tex,150-a,a,a) ;200-a = height
Next a
DisplaySprite(#Buffer1, 1, 1)
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;/////////////////////RENDER WALL FAST/////////////////////////////
Procedure Render16(screen, bmp, height, screenx, row)
a1=0; .
index=bmp+(128*row); .
factor=(64.0/height)* 65536;
ch=100-height/2
If(ch<0)
a1=factor*(-ch); .
ch=0;
dh=200;
Else
dh=100+height/2;
EndIf
While(ch<dh)
color.w= PeekW(index+((a1>>16)<<1) )
PokeW(screen+((320*ch+screenx)<<1),color )
ch=ch+1
a1=a1+factor
Wend
EndProcedure
;////////////////////////////////////////////////////////////
End