February 27, 2021, 04:22:32 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Fireworks by Ross C [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Fireworks by Ross C [ 1+ years ago ] (Read 417 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Fireworks by Ross C [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:39 AM »
Title :
Fireworks
Author :
Ross C
Posted :
1+ years ago
Description :
This code will shoot a firework in the air then explode it. Not much, but someone might find it useful i hope
)
Code :
Code: BlitzBasic
Graphics
800
,
600
SetBuffer
BackBuffer
(
)
Type
shot
Field
x#,y#
Field
speed#
Field
distance
Field
travelled#
Field
cr,cg,cb
End Type
Type
particle
Field
x#,y#
Field
angle#
Field
speed#
Field
time
Field
timer
End Type
While
Not
KeyHit
(
1
)
Cls
; x y speed distance
If
KeyHit
(
2
)
Then
fire_shot
(
Rnd
(
10
,
700
)
,
Rnd
(
200
,
600
)
,
Rnd
(
0.5
,
3
)
,
Rnd
(
50
,
180
)
)
update_shots
(
)
update_particles
(
)
Flip
Wend
End
Function
fire_shot
(
x#,y#,speed#,distance#
)
s.shot=
New
shot
sx = x
sy = y
sspeed = speed
sdistance = sy-distance
scr =
Rand
(
100
,
255
)
scg =
Rand
(
100
,
155
)
scb =
Rand
(
10
,
100
)
End Function
Function
update_shots
(
)
For
s.shot=
Each
shot
sy=sy-sspeed
; move shot
Color
scr,scg,scb
; set color
Rect
sx,sy,
2
,
2
; draw particle
If
sy<sdistance
Then
trnd=
Rand
(
1
,
6
)
; number of Rings of particles the shot will produce (min,max)
For
mloop=
1
To
trnd
; loop for the number of rings of particles the shot will produce (min,max)
speed#=
Rnd
(
0.2
,
2
)
; rnd speed for each ring of particles
incr#=
Rnd
(
10
,
70
)
; angle/spacing between each particle
For
loop=
0
To
incr
; loop thru each particle in the loop, and create
create_new_particle
(
sx,sy,
Rnd
(
speed*
0.8
,speed*
1.2
)
,loop*
(
360
/incr
)
)
Next
Next
Delete
s.shot
End If
Next
End Function
Function
create_new_particle
(
x#,y#,speed#,angle
)
p.particle=
New
particle
px=x
py=y
pspeed=speed
pangle=angle
p imer=
MilliSecs
(
)
p ime=
Rand
(
500
,
2000
)
End Function
Function
update_particles
(
)
For
p.particle=
Each
particle
px=px+
Cos
(
pangle
)
*pspeed
; move particle
py=py+
Sin
(
pangle
)
*pspeed
; move particle
temp=
Rand
(
100
,
255
)
; random red color
temp1=
Rand
(
10
,temp
)
; random green colour, based on the result of the random red colour
Color
temp,temp1,
Rand
(
10
,
190
)
; set colour
Rect
px,py,
Rand
(
1
,
4
)
,
Rand
(
1
,
4
)
; set colour
If
MilliSecs
(
)
>p imer+p ime
Then
Delete
p.particle
End If
Next
End Function
Comments :
Agamer(Posted 1+ years ago)
I love it, well you know I used it for some game I was making nothing much but interesting!
big10p(Posted 1+ years ago)
Ooooooh! Ahhhhhhh!
Subirenihil(Posted 1+ years ago)
Interesting...However, I have a program that does far better effects. Mine is designed for use within other programs, so you have me beat there.Try Fireworks II.
DheDarkhCustard(Posted 1+ years ago)
nifty!someone could use it in a high scores screen.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Graphics
»
[bb] Fireworks by Ross C [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal