Среда, 13.12.2017, 02:28
Приветствую Вас Гость | RSS
Главная | Каталог статей | Регистрация | Вход
Меню сайта
Категории каталога
BlitzMax [14]
Blitz3D [9]
BlitzPlus [0]
Xna [1]
DarkBasic [0]
Общее [3]
Наш опрос
Какой персонаж вам больше по душе?
1. Тор
2. Ктулху
3. Креведко
4. Гном
5. Медвед
Всего ответов: 10
Форма входа
Поиск
Друзья сайта
Статистика

Онлайн всего: 1
Гостей: 1
Пользователей: 0
Статьи
Главная » Статьи » Blitz3D

Ракета в полёте + пламя из сопла
Type snar
Field entity%
Field fire_entity%
Field time%
End Type

Function create_snar()
s.snar=New snar

s\entity=CreateCylinder()
s\fire_entity=CreateSphere()
RotateEntity s\entity,0,0,90

ScaleEntity s\fire_entity,.4,.4,.4
PositionEntity s\fire_entity,1.5,0,0
RotateEntity s\fire_entity,0,-90,0
EntityParent s\fire_entity,s\entity


NameEntity s\entity,Handle(s)


Return Handle(s)
End Function

Function update_snr()
For s.snar=Each snar
If MilliSecs()-s\time>=5
create_fire_sprite(s\fire_entity)
s\time=MilliSecs()
EndIf
Next
End Function
;__________________________________________________
Type fire_sprite
Field entity%
Field time%
Field alpha#
Field size#
End Type

Function create_fire_sprite(parent)
f.fire_sprite=New fire_sprite
f\entity=CopyEntity(sprite)
RotateEntity f\entity,EntityPitch(parent,True),EntityYaw(parent,True),EntityRoll(parent,True)
PositionEntity f\entity,EntityX(parent,True),EntityY(parent,True),EntityZ(parent,True)
omega#=Rnd(0,359)
k#=0.2
MoveEntity f\entity,Cos(omega)*k#,Sin(omega)*k#,0
f\alpha#=1
f\size#=2
f\time=MilliSecs()
Return Handle(f)
End Function

Function update_fire_sprite()
For f.fire_sprite=Each fire_sprite
new_time=MilliSecs()
delta=new_time-f\time
f\time=new_time
f\alpha#=f\alpha#-delta*0.01
f\size#=f\size#-delta*0.005
MoveEntity f\entity,0,0,0.03*delta
EntityAlpha f\entity,f\alpha#
ScaleSprite f\entity,f\size,f\size
If f\alpha<=0
FreeEntity f\entity
Delete f
EndIf
Next
End Function
;_____________________________
;=MAIN LOOP
Graphics3D 800,600,32
Global camera=CreateCamera()
MoveEntity camera,0,0,-30
Global light=CreateLight()
Global sprite=LoadSprite("sprite.bmp"):HideEntity sprite

;__create 1
snar_ptr=create_snar()
s.snar=Object.snar(snar_ptr)
s_ent=s\entity%
PositionEntity s_ent,0,2,0
;__create 2
snar_ptr=create_snar()
s.snar=Object.snar(snar_ptr)
s_ent2=s\entity%
;__create 3
snar_ptr=create_snar()
s.snar=Object.snar(snar_ptr)
s_ent3=s\entity%
RotateEntity s_ent3,0,90,90
;;;==

time=MilliSecs()
While Not KeyHit(1)

new_time=MilliSecs()
delta=new_time-time
time=new_time

MoveEntity s_ent2,0,0.07*delta,0
TurnEntity s_ent2,0.07*delta,0,0

MoveEntity s_ent3,0,0.07*delta,0
TurnEntity s_ent3,0.07*delta,0,0

update_snr()
update_fire_sprite()
RenderWorld
Flip
Wend
End

Вот это нужно для работы -

А вот расширенная версия:

Type snar
Field entity%
Field fire_entity%
Field time%
Field smok
End Type

Function create_snar()
s.snar=New snar

s\entity=CreateCylinder()
s\fire_entity=CreateSphere()
RotateEntity s\entity,0,0,90

ScaleEntity s\fire_entity,.4,.4,.4
PositionEntity s\fire_entity,1.5,0,0
RotateEntity s\fire_entity,0,-90,0
EntityParent s\fire_entity,s\entity


NameEntity s\entity,Handle(s)


Return Handle(s)
End Function

Function update_snr()
For s.snar=Each snar
If MilliSecs()-s\time>=5
create_fire_sprite(s\fire_entity)

s\smok=s\smok+1
If s\smok>Rand(2,5)
s\smok=0
create_smok_sprite(s\fire_entity)
EndIf
s\time=MilliSecs()
EndIf
Next
End Function
;__________________________________________________
Type fire_sprite
Field entity%
Field time%
Field alpha#
Field size#
Field stat
End Type

Function create_fire_sprite(parent)
f.fire_sprite=New fire_sprite
f\entity=CopyEntity(sprite)
RotateEntity f\entity,EntityPitch(parent,True),EntityYaw(parent,True),EntityRoll(parent,True)
PositionEntity f\entity,EntityX(parent,True),EntityY(parent,True),EntityZ(parent,True)
omega#=Rnd(0,359)
k#=0.2
MoveEntity f\entity,Cos(omega)*k#,Sin(omega)*k#,0
f\alpha#=1
f\size#=2
f\time=MilliSecs()
Return Handle(f)
End Function

Function create_smok_sprite(parent)
f.fire_sprite=New fire_sprite
f\stat=1
f\entity=CopyEntity(sprite_smok)
EntityColor f\entity,140,140,140
RotateEntity f\entity,EntityPitch(parent,True),EntityYaw(parent,True),EntityRoll(parent,True)
PositionEntity f\entity,EntityX(parent,True)+Rnd(-1,1),EntityY(parent,True)+Rnd(-1,1),EntityZ(parent,True)+Rnd(-1,1)

MoveEntity f\entity,0,0,5
f\alpha#=.5
f\size#=Rnd(3,4)
f\time=MilliSecs()
Return Handle(f)
End Function

Function update_fire_sprite()
For f.fire_sprite=Each fire_sprite
new_time=MilliSecs()
delta=new_time-f\time
f\time=new_time

If f\stat=0
f\alpha#=f\alpha#-delta*0.01
f\size#=f\size#-delta*0.005
MoveEntity f\entity,0,0,0.03*delta
Else
f\alpha#=f\alpha*.97
f\size#=f\size*1.02
EndIf
EntityAlpha f\entity,f\alpha#
ScaleSprite f\entity,f\size,f\size
If f\alpha<.1
FreeEntity f\entity
Delete f
EndIf
Next
End Function
;_____________________________
;=MAIN LOOP
Graphics3D 800,600,32
Global camera=CreateCamera()
CameraClsColor camera,0,100,155
MoveEntity camera,0,0,-30
Global light=CreateLight()
Global sprite=LoadSprite("sprite.bmp"):HideEntity sprite
Global sprite_smok=LoadSprite("sprite.bmp",3)

HideEntity sprite_smok
;__create 1
snar_ptr=create_snar()
s.snar=Object.snar(snar_ptr)
s_ent=s\entity%
PositionEntity s_ent,0,2,0
;__create 2
snar_ptr=create_snar()
s.snar=Object.snar(snar_ptr)
s_ent2=s\entity%
;__create 3
snar_ptr=create_snar()
s.snar=Object.snar(snar_ptr)
s_ent3=s\entity%
RotateEntity s_ent3,0,90,90
;;;==

time=MilliSecs()
While Not KeyHit(1)

new_time=MilliSecs()
delta=new_time-time
time=new_time

MoveEntity s_ent2,0,0.07*delta,0
TurnEntity s_ent2,0.07*delta,0,0

MoveEntity s_ent3,0,0.07*delta,0
TurnEntity s_ent3,0.07*delta,0,0

update_snr()

update_fire_sprite()
RenderWorld
Flip
Wend
End

Источник: http://boolean.name/showthread.php?t=32

Категория: Blitz3D | Добавил: JohnK (07.06.2007) | Автор: impersonalis
Просмотров: 1727 | Комментарии: 1
Всего комментариев: 0
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]
Copyright JohnK© 2017