Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: The creature on Mon 22/03/2021 07:29:05

Title: Shoals of fish - seeking advice
Post by: The creature on Mon 22/03/2021 07:29:05
Hello everyone.

I'm looking for some advice. I have a lot of underwater environments in the project I'm working but at the moment it's very bare and lacking sea life. My question is what would be the best/simplest way (I'm a medium level coder with AGS and wouldn't call myself advanced) to achieve shoals of fish that randomly swim about the room? Not neseceraly in groups.

I did think about just creating a lot of fish characters and have them move to a random x, y from 0 to the max room size, but creating all those characters seems like an awful lot of work, and I don't really want my project cluttered with an army of fish characters. I did look at the steering behaviour plugin but I couldn't really understand it although it sounded perfect for what I want to do (no example project files). So I pose the question? How would you approach this problem?

Any help would be appreciated.
Title: Re: Shoals of fish - seeking advice
Post by: Khris on Mon 22/03/2021 13:45:09
You could implement your own fish struct (to group together variables for current and target coordinates, state, sprite slot, etc.)
Then you update the coordinates in repeatedly_execute_always and draw the sprites to the background manually.

The downside of this approach is that your fish become part of the background graphic, meaning they'll appear behind everything else. Depending on the perspective of the sea floor you could have some fern or whatever appear in between by including that in the drawing order of the fish though (i.e. you'd have to depth sort everything before drawing it).

The bottom line: the better you want this to look, the more complex it'll be to code.
Title: Re: Shoals of fish - seeking advice
Post by: eri0o on Mon 22/03/2021 15:27:32
Captain D did this in a game recently: https://captaind.itch.io/shoaly-you-cant-be-serious-mags-version
Title: Re: Shoals of fish - seeking advice
Post by: The creature on Mon 22/03/2021 17:17:42
That's impressive erico, not sure how you created the effect but it's food for thought. Khris, my environments are like top down, orthographic. So like the old Zelda games, so drawing to the background wouldn't really work especially with other objects scattered about the place.

I'll keep exploring. I was just curious how other people may have tackled the issue.
Title: Re: Shoals of fish - seeking advice
Post by: eri0o on Mon 22/03/2021 17:20:12
(it's not my game! It's from Captain D   (nod))
Title: Re: Shoals of fish - seeking advice
Post by: Khris on Mon 22/03/2021 17:26:23
In that case: yes, you can also create a bunch of dummy characters and use those. You can use  character[i] in your code where  i  is a variable to iterate over them.