Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 11th May 2010 11:04
Hi all,

I just want some opinions and advice on how to achieve this. Has anyone seen the opening credits to Lemony Snicket's movie? If you do, remember the ocean part and how the ocean is made up of multiple layers of waves?

Is that difficult to achieve in DBPro? I was thinking of importing each layer of water from 3Ds Max and in terms of moving them, use FOR NEXT loops to move them in sync.

Is this the most efficient method to achieve the ocean effect?
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 11:29
I think this is the bit...

http://www.youtube.com/watch?v=5cAUpc0Z4-M

Strangely, I just made a 2D wave effect a little like that, except its animated so the waves go up and down, and something that's going in a commercial project so can't share it exactly.

I just used an image, make your waves in an art package, maybe extra wide, so you can offset the same image several times at different X locations. Then move them up and down in a sine wave, maybe 5 or 6 layers at different heights.

Your image could be applied to a plain, or a sprite or just pasted to the screen - but the main thing is that if you stick to 2D, you have full control over how it looks, and it will be nice and fast. I would use the same angle offset, maybe something like this, then use that for all the waves so they move in unison...

Ang#=wrapvalue(timer()/20.0)

y=500
x=1
for l=0 to 5
inc x,40
if x>0 then dec x,128.0
paste image 1,x+sin(ang#)*16.0,y+cos(ang#)*64.0,1
inc y,48
next l

That's the sort of thing I did, works pretty nicely.


Health, Ammo, and bacon and eggs!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 11th May 2010 11:43
Hmmm... never thought of using SIN waves or the like. I was going to hardcode the movements myself o.O (Yeah I'm still a noob haha)

When you say that if it was in 2D I would have full control, what happens, then, if this is put into a 3D game? Like for example, a 3D game where in the background there is an ocean. Is that what you mean by the 2D part?
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 12:30
A 3D game might not be ideal for this. For 3D, the only option would be to use a ring, like a long strip, formed into a circle with the wave image textured around it. Then with a dozen of these, increment the size on X and Z, so that the ring is bigger but the height stays the same. Kinda like lots of different sizes saw blades sitting inside one another. Then if the camera is in the middle you could look all around and have a decent looking ocean.

But this would only be effective in a very stylised game, proper 3D oceans are best done with shaders so they get refraction and stuff like that - this technique is better suited to quirky games with stricter navigation. For instance the player has to stay on the ground pretty much, so they can't climb up and see the horror story that is the ocean from above. That's the downside, it would look great straight on, but from above or even from a steep angle it would look terrible. Depends on the sort of game your making.


Health, Ammo, and bacon and eggs!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 11th May 2010 13:26
You mean like multiple circular planes right? Like if I was to look at it from plan view (above) it would look like the rings of a tree?

I'm curious now, what kind of 3D game would that be possible to use in if the game was stylized. Like... what about platform games? They're basically 2D because of the restricted camera (except for Klonoa to a certain extent).
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 13:31
A platform game would be good for this, but the main thing is that camera, as long as you can prevent the camera from seeing the ocean from too steep an angle then its good. A 3rd person game would work too, as that tends to give you a camera that sits above and behind the player, so easy to restrict it when the ocean is in view.


Health, Ammo, and bacon and eggs!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 11th May 2010 13:42 Edited at: 12th May 2010 01:58
OK, so the only issue is the camera. Hehehe, I feel like making a 3rd person platform game now =)

Anyway, thanks for the replies Van B ^^
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th May 2010 14:20
Totally, when I watched that clip I actually thought of SoulHunter, a long running DBClassic platform game, one of my favorite games from the forum:

http://forum.thegamecreators.com/?m=forum_view&t=64844&b=8

I can imagine it working in that game, it's a 'classic' 3D platformer with sensibly restricted play area etc. The main thing is that where the ocean would be seen, it could be furnished with bushes etc, to hide the edges and get the most from the effect - would be cool to look out onto the cardboard sea I think .


Health, Ammo, and bacon and eggs!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 12th May 2010 01:57
Hmm... I thought I'd try making an ocean using multiple layers along the Z axis and then moving them in sync to make them move like a wave, but for some reason I can't make a correct FOR NEXT loop for it =/

The ocean either all moves at the same time (i.e. all go up 5 then they go down 5 and repeat, thus not looking like a mexican wave) or the ocean doesn't move or even worse, the ocean disappears =/

It was basically the code you posted, but replacing the PASTE IMAGE code with POSITION OBJECT x. Help -.-"
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th May 2010 00:49
Hey, sorry I missed your response. Will make a little demo...


Health, Ammo, and bacon and eggs!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th May 2010 01:22
Here you go.


Health, Ammo, and bacon and eggs!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 13th May 2010 10:16
wow o.O

That is so awesome! And you're a genius!

Thanks a lot for that =D

Just a small question. Using SIN and COS to determine the movement of the waves, since I only see INC and no DEC, does that mean that those two will always go "up" and "down" even as you continue to increase ang#?

I never got COS and SIN (was kinda terrible at maths hahahah)
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 13th May 2010 12:28
No worries.

Sin and cos are basically the same thing, you pass an angle to them, like SIN(ang#) and they return a value between -1.0 and 1.0 - which you would then multiply by the radius usually. COS is the same as SIN except it will determine the Y coordinate of the angle. The angle can increase with no limit, as even an angle value of thousands can still be calculated with SIN and COS. It's often a good idea to use WRAPVALUE though, as that will keep the angle within a 0-360 limit. So passing an angle of 360 to SIN is the same as passing an angle of 0.

That demo uses the timer to calculate the angle, so will go on forever at the same rate, whether the game is running at 3fps or 300fps - I like to use timer for angle based effects, just a habit I've gotten into.


Health, Ammo, and bacon and eggs!
DB_Newbie
16
Years of Service
User Offline
Joined: 4th Aug 2009
Location:
Posted: 13th May 2010 12:56
Oh..... I see.... I sort of get it when I read your explanation. But I probably have to do it myself first to truly get it.

Practice makes perfect =D

Anyway thanks again Van B *thumbs up*

Login to post a reply

Server time is: 2026-07-26 04:28:09
Your offset time is: 2026-07-26 04:28:09