Now the code is it :
Rem Project: Atom Engine
Rem Created: Thursday, September 24, 2009
Rem ***** Main Source File *****
rem menuIn()
rem sleep 10000
rem set window off
sync on
sync rate 60
remstart Resolution
width#=desktop width() : height#=desktop height()
set display mode width#,height#,32,1
set camera aspect width#/height#
remend
set display mode 1024,768,32
autocam off
phy start
ai start
lm start
set camera range 0.5, 30000
hide mouse
Fog On
global balasAct as integer
global balasMax as integer
load sound "AK74M\fire.wav",100
rem load images
load sound "sonidos\ambiente\incident.wav",123 : set sound volume 123,70 : loop sound 123
load image "bullethole.png", 178
hud=144 : load image "imagenes\hud\corrupt.dds",hud
rem load image "AK74M\AK74vweap_D2.DDS",2
load image "AK74vweap_COLOR.png",2
load image "AK74vweap_NRM.png",3
load image "AK74vweap_SPEC.png",4
Effect = E3D Load Effect( "efectos\fps creator\bumpcubereflectalpha\bumpcubereflectalpha.fx", 1 )
load object "AK74M\AK74_onside.X",10
rem Setup gun for player
lock object on 10
scale object 10,20,20,20
rotate object 10,180,270,90
position object 10,0.9,-0.8,3.7
disable object zdepth 10
set object light 10,1
Set Object Effect 10, Effect
rem Set camera
set camera range 1,10000
set ambient light 100
position camera 315.18,345,-745.316
rem Load Map
load object "bedroom.x",1
load object "bedroom_lm.x",2
rem set bump mapping on 1,1
ghost object on 2,1
rem position camera 335.18,340,-745.316
phy make rigid body static mesh 1
make light 1
position light 1,335.18,340,-745.316
remstart
INIT_WORLD()
LOAD_WORLD(1,"Example\Example.wgd","Example\",2)
remend
rem Camera
position camera x#,y#+10,z#-100
point camera x#,y#-20,z#
rem Player character
make object box 101,10,40,10 : hide object 101 : position object 101,x#,y#+16,z#-100
phy make box character controller 101,315.18, 300, -745.316, 10, 150, 50, 1, 10.5, 45.0
make object box 102,11,20,11 : phy make rigid body dynamic box 102
phy set rigid body kinematic 102,1
AI Add Player 101
remstart create our box controller
make object box 30, 20, 50, 20
phy make box character controller 30, 315.18, 300, -745.316, 10, 150, 50, 1, 10.5, 45.0
hide object 30
remend
rem Player character
dim armas$(9)
armas$(1) = "Colt.45"
armas$(2) = "44 SPCL"
armas$(3) = "M9"
armas$(4) = "G18"
armas$(5) = "JSCS Breecher"
armas$(6) = "AK 47"
armas$(7) = "M16"
armas$(8) = "M107"
armas$(9) = "Plasma cannon"
rem codigo de prueba
balasAct = 100
rem our main loop
KD SetAnisotropy 16
do
if mouseclick() = 1 and balasAct > 0
`Save position of player
x# = object position x(101)
y# = object position y(101)
z# = object position z(101)
`Move player in direction you want to fire bullet
move object 101, 1
`Work out x,y,z vectors by just subtracting the old position from the new position
xvec# = object position x(101) - x#
yvec# = object position y(101) - y#
zvec# = object position z(101) - z#
`Put the player back into the correct position
move object 101,-1
` cast a ray
value = phy ray cast all shapes ( x#,y#,z#,xvec#,yvec#,zvec#)
REM sleep 10
dec balasAct
endif
rem Slow shift keeps character in contact with scene
movementshifter=wrapvalue(movementshifter+1)
movement#=cos(movementshifter)/10.0
`
rem Movement using WASD and Mouselook
speed#=175.0 : if shiftkey()=1 then speed#=250.0
if upkey()=1 or keystate(17)=1 then movement#=speed#
if downkey()=1 or keystate(31)=1 then movement#=0.0-speed#
angy# = object angle y(101) : angx# = camera angle x() : xrotate camera 0
if leftkey()=1 or keystate(30)=1 then yrotate object 101,angy#-90 : phy move character controller 101,speed# : yrotate object 101,angy#
if rightkey()=1 or keystate(32)=1 then yrotate object 101,angy#+90 : phy move character controller 101,speed# : yrotate object 101,angy#
angy#=angy#+mousemovex()/2.0
yrotate camera angy# : xrotate camera angx#+mousemovey()/2.0
yrotate object 101,angy#
`
rem Always move the character, even if still
walkstep#=wrapvalue(walkstep#+(movement#/8.0))
phy move character controller 101,movement#
position camera object position x(101), object position y(101)+15+cos(walkstep#), object position z(101)
phy set rigid body kinematic position 102,object position x(101), object position y(101)+10, object position z(101)
remstart rotate and position the camera based on the box controller
position camera object position x ( 30 ), object position y ( 30 ) + 20, object position z ( 30 )
rotate camera object angle x ( 30 ), object angle y ( 30 ), object angle z ( 30 )
OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#
CameraAngleY# = wrapvalue ( CameraAngleY# + mousemovex ( ) * 0.4 )
CameraAngleX# = wrapvalue ( CameraAngleX# + mousemovey ( ) * 0.4 )
yrotate object 30, curveangle ( CameraAngleY#, OldCamAngleY#, 24 )
xrotate object 30, curveangle ( CameraAngleX#, OldCamAngleX#, 24 )
if CameraAngleX# > 82
CameraAngelX# = 82
endif
rem react to key presses and move the controller
key = 0
if keystate(17) = 1
key = 1
phy move character controller 30, 200.0
endif
if keystate(31) = 1
key = 1
phy move character controller 30, -200.0
endif
if key = 0
phy move character controller 30, 0.0
endif
remend
rem update the simulation and screen
rem gosub controlShooting
gosub hud
gosub armaAct
print (phy get ray cast hit point x ())
print sCREEN FPS()
phy update
gosub rayCollision
remstart
if counter >= 500
stimer = timer()+3000
id = createRagDoll(id,offset)
offset = offset + 20
if offset > 150
offset = 40
endif
counter = 0
endif
inc counter
remend
Text 0,768,"FPS: "+STR$(SCREEN FPS())
sync
loop
remstart
rem In addition, we must ensure the player is always at the center of the universe. To that end, when ever the player moves we must adjust the position of the sky and the 3D listener which represents the player in our game:
rem Player is always focal point of sky
rem position object SkyObj,camera position x(),camera position y(),camera position z()
rem Position listener at player for 3D sound
position listener camera position x(),camera position y(),camera position z()
rotate listener camera angle x(),camera angle y(),camera angle z()
remend
controlShooting:
if mouseclick()=1 and balasAct > 0
rotate object 10,x#,y#,z# `get you player pointing in whichever direction (but he's probably already pointing in the right direction, so dont bother with this bit)
armaxpos# = object position x(10)
armaypos# = object position y(10)
armazpos# = object position z(10)
`Move player in direction you want to fire bullet
move object 10,1
`Work out x,y,z vectors by just subtracting the old position from the new position
xvec# = object position x(10) - armaxpos#
yvec# = object position y(10) - armaypos#
zvec# = object position z(10) - armazpos#
`Put the player back into the correct position
move object 10,-1
temp = phy ray cast all shapes(armaxpos#,armaypos#,armazpos#,xvec#,yvec#,zvec#)
endif
dec balasAct
return
rayCollision:
if phy get ray cast object() = 1
rem set sound volume 123,100
rem color object phy get ray cast object ( ), rgb ( 0, 0, 255 )
delete object 1545
if object exist(1545)
remstart
rayPointx = phy get ray cast hit point x ()
rayPointy = phy get ray cast hit point y ()
rayPointz = phy get ray cast hit point z ()
position object 1545,phy get ray cast hit point x ()+ 10,phy get ray cast hit point y (),phy get ray cast hit point z ()
remend
else
make object plain 1545,image width (178),image height (178)
texture object 1545,178
position object 1545,rayPointx#,rayPointy#,rayPointz#
endif
endif
return
armaAct:
select tecla
do case
case 2:
armaAct$ = armas$(1)
endcase
case 3:
armaAct$ = armas$(2)
endcase
case 4:
armaAct$ = armas$(3)
endcase
case 5:
armaAct$ = armas$(4)
endcase
case 6:
armaAct$ = armas$(5)
endcase
case 7:
armaAct$ = armas$(6)
endcase
case 8:
armaAct$ = armas$(7)
endcase
case 9:
armaAct$ = armas$(8)
endcase
case 10:
armaAct$ = armas$(9)
endcase
endselect
if tecla = 2
armaAct$ = armas$(1)
endif
return
hud:
sprite 1,930,570,hud
set sprite alpha 1,150
set text font "verdana"
set text size 28
text 1030,600,"100"
set cursor 1100,350
print armaAct$
set cursor 1100,450
print balasAct
print rayPointx#
print rayPointy#
print rayPointz#
rem print tecla
return
but the bullethole stais under the bed???
How can I fix it???
please help me