Jump to content
Sign in to follow this  
  • entries
    16
  • comments
    12
  • views
    27809

Adding a skybox, collision detection and software cursor

Sign in to follow this  
Brain

1395 views

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

Sign in to follow this  


0 Comments


Recommended 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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!