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

Username:   Password: 
 RegisterRegister   
 rain help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jestar




PostPosted: Mon Nov 26, 2007 6:52 pm   Post subject: rain help

ok so i am trying to make a weather effects in my game and i am starting with rain...i was wondering how i should go about it...Should i make the rain drops a sprite? am i able to array srpites? i tried just making the drops ovals but its a pain in the butt erasing them for they dont leave a trail...so yeah i am looking for advice on how to go about this...currently i have 1 drop as a sprite and i dont no how to array a srpite so i am stumped.
Sponsor
Sponsor
Sponsor
sponsor
Nick




PostPosted: Mon Nov 26, 2007 11:31 pm   Post subject: RE:rain help

im liking the array however u dont NEED sprites

say you have 10 rain images you want to loop, well in your program when you draw your background you could have a code such as this:
code:
for i:1..10
Pic.Draw(rain(i),0,0,picMerge

so the rain will be drawn over top of everything and the picMerge will erase the white in the image

i hope u understand what i mean
zylum




PostPosted: Tue Nov 27, 2007 12:54 am   Post subject: RE:rain help

The simplest way would be to have each drop be a pixel. You can define a position record which has the parameters x, y and then make an array of this record and initialize the positions to random points on the screen. Then just apply gravity/wind to each element in the array and redraw each pixel. If a pixel goes off the screen, the reposition it to the top of the screen so that if falls down again.
Jestar




PostPosted: Tue Nov 27, 2007 9:06 am   Post subject: Re: rain help

if i drew each rain drop as a pixel then i would have to repaste the background evreytime it moved to erase it and that would cause lots of flashing...and momop i am currently trying your idea, i'll re post if ihave more trouble or i get it to work...thanks for the help guys.





EDIT

ok momop i tried your idea but the problem is that it dosnt erase itself after it moves...and thats mainly the reason why i want to use a sprite for the rain drop....
zylum




PostPosted: Tue Nov 27, 2007 3:43 pm   Post subject: RE:rain help

look into View.Update to stop the flashing. redrawing the background should not be a problem as it should be proceduralized anyways.
belarussian




PostPosted: Wed Nov 18, 2009 6:20 pm   Post subject: Re: rain help

ok THis is really easy here is the code you can change the amount of rain and how fast it moves

View.Set ("offscreenonly")
%set up the rain
const NoOfraindrops := 400
var raindropX : array 1 .. NoOfraindrops of int
var raindropY : array 1 .. NoOfraindrops of int

for raindrop : 1 .. NoOfraindrops
raindropX (raindrop) := Rand.Int (0, maxx)
raindropY (raindrop) := Rand.Int (0, maxy)
end for

loop
for flake : 1 .. NoOfraindrops
%Drop The rain
raindropY (raindrop) -= Rand.Int (1, 5)
%raindropX (raindrop) += Rand.Int (-1, 1)
if raindropY (raindrop) < 0 then
raindropY (raindrop) := maxy
raindropX (raindrop) := Rand.Int (0, maxx)
end if
Draw.FillOval (raindropX (raindrop),raindropY (raindrop), 1, 1, blue)
end for
%Update the screen (because of offscreen only)
View.Update
delay (25)
end loop
belarussian




PostPosted: Wed Nov 18, 2009 9:21 pm   Post subject: RE:rain help

umm well you have to make a background for it to work perfectly.

%Make the background
Draw.FillBox (0, 0, 800, 300, 29)
Draw.FillBox (0, 300, 800, 600, red)

%PUT THIS INSIDE THE LOOP
belarussian




PostPosted: Thu Nov 19, 2009 10:16 pm   Post subject: RE:rain help

AND YOU MIGHT GET A ERROR A FOR FLAKE CHANGE THAT TO RAINDROP

so ya i hope you have a good rain program
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Nov 19, 2009 10:20 pm   Post subject: RE:rain help

Wait... so you found a thread from 2007 and proceeded to tripple-post in it? Locked, warning, etc.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
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  [ 9 Posts ]
Jump to:   


Style:  
Search: