Solved

RAINIGHT

Posted on 2003-11-28
4
179 Views
Last Modified: 2010-04-15
I am doing a project in C graphics , where i am developing a man walking along a river on a  rainy day, ( i.e. It is raining ) I have developed man walking also river too. I am unable to produce the rain there, So plz help me in that , give me code for that.

I am using Turbo c++ compliler
On Windows 98.

For this i will be thankful to u

ASIF

0
Comment
Question by:ASIFANWER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 3

Accepted Solution

by:
guynumber5764 earned 50 total points
ID: 9852862
I don't have the ins & outs of TC and you haven't really stated your problem:  light/heavy rain?  wind?  Can the rain "fade in" initially?

For light rain falling vertically you could:
Declare a structure for every column containing a single row position and a pixel value (or use two arrays)

For each time step:
 - For each column (col)without a rain drop
   - 1 in 200 (or so) chance of starting a new drop:
          - save the top (col,0) pixel
          - set the row value to 0
          - set pixel (col,row) to the rain colour.
 - For each column with a raindrop:
       - set pixel (col,row) back to the saved colour
       - increment row by the rain speed
       - if the drop hits bottom
           - clear it off and set the row value to NO_DROP
          else
           - save the colour of the new (col,row) pixel.
           - set the col,row pixel to rain colour.

For more complex rain behaviour you would probably need to track each drop (row, col, and saved value).  You could make things simpler or more complex with fancier bit operations but you risk getting oobleck under some circumtances.
0
 
LVL 4

Expert Comment

by:void_main
ID: 9881006
Is it a 2-D or a 3-D program?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question