Показать сообщение отдельно
Старый 09.07.2015, 17:06   #10
L-ee-X
Разработчик
 
Аватар для L-ee-X
 
Регистрация: 06.06.2011
Адрес: Ирк. обл.
Сообщений: 541
Написано 133 полезных сообщений
(для 220 пользователей)
Ответ: Как сделать стрельбу

Держи, уже почти готовый CoD
Graphics3D 640,480,32,2
SetBuffer BackBuffer
()

Global 
fntArialr
fntArialr
=LoadFont("Arial",24,False,False,False)


Type Dude
    Field entity
,speed#
End Type

Type Dudet
    Field entity2
End Type

Const TYPE_PLAYER=1,Typelevel=2,enti=3,botar=4,enti2=5
Collisions TYPE_PLAYER
,TYPE_PLAYER,1,1

Healthb
=100
Healthig
=100

SchetB
=0
SchetP
=0
 campiv 
CreatePivot() 
 
cam CreateCamera(campiv)
CameraRange cam0.1,200000
EntityType campiv
,TYPE_PLAYER

lit
=CreateLight()

PositionEntity lit,0,20,0
RotateEntity lit
,10,90,0

gun1
=CreateCube()

ScaleEntity gun1,0.04,0.04,0.1
 PointEntity gun1
,campiv
EntityParent gun1
,campiv
EntityParent gun1
,cam 
PositionEntity gun1
,0,-0.15,+0.3
EntityColor gun1
,99,99,103

gunmu
=CreateCube(gun1)
ScaleEntity gunmu,0.1,0.7,0.7
 PointEntity gunmu
,campiv
EntityParent gunmu
,campiv
EntityParent gunmu
,cam 
PositionEntity gunmu
,0,-0.15,+0.40

bot
=CreateCube()
ScaleEntity bot,0.5,0.8,0.5
PositionEntity bot
,0,0,20
EntityColor bot
,0,160,252
EntityType bot
,botar

gol
=CreateSphere(8,bot)
ScaleEntity gol,0.7,0.5,0.7
PositionEntity gol
,0,1.5,0
EntityColor gol
,231,109,0
EntityType gol
,botar

pln
=CreatePlane()

EntityColor pln,205,88,249

PositionEntity pln
,0,-1,0


 cub1
=CreateCube()
EntityColor cub1,42,255,0
PositionEntity cub1
,-3,0,0
ScaleEntity cub1
,0.3,4,20
EntityType cub1
,Typelevel

 cub2
=CreateCube()
EntityColor cub2,42,255,0
PositionEntity cub2
,3,0,0
ScaleEntity cub2
,0.3,4,20
EntityType cub2
,Typelevel

 cub3
=CreateCube()
EntityColor cub3,255,0,0
PositionEntity cub3
,8,0,20
ScaleEntity cub3
,5,4,0.3
EntityType cub3
,Typelevel

 cub4
=CreateCube()
EntityColor cub4,255,0,0
PositionEntity cub4
,-8,0,20
ScaleEntity cub4
,5,4,0.3
EntityType cub4
,Typelevel

cub2
=CreateCube()
EntityColor cub2,255,0,0
PositionEntity cub2
,20,0,0
ScaleEntity cub2
,0.3,4,40
EntityType cub2
,Typelevel


cub2
=CreateCube()
EntityColor cub2,255,0,0
PositionEntity cub2
,-20,0,0
ScaleEntity cub2
,1,4,40
EntityType cub2
,Typelevel

pot
=CreateCube()
ScaleEntity pot,100,0.01,100

EntityColor pot
,255,255,255
PositionEntity pot
,0,4,0

Collisions TYPE_PLAYER
,typelevel,2,2
 
Collisions botar
,typelevel,2,2


Repeat

For d.Dude=Each Dude
        
        MoveEntity d
\entity,0,0,1

If EntityDistance(gun1,d\entity)>200
FreeEntity d
\entity
    Delete d
    
                    
EndIf


    
Next


If bull<MilliSecs()        

        
bul=bul+1                
            
If bul=25 Then bul=0  
        bull
=MilliSecs()+1
    
EndIf
    
    
    
For 
f.Dudet=Each Dudet
        
        MoveEntity f
\entity2,0,0,1

If EntityDistance(bot,f\entity2)>200
FreeEntity f
\entity2
    Delete f
    
                    
EndIf
            
    
Next


If bull2<MilliSecs()        

        
bul2=bul2+1                
            
If bul2=25 Then bul2=0  
        bull2
=MilliSecs()+1
    
EndIf

If 
EntityCollided (bot,Typelevel)

AlignToVector bot,EntityX(bot)-EntityX(campiv),0,EntityZ(bot)+EntityZ(campiv),0,0.6
EndIf 




TurnEntity bot,0,Sgn(DeltaYaw(bot,campiv))*2.3,0
MoveEntity bot
,0,0,0.05
 
If KeyDown(17)  Then 
TFormVector 0
,0,0.2,cam,campiv 
MoveEntity campiv
,TFormedX(),0,TFormedZ() 
EndIf 

If 
KeyDown(31)  Then
TFormVector 0
,0,-0.2,cam,campiv 
MoveEntity campiv
,TFormedX(),0,TFormedZ() 
EndIf 

If 
KeyDown(30)  Then 
MoveEntity  campiv
,-0.2,0,0
EndIf 

If 
KeyDown(32)  Then 
MoveEntity  campiv
,0.2,0,0
EndIf 

If 
KeyDown(57)
CameraZoom cam,2
Else
CameraZoom cam,1
EndIf 




If 
EntityInView(bot,cam)
For 
g=1 To 1
sphere2
=CreateSphere()
ScaleEntity sphere2,0.1,0.1,0.1
RotateEntity sphere2
,10,0,20
If bul2=0
f
.Dudet=New Dudet
    f
\entity2=CopyEntitysphere2 )
    
EntityColor f\entity2,Rnd(255),Rnd(255),Rnd(255)
        
ResetEntity f\entity2
        
    PositionEntity f
\entity2,EntityX#(bot),EntityY#(bot)-0.3,EntityZ(bot) 
RotateEntity f\entity2,EntityPitch#(bot,1),EntityYaw#(bot),0 
EntityType f\entity2,enti2
Collisions enti2
,Typelevel,2,3
Collisions enti2
,TYPE_PLAYER,1,2
EndIf 
Next

If EntityCollided (campiv,enti2)
Healthig=Healthig-1
EndIf



FreeEntity sphere2

EndIf



TurnEntity campiv,0,-MouseXSpeed(),
If EntityCollided (campiv,tulevel
EndIf 


MoveMouse 320,240
 
If Healthb<1
PositionEntity campiv
,0,0,0
PositionEntity bot
,0,0,20
Healthb
=100
Healthig
=100
SchetB
=SchetB+1
EndIf

If 
Healthig<1
PositionEntity campiv
,0,0,0
PositionEntity bot
,0,0,20
Healthb
=100
Healthig
=100
SchetP
=SchetP+1
EndIf

 
UpdateWorld

 RenderWorld

 SetFont fntArialr
    Text 70
,27,"Health"
     
SetFont fntArialr
    Text 70
,67,"Health-Bot="+Healthb
    Text 70
,97,"Health-Player="+Healthig

    
    
    SetFont fntArialr
    Text 500
,27,"Account"
    
SetFont fntArialr
    Text 500
,67,"Bot="+SchetP

SetFont fntArialr
    Text 500
,97,"Player="+SchetB

 Flip

Until KeyHit
(1)


End 
Тут бот стреляет, посмотри код и сделай чтоб Player еще мог стрелять, как ты говоришь АЛГОРИТМ там присутствует... Написал бы да писать лень
__________________
(Offline)
 
Ответить с цитированием
Сообщение было полезно следующим пользователям:
Gector (09.07.2015)