I have a problem. I make a pixel ligting and is now good but when i move to wall then light hmm i don't know how to say.. a shadow line(?) at the wall. Look at the screen:
sync on
sync rate 60
hide mouse
autocam off
randomize timer()
global numSpheres as integer : numSpheres = 5
global radius# as double float : radius# = 7.0
global littleRadius# as double float : littleRadius# = 2.0
makeLevel()
makePlayer()
global rtimer as integer
global stimer as integer
global vtimer as integer
rem player movement vector
global vx# as double float
global vy# as double float
global vz# as double float
global gravity# as double float : gravity# = -0.1
global slope# as double float : slope# = 0.5
global ground as integer : ground = 1
global jumptimer as integer : jumptimer = 0
global syncmode as integer : syncmode = 60
global view as integer : view = 1
global hide as integer : hide = 0
global speed as float = 0.1
global speedmouse as float = 9.0
do
MovePlayer()
positionCameraToObject(2,view)
realtimeShadow()
text 0,0,"W/A/S/D poruszanie, Spacja skok"
text 0,10,"FPS: "+str$(screen fps())
text 0,20,"Dotyka gruntu: "+str$(ground)
text 0,30,"Xpozycja: "+str$(vx#)
text 0,40,"Zpozycja: "+str$(vz#)
text 0,50,"Ypozycja: "+str$(vy#)
sync
loop
function makeLevel()
rem PER PIXEL LIGHTING
load effect "PixelLighting.fx",1,0
load object "Mapa.X",1
rotate object 1,-90,0,0
sc_setupComplexObject 1,1,2
`sc_setupObject 1,1,0
set object effect 1,1
load image "Normalize.dds",5
load image "rock042.jpg",3
load image "rock042bump.jpg",4
load effect "NormalMapping.fx",3,0
load object "Mury.X",4 : set effect constant float 3,"U",1.0
set effect constant float 1,"V",1.0
rotate object 4,-90,0,0
sc_setupComplexObject 4,1,2
texture object 4,0,3
texture object 4,1,4
texture object 4,2,5
set object effect 4,3
hide light 0
Fog off
fog color rgb(0,0,0)
fog distance 400
color backdrop rgb(0,0,0)
rem NormalMapping
load image "metal106.jpg",1
load image "metal106BUMP.jpg",2
load effect "NormalMapping.fx",2,0
Load object "brama.X",3 : set effect constant float 2,"U",1.0
set effect constant float 1,"V",1.0
rotate object 3,-90,0,0
sc_setupComplexObject 3,1,2
texture object 3,0,1
texture object 3,1,2
texture object 3,2,5
set object effect 3,2
rem all level objects are group 1
endfunction
function makePlayer()
make object sphere 2,radius#*5.0
position object 2,-80,200,-20
sc_setupObject 2,0,1
hide object 2
`Torch
load image "Flare.JPG",50
make object sphere 50,50
texture object 50,50
ghost object on 50
set object light 50,0
vec = make vector4(1)
rem player has no group
endfunction
function movePlayer()
rem rotate player with mouse
XAngle# = wrapvalue(camera angle x() + 180.0) + mousemovey()/speedmouse
if XAngle# < 90.0 then XAngle# = 90.0
if XAngle# > 270.0 then XAngle# = 270.0
XAngle# = wrapvalue(XAngle# - 180.0)
YAngle# = wrapvalue(camera angle y() + mousemovex()/speedmouse)
rotate object 2,XAngle#, YAngle#, 0
oldx# = object position x(2)
oldy# = object position y(2)
oldz# = object position z(2)
rem apply gravity, and user changes to movement
angy# = object angle y(2)
vx# = 0
vz# = 0
if vy#=0 and jumptimer=0 then vy# = vy# + 12*gravity# else vy# = vy# + gravity#
if keystate(32)=1 then vx# = vx# + cos(angy#) : vz# = vz# - sin(angy#)
if keystate(30)=1 then vx# = vx# - cos(angy#) : vz# = vz# + sin(angy#)
if keystate(31)=1 then vx# = vx# - sin(angy#) : vz# = vz# - cos(angy#)
if keystate(17)=1 then vx# = vx# + sin(angy#) : vz# = vz# + cos(angy#)
if ground=1
if spacekey()=1 and jumptimer=0 then vy# = vy# + 3.0 : jumptimer = 20
endif
`Torch Position
position object 50,oldx#,50,oldz#
rotate object 50,90,0,-90
set vector4 1,object position x(50),object position y(50),object position z(50),0
set effect constant vector 1,"LightPosition",1
set effect constant vector 2,"LightPosition",1
set effect constant vector 3,"LightPosition",1
rem this would be the player's final position without collision
x# = oldx#+vx#
y# = oldy#+vy#
z# = oldz#+vz#
collide = sc_SphereCastGroup(1,oldx#,oldy#,oldz#,oldx#,oldy#+vy#,oldz#,radius#,0)
if collide>0
ny# = sc_getCollisionNormalY()
if abs(ny#)>slope#
oldy# = sc_getStaticCollisionY()
else
x# = x# - oldx# : z# = z# - oldz#
oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()
x# = x# + oldx# : z# = z# + oldz#
endif
if ny#>slope#
ground = 1
vy# = 0
else
ground = 0
if ny#<-slope# then vy# = gravity#
endif
else
oldy# = oldy# + vy#
ground = 0
endif
if ground = 1 and jumptimer>0 then dec jumptimer
collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,oldy#,z#,radius#,0)
if collide>0
x# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
vx# = 0
vz# = 0
endif
rem position the player
position object 2,x#,oldy#,z#
sc_updateObject 2
endfunction
function realtimeShadow()
endfunction
function positionCameraToObject(obj,thirdPerson)
position camera object position x(2),object position y(2)+10,object position z(2)
rotate camera object angle x(2),object angle y(2),object angle z(2)
endfunction
if memblock exist(1) then delete memblock 1