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

Проблема в том что блиц придирается к программе:короче когда я стреляю в фрица, падают либо все,либо никто вобще не падает,либо творится вобще чтото непонятное!Помогите плиз,в чем проблема???

		AppTitle ("")
Include "Libs\lib1.dll"
Include "Libs\lib.dll"
Global health% = 100
	Global file1
	Global file2
	Global file3
	Global map1
	Global m ;skybox
	Global i
	Global time#
	Global sound1 = LoadSound("Sounds\walk1.wav")
	Global sound2 = LoadSound("Sounds\walk2.wav")
	Global sound3 = Load3DSound("Sounds\die.wav")
	Global sound4 = Load3DSound("Sounds\enemydie.wav")
	Global sound5 = Load3DSound("Sounds\alert.wav")
	Global sound6 = LoadSound("Sounds\echo.wav")
	Global sound7 = LoadSound("Sounds\reload.wav")					
	Global sound8 = LoadSound("Sounds\gun_wall.wav")	
	Global main_sound = LoadSound("Sounds\intro.wav")
	Global cursor = LoadImage("Images\cursor.bmp")
	Global menu_image = LoadImage("Images\1024x768.bmp")
		Type flare
		Field x#,y#,z#
		Field entity
		Field cylinder
		Field light
		End Type 
			Type shot
			Field x#,y#,z#
			Field entity1
			Field magazine%
			Field bullets%
			Field dist#
			End Type
					Type friz
					Field x#,y#,z#
					Field entity
					Field status
					Field enemybox
					Field sphere1,sphere2
					Field health%
					End Type 
					Dim abc.friz(50)
					Global num% = 0
				file1 = OpenFile("Config\config1.ini")
				io_result = ReadLine(file1)
				If io_result = 1 Then Graphics3D 1600,900,32,1
				If io_result = 2 Then Graphics3D 1280,768,32,1
				If io_result = 3 Then Graphics3D 1024,768,32,1
				If io_result = 4 Then Graphics3D 640,480,32,1
				SetBuffer BackBuffer()
	Global texture1 = LoadTexture("data\models\media\mymp5.bmp")
	Global texture4 = LoadTexture("Textures1\brick\algaebricks.jpg")
	Global texture5 = LoadTexture("Textures1\lamps\lamp1.jpg")	
	Global user
	Global camera
	Global x# = 0
	Global bullet = LoadSprite("images\bullet.bmp")
	Global weapon = LoadAnimMesh("Data\Models\media\mp5.b3d",camera);camera
		Const user_type = 1
		Const ground_type = 2
		Const shot_type = 3
		Const friz_type = 4
Function create_weapon()
			ExtractAnimSeq(weapon,1,1 )
			ExtractAnimSeq(weapon,2,8 )
			TurnEntity weapon,0,90,0
			ScaleEntity weapon,0.1,0.1,0.1
			PositionEntity weapon,-7,9,5
			EntityOrder weapon,-1
			EntityTexture weapon,texture1
End Function 
Function create_friz(x#,y#,z#,dist#)
num% = num%+1
abc(num)  = New friz
abc(num)\x# = x#
abc(num)\y# = y#
abc(num)\z# = z#
;=========================ENTITYES=====================================
abc(num)\entity = LoadAnimMesh("Data\Models\Media\Officer.b3d")
abc(num)\enemybox = CreateSphere()
abc(num)\sphere1 = CreateSphere()
abc(num)\sphere2 = CreateSphere()
;=========================ENTITYES OPERATIONS=========================
	RotateEntity abc(num)\enemybox,0,90,0
	EntityType abc(num)\enemybox,friz_type
	ScaleEntity abc(num)\enemybox,0.1,0.25,0.09
	ScaleEntity abc(num)\sphere1,0.01,0.01,0.01
	ScaleEntity abc(num)\sphere2,0.01,0.01,0.01	
	EntityAlpha abc(num)\enemybox,0.0001
	EntityAlpha abc(num)\sphere1,0.0001
	EntityAlpha abc(num)\sphere2,0.0001
	PositionEntity abc(num)\enemybox,x#,y#+0.3,z#

		PositionEntity abc(num)\entity,x#,y#,z#
		ScaleEntity abc(num)\entity,0.0075,0.0075,0.0075
		
			PositionEntity abc(num)\sphere1,EntityX(abc(num)\enemybox),EntityY(abc(num)\enemybox),EntityZ(abc(num)\enemybox)
			PositionEntity abc(num)\sphere2,EntityX(abc(num)\enemybox),EntityY(abc(num)\enemybox),EntityZ(abc(num)\enemybox)+dist#
;=========================EXTRACT ANIM SEQ============================
					ExtractAnimSeq(abc(num)\entity,1,32 ) ; 1- idle
					ExtractAnimSeq(abc(num)\entity,33,83 ) ; 2- look_around
					ExtractAnimSeq(abc(num)\entity,84,117 ) ; 3- walk
					ExtractAnimSeq(abc(num)\entity,118,134 ) ; 4- run
					ExtractAnimSeq(abc(num)\entity,135,150 ) ; 5- arm
					ExtractAnimSeq(abc(num)\entity,150,159 ) ; 6- shoot_forward
					ExtractAnimSeq(abc(num)\entity,161,181 ) ; 7- disarm
					ExtractAnimSeq(abc(num)\entity,182,197 ) ; 8- shoot_down
					ExtractAnimSeq(abc(num)\entity,198,213 ) ; 9- shoot_up
					ExtractAnimSeq(abc(num)\entity,214,239 ) ; 10- reload
					ExtractAnimSeq(abc(num)\entity,240,270 ) ; 11- die1
					ExtractAnimSeq(abc(num)\entity,271,311 ) ; 12- die2
					ExtractAnimSeq(abc(num)\entity,312,325 ) ; 13- die3
;======================================================================
Animate abc(num)\entity,1,0.7,1
;abc(num)\status = 0
abc(num)\health% = 100
End Function 
Function update_friz()
For i = 1 To num
EntityParent abc(i)\enemybox,abc(i)\entity
;=========================FREE - WALKING FRIZ===========================
If (180 - Abs(-DeltaYaw(abc(i)\enemybox,user)+100)) < 70 And (abc(i)\health%>0) And EntityDistance(abc(i)\entity,user)<20 And EntityVisible(abc(i)\enemybox,user) Then 
abc(i)\status = 1
EndIf
;If abc(i)\health% < 0 Then
;abc(i)\status = 2
;EndIf
If abc(i)\status = 0 Then 
MoveEntity abc(i)\entity,0,0,-0.035
If EntityDistance(abc(i)\entity,abc(i)\sphere2)<1 Then pointer(abc(i)\entity,abc(i)\sphere1)
If EntityDistance(abc(i)\entity,abc(i)\sphere1)<1 Then pointer(abc(i)\entity,abc(i)\sphere2)
If AnimTime(abc(i)\entity)>30.8 Then
Animate abc(i)\entity,1,1,3
EndIf
ElseIf abc(i)\status = 1 Then
pointer(abc(i)\entity,user)
If AnimTime(abc(i)\entity)>13 Then
Animate abc(i)\entity,1,1.4,6
EmitSound sound5,abc(i)\entity
EndIf
ElseIf abc(i)\status = 2 Then
If AnimTime(abc(i)\entity)>30.8 Then
;res = Rnd(11,12)
Animate abc(i)\entity,3,0.9,11
EndIf
EndIf
Next
End Function
Function create_world()
		map1 = loadcsm("level1.csm","Textures\",ground_type)
		ScaleEntity map1,0.004,0.004,0.004
		PositionEntity map1,0,0,0
		create_user()
		skybox()
		create_weapon()
		CreateListener(user,1,1,20)
;================================CREATE FLARES==================================		
		create_flare(0,1.75,1)
		create_flare(-3.5,1.75,1)							
		create_flare(-6,1.75,-2)		
		create_flare(-6,1.75,2)			
		create_flare(0,1.75,-3)																
		create_flare(0,1.75,5)																
		create_flare(4,1.75,5)																
		create_flare(-6,1.75,5)
		create_flare(-6,1.75,-4.3)																
;================================CREATE FRIZ======================================
create_friz(0,-0.52,0,6)
create_friz(-3,-0.52,-2,5)
;==================================================================================									
End Function
Function jump()
	If (x#=0)Or(x#=0.03)Then 
	x#=-0.3
EndIf
End Function 
Function create_shot(x#,y#,z#)
			a.shot = New shot
			PlaySound sound8
			a\x# = x#
			a\y# = y#
			a\z# = z#
			a\entity1 = LoadSprite("images\bullet.bmp")
			a\dist# = 100
			EntityAlpha a\entity1,0.0001
			ScaleSprite a\entity1,0.001,0.001
			PositionEntity a\entity1,x#,y#,z#
			TurnEntity a\entity1,EntityPitch(camera),EntityYaw(user),0
			EntityType a\entity1,shot_type
			EntityPickMode a\entity1,1
			EntityRadius a\entity1,0.001
			Return True
End Function 
Function create_flare(x#,y#,z#)
				a.flare = New flare
				a\entity = LoadSprite("Images\flare.bmp")
				ScaleSprite a\entity,0.4,0.4
				PositionEntity a\entity,x#,y#,z#
				a\cylinder = CreateCylinder(32)
				ScaleEntity a\cylinder,0.1,0.05,0.1
				PositionEntity a\cylinder,x#,y#+0.1,z#
				EntityTexture a\cylinder,texture5
End Function 
Function pointer(e1,e2)
		x1 = EntityPitch(e1,1)
		z1 = EntityRoll(e1,1)
		PointEntity e1,e2
		RotateEntity e1,x1,EntityYaw(e1)-180,z1
End Function
Function create_user()
	user = CreateSphere()
	camera = CreateCamera(user)
	CameraFogMode camera,0
	CameraFogColor camera,192,192,192
	CameraFogRange camera,1,50 
	EntityRadius user,0.5
	EntityOrder user,map1
		file2 = OpenFile ("Config\Config2.ini")
		io_result1 = ReadLine(file2)
		If io_result1 = "1" Then CameraRange camera,0.1,1000
		If io_result1 = "2" Then CameraRange camera,0.1,100000
		If io_result1 = "3" Then CameraRange camera,0.1,1000000
		PositionEntity user,-7,10,3;-7,10,3
		health% = 100
		EntityType user,user_type
		Collisions user_type,ground_type,2,3
End Function
Function reload()
	PlaySound sound7
End Function 
Function alert(file$,cur_t)
			alert_font1 = LoadFont("Courier",30,1,1,0)
			SetFont alert_font1
			kdv = OpenFile(file$)
			result$ = ReadLine(kdv)
			If time<cur_t
			time=time+1
			Color 0,0,0
			Rect 0,GraphicsHeight()-100,GraphicsWidth(),GraphicsHeight()
			Color 255,0,0
			Text 10,GraphicsHeight()-70,result$
			EndIf
			CloseFile(kdv)
			FreeFont alert_font1
End Function
Function update_user()
				v# = 0.15
				u# = 80
				EntityParent weapon,camera
				TurnEntity camera,MouseYSpeed()/2,0,0
				TurnEntity user,0,-MouseXSpeed()/2,0
				If KeyHit(3) Then SaveBuffer(BackBuffer(),"Screenshots\Screenshot.bmp")
				If KeyDown(17) Then MoveEntity user,0,0,v#
				If KeyDown(30) Then MoveEntity user,-v#,0,0
				If KeyDown(32) Then MoveEntity user,v#,0,0
				If KeyDown(31) Then MoveEntity user,0,0,-v#
				If KeyHit(19) Then reload()
				If MouseDown(1) Then 
				create_shot(EntityX(user),EntityY(user),EntityZ(user))
				If AnimTime(weapon)>5
				Animate weapon,1,15,2
				EndIf
				EndIf
				If Not MouseDown(1) Then Animate weapon,1,1,1,1
				If KeyDown(57) Then jump()
				MoveMouse GraphicsWidth()*0.5,GraphicsHeight()*0.5
				If Abs(EntityPitch#(camera))>u# RotateEntity camera,u#*Sgn(EntityPitch#(camera)),0,0
End Function 
create_world()
	x#=0
		While Not KeyHit(1) 
		Collisions shot_type,friz_type,2,1
		HideEntity bullet
		update_user()
		update_shot()
		update_friz()
		If Not EntityCollided(user,ground_type) Then 
		x# = x#+0.03
		Else
		x# = 0
		EndIf
		TranslateEntity user,0,-x#,0
		UpdateWorld
		RenderWorld
		;alert("Data\dialogs\auto\dialog1.kdv",100)
		Color 255,0,0
		Plot MouseX(),MouseY()
		Collisions user_type,friz_type,2,3
		Text 10,10,num%
		Flip
		Wend
		EndGraphics()
		End
		
Function update_shot()

					For z.shot = Each shot
					For i = 1 To num
					EntityOrder z\entity1,-1
					MoveEntity z\entity1,0,0,5
					z\dist#=z\dist#-1
					If z\dist#<0 Then
					FreeEntity z\entity1
					Delete z
					ElseIf EntityCollided(z\entity1friz_type) Then
					abc(i)\health% = -1
					abc(i)\status = 2
					EndIf
					Next
					Next
End Function
(Offline)
 
Ответить с цитированием