Тема: Стрельба
Показать сообщение отдельно
Старый 25.07.2007, 15:00   #6
Fray
AnyKey`щик
 
Регистрация: 11.03.2007
Сообщений: 5
Написано 0 полезных сообщений
(для 0 пользователей)
Re: Стрельба

Не подскажете а как сделать так чтоб выстрел происходил при нажатие мыше в этом коде:
Graphics3D 800,600,32

Type s
	Field entity
	Field upt
End Type

Function s_construct.s(ctrl,ctrl2)
	obj.s=New s
	obj\entity=CreateSphere(8,ctrl)
	EntityParent obj\entity,0
	PointEntity obj\entity,ctrl2
	obj\upt=-1
	Return  obj
End Function

Function s_update()
	For o.s=Each s
		If o\upt=-1
			o\upt=MilliSecs()
		EndIf
		dt=MilliSecs()-o\upt
		o\upt=MilliSecs()
		MoveEntity o\entity,0,0,dt*0.1
		If EntityDistance(o\entity,a)>100
			FreeEntity o\entity
			Delete o
		EndIf
	Next
End Function

Global a=CreateCube()
EntityAlpha a,0.5
b=CreateCube(a)
ScaleEntity b,0.25,.25,.25
EntityColor b,100,0,0
MoveEntity b,0,0,3

camera=CreateCamera()
MoveEntity camera,0,0,-15

light=CreateLight()

Color 255,255,0
SetBuffer BackBuffer()
time=MilliSecs()
While Not KeyHit(1)
	dtm=MilliSecs()-time
	time=MilliSecs()
	v#=dtm*0.01
	TurnEntity a,v,v,v
	If MilliSecs()-tcr>300
		s_construct(a,b)
		tcr=MilliSecs()
	EndIf
	s_update()
	RenderWorld()
	;=
	CameraProject camera,EntityX(a),EntityY(a),EntityZ(a)
	x1=ProjectedX()
	y1=ProjectedY()
	CameraProject camera,EntityX(b,True),EntityY(b,True),EntityZ(b,True)
	x2=ProjectedX()
	y2=ProjectedY()
	Line x1,y1,x2,y2
	;=
	Flip
Wend
End
(Offline)
 
Ответить с цитированием