Getting a Gist Of My Code

 

I know I don’t post very often – believe me, 2015 and 2016 have been a helluva ride – but I have been writing a lot of code. I mean, a lot. A lot of the code I write, since it’s Unity, I have compartmentalized in scripts that I import over to a multitude of projects. Seeing as how a lot of these are used and fleshed out in projects that will never see the light of day, I thought “Hey, why not just put them up on the site?”

So, I’ve created a Github account, and I’m placing them in their own GitHubGists (or Repositories, if they span multiple files). This would be a quick, dirty, and effective way to get my code out to you guys so maybe, just maybe, it can actually be used in a project somewhere.

Any code I put up in my Gist, I’ll also link to it somewhere on this site as well for direct linkage.

So, go have a look at my GitHub Gist! Maybe you can find something useful there!

Link to the Path: A* Pathfinding for Beginners

A* Pathfinding for Beginners

OK, so a while back I posted a link for a simple implementation for A* Pathfinding for C/C++. The page gets a bunch of hits, but I get a lot of people asking me to explain it. Well, it’s not my code to really explain, and I haven’t tested it out for myself. Rather than go through and make a huge tutorial, I figured I’d take the lazy route, and provide you with a resource to help explain it a bit. This page breaks down A*Pathfinding to the basics and gives a great explanation down to even the heuristics (If you don’t know that word, you’ll need this link).

So, now with this in hand, pathfinding should be easier to grasp now. Give it another go, and let me know how it turns out! Good luck!

Unity 3D – Super Simple Animation System (SSAS)

One thing I always considered good practice is “If you know what you need, and ‘the wheel’ is over-bloated, it’s OK to reinvent.” I looked at animation systems involving many awesome features, but I wanted something really, really simple. Named after my room mate, here is the Super Simple Animation System (SSAS).

Continue reading Unity 3D – Super Simple Animation System (SSAS)

Quick Code Tip: Fix Precision with Floating Points

Let’s say you have a floating point value of 200.21, and you convert it to an int, like so:

int amount = (int)(famount * 100);

Depending on processor, libraries, compiler and tons of other stuff, your value may APPEAR to be 200.21, but when you do your conversion the value comes out to 20020. What happened to that extra 1?!

Well, though you may see 200.21, the computer is actually storing 200.209999999… (because, you know, 0.999… == 1).

This doesn’t happen all the time, but when it does, it’s a pain. So how do we fix this?

Just add 0.5. Seriously.

int amount = (int)((famount * 100) + 0.5f));

Bam. Let’s break this down, PEMDAS style.

(famount * 100)
Ok, so we know that famount is not 200.21, but 200.2099999… This now brings us to 20020.99999…

((20020.999…) + 0.5f)
The 0.5 now brings us to 20021.49999… Like magic.

int amount = (int)(20021.4999…)
Saving all the pennies.

Good job. You just saved the world from mathematical inaccuracy.

Until next time, take care. (After that, do whatever the heck you want.)

C++ Link: A-star Shortest Path Algorithm (C++ recipe)

Pathfinding A Star
Image via Wikipedia

Thank you, StumbleUpon! I just so happen to have come across a handy code snippet for the A* pathfinding algorithm.  This is pretty much a staple in any AI programmer’s arsenal.

So here’s the code! Enjoy, peoples!

A-star Shortest Path Algorithm (C++ recipe)

The Lessons | Learning WebGL

 

Hey! You! Do you like OpenGL? Do you like the Internet? Can you program? Then you’re gonna want to see this!

The Lessons | Learning WebGL.

Code Snippet Quick Reference

I have created a quick way to find the code snippets you’re looking for! The Code Snippet Quick Reference under the Code tab at the top. Now you can find all the snippets for C/C++, Unity, and even the Math Algorithms all in one easy place (OK, technically 3, but shut up; I’m trying to do you a favor, here!).