🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Adding a skybox, collision detection and software cursor

Published January 25, 2015
Advertisement
Hi everyone!

I've found some time today to make further progress on Firework Factory, adding three things as mentioned in the title:

  • Added AABB collision detection of boxes and particles, so that the game mechanics now function entirely correctly for crates
  • Added a skybox, to make the game world seem less dull
  • Added a software cursor



    Firstly, the collision detection of boxes was added. This was quite a simple change to make to the source, and luckily AABB checks are not CPU intensive, and even when i have to check against thousands of active particles, it does not seem to be too much of a problem smile.png Admittedly, you don't see many games where particles have to be collision checked with anything more than a plane (raindrops falling on the floor, maybe?) so this is a break from the norm compared to a lot of games that use particles purely as passive effects.

    The skybox, well, I guess this is the technical term but there is nothing related to the sky about it... as you are inside the factory. I added an in-joke here which you will probably get if you are in England. On the right hand wall is a HSE poster, a mandatory statement of health and safety compliance for UK businesses. I've had to doctor out the royal crest in the top left (I don't want any legal trouble for duplicating the crest!) but it just serves as a joke, having a safety compliance notice on the wall of what is supposed to be a very unsafe place by design.

    The game grid still 'floats' off the surface of the factory. I intend for it to always be raised off the floor like a table, and at some point later i may add legs at the bottom or chains hanging it from the roof. The crazy design is of course in no way related to any real life sensible factory.

    The final change this time around is a software cursor. There are two reasons for adding this - firstly, the 2D version of the game had it, and it looked quite nice, being alpha blended and translucent. Secondly, the functions required to load and render the sprite on the screen was something I didn't know how to do in Direct3D 11 until now. Now that i have implemented it, I can easily use this for displaying GUI and menu systems, and the game's HUD which indicates the next crate, etc. The addition of 2D sprites is done via a simple sprite class:/* The Sprite2D class is a wrapper around loading and drawing 2D sprites to a * Direct2D render target, loaded via WIC. */class Sprite2D{private: // Direct2D Bitmap ID2D1Bitmap* graphic; // Direct2D render target ID2D1RenderTarget* rendertarget;public: // Create a new Sprite2D from a file on disk using WIC to load the image. // Throws std::exception on failure to load the file. Sprite2D(ID2D1RenderTarget *pRenderTarget, PCWSTR uri); // Draw the Sprite2D. DX11::Begin2D() must be called before this can be used. void Draw(const D2D1_RECT_F &destination, float opacity, const D2D1_RECT_F &source); // Free bitmap resource ~Sprite2D();};
    The render target drawn to is an independent texture, which is drawn to the screen with translucency over the top of the 3D scene, therefore any GUI elements, menus etc that i draw can always be gauranteed to be on top of the action.

    Next on the list is exactly that: A simple menu. Coming soon to a YouTube video near you...

    As always, comments are welcome and encouraged! smile.png
3 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement