Page 1 of 1

dynamic water example

PostPosted: Tue Jul 15, 2008 6:36 am
by feral
this is a rough attempt at dynamic water - it may help some of you think up new ideas.......

feel free to use it for your own games if you want..
note: becuase it uses a lot of transparency effects on BIG images... it will slow down your games,
so if you want to use it , think of slower game ideas rather then a high speed game..
fihsgrab.jpg
a screen grab from the screensaver
looks better in real life :( jpeg losses

water2.zip
ged files and data
(59.28 KiB) Downloaded 352 times



PS: i also used it to make a screensaver thingo
It started out to be a game idea... but then I got stuck and didn't know what do next.. writers block :oops:

attached is an exe of the screensaver idea as well

fish3.zip
(1.04 MiB) Downloaded 255 times


NOTE: I used my spritemaker program to make the rotated "fishes" and I also used it to create the dissolving "food block" sprite...

cheers
feral

Re: dynamic water example

PostPosted: Tue Jul 15, 2008 11:51 am
by segwego12
Does this wan't intel or is this broken cuz I have nVidia.

Re: dynamic water example

PostPosted: Tue Jul 15, 2008 1:25 pm
by feral
segwego12 wrote:Does this wan't intel or is this broken cuz I have nVidia.


why ? what happens ? it should work on any platform ?

Re: dynamic water example

PostPosted: Tue Jul 15, 2008 1:32 pm
by segwego12
are there supposed to be fish cuz i can't see any of them. And i'm talking about my video card.

Re: dynamic water example

PostPosted: Tue Jul 15, 2008 1:44 pm
by feral
sorry, I double posted this, because I meant to show the water example here only, as a ged ... and the "fish screensaver" in the development section..

which was silly ... I don't know what i was thinking :oops:

anyhow, both the water demo ged, (no fish) and the final exe (with fish) are now both here..see the first post

The water demo was only meant show an idea of how to do dynamic looking water

the fish thing was a game I was planning on ....and that exe is now here too...

tho if anyone wants to know how to do the fish thing I will clean up the code, and post that here as well..

cheers
feral

Re: dynamic water example

PostPosted: Tue Jul 15, 2008 7:49 pm
by Thanx
Hey feral!
Those are absolutely great, both of them!
I'd be interested in the code for the fishy demo too... I can guess what your game idea was... :P
:D
The only thing I'd add to it is sound. With sound I'd really feel underwater with that thing on... :):D8):P
Cool!!
Cheerz!
Thanx

Re: dynamic water example

PostPosted: Wed Jul 16, 2008 12:20 am
by feral
The code for fishes now included, although a little rough, keep in mind this was meant to be the beginning of a game and is not complete...
FISH.zip
ged and data files
(258.28 KiB) Downloaded 205 times

also I added a sound file, but it doesn't work well on my PC.. press space to hear the sound... it may not work on yours either... but let me know.. it seems to be playing multiple copies of the same sound...

basically the fish are simply "homing missiles" with some random values thrown in..

hope it helps

feral
PS: I cut down the number of fish becuase it runs slow on my ancient PC , but if you want more, simply clone them, and in the collision event lower the number of "bites" need to finish the block ( if it disappears to fast with many fish)

PPS: if anyone makes a game using these ideas and want more background water bitmaps I am happy to make em, but only if you have a game made... :D

Re: dynamic water example

PostPosted: Wed Jul 23, 2008 6:34 pm
by zygoth
I have been trying to make a fish really act like a homing missile by every frame changing its angle by +5 or - 5 depending on which would take less moves to reach the direction of the player. Is this making any sense at all? I have tried a lot of stuff, but I can't seem to get it to work- could somebody show me some code that would work?

Re: dynamic water example

PostPosted: Wed Jul 23, 2008 7:21 pm
by zygoth
Never mind, guys, i figured out how to do it. This is great code for realistic homing missiles, and I've wanted to make it for a long time. Here it is:

if (angle >=181 && angle <=359)if(direction(x, y, player.x, player.y) >=angle)angle = angle + 4;
else
if(angle >= 181 && angle <=359)if(direction(x, y, player.x, player.y)<= angle - 180)angle = angle + 4;
else
angle = angle - 5;

if(angle <= 180 && angle >=0) if(direction(x, y, player.x, player.y) <= angle)angle = angle -5;
else
if(angle <= 180 && angle >=0) if(direction(x, y, player.x, player.y) >= angle + 180)angle = angle - 5;
else
angle = angle + 4;
angle = angle + 1;


yeah, it's huge and ugly, but it works perfectly. put into a fish from this demo instead of the angle = direction makes each fish into a realistic homing missile. I will try to upload the ged file but my computer never seems to like it when i try to post files.

Re: dynamic water example

PostPosted: Wed Jul 23, 2008 11:56 pm
by feral
cool effect zygoth :D

an easier way to to do the same thing is with vectoradd() ...a built in GE function...

essentially it does the same thing your code does by taking the existing angle and directional_velocity and compars them with an another angle ( in this case the current angle to the target (foodblock) it then will add or subtract angles/velocities automatically for you,.. in increments

try this code here in the fish draw
Code: Select all
float FishAngle; //create a new var

FishAngle = direction(x, y, player.x, player.y); //find current angle to target

directional_velocity = 5;

vectoradd(&angle, &directional_velocity, FishAngle, .5);
//use current angle and velocity to set new angle using increments of x ...
//in this case.5... use higher numbers to home in faster..



from script reference
vectoradd: Adds vector2 (angle2, magnitude2) to vector1 (angle1, magnitude1) and returns the result in vector1 (angles in degrees).
void vectoradd(double *angle1, double *magnitude1, double angle2, double magnitude2).

and the tutorial here
http://game-editor.com/examples/vectoradd.zip

Re: dynamic water example

PostPosted: Thu Jul 24, 2008 12:42 am
by zygoth
hmmm...it's definitely prettier, but I prefer my code where the fish adjust the same amount every time rather than a fraction of the difference. with yours the closer it gets to the right angle the slower it improves. I suppose you could use either one, really.
Nice water effect by the way.