# 2d water effect

This topic is 2779 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,
I want to make a 2d game in which the character moves in the water and ripple effect are shown as the character moves in the water.
the effect should be somewhat as shown in this video My link

I want to know : 1 ) What approach i should take to implement it, is there any specific fluid simulation algorithm that i have to go through??
I want to implement it in a simple and quick manner.

I am using C/C++ and SFML

All suggestion are welcome.

##### Share on other sites
You double posted this but I'll answer it here. In the description of the youtube video there is a link: http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
On this page it is fully explained how the algoritm works. Suggest taking a look at that.

##### Share on other sites

You double posted this but I'll answer it here. In the description of the youtube video there is a link: http://freespace.vir...ics/x_water.htm
On this page it is fully explained how the algoritm works. Suggest taking a look at that.

yeah i saw that link. But that is for creating the ripple effect, but first i want to know how to implement the water simulation, then i can use that approach for the ripple's.
What type of algorithm should i use it for 2d water simulation.??

##### Share on other sites

yeah i saw that link. But that is for creating the ripple effect, but first i want to know how to implement the water simulation, then i can use that approach for the ripple's.
What type of algorithm should i use it for 2d water simulation.??

What do you mean exactly? The ripple effect and the 'water simulation' are one and the same, more or less, so it seems to me the algorithm described in the linked article is exactly what you're looking for.

##### Share on other sites

yeah i saw that link. But that is for creating the ripple effect, but first i want to know how to implement the water simulation, then i can use that approach for the ripple's.
What type of algorithm should i use it for 2d water simulation.??

I think you are confusing something here or not expressing yourself not clearly enough. What do you mean by a water simulation? If it's creating the ripples then the provided link quite clearly describes how to generate ripples on a 2D surface. (If you make it blue and name it water then it's ripples on water). It's not a water simulation by any means. It's just a background image with ripple effect generated on it. If you want to simulate the behavior of water completely then it's a different question from how to make an effect.

Edit: Ninjaed =w=;;

##### Share on other sites
If you would implement real simulated water you would not need the tutorial / guide from that link.

##### Share on other sites
Hi,
I am trying to implement the algorithm as shown in the link http://freespace.virgin.net/hugo.elias/graphics/x_water.htm.

I am having some doubts in the implementation logic such as:

1) I have displayed a .tga file with water image -> I can click on it and get the clicked position.
Then using some calculation I determine a DEPTH value using the clicked position.

MY DOUBT = How this depth value and the pixel of the image to be related.????
What should i do with the depth value been calculated?

2) Pixel are composed of value (r,g,b). Then should i change the value of (r,g,b) for each pixel.???

3) Do I have to display the images pixel wise??
as I am using SFML it has the option of directly displaying the image like:
 sf::Image.LoadFromFile("Water.tga"); sf::Sprite* sprite = new sf::Sprite(Image); Game.Draw(*sprite); 

4) The two buffers to be used like
char* buf_write;

should it be stored with pixel values of the image eg ( Water.tga) in the beginning?? The ProcessWater() as mentioned in the algorithm of the link
should i store the pixel values in the buffers in this function???

All suggestion are welcome. ( pretty much confused ) ..What should be the step by step logic to be followed

..

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013753
×