Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
fire works
Author Message
repsoccer16

Posted: Thu Apr 24, 2008 7:20 am   Post subject: RE:fire works

good program just need to slow it down a ways.

death bringer

Posted: Tue Apr 29, 2008 10:59 am   Post subject: RE:fire works

I fixed the code and made the effect slower enjoy
-Death bringer

setscreen ("graphics:max;max,offscreenonly")

const size := 100
const fireLength := 150
var decay := 0.98
var gravity := 1
var pixel : array 1 .. size, 1 .. 2 of real
var velocity : array 1 .. size, 1 .. 2 of real
var px, py : real

procedure newFire (x, y, vx, maxV : real)
var ang : int
for i : 1 .. size
pixel (i, 1) := x
pixel (i, 2) := y
ang := Rand.Int (0, 360)
velocity (i, 1) := cosd (ang) * (Rand.Real * (2 * maxV) - maxV) + vx
velocity (i, 2) := sind (ang) * (Rand.Real * (2 * maxV) - maxV)
end for
end newFire

procedure moveFire (c : int)
for i : 1 .. size
pixel (i, 1) += velocity (i, 1)
pixel (i, 2) += velocity (i, 2)
velocity (i, 1) *= decay
velocity (i, 2) -= gravity
velocity (i, 2) *= decay
drawdot (round (pixel (i, 1)), round (pixel (i, 2)), c)
end for
end moveFire

procedure launch (x, ang, spd, c : int)
px := x
py := 0
var pvx, pvy : real
pvx := cosd (ang) * spd
pvy := sind (ang) * spd
loop
exit when pvy < 0
drawfillbox (0, 0, maxx, maxy, 7)
px += pvx
py += pvy
pvx *= decay
pvy -= gravity
pvy *= decay
drawfilloval (round (px), round (py), 3, 3, c)
View.Update
cls
end loop
newFire (px, py, pvx, 10)
for i : 1 .. fireLength
drawfillbox (0, 0, maxx, maxy, 7)
moveFire (c)
View.Update
cls
end for
end launch

loop
launch (Rand.Int (100, maxx - 100), Rand.Int (70, 110), 40, Rand.Int (0, 255))
end loop
death bringer

Posted: Tue Apr 29, 2008 11:18 am   Post subject: RE:fire works

Also

setscreen ("graphics:max;max,offscreenonly")

const size := 100
const fireLength := 200
var decay := 0.93
var gravity := 0.1
var pixel : array 1 .. size, 1 .. 2 of real
var velocity : array 1 .. size, 1 .. 2 of real
var px, py : real

procedure newFire (x, y, vx, maxV : real)
var ang : int
for i : 1 .. size
pixel (i, 1) := x
pixel (i, 2) := y
ang := Rand.Int (500, 30000)

velocity (i, 1) := cosd (ang) * (Rand.Real * (2 * maxV) - maxV) + vx
velocity (i, 2) := sind (ang) * (Rand.Real * (2 * maxV) - maxV)
end for
end newFire

procedure moveFire (c : int)

for i : 1 .. size
pixel (i, 1) += velocity (i, 1)
pixel (i, 2) += velocity (i, 2)
velocity (i, 1) *= decay
velocity (i, 2) -= gravity
velocity (i, 2) *= decay
drawdot (round (pixel (i, 1)), round (pixel (i, 2)), c)
end for
end moveFire

procedure launch (x, ang, spd, c : int)
px := x
py := 0
var pvx, pvy : real
pvx := cosd (ang) * spd
pvy := sind (ang) * spd
loop
exit when pvy < 0
drawfillbox (0, 0, maxx, maxy, 7)
px += pvx
py += pvy
pvx *= decay
pvy -= gravity
pvy *= decay
drawfilloval (round (px), round (py), 2, 2, c)
View.Update
cls
end loop
newFire (px, py, pvx, 10)
for i : 1 .. fireLength

drawfillbox (0, 1, maxx, maxy, 7)

moveFire (c)
View.Update
cls
end for
end launch

loop
launch (Rand.Int (100, maxx - 100), Rand.Int (70, 110), 40, Rand.Int (0, 255))
end loop
Tallguy

Posted: Tue Apr 29, 2008 12:39 pm   Post subject: RE:fire works

nows its really fast
raidercom

Posted: Tue Apr 29, 2008 2:36 pm   Post subject: Re: fire works

I can hardly see anything its so fast...

Might wanna try a Time.DelaySinceLast (75) in the main loop.
death bringer

Posted: Thu May 01, 2008 11:03 am   Post subject: RE:fire works

Sorry about the last 2 post i made. when i had goten home it had gone faster on my computer i hope now this post finishes this issue.

setscreen ("graphics:max;max,offscreenonly,nocursor")
colorback (7)
process Bump_Sound2
sound (500, 200)
end Bump_Sound2
process Bump_Sound
sound (1000, 1)
end Bump_Sound
procedure Blur_Screen (I, C : int)
Blur_Screen (100, 9)
for B : 1 .. I
drawline (Rand.Int (1, maxx), Rand.Int (1, maxy),
Rand.Int (1, maxx), Rand.Int (1, maxy), C)

end for
end Blur_Screen

const size := 100
const fireLength := 400
var decay := 0.93
var gravity := 0.1
var pixel : array 1 .. size, 1 .. 2 of real
var velocity : array 1 .. size, 1 .. 2 of real
var px, py : real

procedure newFire (x, y, vx, maxV : real)
var ang : int
for i : 1 .. size
pixel (i, 1) := x
pixel (i, 2) := y
ang := Rand.Int (500, 30000)

velocity (i, 1) := cosd (ang) * (Rand.Real * (2 * maxV) - maxV) + vx
velocity (i, 2) := sind (ang) * (Rand.Real * (2 * maxV) - maxV)
end for
end newFire

procedure moveFire (c : int)

for i : 1 .. size
pixel (i, 1) += velocity (i, 1)
pixel (i, 2) += velocity (i, 2)
velocity (i, 1) *= decay
velocity (i, 2) -= gravity
velocity (i, 2) *= decay

drawdot (round (pixel (i, 1)), round (pixel (i, 2)), c)
end for
end moveFire

procedure launch (x, ang, spd, c : int)
px := x
py := 0
var pvx, pvy : real
pvx := cosd (ang) * spd
pvy := sind (ang) * spd
loop
fork Bump_Sound2
exit when pvy < 0

px += pvx
py += pvy
pvx *= decay
pvy -= gravity
pvy *= decay
drawfilloval (round (px), round (py), 2, 2, c)
View.Update
cls
end loop
newFire (px, py, pvx, 20)
for i : 1 .. fireLength

moveFire (c)
View.Update
cls
end for
fork Bump_Sound
end launch

loop
launch (Rand.Int (100, maxx - 100), Rand.Int (70, 110), 40, Rand.Int (0, 255))
end loop
Michael516

Posted: Fri May 02, 2008 8:08 am   Post subject: RE:fire works

this one works a lot better, but i think that the fireworks need to be a little more colorful.
Carey

Posted: Mon May 05, 2008 10:16 am   Post subject: RE:fire works

Please get a lock on this. This topic is 4 years old.

death bringer

Posted: Mon May 05, 2008 10:48 am   Post subject: RE:fire works

If you want the fire work to move even slower place this after line 57

delay(3)
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 2 of 2  [ 24 Posts ]
Goto page Previous  1, 2
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: