There is already a slipping collision, in any case at home its work very well. Fires was added. The case blue can be moved. The life was to add, of the damage appears with fires and the balls unfavourable. For the demolition of certain object I work above.
SYNC ON
SYNC RATE 60
SET DISPLAY MODE 1280,1024,32
HIDE MOUSE
rem valeur
null = make vector3(1)
null = make vector3(2)
null = make matrix4(3) : projection matrix4 3
null = make matrix4(4) : view matrix4 4
null = make matrix4(5) : world matrix4 5
gunOffsetX AS FLOAT = 15.0
gunOffsetY AS FLOAT = -20.0
gunOffsetZ AS FLOAT = 20.0
xPos AS FLOAT
zPos AS FLOAT
speed AS FLOAT = 10.0
xLook AS FLOAT
yAng AS FLOAT
lookSpeed AS FLOAT = 0.2
gunBobSpeed AS FLOAT = 6.0
gunBobMove AS FLOAT = 3.0
gunBobHeight AS FLOAT = 1.5
gunBobAng AS FLOAT
gunTurnAng AS FLOAT
gunLookAng AS FLOAT
mouseMovementX AS FLOAT
mouseMovementY AS FLOAT
v=2
val#=timer()
y#=100
r=100
bounce = 6
Angle = 0
Angle2 = 0
Angle3 = 0
add = 5
line#=100000.0
vie#=100
blur=100
rem fog et fond noir
fog on
color backdrop RGB(0,0,0)
rem création du personnage
MAKE OBJECT box 1,50,125,50
position object 1,0,62.5,0
HIDE OBJECT 1
MAKE MESH FROM OBJECT 1,1
ADD LIMB 1,1,1
DELETE MESH 1
rem création de l'arme
MAKE OBJECT BOX 2,10,10,100
GLUE OBJECT TO LIMB 2,1,1
disable object zdepth 2
rem création de l'object pour l'impact
make object sphere 3,10
color object 3,rgb(255,0,0)
hide object 3
rem création du sol
make object plain 6,10000,10000
rotate object 6,-90,0,0
position object 6,5000,0,5000
color object 6,RGB(0,255,0)
ghost object on 6
rem création des careaux du sol
MAKE MATRIX 1,10000,10000,100,100
make object cube 500,100
position object 500,500,50,500
color object 500,RGB(0,64,128)
GoSub _FlameSetup
rem début boucle
DO
GoSub _FlameLoop
rem déplacer objet bleu
if object collision(500,1)<>0
CollideObjects(object collision(500,1),500)
endif
rem blur
set camera to image 0,1,1024,1024
sprite 1,0,0,1
set sprite 1,0,1
size sprite 1,screen width(),screen height()
set sprite alpha 1,blur
rem création des obstacles
for g=200 to 400
if object exist(g)
else
make object cube g,100
position object g,rnd(10000),50,rnd(10000)
color object g,RGB(255,0,0)
endif
next
rem valeur 3d en 2d pour le réticule
project3dTo2d(1,object position x(3),object position y(3),object position z(3))
rem calculer la distance entre l'objet et le personnage
view matrix4 4
project vector3 1,2,3,4,5
cxa#=cxa#+(mousemovey()/10.0)
if cxa#<-90.0 then cxa#=-90.0
if cxa#>90.0 then cxa#=90.0
a2#=wrapvalue(a2#+(mousemovex()))
d# = cos(cxa#) * line#
x2#=object position x(1)
z2#=object position z(1)
ty# = y2# - sin(cxa#) * line#
tx# = newxvalue(x2#,a2#,d#)
tz# = newzvalue(z2#,a2#,d#)
olddist# = line#
for obj=200 to 400
if object exist(obj)
dist# = intersect object(obj, x2#,y2#,z2#,tx#,ty#,tz#)
if dist# < olddist# and dist# > 0
olddist# = dist#
endif
endif
next obj
dist# = olddist#
if dist# = 0 then dist# = line#
gdist# = cos(cxa#)*dist#
tx# = newxvalue(x2#, a2#, gdist#)
ty# = y2# - sin(cxa#)*dist#
tz# = newzvalue(z2#, a2#, gdist#)
rem positionne la sphere a l'endroit de l'impact présumé
position object 3,tx#,ty#,tz#
rem tir
if mouseclick()=1
for bullet=100 to 100
if object exist(bullet)
delete object bullet
make object cube bullet,10
position object bullet,object position x(3),object position y(3),object position z(3)
else
make object cube bullet,10
position object bullet,object position x(3),object position y(3),object position z(3)
endif
next
endif
mouseMovementX = MOUSEMOVEX()
mouseMovementY = MOUSEMOVEY()
text x vector3(1),y vector3(1),"+"
text 0,10,"FPS : "+str$(screen fps())
text 0,20,"VIE : "+str$(vie#)
rem valeur pour collision glissante
oldx4 = object position x(1)
oldy4 = object position y(1)
oldz4 = object position z(1)
oldangle4 = object angle y(1)
rem courire
if keystate(42)=1
r=100
y2#=r-30
u=10
endif
rem accroupi
if keystate(46)=1
r=50
y2#=r-30
u=2
endif
rem marcher
if keystate(42)=0 and keystate(46)=0
r=100
y2#=r-30
u=5
endif
y2#=r-30
rem mouvement
IF keystate(17)+keystate(31)+keystate(30)+keystate(32) > 0
rem avancer
if keystate(17)=1
move object 1,u
bounce = 1
add = 5
else
add = 0
bounce = 6
ENDIF
rem reculer
if keystate(31)=1
move object 1,-u
ENDIF
rem pas à gauche
if keystate(30)=1
if object angle z(1)=0
yrotate object 1,object angle y(1)-90
move object 1,u
yrotate object 1,object angle y(1)+90
else
yrotate object 1,object angle y(1)+90
move object 1,u
yrotate object 1,object angle y(1)-90
endif
ENDIF
rem pas à droite
if keystate(32)=1
if object angle z(1)=0
yrotate object 1,object angle y(1)+90
move object 1,u
yrotate object 1,object angle y(1)-90
else
yrotate object 1,object angle y(1)-90
move object 1,u
yrotate object 1,object angle y(1)+90
endif
ENDIF
rem valeur pour collision glissante
x4 = object position x(1)
y4 = object position y(1)
z4 = object position z(1)
angle4 = object angle y(1)
rem collision glissante
for o=200 to 400
if object exist(o)
if object collision(1, o)>0
position object 1, oldx4, y4, z4
if object collision(1, o)>0
position object 1, x4, y4, oldz4
if object collision(1, o)>0
position object 1, oldx4, y4, oldz4
endif
endif
endif
endif
next o
rem mouvement respiratoire
y# = r+sin(angle)/bounce
gunBobAng = WRAPVALUE(gunBobAng+gunBobSpeed)
ELSE
gunBobAng = CURVEANGLE(0,gunBobAng,10)
ENDIF
gunTurnAng = CURVEANGLE(WRAPVALUE(mouseMovementX),gunTurnAng,10)
gunLookAng = CURVEANGLE(WRAPVALUE(mouseMovementY),gunLookAng,10)
OFFSET LIMB 1,1,gunOffsetX+SIN(gunBobAng)*gunBobMove,gunOffsetY+ABS(COS(gunBobAng))*gunBobHeight,gunOffsetZ
ROTATE LIMB 1,1,gunLookAng,gunTurnAng,0
yAng = WRAPVALUE(yAng + mouseMovementX*lookSpeed)
xLook = WRAPVALUE(xLook + mouseMovementY*lookSpeed)
rem gravité
if object collision(1,6)
l2#=0
else
l2#=l2#+0.3
l#=l#+l2#
endif
rem vie
for tiren=20000 to 30000
if object exist(tiren)
if object collision (1,tiren)
delete object tiren
vie#=vie#-0.1
endif
endif
next tiren
rem mouvement camera celon object et mouvement respiratoire
position object 1,object position x(1),r-l#,object position z(1)
Inc Angle , 5
Inc Angle2, rnd(add)
Inc Angle3, rnd(add)
ROTATE OBJECT 1,0+wrapvalue(cxa#),yAng+a2#,0
PITCH OBJECT DOWN 1,xLook
POSITION CAMERA object position x(1),object position y(1),object position z(1)
ROTATE CAMERA xLook+wrapvalue(cxa#),yAng+sin(Angle2)+a2#,0-sin(Angle3)
SYNC
rem fin de boucle
LOOP
_FlameSetup:
FlameCount = 1200
FlameID = 50
ImageID = 50
FlameSize# = 12
FlameRadius# = 25
FlameHeight# = 50
FlameSpeed# = 1
FlameTapper# = 0.97
FlameDim# = 3
FlameShrink# = 1.25
Type Flame
ID
Radius#
Degree
Depth#
Size#
Fade#
EndType
Make object cube FlameID,1
hide object FlameID
create bitmap ImageID,50,50
ink rgb(200,130,30),0
for x=1 to 1000
ang=rnd(360)
rad=rnd(20)
dot 25+sin(ang)*rad,25+cos(ang)*rad
next x
`Blur fire image
blur bitmap ImageID,3
get image ImageID,0,0,50,50
delete bitmap ImageID
Dim Flame(FlameCount) as Flame
for i = 1000 to FlameCount
Flame(i).Radius# = rnd(flameRadius# * 100)
Flame(i).Radius# = Flame(i).Radius# / 100
Flame(i).Degree = rnd(359)
Flame(i).Depth# = rnd(FlameHeight#)
Flame(i).ID = FlameID + i
make object plain Flame(i).ID, FlameSize#, FlameSize#
position object Flame(i).ID,100,0,100
texture object Flame(i).ID,ImageID
set object ambient Flame(i).ID,0
set object transparency Flame(i).ID,1
Ghost Object on Flame(i).ID
Next i
Return
_FlameLoop:
for i = 1000 to FlameCount
If Flame(i).Depth# > FlameHeight#
Flame(i).Radius# = rnd(flameRadius# * 100)
Flame(i).Radius# = Flame(i).Radius# / 100
Flame(i).Degree = rnd(359)
Flame(i).Depth# = 0
Flame(i).Fade# = 200
Flame(i).Size# = 100
endif
Flame(i).Depth# = Flame(i).Depth# + FlameSpeed#
Flame(i).Fade# = Flame(i).Fade# - FlameDim#
Flame(i).Radius# = Flame(i).Radius# * FlameTapper#
Flame(i).Size# = Flame(i).Size# - FlameShrink#
if object collision(Flame(i).ID,1) then vie#=vie#-0.01
Position Object Flame(i).ID, object position x(FlameID)+300,object position y(flameID),object position Z(FlameID)+300
Set object to object orientation Flame(i).ID, FlameID
Move object Right Flame(i).ID, cos(Flame(i).Degree) * Flame(i).Radius#
Move Object UP Flame(i).ID, Flame(i).Depth#
Move Object Flame(i).ID, Sin(Flame(i).Degree) * Flame(i).Radius#
scale object Flame(i).ID,flame(i).size#,Flame(i).size#,100
fade object Flame(i).ID,Flame(i).Fade#
set object to camera orientation Flame(i).ID
next i
Return
function project3dTo2d(result as integer,x as float, y as float, z as float)
set vector3 2,x,y,z
view matrix4 4
project vector3 1,2,3,4,5
endfunction
function CollideObjects(Pl,Df)
Dfx#=object position x(Df)
Dfz#=object position z(Df)
Dfsx#=object size x(Df)/2
Dfsz#=object size z(Df)/2
left#=intersect object(Pl,Dfx#-Dfsx#,0,Dfz#-Dfsz#,Dfx#-Dfsx#,0,Dfz#+Dfsz#)
top#=intersect object(Pl,Dfx#-Dfsx#,0,Dfz#+Dfsz#,Dfx#+Dfsx#,0,Dfz#+Dfsx#)
right#=intersect object(Pl,Dfx#+Dfsx#,0,Dfz#+Dfsz#,Dfx#+Dfsx#,0,Dfz#-Dfsz#)
bottom#=intersect object(Pl,Dfx#-Dfsx#,0,Dfz#-Dfsz#,Dfx#+Dfsx#,0,Dfz#-Dfsz#)
if left# > 0 then move object right Df,10
if top# > 0 then move object Df,-10
if right# > 0 then move object left Df,10
if bottom# > 0 then move object Df,10
endfunction