help with seting up the lake v1.3 module in room

Started by Icey, Fri 31/12/2010 00:55:05

Previous topic - Next topic

Icey


In this pic I would like the red outlined area (water) to move and when the player walks over the bridge he and his partner are reflected

Do you think you could take this and add the water effect and test then give me the code?

I should have posted this earlier but I forgot so if you someone can please explain this before tomorrow. It would be great.

Khris

#1
Instead of PM'ing back and forth, let's have a go at this here, ok?

The good news is, with the bridge being as high is it is, the character reflections won't be visible, so we don't need to worry about them.
To make only the red areas move, we have to draw the ground areas on the background after the lake has been drawn. This is achieved pretty easily, just Room.GetDrawingSurfaceForBackground(), then draw the sprite to it and .Release();

Why is the second pic i.e. the actual background I presume 333x264?

Nevermind, I'm building the room right now and will post the result.


Edit:
Ok, here is the relevant part from the room script:
Code: ags
Lake Room1Lake;

function room_Load()
{
  Room1Lake.DefaultConstruct();
  Room1Lake.x = 30;
  Room1Lake.y = 240;
  Room1Lake.w = 268;
  Room1Lake.h = 240;
  Room1Lake.yRippleSize = 0.2;
  Room1Lake.xRipplePhaseScale = 0.3;
  Room1Lake.xRipplePhaseScale = 0.3;
  SetViewport(0, 240);
}

function room_RepExec()
{
  Room1Lake.Update();
  DrawingSurface*ds = Room.GetDrawingSurfaceForBackground();
  ds.DrawImage(30, 240, 41);
  ds.Release();
  ...
}

Feel free to try different values for RippleSize and PhaseScale.

Here's sprite 41 and the room bg at 50%:
           

As you can see I heavily edited the top portion to make the reflection fit the scenery.

The idea is that the lake spans (almost) the whole lower 320x240, reflecting the upper 320x240. The sprite on the left is pasted on top after the lake is drawn each loop.

Note that I had to fix the viewport to 0,240 to hide the reflection. If the room is supposed to be scrolling, you have to write your own routine to calculate the viewport. This is easy; all you do is set x,y to player.x-160, player.y-120, then bind x,y to the desired coordinate range. E.g. if the room is supposed to be 640 wide, bind x to 0-320 and leave y at 240. Then the room will only scroll horizontally and the reflection portion will remain hidden.

Here's the compiled game:
http://db.tt/Xa74ik8
(press space to hide/unhide sprite 41)

Icey

Oh, I didnt even notice this post. Thanks khris.

Icey

#3
Oh and I have a few more questions.

I will be using the actual background pic.

   1.should I take that and flip like you did?

  2.Should I cut the main lake aera out of the pic like you did and make it an object?

  3.When you say bind the x,y what exactly do you mean?

4.When I use the your edited pink pic I only see the bottom water aera?

basicly I cant get the water to to reach the top of the screen it stops at the bridges leges.

Khris

1,2,4. Yeah sure, I didn't flip it for fun.

Look, you have to understand how the module works and why I'm using that mirrored background, otherwise this is going to be a long topic full of me explaining the same stuff over and over again.

As you can see, I changed the lake dimensions in room_Load (I assume you missed this i.e. this should answer question #4). The rectangle I defined for the lake module to use will mirror a rectangle of the same size directly above. Due to the perspective of the room I had to make the whole visible part a lake, then put the reflection part above it. You don't really need to flip the room; you can simply fill the top half with water since the ground is then drawn on top of the lake surface (now mirroring only water) anyway.

Again, why did you use such random room background dimensions?

3. Binding x to 0-320 would be:
Code: ags
  if (x < 0) x = 0;
  if (x > 320) x = 320;

SMF spam blocked by CleanTalk