Tuesday, March 9, 2010

Sad days indeed....

Well, here's something that has hit me hard...

Just the other day, I rebooted my Windows 7 machine due to a system update and BOOM... the RAID 0 settings I had for my 2 1TB drives was destroyed, can you see what happened here?

Did you know that you can't just say, make a RAID 0 and poof your data will be returned to you?
Yes, you've read that right... everything I had on my hard drives was wiped clean. The downside to this, I've lost everything I had on my computer...

Thankfully, my friend who is working on the games with me has an older copy of the games, but at least not everything has been lost!

What's worse is, 2 days before I had fixed my gimbal locked camera and we had a full 360 degree of freedom. Oh well, now that I know how it's done, I can rebuilt that code easily.

Tuesday, March 2, 2010

The problem with Cameras and a Gimbal!

Alright. There might be some of you who just by looking at the title to this post go: Duh!

And for those of you, who like me, wouldn'tve figured out what the problem is here's the low down.
I keep saying that my camera controls aren't quite what I want and there's a reason for that. I'm working in a 3D space, but I'm using a 2D input device (the mouse).

Now, my original code to rotate the cube around the screen was by adjusting the x and y rotations by the value that the mouse has moved. Seemed simple enough. Create a degree of rotation, transfer that into a Matrix and poof! Instant rotation of the cube... and this does work... mostly. The problem is, I'm only using 2 out of 3 dimensions for rotation... can anyone see the problem?

I did some research and found out the term... it's called Gimbal Lock. This happens with 3D maths that use regular vectors and matrices... 1 axis of rotation lines up with a 2nd axis and suddenly they're locked together, unable to seperate. Leaving you only 2 degrees of rotation. Well my code has this without even bothering to lock an axis. Since I was only using the x- and y-axis, this locked the z-axis from any rotation. In theory I deliberately coded in a Gimbal Lock.

Now, I've read about how I can prevent this completely by using Quaternions... what's a Quaternion? Good question, I never studied these in University, so everything I'm learning is from the wonderful internet. With that said, I think I have a rough enough understanding on how they work and how to use them. Unfortunately, the XNA libraries don't have prebuilt Quaternion maths, so it looks like I'll be creating a new Component to my GameLibrary that'll handle all of my Quaternions.

(As a quick heads up for people who've never heard of Quaternions... they work in 4D space, wrap your head around that!)

Friday, February 12, 2010

It's alive!

Alright, I feel like an idiot now.

This bug for 2 weeks has been plaguing me everytime I tried to fix it.

Here's the deal:

My original code that detected match-3's and created new objects. It was just buggy to the point that it was unplayable.

So, I decided to completely rewrite the code. I scrapped everything match-3 related and rebuilt the code from scratch. (Thanks to C# and #regions!)

Well, the code is very... hrmm, the best description I can think of is "dynamic". The functions shift the intent of the functions that they call.

From here, I created a couple of helpers to manage everything, but I did make one specific function that creates the new tiles and moves them into place. I had just forgotten one specific thing.

Here's the deal:

I had to create a mouse selection routine for the original selection system. Raycasting a point into the level and then determining the closest object to the front of the screen that's clickable.

Now. This selection code uses a Container I had created called the Object Container. It does what it says it does. It contains all of the objects in the game. But here's the catch. If the object you're trying to click on isn't in the Object Container... it doesn't trigger the click. This was my problem. I had completely forgotten to add the new tiles into the Object Container. So when I clicked, they were essentially invisible. One line added and the code is fixed!

I am thinking that this is a problem with the clicking code. I'll probably update the base object creation code to automatically add new objects to the Object Container and this would remove any future similar issues.

Well that's it. Time to go, maybe I'll start on fixing the camera controls since they're not QUITE what I'm wanting...

Till next time!

Updated Match-3

Well, it's been awhile so here's a quick update.

I've refactored the entire match-3 system. It's much more efficient and actually detects all matches correctly. It even moves the tiles into the correct space everytime now. But I've hit another new bug from the refactoring. The new tiles that are created not clickable. What's weird about this is the fact that from all of my debugging, I can see that the tiles themselves are clickable, but yet I'm not getting them to click on.

As I've been writing this, I think I just realized what the problem is with my clicking.
I'll post again if my theory is correct...

Signing out.

Friday, January 22, 2010

The magic of 3D Match-3's

Alright folks. Newest update! Whoohoo, I know it's been awhile, but I hit a snag in the code and have been working on fixing an annoying and infrequent bug.

So... what's been going on lately? Glad of you to ask, here's the lowdown on it.

Our match-3 game is progressing incredibly. I've been working on the animation codes a bit to improve them. Plus, I'm now able to swap tiles around on the cube. To the point where a Match-3 is actually detected! Yes, that's right, basic gameplay is almost complete!

Now, I have matches being removes, and new tiles coming in to replace them as per the basic game design. But I have hit a weird infrequent bug that, when a match-3 is discovered... for some reason the tiles don't shift into place to replace to newly removed tiles. It's weird. The match-3 is removed, but new ones don't fall into place. This is what I'm working on. Though, my animation code to replace the tiles is EXTREMELY ugly and incredibly inefficient. I'll be refactoring that entire code first into a few helper functions to trim down the code. It's very repetitive, so I should be able to animate all 6 directions of the cube with only a couple of functions.

(Of course, this goes without saying, if refactoring this code fixes my bug... I'll be very very happy!)

After this, I want to rework the camera controls since the rotation of the cube is dependent on the camera and it's not working how I would like it. So that'll be next... after this, I get to do some proper 3D models. Once it looks good, scoring will be added... bonus tiles, maybe various game modes. Oh, mustn't forget to add a proper menu system, and even a highscores table. But this is all done later, I want the gameplay to work so that I can test it and make sure that it's a viable game.

Well, that's all for now... till next time!