Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with making a smoke effect
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Schaef




PostPosted: Sun Jan 18, 2004 6:10 pm   Post subject: Help with making a smoke effect

Hey,
I need to make a program for school that has a house with smoke coming out of the chimney and some other animation. Can someone give me some kind of an idea of what i could do for my smoke effect. Just give me an idea i dont need a source code or nething. Neways here is the house so far:

code:
var a,br : int
br := 185
a:=54
View.Set ("graphics:640;480, nobuttonbar")
 

 
colourback(a)
cls

drawfillbox (0, 0, maxx, 210, 2)
drawfillbox (250, 70, 400, 200, 113)
drawfillbox (250,0,400,70,2)

% WALKWAY---------------------------------------------------------------------
drawline (221,0,300,70,8)
drawline (269,0,350,70,8)
drawline (220,0,270,0,8)
drawline (300,70,350,70,8)
 
drawfill (300,50,8,8)

drawline (500, 140, 500, 250, 113)
drawline (400, 70, 500, 140, 113)
drawline (400, 200, 500, 250, 113)

drawline (400, 185, 500, 237, 113)
drawline (400, 169, 500, 223, 113)
drawline (400, 155, 500, 209, 113)
drawline (400, 140, 500, 195, 113)

drawline (400, 80, 500, 150, 113)
drawline (400, 95, 500, 162, 113)
drawline (400, 110, 500, 175, 113)
drawline (400, 125, 500, 185, 113)

drawfill (450, 200, 113, 113)
drawfill (450, 220, 113, 113)
drawfill (450, 180, 113, 113)
drawfill (450, 185, 113, 113)
drawfill (450, 160, 113, 113)
drawfill (450, 140, 113, 113)
drawfill (450, 145, 113, 113)
drawfill (450, 120, 113, 113)
drawfill (450, 110, 113, 113)

drawline (400, 185, 500, 237, 16)
drawline (400, 169, 500, 223, 16)
drawline (400, 155, 500, 209, 16)
drawline (400, 140, 500, 197, 16)

drawline (400, 80, 500, 150, 16)
drawline (400, 95, 500, 162, 16)
drawline (400, 110, 500, 175, 16)
drawline (400, 125, 500, 185, 16)

drawline (400, 70, 400, 200, 16)

for wall : 1 .. 8
    drawline (250, br, 400, br, 16)
    br := br - 15
end for

%ROOF------------------------------------------------------------------------
drawline (325, 300, 425, 350, 26)
drawline (500, 250, 425, 350, 26)
drawline (325, 300, 400, 200, 26)
drawline (400, 200, 500, 250, 26)
drawfill (400, 300, 26, 26)
 
drawline (250, 200, 325, 300, 23)
drawline (325, 300, 400, 200, 23)
drawline (250, 200, 400, 200, 23)
 
drawfill (300, 250, 23, 23)
 

drawline (400, 70, 400, 200, 183)
drawline (400, 200, 500, 250, 113)
drawline (500, 250, 425, 350, 26)



%CHIMNEY--------------------------------------------------------------
drawline (425, 275, 450, 250, 23)
drawline (450, 250, 450, 330, 23)
drawline (425, 275, 425, 345, 23)
drawline (425, 345, 450, 330, 23)
drawline (425, 345, 455, 360, 23)
drawline (450, 330, 480, 345, 23)
drawline (455, 360, 480, 345, 23)
drawline (450, 330, 480, 345, 23)



drawfill (440, 300, 23, 23)
drawfill (450, 350, 16, 23)
drawline (480,345,480,270,26)
drawline (450,330,450,250,26)
drawline (450,330,480,345,26)
drawfill (470,310,26,26)

drawline (450, 250, 480, 265, 26)
drawline (480, 265, 480, 345, 26)
drawline (450, 330, 480, 345, 26)
drawline (450, 250, 450, 330, 26)
drawfill (460, 300, 26, 26)


%DOOR-----------------------------------------------------------------
drawfillbox (300, 70, 350, 150, 0)
drawfilloval (340, 100, 3, 3, 23)
%WINDOWS--------------------------------------------------------------
drawbox (260, 140, 290, 170, 0)
drawbox (360, 140, 390, 170, 0)
drawline (260, 155, 290, 155, 0)
drawline (275, 140, 275, 170, 0)
drawline (360, 155, 390, 155, 0)
drawline (375, 140, 375, 170, 0)

drawfillbox (261, 141, 274, 154, 68)
drawfillbox (261, 156, 274, 169, 68)
drawfillbox (276, 141, 289, 154, 68)
drawfillbox (276, 156, 289, 169, 68)

drawfillbox (361, 141, 374, 154, 68)
drawfillbox (361, 156, 374, 169, 68)
drawfillbox (376, 141, 389, 154, 68)
drawfillbox (376, 156, 389, 169, 68)

View.Update
a:=a-1
if a=54 then
elsif a=53 then
elsif a=52 then a:=78
elsif a=77 then a:=38
elsif a=37 then a:=21
elsif a=20 then
elsif a=19 then a:=54
end if
 
Sponsor
Sponsor
Sponsor
sponsor
Homer_simpson




PostPosted: Sun Jan 18, 2004 7:10 pm   Post subject: (No subject)

a little particle engine would do...
Schaef




PostPosted: Mon Jan 19, 2004 3:43 pm   Post subject: (No subject)

whats that?
Andy




PostPosted: Mon Jan 19, 2004 5:07 pm   Post subject: (No subject)

a program that turns images into lil particles and move them around
Mazer




PostPosted: Mon Jan 19, 2004 6:23 pm   Post subject: (No subject)

Not necessarily images, especially in turings case since many images could kill the framerate. Anyways, I would suggest you have variables for the x and y position of the chimney where the smoke should emerge, then make more variable (an array) for the x and y coordinates of the smoke, and draw grey ovals at those points for the smoke. Have the y coordinate of the smoke increase at a constant rate, then try having the x coordinate randomly increase or decrease by a set amount. Then, once the y coordinate reaches a certain value, reset the x and y position of the smoke back to the original position.
Schaef




PostPosted: Mon Jan 19, 2004 6:26 pm   Post subject: (No subject)

i have my smoke done now.. how would i set up a code so that I would have a whole bunch of dots placed randomly inside of a circle boundary
TheXploder




PostPosted: Mon Jan 19, 2004 7:41 pm   Post subject: (No subject)

Holy thats a lot of code for just smoke.
I would try a combination of local and global variables.

code:


----------------------------------DESCRIPTION-----------------------------------

% 'procedure [variable of procedure]' starts a procedure and it has to end with 'end [variable of procedure]'

% procedure [variable of procedure] ([local varibles]:[type])
% ex. [b]procedure objBox (x, y, clr : int)[/b]

% .....

% end [variable of procedure]
% ex. [b]end objBox[/b]

% end closes the procedure

% local variables are only declared within the procedure
% if you want to give it a value or change the value of those variables
% you have to use this:

% [variable of procedure](variables and their values)
% ex. [b]objBox(x,y,clr)[/b]

% but instead of writing 'objBox(x,y,clr)' you can add a value to it
% something like 'objBox(1,1,1)'

% So lets go ahead and create a new procedure:

%-----------------------------CODE-----------------------------------------------

procedure fxSmokeParticle (x, y, clr : int)
      drawoval(x, y, x + 10, y + 10, clr)
end fxSmokeParticle

fxSmokeParticle(1,1,1)


Ohh Rolling Eyes I've almost written a tutorial on procedures...
-----------------------------------------------------------------

That should cut down your code by a million,
you can even have colour variation if you change one variable.

And about the random dots... if I'm not mistaken you are heading towards an Airbrush effect with that, if you want transparency spoke look into images. You could do it with a loop, but that would slow down the movement of the smoke...

Hope this helps... Wink

-=TheXploder=-
Mazer




PostPosted: Mon Jan 19, 2004 7:47 pm   Post subject: (No subject)

I may be blind, lazy, and fat, but I'm pretty sure there was no code for smoke anywhere in there...
And there really isn't much use in making a procedure for one line, and that is some funky smoke you've got there... the size of the particle is more than the x and y pos of the particle...
TheXploder




PostPosted: Mon Jan 19, 2004 8:13 pm   Post subject: (No subject)

Just as an example what you can do with what i've shown you above...

code:

var sizeOfParticle : int

procedure fxSmokeParticle (x, y, particleSize, clr : int)
    drawfilloval (x, y, particleSize, particleSize, clr)
end fxSmokeParticle

procedure fxSmokeParticle2 (x, y, particleSize, clr : int)
    drawfilloval (x, y, floor(particleSize/2), floor(particleSize/2), clr)
end fxSmokeParticle2

proc fxSmokeParticleSystem (x, y, particleSize : int)
    fxSmokeParticle (x + particleSize, y + particleSize, particleSize, gray)
    fxSmokeParticle2 (x + particleSize, y + particleSize, particleSize, darkgray)
end fxSmokeParticleSystem

randint(sizeOfParticle,1,10)

fxSmokeParticleSystem (100, 100, sizeOfParticle)


-=TheXploder=-
AsianSensation




PostPosted: Mon Jan 19, 2004 9:41 pm   Post subject: (No subject)

I was about to make the smoke effect, but then I saw this awesome code posted before me, and so now I am shocked by the ingenious programming done by TheXploder and not going to post mine because it looks like crap compare to his.

btw, if you want to know how I did mine, I make a cluster of particles, and then make them spread out as the big cluster rises, kinda like a cloud puff. Then the particles disappear after some time, and another puff appears.

The only problem I have is generating the cluster. so far it's in a circle and looks like crap, how do I make it generate in a cloud shape thing? Maybe I'll have to use whatdotcolor on this one......damn it.
Schaef




PostPosted: Tue Jan 20, 2004 7:05 am   Post subject: (No subject)

hey,
this is a code that i have so far for a cloud. How do you think i could alter it so that the particles would move across the sky?

code:

View.Set("graphics:640;480, nobuttonbar, offscreenonly")
colorback(54)
cls

proc cloud3 (x, y, r, clr : int)
    var clx, cly : int
    randint (clx, -r, r)
    randint (cly, -r, r)
    if (clx ** 2 + cly ** 2) <= r ** 2 then
        drawdot (clx + x, cly + y, white)
    end if
end cloud3
 
var clox, cloy: int
 
randint (clox,0,maxx)
randint (cloy,0,maxy)

for cloud:1..300
        cloud3 (clox, cloy, 20, white)
end for

var clrand:int
var clrand2:int
var clmrand:int
var clmrand2:int

for cloud2:1..50
randint (clrand,-20,20)
randint (clrand2,-20,20)

clox:=clox+clrand
cloy:=cloy+clrand2

for cloud:1..300
        cloud3 (clox, cloy, 20, white) 
        end for
end for
 
 
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 11 Posts ]
Jump to:   


Style:  
Search: