Author Topic: MODULE: Underwater v1.1  (Read 13460 times)

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
MODULE: Underwater v1.1
« on: 19 Aug 2009, 06:13 »
Underwater module
v1.0 for AGS 2.72+

Distorts a background in a wibbly wavy way.
Hard to show a screenshot, but you can see it in action in this demo:
http://www.kweepa.com/step/ags/tech/UnderwaterDemo.zip
Get the module here:
http://www.kweepa.com/step/ags/tech/Underwater11.zip
Video on youtube:


Version history:
1.1 Added characters and objects (depending on baseline)
1.0 Initial version

Steve
« Last Edit: 20 Aug 2009, 21:29 by SteveMcCrea »
Still waiting for Purity of the Surf II

Dualnames

  • Local Moderator
  • Rottwheelers
  • Pretty Badass
    • Dualnames worked on a game that was nominated for an AGS Award!
      Dualnames worked on a game that won an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #1 on: 19 Aug 2009, 08:16 »
Are you married? Wow, subspark will love this!!! Thanks a lot stevey!!
No more military army stuff. I'm alive and back.

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    •  
    • SSH worked on a game that was nominated for an AGS Award!
      SSH worked on a game that won an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #2 on: 19 Aug 2009, 11:04 »
Is it possible to run this effect on only a small area?

Snake

  • @_@
    • I can help with making music
    •  
    • I can help with story design
    •  
    • Snake worked on a game that was nominated for an AGS Award!
      Snake worked on a game that won an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #3 on: 19 Aug 2009, 15:02 »
Steve... that's awesome :o
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

TerranRich

  • I'm Terran Riiiick!
    • I can help with characters
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
    • I can help with web design
    •  
    • TerranRich worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #4 on: 19 Aug 2009, 15:42 »
I wish people would post videos of their modules in action. :P

Thanks, Steve! This will be very useful to a lot of developers here :)
Status: Trying to come up with some ideas...

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #5 on: 19 Aug 2009, 16:33 »
I wish people would post videos of their modules in action. :P
Be my guest! It would take me longer to record, convert, and upload the video than to write the module! :=

Is it possible to run this effect on only a small area?
Yes, that would be possible. Are you thinking about a window in an underwater base or something like that? I'll have a think about the best way to handle the edges.

Are you married? Wow, subspark will love this!!! Thanks a lot stevey!!
Sorry, yes I am!
I considered posting this in sparky's thread...
Still waiting for Purity of the Surf II

Joseph DiPerla

  • Joseph DiPerla, Adventure Game Creator Wannabe!
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with play testing
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
    • I can help with web design
    •  
Re: MODULE: Underwater v1.0
« Reply #6 on: 19 Aug 2009, 17:16 »
Wow. Nice job. Anyway you can get that to work along with the character? It just doesn't seem right that the character doesn't have the same effect happen to him.
Joseph DiPerla--- http://www.adventurestockpile.com
Play my Star Wars MMORPG: http://sw-bfs.com
See my Fiverr page for translation and other services: https://www.fiverr.com/josephdiperla
Google Plus Adventure Community: https://plus.google.com/communities/116504865864458899575

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #7 on: 19 Aug 2009, 17:50 »
Anyway you can get that to work along with the character?
I'd have to have a third buffer, render the bg, characters and objects to that, then do the underwater effect on top (and hide the visible objects). I think it's easy enough to get the current frame for characters...
Still waiting for Purity of the Surf II

monkey0506

  • AGS Project Tracker Admins
  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    •  
Re: MODULE: Underwater v1.0
« Reply #8 on: 19 Aug 2009, 18:11 »
I think it's easy enough to get the current frame for characters...

Sure, that's easy enough:

Code: Adventure Game Studio
  1. ViewFrame *frame = Game.GetViewFrame(player.View, player.Loop, player.Frame);
  2. DynamicSprite *sprite = DynamicSprite.CreateFromExisitingSprite(frame.Graphic);
  3. if (frame.Flipped) sprite.Flip(eFlipLeftToRight);

Though you do have to use a DynamicSprite if the frame is flipped (otherwise you can just use the raw sprite number). You could avoid creating the sprite unnecessarily by doing something like:

Code: Adventure Game Studio
  1. ViewFrame *frame = Game.GetViewFrame(player.View, player.Loop, player.Frame);
  2. DynamicSprite *sprite;
  3. int graphic = frame.Graphic;
  4. if (frame.Flipped) {
  5.   sprite = DynamicSprite.CreateFromExistingSprite(graphic);
  6.   sprite.Flip(eFlipLeftToRight);
  7.   graphic = sprite.Graphic;
  8. }

I am assuming that you're using a DrawingSurface at some point which the character sprites would be drawn onto? Because at that point it's safe to delete the DynamicSprite (if any) of course.

Re: MODULE: Underwater v1.0
« Reply #9 on: 19 Aug 2009, 18:28 »
Cool module. The functionality is very similar to the refraction part of my EffectObjects module, though that works on objects (as you can tell from the name) rather than backgrounds. Basically it turns any object into a lens which can scale/distort background, objects and characters behind it. I'm using 3.1.2, so DrawingSurface functions and CopyTransparencyMask are a great help. But I'm sure something similar could be done in 2.72.

The thing you have to remember if you want to RawDraw characters/objects onto the background before distorting it is to sort them by baseline first. Since characters and objects can move around and new characters can enter the room this has to be done every game loop, which is a bit of a pain but doesn't cause too much slowdown. Also, any walkbehinds within the distorted area would have to be faked by using objects.

Snake

  • @_@
    • I can help with making music
    •  
    • I can help with story design
    •  
    • Snake worked on a game that was nominated for an AGS Award!
      Snake worked on a game that won an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #10 on: 19 Aug 2009, 18:51 »
Wow, if you can get this to work with the characters and objects too, that would be even better. I was actually going to ask about that in my first post but I had lost track of time and had to leave.
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.1
« Reply #11 on: 20 Aug 2009, 06:05 »
Thanks monkey & GG for the pointers.
New version uploaded with a new helper module FakeScreen that composites objects and characters (sorted, scaled and transparent) onto a background frame before the Underwater module does its work. A walkbehind hides the actual objects and characters.

The demo has also been updated to reflect the changes.

Steve
Still waiting for Purity of the Surf II

monkey0506

  • AGS Project Tracker Admins
  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    •  
Re: MODULE: Underwater v1.1
« Reply #12 on: 20 Aug 2009, 06:16 »
A walkbehind hides the actual objects and characters.

So you have to cover the entire room in a walkbehind area, or does the module apply the effect to said area?

And you're welcome...looked over your code. Snazzy stuff you've got going on in there. :D

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.1
« Reply #13 on: 20 Aug 2009, 14:53 »
A walkbehind hides the actual objects and characters.
So you have to cover the entire room in a walkbehind area...?
Yup! This is the easiest way to keep all the properties of the objects and characters intact. If you want to draw a window or porthole in front, you just set the walkbehind baseline above the window baseline. Then you can have a character walk in front of the window or swim behind it.
Still waiting for Purity of the Surf II

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.0
« Reply #14 on: 20 Aug 2009, 21:30 »
I wish people would post videos of their modules in action. :P
Video on youtube:

Still waiting for Purity of the Surf II

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    •  
    • SSH worked on a game that was nominated for an AGS Award!
      SSH worked on a game that won an AGS Award!
Re: MODULE: Underwater v1.1
« Reply #15 on: 20 Aug 2009, 22:46 »
Hmm, what I actually really wanted was a reflective, wobbly surface of the water but only taking up a small part of the screen (e..g. in a fountain thats part of the background)

Kweepa

  • Mutated Guano Deviser
    • Best Innovation Award Winner 2009, for his modules and plugins
    •  
    • Kweepa worked on a game that was nominated for an AGS Award!
Re: MODULE: Underwater v1.1
« Reply #16 on: 20 Aug 2009, 23:13 »
Then you want the Lake module!
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=27356.0
You'd need to cover up a bit of it with an object.
Still waiting for Purity of the Surf II

subspark

  • Some things, you just can't unsee.
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with making music
    •  
    • I can help with play testing
    •  
    • I can help with proof reading
    •  
    • I can help with story design
    •  
    • I can help with translating
    •  
    • I can help with voice acting
    •  
Re: MODULE: Underwater v1.1
« Reply #17 on: 22 Aug 2009, 04:15 »
Good work Steve! I knew someone would tackle my idea. Although I'm sure it was hardly a tackle.

Many cheers,
Sparky.

Ali

  • What will become of the baron?
    • Ali worked on a game that was nominated for an AGS Award!
      Ali worked on a game that won an AGS Award!
Re: MODULE: Underwater v1.1
« Reply #18 on: 22 Aug 2009, 18:38 »
The demo looks great, I could watch it for ten minutes...

However I ran into problems using it in an 800x600 32bit game. It came out like this:


(The background was a pencil line drawing from uncle-mum's Stediddy game)

Before I added a full screen walkbehind the pink colour was constant and behind the characters. Now it flashes on and off - at about the default rate for background animation now that I think about it. I tried downgrading to 16 setting which had no effect and I lowered the game resolution but the magenta colour remained.


EDIT: Ignore all this Steve, it looks like AGS corrupted the bitmap somewhop when I exported it. Opening the file in MSPaint and saving it again made the magenta go away. Nothing to do with your module. Keep up the good work!
« Last Edit: 22 Aug 2009, 18:57 by Ali »

Re: MODULE: Underwater v1.1
« Reply #19 on: 22 Aug 2009, 18:46 »
Now it flashes on and off - at about the default rate for background animation now that I think about it.

Have you tried calling SetBackgroundFrame(0) in the player_enters_room event (unless the module already does this)?