Показать сообщение отдельно
Старый 01.11.2006, 14:46   #23
GoodWin
ПроЭктировщик
 
Регистрация: 14.08.2006
Сообщений: 105
Написано 15 полезных сообщений
(для 19 пользователей)
Re: Нужен огонь.

Я вот огонек наваял... оцените, но строго не судите...
;================================================= =================
;Author: GoodWin
;Email: [email protected]
;Date: 01.11.2006
;Notes: Ñïàñèáî bradford6 çà èäåþ
;================================================= =================
Include "fps.bb"
Graphics3D 640,480,16,2
Const UPS=60
Const MAXPARTICLE%=40
Type Particle
Field entity
Field speed#
Field life#
Field scalex#
Field scaley#
Field rotate#
Field alpha#
End Type
Type Emiter
Field entity
Field count%=0
Field p.particle[MAXPARTICLE%]
End Type

camera=CreateCamera()
PositionEntity camera,0,0,-5
light=CreateLight()
Global sphere=CreateSphere():ScaleEntity sphere,.2,.2,.2
PositionEntity sphere,0,-2,0
EntityColor sphere,200,200,100
Global fire=LoadSprite ("fire.jpg",9):HideEntity fire
s=CreatePivot (sphere)
PositionEntity s,-10,0,0
CreateEmiter(sphere)
CreateEmiter(s)
period=1000/UPS
time=MilliSecs()-period
Repeat
Repeat
elapsed=MilliSecs()-time
Until elapsed
ticks=elapsed/period
tween#=Float(elapsed Mod period)/Float(period)

For k=1 To ticks
time=time+period
If KeyHit(1) End
TurnEntity sphere,0,1,0
UpdateParticle()
UpdateWorld
Next

RenderWorld tween
Render2D()
Flip
Forever
;-=Functions=-
Function UpdateParticle()
For e.Emiter=Each Emiter
If e\count<MAXPARTICLE Then
e\count=e\count+1
e\p.particle[e\count]=New Particle
e\p.particle[e\count]\entity=CopyEntity(fire)
PositionEntity e\p.particle[e\count]\entity,EntityX#(e\entity,1)+Rnd(-.2,.2),EntityY#(e\entity,1),EntityZ#(e\entity,1)+R nd(-.2,.2)
e\p.particle[e\count]\scalex#=Rnd(.6,.7):e\p.particle[e\count]\scaley#=Rnd(.6,.7)
e\p.particle[e\count]\rotate#=Rnd(-1,1)
e\p.particle[e\count]\life=Rand(20,40)
e\p.particle[e\count]\speed#=Rnd(.08,.1)
e\p.particle[e\count]\alpha#=Rnd(.3,.9):;DebugLog "count "+e\count+" Alpha "+e\p.particle[e\count]\alpha
EntityAlpha e\p.particle[e\count]\entity,e\p.particle[e\count]\alpha#
ShowEntity e\p.particle[e\count]\entity
EndIf
For n = 1 To e\count
If e\p.particle[n]\life > 0
e\p.particle[n]\scalex#=e\p.particle[n]\scalex#*.94
e\p.particle[n]\scaley#=e\p.particle[n]\scaley#*.94
e\p.particle[n]\rotate=e\p.particle[n]\rotate*Rnd(1.2,1.8)
e\p.particle[n]\alpha#=e\p.particle[n]\alpha#*.7
e\p.particle[n]\life = e\p.particle[n]\life -1
EntityAlpha e\p.particle[n]\entity,e\p.particle[n]\alpha#
RotateSprite e\p.particle[n]\entity,e\p.particle[n]\rotate
ScaleSprite e\p.particle[n]\entity,e\p.particle[n]\scalex#,e\p.particle[n]\scaley#
MoveEntity e\p.particle[n]\entity,0,e\p.particle[n]\speed#,0:
Else
HideEntity e\p.particle[n]\entity
PositionEntity e\p.particle[n]\entity,EntityX#(e\entity,1)+Rnd(-.25,.25),EntityY#(e\entity,1),EntityZ#(e\entity,1) +Rnd(-.25,.25)
e\p.particle[n]\scalex#=Rnd(.6,.7):e\p.particle[n]\scaley#=Rnd(.6,.7)
e\p.particle[n]\rotate#=Rnd(-1,1)
e\p.particle[n]\alpha#=Rnd(.5,.8)
e\p.particle[n]\life=Rand(10,40)
EntityAlpha e\p.particle[n]\entity,e\p.particle[n]\alpha#
ShowEntity e\p.particle[n]\entity
EndIf
Next
Next
End Function
Function CreateEmiter(entity)
e.Emiter= New Emiter
e\entity=CreatePivot (entity)
e\count=0
End Function
Function Render2D()
Text 10,10,fps()
End Function
(Offline)
 
Ответить с цитированием