Thread: Weather in 2D tile engines

  1. #1
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607

    Weather in 2D tile engines

    I've added some weather effects to our 2D tile engine. You can't really see it here or hear it for that matter, but the system works quite well.

    I'm working on doing some more alpha with the rain but this works for now.
    The tile map was created in my tile editor and loaded into the engine.

    The diffuse color has been altered for all the tiles to account for a stormy day.

    When the weather system first starts up I load the various weather sounds and save the ID returned from my sound manager class. I set the rain sounds to looping via the sound manager. Then when the rain starts, I tell the sound manager to play the rain sound ID and it loops indefinitely...or as long as it rains. A thunder timer is then started to denote when the next clap of thunder will be. When this timer has elapsed I set lightning to true and a white 50% alpha blended quad is rendered over the entire screen making it flash. The flash lasts for approximately .25 seconds. A thunder delay timer is then fired off and when it elapses I play the thunder sound ID and set the timer for the next clap of thunder.

    The entire system is started by calling Start(). When I'm done with the class the start function will set a spool up time to get to the desired rain percentage. When the rain is at max the thunder process will begin. The spool up is specified in the script command to make it rain. You can then stop the rain by calling Stop() which will gradually spool down the rain till it turns off completely.

    The rain is a simple line list in Direct3D and wraps at the edges of the screen. The vertices are in a custom vertex array that I then send to Direct3D to render. I can update the vertices in the array w/o locking the buffer b/c it's a custom vertex buffer. You can change the percent of rain from 0 to 100, the speed of the rain, and the angle it falls at. 100% rain means there will be 256 individual lines of rain rendered. The formula is 512*(rainpercent/100) to account for all vertices. Each line is of course 2 vertices. When the final product is done we will be placing rain splatter animations at various places on tile layer 1 to simulate rain hitting the ground. Since this is 2D I really have no way of detecting a collision with anything. I could assign each raindrop a certain location to fall to and then fire of a rain splatter animation but I've not gotten that far yet. The entire system works with ID's for sound, textures, maps, and objects. So accessing any of those can be done provided you have the ID.

    Quite happy with the system so far.

    Just thought I'd post in case anyone was wondering how they might do something like this in their own 2D tile system.
    Last edited by VirtualAce; 03-12-2011 at 11:42 AM.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    This looks really good, and with sound its even better!

    The flash and thunder really adds to the rain, gives it a very nice feel to it.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Very nice looking Bubba. Glad to see your Zelda Clone moving forward

  4. #4
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    What? No clouds moving across the screen?

  5. #5
    The Right Honourable psychopath's Avatar
    Join Date
    Mar 2004
    Location
    Where circles begin.
    Posts
    1,071
    That tile set looks familier. I think I may have used it in my RPG Maker 2000 days.

    Very nice though, all the same.
    M.Eng Computer Engineering Candidate
    B.Sc Computer Science

    Robotics and graphics enthusiast.

  6. #6
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I was wondering where the tile sets came from. I'm not the artist so I have no idea where this stuff is coming from. Hopefully we can get some people to work as hard on the art as we are on the game code.

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Art has always been my downfall when I start making anything. Just started my ventures into isometric tiles again... I gave up before because it was beyond my skills at that point but I feel I am a lot string of a programmer now heh. Anyway... you and Shaki are some of my inspiration to try and push and do this.

    Bubba, would you mind a couple questions about your maps? I was wondering if you have ids for each terrain type and if you either store a copy of the tile with the map or put it in a library? I haven't exactly decided how to do this because I am sure that maps will share tiles so I wouldn't want to have to load them seperately... but I don't know if I want to be locked into certain id for tile type.

    I was considering using 8x8 tile sections and loading via a struct so I could leave it in binary and not have to parse it. Then just having the map dimension in multiples of 8.

    Just want to hear your ideas on this since you have implemented something already, if you don't mind that is.
    Last edited by Wraithan; 09-26-2006 at 03:09 PM.

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    1,218
    Graphic is my worst side too, never been good with programs like photoshop and the like.

    And just try and keep trying wraithan eventually youll get there.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need testers for editor
    By VirtualAce in forum Game Programming
    Replies: 43
    Last Post: 07-10-2006, 08:00 AM
  2. 2D Tile Based Game
    By cboard_member in forum Game Programming
    Replies: 6
    Last Post: 07-29-2005, 01:04 AM
  3. Tile engines
    By Stray_Bullet in forum Game Programming
    Replies: 7
    Last Post: 03-21-2002, 08:12 PM
  4. 2d non tile based
    By DavidP in forum Game Programming
    Replies: 4
    Last Post: 02-01-2002, 12:51 PM
  5. Tile Editor
    By Nick in forum Linux Programming
    Replies: 3
    Last Post: 08-10-2001, 11:24 PM