Find Jobs
Hire Freelancers

convert basic code into a function.

$15-20 USD

Cerrado
Publicado hace más de 13 años

$15-20 USD

Pagado a la entrega
so I've been given some code to play with and it works great by itself but I need to convert it into a function to work in the game. code in question is a particle system ( for fireworks effects ) code is using the blitz3d engine I will supply full source code of the game and am usually online to answer questions. ## Deliverables so I've been given some code to play with and it works great by itself but I need to convert it into a function to work in the game. [code] ; lesson 8, random particle Graphics3D 800,600,16,2 SetBuffer BackBuffer() Rnd MilliSecs() campivot=CreatePivot() camera=CreateCamera(campivot) MoveEntity camera,0,10,-30 ground=CreatePlane() groundt=LoadTexture("[login to view URL]") ScaleTexture groundt,20,20 EntityTexture ground,groundt CameraClsColor camera,70,130,210 ;==================================================== particle1=LoadSprite("World/Sprites/TFX/[login to view URL]",2) EntityAlpha particle1,0 particle2=LoadSprite("World/Sprites/TFX/[login to view URL]",2) EntityAlpha particle2,0 particle3=LoadSprite("World/Sprites/TFX/[login to view URL]",2) EntityAlpha particle3,0 particle4=LoadSprite("World/Sprites/TFX/[login to view URL]",2) EntityAlpha particle4,0 Type particle Field physicalparticle Field x,y,z Field rp,ry,rr Field speed# Field life# End Type frametimer=CreateTimer(60) ;==================================================== ; Main loop While Not KeyHit(1) WaitTimer(frametimer) If KeyHit(57) cuepyro=1 If cuepyro=1 Then For a=1 To 500 ; Create spark.particle=New particle particlepick=Rnd(1,4) ; ranom pick of 4 types of particle If particlepick=1 spark\physicalparticle=CopyEntity(particle1) If particlepick=2 spark\physicalparticle=CopyEntity(particle2) If particlepick=3 spark\physicalparticle=CopyEntity(particle3) If particlepick=4 spark\physicalparticle=CopyEntity(particle4) ; Position spark\x=0 spark\y=10 spark\z=0 PositionEntity spark\physicalparticle,spark\x,spark\y,spark\z ; Aim spark\rp=Rnd(1,360) spark\ry=Rnd(1,360) spark\rr=Rnd(1,360) RotateEntity spark\physicalparticle,spark\rp,spark\ry,spark\rr ; Life spark\life#=Rnd(0.1,1.0) ; added variable life again to show the counter at work better EntityAlpha spark\physicalparticle,spark\life# ; Speed spark\speed#=Rnd(0.03,0.2) ; particlecount=particlecount+1 ; each time it creates a particle we will increase the counter by 1 PlaySound "[login to view URL]" Next cuepyro=0 EndIf For spark.particle=Each particle spark\life#=spark\life#-0.01 MoveEntity spark\physicalparticle,0,spark\speed#,0 EntityAlpha spark\physicalparticle,spark\life# If spark\life<0.01 Then FreeEntity spark\physicalparticle Delete spark particlecount=particlecount-1 ; each time we kill a particle we will decrease the counter by 1 EndIf Next If particlecount <=0 And pyrun <=5 cuepyro=1 pyrun = pyrun +1 EndIf UpdateWorld RenderWorld Text 20,20,"Active Particles= "+particlecount ; pretty sure there is a way to just count all active particles but for now this method will suffice Text 35,35,"Run Count= "+pyrun Flip ;TurnEntity campivot,0,1,0 Wend End [/code] i tried this... [code] Function pyro() ;==================================================== particle1=LoadSprite("[login to view URL]",2) EntityAlpha particle1,0 particle2=LoadSprite("[login to view URL]",2) EntityAlpha particle2,0 particle3=LoadSprite("[login to view URL]",2) EntityAlpha particle3,0 particle4=LoadSprite("[login to view URL]",2) EntityAlpha particle4,0 End Function Type particle Field physicalparticle Field x,y,z Field rp,ry,rr Field speed# Field life# End Type Function pyro2() If cuepyro=1 Then For pyroa=1 To 500 ; Create spark.particle=New particle particlepick=Rnd(1,4) ; ranom pick of 4 types of particle If particlepick=1 spark\physicalparticle=CopyEntity(particle1) If particlepick=2 spark\physicalparticle=CopyEntity(particle2) If particlepick=3 spark\physicalparticle=CopyEntity(particle3) If particlepick=4 spark\physicalparticle=CopyEntity(particle4) ; Position spark\x=0 spark\y=10 spark\z=0 PositionEntity spark\physicalparticle,spark\x,spark\y,spark\z ; Aim spark\rp=Rnd(1,360) spark\ry=Rnd(1,360) spark\rr=Rnd(1,360) RotateEntity spark\physicalparticle,spark\rp,spark\ry,spark\rr ; Life spark\life#=Rnd(0.1,1.0) ; added variable life again to show the counter at work better EntityAlpha spark\physicalparticle,spark\life# ; Speed spark\speed#=Rnd(0.03,0.2) ; particlecount=particlecount+1 ; each time it creates a particle we will increase the counter by 1 PlaySound "[login to view URL]" Next cuepyro=0 EndIf For spark.particle=Each particle spark\life#=spark\life#-0.01 MoveEntity spark\physicalparticle,0,spark\speed#,0 EntityAlpha spark\physicalparticle,spark\life# If spark\life<0.01 Then FreeEntity spark\physicalparticle Delete spark particlecount=particlecount-1 ; each time we kill a particle we will decrease the counter by 1 EndIf Next If particlecount <=0 And pyrun <=5 cuepyro=1 pyrun = pyrun +1 EndIf End Function [/code]
ID del proyecto: 3709028

Información sobre el proyecto

1 propuesta
Proyecto remoto
Activo hace 14 años

¿Buscas ganar dinero?

Beneficios de presentar ofertas en Freelancer

Fija tu plazo y presupuesto
Cobra por tu trabajo
Describe tu propuesta
Es gratis registrarse y presentar ofertas en los trabajos
1 freelancer está ofertando un promedio de $15 USD por este trabajo
Avatar del usuario
See private message.
$15,30 USD en 14 días
0,0 (0 comentarios)
0,0
0,0

Sobre este cliente

Bandera de CANADA
lindsay, Canada
5,0
53
Forma de pago verificada
Miembro desde oct 4, 2006

Verificación del cliente

¡Gracias! Te hemos enviado un enlace para reclamar tu crédito gratuito.
Algo salió mal al enviar tu correo electrónico. Por favor, intenta de nuevo.
Usuarios registrados Total de empleos publicados
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Cargando visualización previa
Permiso concedido para Geolocalización.
Tu sesión de acceso ha expirado y has sido desconectado. Por favor, inica sesión nuevamente.