17 Reusable Code Snippet Topics
Remove Filter I realized that I haven't released any snippets in a while so I figured while I was working on some interesting projects of my own that I would release one that I recently decided to write because I don't see the algorithm out there in C# very often. This snippet … | |
The snippet provided will cover the basics of an on screen keyboard; the only things it doesn't have are numbers, symbols, and extra keys. This will give you the fundementals to build off of. It's written using Microsoft's XNA Framework, however it should be fairly simple to port over to … | |
These are just some of the more useful #define statements I've used in C++. These are some of the statements you'll use the most (in the case of template<typename T> when you use it, you use it a lot!). So I figured I'd post it for others, even though a … | |
Just a couple basic static mathematical helper methods that I've found useful for game development. Feel free to add some in replies for future visitors. I will do another post later this week with advanced helper methods from trig and calc. I will also do a geometry helper class as … | |
Figured I've been working on material for a while and would throw these up for everyone that needs them in the future to use. It's very simple implementation; if I get enough people asking me to, I will write the methods for each of the instructions so you don't have … | |
I had a small problem with collision detection starting out with XNA 4.0 so I figured I'd release a simple snippet that helps with two different types of collision detection; Per-Pixel and Rectangular. To use simply copy and paste the snippet into your current source, or you could put it … | |
I get tired of having to google this simple line of code all the time. My problem with memorizing it is that I switch back and forth between C# and C++ all the time, and the way you overload operators in each is different. So once I learn one again, … | |
I realize I haven't released anything in a while so I figure I'll just type a basic set of things for you all to use or learn from. All of the following requires XNA Framework, but can be easily ported over to .NET Framework for use with forms applications. The … | |
I haven't tested this yet but it should work. The implementation is fairly simple. I don't have my laptop so I can debug the code at the present time. This basically increments the frame count everytime the game draws itself (allowing us to calculate frames per second considering the draw … | |
I've developed a simple class and enum that will make ammunition creation and usage simpler in game development for those who are interested. I will be making a tutorial video on how I made this so that you will fully understand how the code works if you do not. Simply … | |
I used a label inside my snippet just to test it; but this will simply increment and decrement a float value by 0.2f between the values specified in the conditionals. I have it updating between 8f and 15f. Must be run on a timer (make sure the interval is low … | |
There only two glitches within this code that I can't seem to get 100% spot on. However, this will create a functioning menu (text based) on your form at runtime. I plan to develop an actual control exactly like it. It uses a custom class I developed called LocationBounceEffect that … | |
XNA Game Studio is not required to use this functionality. This example is very basic, and I typed it up because I was bored. It does not contain functionality for navigation through the menu, but it will display the menu as it should at the specified location. Please enjoy it, … | |
This release is an updated version of my previously released code snippet entitled "Get Internet Connection State". I've made this snippet into an actual control that you can add to your toolbox. It can be used with all versions of Visual Studio C#. I'm also posting the main source code, … | |
I've developed a code that is intended to be used in an application extension (as with all my codes) that will tell you if the current computer has an internet connection. To use just include the namespace given at the top of the snippet, then the connection state is a … | |
The idea is to do basic math to find the difference in size between the object and the form. To do this take the object size (int1, int2) and the form size (int1_1, int2_2) then get the difference by subtraction. The math is (int1 - int1_1, int2 - int2_2) so … | |
I know there are others out there who haven't figured it out yet I figure I'll help out. The code snippet included will over-ride the pre-designed menu highlight. :D Just change the color of the pen or brush to whatever you want the highlight to be. :) All of the … |