06-21-2005, 09:29 PM
Quote:Declare Sub drawflat(a,b,fromX,H)
dim shared FloorMap(9,9) as integer, TextureMap(9,9) as integer
dim shared Textures(9,9) as integer
type Ray
HitX as integer
HitY as integer
HitCount as integer
Far as integer
end type
Dim shared RayData(31) as Ray, TextureHits(9,9) as integer
for i = 0 to 9:for j = 0 to 9
read FloorMap(j,i)
TextureMap(j,i) = int(rnd*256)+1
Textures(j,i)= i
next j:next i
screen 13
x!=5:y!=5! = 0
do:A$ = right$(inkey$,1)
if A$ = chr$(27) then end
if A$ = "H" then x! = x! + cos(D!):y!= y! + Sin(D!)
if A$ = "P" then x! = x! - cos(D!):y!= y! - Sin(D!)
if A$ = "K" then D! = D! - .1
if A$ = "M" then D! = D! + .1
if D! <0 then D! = 6.1
if D! > 6.2 then D! = 0
if A$ <> "" then
cls
i=-1
print D!
for j! = D! - 1 to D! + 1 step (2/32)
i=i+1
addX!=0
addY!=0
Far = 0
do:Far = Far + 1
addX! = addX! + cos(j!)
addY! = addY! + sin(j!)
if FloorMap(int(x!+addX!),int(y!+addY!))<> 0 then exit do
loop
RayData(i).HitX = x!+AddX!
RayData(i).HitY = y!+AddY!
RayData(i).Far = Far
TextureHits(x!+AddX!,y!+AddY!)=TextureHits(x!+AddX!,y!+AddY!)+1
RayData(i).HitCount = TextureHits(x!+AddX!,y!+AddY!)
next j!
for i = 0 to 31
Far = RayData(i).Far
if Far>9 then Far = 9
Height = 200-(10*Far)-(10*Far)
Numerator = RayData(i).HitCount
Denominator= TextureHits(RayData(i).HitX,RayData(i).HitY)
DrawFlat i*10,99-(Height/2), 10*(Numerator/Denominator), Height*2
next i
end if
loop
Data 1,1,1,1,1,1,1,1,1,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,1,1,1,1,1,1,1,1,1
sub drawflat(a,b,fromX,H)
i = fromX -1:for j = 0 to 9:
line (a,b+(j*(H/20)))-step(10,H/20),textures(i,j),bf
next j
end sub
I know I haven't quite figured out texture-mapping (to put it mildly), but I've a feeling the bugs in this (certain area's are just random color-blocks, and it crashes after a random number of moves) are more to do with me impinging on other areas of memory, because my FB doesn't seem to mind me putting in to high indices in arrays, which can be dangerous.
Of course, it may also be my FB version is too old, if nothing goes wrong for ye guys that's probably it.
matt... feeling like a fuc king n00b...