• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
  • entries
    44
  • comments
    44
  • views
    58217

World coordinate system based cloud particle system done

Sign in to follow this  
Followers 0
Norman Barrows

795 views

World coordinate system based cloud particle system done


well that didn't take long!

Caveman uses the following world coordinate system:

The game world map is divided up into 5x5 mile map squares. Each map square has its own d3d coordinate system. So a location in the world is speccified by map x and z, AND by a d3d x,y,z in that map square: IE mx,mz,x,y,z.

all i had to do was add an mx,mz to a cloud struct.

init them to the players mx,mz in init_cloud2

made draw_cloud3 use them instead of the player's mx,mz to calculate camera relative coordinates.

added a wrap_around_cloud function to wrap a cloud around to the other side of the cloud box when it moves outside the cloud box, or the cloud box moves beyond it.

added a movecloud function to move a cloud based on windspeed and direction from the weather engine

made sort_clouds (for alpha blending) use world cloud coordinates converted to camera relative coordinates for sorting

added a remove_last_cloud function to remove the last active cloud from the array of cloud structs. The array of cloud structs is statically allocated, as the max number of particles (currently 400) is known at compile time. each cloud struct has an "active" boolean (implemented as int, 0=false, 1=true). when a cloud is added, its "active" variable is set to 1. when its removed, its "active" variable is set to 0. only active clouds are rendered and updated.

added an update _clouds function that adds or removes clouds based on changes in cloud cover info provided by the weather engine, and then calls update_cloud for each active cloud.

added a wrap_around_clouds function that calls wrap _around_cloud on each active cloud. the "cloud box" is the area around the camera that active clouds are in. the cloud box is currently set to a bounding box radius of 2000 units around the camera, and altitudes from 500 to 700 units. since the cloud box is based on the camera's location, the camera must be set before making clouds outside the cloud box wrap around. this tripped me up for a moment. i was handling wrap around once after player/camera/cloud box movement and cloud movement had both been done. but when you changed map squares, it seemed to draw the clouds at their old position (IE 5 miles away) for one frame. doing wrap around after cloud box movement and after cloud movement didn't fix things. the reason is because the player had moved to the next map square, but render hadn't been called, yet, so the camera hadn't been moved to the next map square yet! the solution was to call wrap around once on all clouds just before drawing, at which point the camera has already been set to the new map square.

so now the clouds come and go as you move, and come and go with the winds, and don't change drawing order when you change map squares, and increase and decrease in number with changes in cloud cover. now i need to add grey and red cloud textures and make it use them when appropriate. The original version supported blue, grey, and red skies, and white, grey, and red clouds. Right now the new version only supports blue skies and white clouds.

I think a lot of why it was so quick and easy had to do with the following:

1. CScript. all the new code was done in CScript which allowed the quick coding of the simple routines required.

2. Existing functions in the game. things like normalize_location and camera_relative_coords. being able to copy paste edit x+=spd*cos(yr) etc from generic_move to update_cloud. i can never remember if its x+=sin or x+=cos. wait. just thought about it for a sec, its x+=sin(yr). but usually i'm lazy and just find the formula somewhere in the code like generic_move (moves the player any of 4 directions), move_animal (moves a non-player entity), or move_missile (moves a projectile), and copy and edit it - less typing!

3. the fact that i've been writing particle systems for games for 25 years now. yeah - i know, no fair!

CScript really is nice, i should have been using it all along. i can code new stuff and mod old stuff in a flash. and it only adds 2 seconds to the build time for 71,000+ lines of source code, and that includes the time to minimize visual studio 2012, launch CScript, click to quit when it finishes translating, maximize VS 2012 again, and hit F7 to build. I had it setup as a pre-build step, but since you edit the CScript .cs input file and not the .cpp output file generated by CScipt, VS 2012 thinks the build is up to date since the .cpp file hasn't changed (yet). this means you have to do a rebuild to trigger the CScript pre-build action, or make a change to the current .cpp file. so i went back to a shortcut on the desktop to launch CScript. i also tried it as a tool button, but you can't make it project specific to pass project specific source file names. There's probably some way to do it, but the desktop shortcut with the file name as a parameter works fine.

0
Sign in to follow this  
Followers 0


0 Comments


There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now