Тема: Стрельба
Показать сообщение отдельно
Старый 21.02.2009, 23:55   #1
Mark Castle
Знающий
 
Регистрация: 04.10.2008
Адрес: Киев
Сообщений: 230
Написано 3 полезных сообщений
(для 3 пользователей)
Лампочка Стрельба

Помогите со стрельбами!
пожалуйста переделайте код чтобы при попадании пули в шар шар исчезал!
я уже намучался...не знаю как сиё организовать...
вот и код...
Graphics3D 640,480,32,1
SetBuffer BackBuffer()
AppTitle "Great Army"
Global dv,user,bott,ap,sh,ap1,ap2,ap3,ap4,ap5,camera,mina,orujie,prizel = LoadImage("D:\battle\prizel.bmp"),jashch
Global shot_sprite=LoadSprite("D:\battle\shot.png")
Global health%=100
Const jashch_type = 2,user_type = 1,orujie_type = 3,terr_type = 4,ground_type= 5,mina_type = 6,m_type = 7,stena1_type = 8,stena2_type = 9,stena3_type = 10,stena4_type = 11,der_type = 12,shot_type = 13,potolok_type = 14,ap_type = 15,ap1_type = 16,ap2_type = 17,ap3_type = 18,ap4_type = 19,bot_type = 20,dv_type = 21,sh_type = 22
Const g# = 0.05
Type shot 
             Field entity  
End Type
Type bot 
             Field entity  
End Type
Function jadbomb()
;;;;;;;;;
;;;;;;;;;
;;;;;;;;;
End Function
Function mashina()
mashina = LoadMesh("D:\battle\rallycar1.3ds")
ScaleEntity mashina,0.04,0.04,0.04
PositionEntity mashina,0,0,-50
EntityType mashina,m_type
Collisions user_type,m_type,2,2
textfc = LoadTexture ("D:\battle\rallycar.jpg")
EntityTexture mashina,textfc
End Function 
Function create_bot(x#,y#,z#) 
b.bot=New bot
b\entity=CreateSphere() 
EntityType b\entity,bot_type
texrt = LoadTexture("D:\battle\bagr.bmp")
EntityTexture b\entity,texrt
PositionEntity b\entity,x#,y#,z# 
Return True 
End Function
Function update_bot() 
v#=0.2
For a.bot=Each bot 
PointEntity a\entity,user 
MoveEntity a\entity,0,0,v# 
RotateEntity a\entity,10,10,10
Next 
End Function
Function aptechka()
ap = CreateCube()
PositionEntity ap, 0,0,-17
ScaleEntity ap,0.1,0.1,0.1
EntityType ap,ap_type
Collisions user_type,ap_type,2,2
ap1 = CreateCube()
PositionEntity ap1, Rnd(-450, 450),0, Rnd(-450, 450)
ScaleEntity ap1,0.1,0.1,0.1
EntityType ap1,ap1_type
Collisions user_type,ap1_type,2,2
ap2 = CreateCube()
PositionEntity ap2, Rnd(-450, 450),0, Rnd(-450, 450)
ScaleEntity ap2,0.1,0.1,0.1
EntityType ap2,ap2_type
Collisions user_type,ap2_type,2,2
ap3 = CreateCube()
PositionEntity ap3, Rnd(-450, 450),0, Rnd(-450, 450)
ScaleEntity ap3,0.1,0.1,0.1
EntityType ap3,ap3_type
Collisions user_type,ap3_type,2,2
ap4 = CreateCube()
PositionEntity ap4, Rnd(-450, 450),0, Rnd(-450, 450)
ScaleEntity ap4,0.1,0.1,0.1
EntityType ap4,ap4_type
Collisions user_type,ap4_type,2,2
End Function 
Function create_Shot(x#,y#,z#,pitch#,yaw#,roll#) 
background = PlayMusic("D:\battle\gun_wall.wav")
s.shot=New shot s\entity=CopyEntity(shot_sprite) 
PositionEntity s\entity,x#,y#,z#,1 
RotateEntity s\entity,pitch#,yaw#,roll#,1 
Return True 
End Function
Function update_shot() 
vs#=10
For a.shot=Each shot 
MoveEntity a\entity,0,0,vs# 
Next 
If MouseHit(1) create_shot(EntityX(user),EntityY(user),EntityZ(user),EntityPitch(camera),EntityYaw(user),0)
End Function
Function mina()
mina = CreateCylinder()
ScaleEntity mina,0.1,0.1,0.1
EntityType mina,mina_type
For x = 1 To 500
mina = CopyEntity(mina)
PositionEntity mina, Rnd(-450, 450),0, Rnd(-450, 450)
Next 
End Function 
Function create_user(x#=0,y#=1,z#=-15)
user = CreateSphere()
camera = CreateCamera(user)
PositionEntity camera,0,1,-1 
PositionEntity user,x#,y#,z# 
EntityType user,user_type
End Function 
Function create_carta()
c=LoadMesh ("D:\battle\tree1.3ds")
tex = LoadTexture("D:\battle\m_tree2.bmp")
EntityType c,der_type
EntityTexture c,tex
For xc = 1 To 10
c = CopyEntity(c)
PositionEntity c, Rnd(-450, 450),0, Rnd(-450, 450)
Collisions user_type,der_type,2,2
Next 
d=LoadMesh ("D:\battle\papor.3ds")
ScaleEntity d,0.05,0.05,0.05
tex = LoadTexture("D:\battle\m_tree2.bmp")
EntityTexture d,tex
For xf = 1 To 300
d = CopyEntity(d)
PositionEntity d, Rnd(-450, 450),0, Rnd(-450, 450)+20
Next
jashch = LoadMesh("G:\Blitz3d\Media\geometricks_models\wood-crate\wcrate1.3ds")
PositionEntity jashch,0,0.6,20
ScaleEntity jashch,0.03,0.03,0.03
EntityType jashch,jashch_type
For x = 1 To 50 
jashch = CopyEntity(jashch)
PositionEntity jashch, Rnd(-450, 450),0.6, Rnd(-450, 450)
Collisions user_type,jashch_type,2,2
Next 
End Function 
Function holm()
t = CreateTerrain(64)
TerrainShading t, 1
grass = LoadTexture( "D:\battle\trv1.jpg" )
ScaleTexture grass, 5,5
EntityTexture t, grass
ScaleEntity t, 2, 160, 2
EntityType t,terr_type
For n = 1 To 5
For x = 0 To 64
For z = 0 To 64
If n=1 Then
ModifyTerrain t, x, z, Rnd(0, 1)
Else
ModifyTerrain t, x, z, (TerrainHeight(t, x - 2, z) +TerrainHeight(t, x, z - 2) + TerrainHeight(t, x, z) +TerrainHeight(t, x + 2, z) + TerrainHeight(t, x, z + 2)) /8
End If
Next
Next
Next
Collisions user_type,terr_type,2,2
End Function 
Function orujie()
orujie = LoadMesh("D:\battle\weapon.b3d")
PositionEntity orujie,MouseX,MouseY,5
ScaleEntity orujie,0.05,0.05,0.05
End Function
Function update_user()   
V#=0.2
TurnEntity camera,MouseYSpeed(),0,0 
TurnEntity user,0,-MouseXSpeed(),0 
If KeyDown(30)=1 Then MoveEntity user,-V#,0,0 
If KeyDown(32)=1 Then MoveEntity user,V#,0,0 
If KeyDown(17)=1 Then MoveEntity user,0,0,+V# 
If KeyDown(31)=1 Then MoveEntity user,0,0,-V# 
MoveEntity user,0,-g,0
MoveMouse GraphicsWidth()*0.5,GraphicsHeight()*0.5
End Function
Function MakeSkyBox( file$ )
m=CreateMesh()
b=LoadBrush( file$+"nebo2.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,-1,0,0:AddVertex s,+1,+1,-1,1,0
AddVertex s,+1,-1,-1,1,1:AddVertex s,-1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
b=LoadBrush( file$+"nebo3.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,-1,0,0:AddVertex s,+1,+1,+1,1,0
AddVertex s,+1,-1,+1,1,1:AddVertex s,+1,-1,-1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
b=LoadBrush( file$+"nebo1.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,+1,+1,+1,0,0:AddVertex s,-1,+1,+1,1,0
AddVertex s,-1,-1,+1,1,1:AddVertex s,+1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
b=LoadBrush( file$+"nebo4.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,0:AddVertex s,-1,+1,-1,1,0
AddVertex s,-1,-1,-1,1,1:AddVertex s,-1,-1,+1,0,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
b=LoadBrush( file$+"5.jpg",49 )
s=CreateSurface( m,b )
AddVertex s,-1,+1,+1,0,1:AddVertex s,+1,+1,+1,0,0
AddVertex s,+1,+1,-1,1,0:AddVertex s,-1,+1,-1,1,1
AddTriangle s,0,1,2:AddTriangle s,0,2,3
FreeBrush b
ScaleMesh m,450,450,450
FlipMesh m
EntityFX m,9
EntityOrder m,10
Return m
End Function
Function glava1()
f=LoadFont ("courier",15,False,False,True)
SetFont f 
Color 255,255,255 
Text 200,200,"Прибытие"
FreeFont f
WaitKey
End Function 
Function bunker1();;;;;;;;;;;;;;;
dver = CreateCube()
PositionEntity dver,-6,2.5,-70
ScaleEntity dver,2,2.5,1
dv = LoadTexture("D:\battle\wcrate.jpg")
EntityTexture dver,dv
EntityType dver,dv_type
stena1 = CreateCube()
PositionEntity stena1,0,0,-50
EntityAlpha stena1,0.4
ScaleEntity stena1,10,5,1
stena2 = CreateCube()
PositionEntity stena2,-9,0,-61
ScaleEntity stena2,1,5,10
stena3 = CreateCube()
PositionEntity stena3,9,0,-61
ScaleEntity stena3,1,5,10
stena4 = CreateCube()
PositionEntity stena4,2,0,-70
ScaleEntity stena4,6,5,1
potolok = CreateCube()
PositionEntity potolok,0,6,-60
ScaleEntity potolok,10,1,11
EntityType stena1,stena1_type
EntityType stena2,stena2_type
EntityType stena3,stena3_type
EntityType stena4,stena4_type
EntityType potolok,potolok_type
texture = LoadTexture("D:\battle\meta3.jpg")
EntityTexture potolok,texture
EntityTexture stena1,texture 
EntityTexture stena2,texture 
EntityTexture stena3,texture 
EntityTexture stena4,texture 
Collisions user_type,stena1_type,2,2
Collisions user_type,stena2_type,2,2
Collisions user_type,stena3_type,2,2
Collisions user_type,stena4_type,2,2
End Function       ;;;;;;;;;;;;;;;
Function bunker();;;;;;;;;;;;;;;
dver = CreateCube()
PositionEntity dver,-6,2.5,-25
ScaleEntity dver,2,2.5,1
dv = LoadTexture("D:\battle\wcrate.jpg")
EntityType dver,dv_type
EntityTexture dver,dv
stena1 = CreateCube()
PositionEntity stena1,0,0,-5
ScaleEntity stena1,10,5,1
stena2 = CreateCube()
PositionEntity stena2,-9,0,-16
ScaleEntity stena2,1,5,10
EntityAlpha stena2,0.4
stena3 = CreateCube()
PositionEntity stena3,9,0,-16
ScaleEntity stena3,1,5,10
stena4 = CreateCube()
PositionEntity stena4,2,0,-25
ScaleEntity stena4,6,5,1
potolok = CreateCube()
PositionEntity potolok,0,6,-15
ScaleEntity potolok,10,1,11
EntityType stena1,stena1_type
EntityType stena2,stena2_type
EntityType stena3,stena3_type
EntityType stena4,stena4_type
EntityType potolok,potolok_type
texture = LoadTexture("D:\battle\meta3.jpg")
EntityTexture potolok,texture
EntityTexture stena1,texture 
EntityTexture stena2,texture 
EntityTexture stena3,texture 
EntityTexture stena4,texture 
Collisions user_type,stena1_type,2,2
Collisions user_type,stena2_type,2,2
Collisions user_type,stena3_type,2,2
Collisions user_type,stena4_type,2,2
End Function       ;;;;;;;;;;;;;;;
Function create_world()
light=CreateLight()
RotateEntity light,90,0,0 
terrain = CreatePlane()
texture = LoadTexture("D:\battle\trv1.jpg")
ScaleTexture texture,5,5
EntityTexture terrain,texture
EntityType terrain,ground_type
Collisions user_type,ground_type,2,2
create_user()
HideEntity shot_sprite
makeskybox("D:\battle\")
End Function  
Function death()
End
End Function 
Function botshch()
HideEntity bot
End Function
Function pov()
health%=health%+15
HideEntity ap
End Function 
Function pov1()
health%=health%+15
HideEntity ap1
End Function 
Function pov2()
health%=health%+15
HideEntity ap2
End Function 
Function pov3()
health%=health%+15
HideEntity ap3
End Function 
Function pov4()
health%=health%+15
HideEntity ap4
End Function 
Function pov5()
health%=health%+15
HideEntity ap5
End Function 
create_world()
create_carta()
bunker()
bunker1()
aptechka()
For j=1 To 10 
create_bot(Rnd(-450,450),0,Rnd(-450,450))
Next
While Not KeyHit(1)=1
update_user() 
update_shot()
update_bot()
If EntityCollided (user,ap_type) Then pov()
If EntityCollided (user,ap1_type) Then pov1()
If EntityCollided (user,ap2_type) Then pov2()
If EntityCollided (user,ap3_type) Then pov3()
If EntityCollided (user,ap4_type) Then pov4()
Collisions bot_type,stena1_type,2,2
Collisions bot_type,stena2_type,2,2
Collisions bot_type,stena3_type,2,2
Collisions bot_type,stena4_type,2,2
Collisions bot_type,der_type,2,2
Collisions bot_type,jashch_type,2,2
Collisions user_type,bot_type,2,2
Collisions bot_type,dv_type,2,2
;If EntityCollided (user,stena1_type) Then health%=health%-10
;If EntityCollided (user,stena2_type) Then health%=health%-10
;If EntityCollided (user,stena3_type) Then health%=health%-10
;If EntityCollided (user,stena4_type) Then health%=health%-10
;If EntityCollided (user,potolok_type) Then health%=health%-10
If EntityCollided (user,bot_type) Then health%=health%-1
If EntityCollided (shot_sprite,bot_type) Then End
If EntityCollided(user,m_type) Then End
UpdateWorld()
RenderWorld()
f=LoadFont ("courier",15,False,False,True)
SetFont f 
Color 255,0,255 
Text 10,465,"Здоровье : "+health%
If health%<0 Then death()
FreeFont f
DrawImage(LoadImage("D:\battle\prizel.bmp"),MouseX(),MouseY())
DrawImage(LoadImage("D:\battle\soldier.jpg"),575,340)
Flip
Wend
End
извините за тофтологию в функциях pov(),просто неделю назад стал изучать Blitz3D...
(Offline)
 
Ответить с цитированием