Wonderful 2D Water effects...

Game development specific discussions.
Post Reply
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

you are correct, BC... although this image processing stuff is pretty cool, and it is really nifty to have actual ripples and waves that traverse tile boundaries, etc...

I think I like the Wesnoth version best so far, even though it doesn't seem to have the ability to show directional flow as your first link does... good links, sir!
dafhi
Posts: 1652
Joined: Jun 04, 2005 9:51

Re: Wonderful 2D Water effects...

Post by dafhi »

btw .. @D.J.Peters .. really good :D
D.J.Peters wrote:

Code: Select all

'mov edi,[pDes]
dim as ubyte ptr pedi=pDes
I somewhat agree with BC2, although innovation is good. DJ Peters example is crazy fast.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

dafhi wrote:btw .. @D.J.Peters .. really good :D
D.J.Peters wrote:

Code: Select all

'mov edi,[pDes]
dim as ubyte ptr pedi=pDes
I somewhat agree with BC2, although innovation is good. DJ Peters example is crazy fast.
it is always a compromise between speed vs graphical niceties vs gameplay (usually gameplay isn't too much of a speed hit though)

Since speed is the key limiting thing, I always try to make things as fast as possible without sacrificing quality... leaving more cpu time for improvements elsewhere..

in this case:

benefits:
decent looking water that is not only seamless, but always traverses tile boundaries... very nice!
extra nice effects like dynamic water interactions like rain drop ripples and object 'wakes'

cons:
very cpu intensive
much more complicated to implement, especially on a moving tilemap

alternatives:
water can be made with animated tiles that looks just as good
the effects can be simulated with additional animated tiles
both these methods are fast

the only real issue I have with tiles (animated or not) is that I am not an artist... so that means using free stuff or depending upon the artistic skills and time of another... I think it is safe to say that most of us 'hobbyist' programmers tend to be jack-o-all-trades, control every aspect of their own creations... though we can work well together also

I find that all my programs (games?) tend to all look the same because I keep using the same tried n true tilesets....usually Reiner's...which are fine for FPO's, but if I ever get to the point of a finished product then I would need to hire/conscript an artistic type
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

on the other hand... I have NEVER seen tiles that look like this water.... simply gorgeous (to me)


Image
dafhi
Posts: 1652
Joined: Jun 04, 2005 9:51

Re: Wonderful 2D Water effects...

Post by dafhi »

another update. noticeable speed improvement

@leopardpm - I agree. beauty and innovation.

- ToDo
normals
terrain

BTW, regulate() is dodicats. I use my own udt atm but switch to regulate() for shortness
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

dafhi wrote:another update. noticeable speed improvement
YAY!
- ToDo
normals
terrain
TRIPLE YAY!
BTW, regulate() is dodicats. I use my own udt to handle anim and physics fps seperately
I figured, since both require different timings, I am thinking about how to make a general FPS/animation timings routine... haven't gotten the courage up yet to tackle it
I use my own udt
... I have no doubt.....
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Wonderful 2D Water effects...

Post by D.J.Peters »

With perlin noise or other random stuff you can create seamless tiles.
Image
If you move a virtual window over it and read the pixels as rectangle or as isometric shape you get a kind of flow.
Image
If the virtual window has a x,y position you can move in any organic path or simple in straight lines.
I moved the virtual window diagonal over the water tile (32 times) and got 32 animated frames.
Image
You can add an apha channel to it so you can see a warbing ground layer or fishes under it
As final step run your water simulation only in the alpha channel of the animated frames.
Or use an byte image for the waves !

You can mix an (8bit) byte image as alpha channel with other RGBA FreeBASIC images.
This example shows the special method for setting a 32-bit alpha channel using an 8-bit image: http://www.freebasic.net/wiki/wikka.php ... PgAlphaGfx

Joshy
Last edited by D.J.Peters on Oct 03, 2017 3:45, edited 1 time in total.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

i feel stupid - thanks for taking the time to lay it out, I didn't fullyunderstand from your previous post exactly how to incorporate the perlin noise and the tiles together, but now it makes sense... gonna sit and digest this for awhile now...
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

ooooo, very yummy information! thank you!

I think I might have to put yet another project onto my list: combine the above stuff with your stuff and maybe the other stuff (the wave thing me n dafhi have been doing) into one nice, animated, tileable, terrain tile creator. User can tweak the parameters, including the color palette, alpha blending, tile size and shape (Square, Diamond, or Hex), of the different layers and have real-time visual feedback of his tweaks: of a single tile, of multiple tiles together, of different tiletypes (like shore tiles, other land tiles, etc) incorporated so can adjust color, etc to better fit into the 'color scheme'. Be able to save the 'tweaks' themselves, as well as autocreate the animated tileset for use in other programs... handy 'little' program! When I start it, I will definitely need to hit you up on explaining your process - as you have laid it out, I am understanding much more, except what determines the 'seamless' aspect and what you mean by this: "Or use an byte image for the waves !" - think I got most of everything else. Did your choice of '32' frames/movements have anything to do with the seamless part, does it matter the tile size and shape (Square, Diamond, Hex?)... many little questions to pester you about!

I think this makes major project #657 on my list!
BasicCoder2
Posts: 3917
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Wonderful 2D Water effects...

Post by BasicCoder2 »

I think I might have to put yet another project onto my list: combine the above stuff with your stuff and maybe the other stuff (the wave thing me n dafhi have been doing) into one nice, animated, tileable, terrain tile creator.
Have you looked at or used the free TILED program?

http://www.mapeditor.org/

First you must settle on the mechanics of the game engine and include an ability for this engine to use the types of tiles and the tile file format of the tile editor which are .tmx files in the case of the TILED editor.

I have written a few very simple tile editors for my own use but these use my own file types to suit the way I would use the tiles in a program. Essentially they are simple saved as an array of tileID numbers. Another important feature of a game engine is the use of layers.

The problem is you can spend forever fiddling the details and never actually get around to actually writing a proper working game. What I admire is those who stop polishing the wood and instead start using it to actually create working examples. For example the FreeBasic game Toad on Fire uses a very basic tile world and perhaps not the greatest match of images but at least it is sort of up and running. You can spend your life designing the perfect house while someone else just builds a crappy house, but at least they have a house.
.
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: Wonderful 2D Water effects...

Post by D.J.Peters »

Yes tiled is my first choice also and the tmx map format it's easy to use and very well documented.

Joshy
Image
Last edited by D.J.Peters on Oct 03, 2017 3:43, edited 1 time in total.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

BasicCoder2 wrote:I have written a few very simple tile editors for my own use but these use my own file types to suit the way I would use the tiles in a program. Essentially they are simple saved as an array of tileID numbers. Another important feature of a game engine is the use of layers.
this has been my experience as well: homebrew my own map editor to make the maps available to the game engine. Pretty simple, depending upon how complex the tile transitions are to be handled.
Have you looked at or used the free TILED program?
I think I glanced at it a few years ago, just download it from your link and have done a basic look through - appears pretty comprehensive - I want to look more in depth into the structure of the TMX format. All in all, it seems very capable to handle a variety of game types and situations.

But, if I understand correctly, "Tiled" is a tile map editor, what I was thinking about in the post above would be a Animated Tile generator: to actually create the animations, frames, and tiles for making: water, lava, fog, gas, clouds, etc.... basically, it seems that Mr. Peters' Perlin noise (and other random noise generators) can be combined with different blurring and alpha manipulations to easily generate good looking animation for these kinds of 'fluid' tile animations. I wasn't thinking of making yet another Tile Map maker, something Tiled is already well suited for.
The problem is you can spend forever fiddling the details and never actually get around to actually writing a proper working game
The problem with this all comes down to creativity - I really have only one 'game' in mind, which we have discussed. But, my creativity is severely lacking in that direction and it is such a dauntingly large project (in its ultimate form) that I find my time spent is more enjoyed by figuring out specific algorithms, all related in some form to game programming. I seem to have more 'creativity' in finding alternate methods of performing a defined task or routine, such as pathfinding, or some other 'problem'. I can string together sentences well enough, but I would never delude myself into thinking I could write a novel - and I definitely would NOT enjoy the attempt!
What I admire is those who stop polishing the wood and instead start using it to actually create working examples. For example the FreeBasic game Toad on Fire uses a very basic tile world and perhaps not the greatest match of images but at least it is sort of up and running.
One thing I am definitely NOT, is a general game designer... I don't like alot of game genres (esp: side-scrolling fighting) and have very little creative juices to contribute towards the game 'idea'. I do enjoy RTS games, simulation games, sometimes RPG games and it is in these areas that I have 'some' ideas as to how I might do things better or different and thus contribute towards a game design (instead of just rehashing a previous game).
You can spend your life designing the perfect house while someone else just builds a crappy house, but at least they have a house
so true, yet, is not a good analogy at all. We are not talking about a house, or survival, or anything other than pure entertainment... the time I spend programming is 'fun' time for me, I like to research new (to me) techniques, learn what others have discovered, uncover secret algorithm 'tricks' - I enjoy doing these things, tackling and overcoming small obstacles (like how I now feel pretty confident in understanding A-Star, as well as some other pathing techniques).... I simply do not have a 'need' to create a finished game, either for ego or for survival(monetarily), and I am quite happy with exploring the process of all the aspects to game programming.

That said, IF myself or someone that approached me, had some 'great idea' (one that I also liked and believed in) for a game that was within my programming capability and time limitations to create - I would welcome the defined focus and goal an would love to be a part of such a project. But, right now, I am fresh out of ideas for games that are within my reach to create. Sure, I could make a Pac-Man, or Frogger, or Lunar Lander, or perhaps a RogueLike/Adventure, maybe a Tower Defense like Kingdom Rush - Frontiers (http://www.kongregate.com/games/ironhid ... -frontiers... and the last two are actually something I wouldn't mind doing, but for the most part - the games that I would like to create, are not within my immediate grasp as far as programming abilities.

What are your goals and desires in this regard? You seem to really want to create some sort of game, but you don't really like or play games in general, is that right? Are you looking for someone to have an idea for game that you could then work on? I think we both agree that it is in the 'generating a good game idea that inspires enthusiasm' that is hardest for both of us. If you are interested, look at the above tower defense game (Kingdom Rush is part 1, the link above is to the sequel, Kingdom Rush - Frontiers). It is a HIGHLY polished game, but its underlying mechanics are relatively easy. The AI is within our reach, being nothing more than FSMs, but the gameplay is entertaining and challenging. It is also very limited in its definition, meaning, the scope of the game is very defined so the task of programming a game like it would not necessarily be a monstrous project. I could even be limited to just creating a single 'level' and provide a good proof of concept. It also happens to be one of the types of smaller games that I wouldn't mind being a part of creating, as I would like to play it as well.
BasicCoder2
Posts: 3917
Joined: Jan 01, 2009 7:03
Location: Australia

Re: Wonderful 2D Water effects...

Post by BasicCoder2 »

Postby leopardpm » Aug 30, 2016 2:26
I do enjoy RTS games, simulation games, sometimes RPG games and it is in these areas that I have 'some' ideas as to how I might do things better or different and thus contribute towards a game design (instead of just rehashing a previous game).
No I don't play computer games. This makes it harder to write a game. I could never have written the Harry Potter series because that kind of story is not part of my fantasy world. My interest in computers came from an interest in electronics and "thinking" machines.

Writing a game has some interest as it is a puzzle to solve. My wife likes to solve word and number games on her mobile phone but I find them boring. I would rather write the puzzles than play them.
If you are interested, look at the above tower defense game (Kingdom Rush is part 1, the link above is to the sequel, Kingdom Rush - Frontiers). It is a HIGHLY polished game, but its underlying mechanics are relatively easy.
Ok. To start with how would the enemy sprites navigate a path way? I thought perhaps a path could be drawn for each enemy sprite or they could choose from available paths. When they meet an opponent while traveling a path interaction with the opponent would take over control until the battle was won or lost. First you need to draw the paths to be saved as part of the program. The only problem with the path creating program below is the mouse read is slow (for reasons I never understood) and thus the points might not connect causing the enemy sprite to move at different speeds.

Code: Select all

'some useful defines
'Const Pi = 4 * Atn(1)
'Dim Shared As Double TwoPi = 8 * Atn(1)
'Dim Shared As Double RtoD = 180 / Pi   ' radians * RtoD = degrees
'Dim Shared As Double DtoR = Pi / 180   ' degrees * DtoR = radians

screenres 640,480,32
color rgb(0,0,0),rgb(163,129,78):cls
dim shared as integer mx,my,mb,ox,oy    'mouse variables
dim shared as integer px(1000),py(1000) 'thousand steps
dim shared as integer pathSize

type SPRITE
    as integer x
    as integer y
    as integer w
    as integer h
    as integer dx
    as integer dy
    as integer t  'type
    as integer a  'alive
end type

dim shared as SPRITE  spr( 0 to 9 )

for i as integer = 0 to 9
    spr(i).x = int(rnd(1)*640)
    spr(i).y = int(rnd(1)*480)
    spr(i).dx = 0
    spr(i).dy = 0
    spr(i).w = 11
    spr(i).h = 17
    spr(i).a = 0
next i

sub updateDisplay()
    screenlock
    cls
    locate 2,2
    print "DRAW PATH WITH MOUSE WHILE HOLDING DOWN LEFT BUTTON"
    circle (320,240),200,rgb(217,193,140),,,.6,f
    line (0,240-20)-(300,240+20),rgb(217,193,140),bf
    line (360,240-20)-(639,240+20),rgb(217,193,140),bf
    circle (320,240),150,rgb(163,129,78),,,.5,f
    'draw alive sprites
    for i as integer = 0 to 9
        if spr(i).a = 1 then
            line (spr(i).x,spr(i).y)-(spr(i).x+spr(i).w,spr(i).y+spr(i).h),rgb(255,0,0),bf
        end if
    next i
    'draw line
    for i as integer = 0 to pathSize-1
        pset(px(i),py(i)),rgb(0,0,0)
    next i
    screenunlock
end sub

do
    updateDisplay()
    getmouse mx,my,,mb
    if mb = 1 then  'mouse button down
        pathSize = 0
        px(pathSize)=mx
        py(pathSize)=my
        pathSize = pathSize + 1
        ox = mx
        oy = my
        while mb=1
            getmouse mx,my,,mb
            if mx<>ox or my<>oy then 'mouse moved
                px(pathSize)=mx
                py(pathSize)=my
                pathSize = pathSize + 1
                ox = mx
                oy = my   
            end if
            updateDisplay()
            sleep 2
        wend
        spr(0).a = 1  'activate sprite
        for i as integer = 0 to pathSize-1
            spr(0).x = px(i)-5
            spr(0).y = py(i)-8
            updateDisplay()
            sleep 20
        next i
        spr(0).a = 0  'deactivate sprite
        pathSize = 0
    end if
    
    sleep 2
loop until multikey(&H01)
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: Wonderful 2D Water effects...

Post by leopardpm »

lol - you always make me smile!

First: Luv your path drawing/following demo, its fun to play with all by itself!

Second: regarding the mouse 'skipping' - I have always wondered about this issue as well, there is something going on behind the scenes which is eating cpu time or otherwise denying the getmouse routine from getting values...

This can be solved by drawing a path LINE between the mouse points, that way the path will be only one pixel per move instead of occassional big jumps... of course, move the mouse too fast and you get a bunch of straight lines instead of curves, but is still better...
Writing a game has some interest as it is a puzzle to solve. My wife likes to solve word and number games on her mobile phone but I find them boring. I would rather write the puzzles than play them.
on this I relate with you - programming is the 'puzzle' for me, not necessarily a 'game' but even the individual pieces, like your Path Following routine above...

for path finding in a tower defense type game, is best to use a flow map type deal - run it once for the map and every critter uses this map to determine their next location from their current location... can't get any speedier. The only thing to do is to incorporate some sort of steering to go around dynamic obstacles or other agents that might be stopped (attacking?)

Take a look at this: http://www.redblobgames.com/pathfinding/tower-defense/

he explains it better I think
Post Reply