
Just a post to let anybody who's reading this that I've finished the level saving and loading features and they work quite nicely. The in-game level editor (still a work in progress--it's not very fancy at all) can save all the blocks in the current level as an XML file. I can then add that file to the project, where my Content Pipeline library converts it into a binary XMB file at compile time. My XMB reader then converts said XMB file into objects in memory.
Basically, List<Block> -> XML -> XMB -> List<Block>. Apparently doing it in this way is much faster than the easier way of simply writing to and reading from plain text XML files. When you're saving thousands of blocks, you end up with a good 2 or 3 megs of XML which takes far too long to parse.
I'll post details, code, video, et cetera a little later on.
Also, I should say that writing this took a good deal of work on my part, and once again the XNA tutorials were a HUGE help. However, while in the middle of this, the XNA site was down for about a day preceeding their big relaunch, and this was the first time I just NEEDED other people's help. I ended up getting it on the forums after the relaunch, and it helped me to understand some of the things that weren't clear to me before. In other words, "Thanks, internerds!" Where would we be without you?
Source:
Program.cs, Extinct.cs, Species,cs, Block.cs, BlockReader.cs (rar)
BlockPipelineContent.cs, BlockSettingsWriter.cs (rar)
Wednesday, May 21, 2008
Extinctathon: level editor saving and loading complete
Wednesday, May 14, 2008
Extinctathon: Level Editor
I've been working on Extinctathon pretty regularly lately, at least 2-3 hours per day, and I've updated quite a bit. I've got multiple types of background tiles (Block objects), I've updated the collision detection (it works about 95% as well as I want it to), and the beginnings of a level editor (as seen in the video). It's all in one program; you hit up on the d-pad to toggle between editing and debug modes (as seen in the upper right hand corner). In edit mode the shoulder buttons cycle forward and back through the types of tiles (grass, mountain, cloud, block), and the cursor is moved with the left hand joystick. Tiles are placed by pressing A.
I still have quite a bit to work on, including adding blocks that can be broken, blocks that can pop out power-ups, enemies, and all sorts of other stuff. The code needs cleaning up, too, and there's a good amount of commenting that I need to do before I move forward. The next step I'll be taking, however, is adding a level loading and saving system. I'd like to then make one semi-complete level so that I can test it out and then add enemies. I'll hopefully do that this week.
Source:
Extinct.cs
Species.cs
Block.cs
Friday, May 9, 2008
Project 5: Extinctathon!

Extinctathon is my newest project, and boy, is it a doozie (I just wanted to say that). Imagine Bioshock and Super Mario Brothers and Margaret Atwood all rolled up into one--that's Extinctathon.
So far it's a 2D side scroller with a rabbit-monkey hybrid that can walk and jump. It sort of has collision detection in that if you fall on top of something you stay on top of it and if you walk into something you magically appear on top of it because it's not really done yet. It takes input from the XBox 360 controller (just got two this morning) and moves the little guy around onscreen.
It's already big enough to occupy three (3!) source files, and it's only getting bigger. I've only spent 2 or 3 hours on it so far, so it's pretty limited, but I'm looking forward to working on it in the coming weeks.
I'll post more when I have the time.
Wednesday, May 7, 2008
Project 4: Solvle

Okay, so I'm pretty proud of myself for this one. Using the methods from my previous project, I added the ability to, given a particular arrangement of letters from a game of Boggle, find all the words possible according to the rules of the game.
This is accomplished by the same basic method that a human would use while playing the same game: starting with a letter, move on to the adjacent or diagonal tiles to find any English words. I used the ENABLE word list which is a free text-based Scrabble dictionary in exactly the format I needed.
The first working version of the search took a good 90 seconds on my computer, which seemed way too long for practical use. It was searching literally EVERYTHING, though, even after it would be impossible to find additional words. In other words, if searching on a path yielded "ASDF", which isn't a substring of anything, it would keep on searching all possible subpaths which would all yield nothing. One line of code later, and the search results are visible by the time the mouse button has been lifted up.
It works great, as verified by a few games of Noggin (I'm not a habitual cheater, I just wanted to test it out). The only words I didn't get were verified as not being in my dictionary file. Aside from those, Solvle found every single word on the list in a fraction of a second. Fun.
One thing I did differently this time is I tried to fully document the code as I was doing it. It's a good habit to encourage, so I'll make myself do it even though for most of this stuff I'll be the only person to see it. Still, the code could certainly use some tidying up, and some optimizations here and there. I'll take a look at it later.
With regards to what's coming next, I've been talking with somebody about moving on to Scrabble. That would be WAY more complicated, however, and I might want to do something a little lighter for the moment. My wired Xbox controller should be here soon, so I'll get to work a little more with XNA. I'm looking forward to that.
Source:
Solvl.cs
Solvl.Designer.cs
Solvl.resx
Friday, May 2, 2008
Project Update: Dictofunk
I've updated Dictofunk to add searching to the tree. It's fast enough that it updates in the time between keystrokes while typing a word. I'll post screen shots, details, and the updated source code when I get home.
Second update:
I've gone ahead and made the Boggle Solver program in the past couple of days based on the tree stuff done already. I'll pretty it up a big (both visually and in code) and post it later today.
Sunday, April 27, 2008
Project 3: Dictofunk

My newest project had the objective of loading a word list from a text file and converting the words into a tree.
In other words:
act
arc
art
would become
a->c->t
.->r->c
....->t
This is one of those sort of important, school-y types of things that people should learn, and I wanted to do it for the Boggle Solver program (given a Boggle board and a list of valid words, find all possible words within the rules of Boggle) I had talked with somebody about a couple of months ago.
The basic process involved is this:
1. Read a word from a file.
2. Starting out with an empty tree, search the top level of the tree for the first letter in the word.
3a. If you find it, make that spot the top of the new tree.
3b. If you don't, add the letter to the tree, make that letter the top of the new tree.
4. Chop off the first letter of the word and start over at 2 with your new subtree.
Finally, when the word is done, it sticks a "." at the end so it knows it's a complete word (so that you know, for instance, while "act" and "actual" are words, "actu" and "actua" aren't--they won't have a "." in their subtrees).
Here's the same algorithm in C# form:
public void insertWord(TreeNode thisNode, Char[] chars)
{
bool found = false;
String charString = new String(chars);
if (charString.Length > 0)
{
charString = charString.Substring(1);
foreach (TreeNode branch in thisNode.Nodes)
{
if (branch.Text == chars[0].ToString())
{
found = true;
insertWord(branch, charString.ToCharArray());
}
}
if (!found)
{
insertWord(thisNode.Nodes.Add(chars[0].ToString()), charString.ToCharArray());
}
}
}
And that's pretty much that. The actual algorithm is fast (as seen in the screen shot, with the test dictionary of over 70,000 words it was going through about 13,000 words per second). Loading the tree into the Windows Form, however, takes a good 60-90 seconds. That's not a major concern, however, since the graphical display (yet another great thing that C# does that makes life so easy) is essentially pointless except for visually verifying that the algorithm works. I was kind of shocked that this was even included as a basic display type. Oh, the future.
Oh, also, C# in general was a huge help in doing this in that it I didn't have to worry about constructing a tree class of my own. I was able to spend my time actually figuring out the algorithm I needed, which, while I've certainly read about tree insertions before, I did last night and this morning on my own. Once again, this is totally freshman programming class stuff, but it feels good to know I did it more or less on my own.
Source
Dictofunk.cs
Saturday, April 26, 2008
Update: Time Sheet Calculator v. 0.2
I recently updated the Time Sheet Calculator program to incorporate a few additions I wanted to have after using it to do the payroll this past week. For the record, it saved me at least 90 minutes of work this week alone, and it will save me about that much time once every two weeks in the future.
I needed to add a button to reset all the fields to 0, and I labeled it "TARE" because I felt like labeling it "TARE". I also fixed the formatting of the total time display so that it displayed it in HH:MM rather than the default format of d.hh:mm. Finally, I changed the format of the individual DateTimePickers to be hh:mm am/pm, because the seconds were unused and leading to too many mistyped numbers. If I think of anything else to add, I'll post it. Right now I'm satisfied.
Source:
TSCv0_2.cs
TSCv0_2.Designer.cs
TSCv0_2.resx
Wednesday, April 23, 2008
Project 2: Swarm and Gravitate
In this program, I started learning the basic flow of the Windows Forms program. I did some event handling and some graphics, learned some more stuff that C# makes retarded easy (the List
Swarm() calculates the center position of the collection of bodies and everybody accelerates towards that position. Gravitate() attracts the bodies to one another by (something resembling) gravity. This is all, of course, 2D.
Things I'd like to add:
Hitting tab to center on a body doesn't properly work. I need to fix that. - Once that works, I'd like to be able to double click on a position to center on that point.
- There is no consequence of collisons--gravity simply turns off when the bodies are about to touch (to keep them both from rocketing off into space).
- It'd be nice to put in a menu to add / delete planetary bodies.
- It'd be nice to put in controls to drive around one of the planets.
Here's the source file.
Friday, April 18, 2008
Project 1: Time Sheet Calculator
Okay, so this whole thing started the other day when I got sick of doing payroll. At my workplace, the staff members clock in and clock out with and old-fashioned time card system, once which prints the time on a piece of card stock. Every other Thursday, I have to go through every single card, calculate the shift times in my head, and then add them all up on my own. It's a tedious and pointless process. I could spend a couple hundred bucks to buy an electronic system that would make it automatic. That, OR--!!!
I downloaded Visual C# Express, since I heard every retard on the planet is using C# these days. I learned what I needed to know from the in-program documentation, and start to finish spent about 30 or 40 minutes. Here's what I ended up with:
It's ugly, right? But it gets the job done. I spend about 2 hours per payroll adding all that up--with this, I'll probably spend 15 minutes.
Here's the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace PayrollMcGee
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void TotalLabel_Update()
{
TotalLabel.Text = ((dateTimePicker2.Value - dateTimePicker1.Value) +
(dateTimePicker4.Value - dateTimePicker3.Value) +
(dateTimePicker6.Value - dateTimePicker5.Value) +
(dateTimePicker8.Value - dateTimePicker7.Value) +
(dateTimePicker10.Value - dateTimePicker9.Value) +
(dateTimePicker12.Value - dateTimePicker11.Value) +
(dateTimePicker14.Value - dateTimePicker13.Value) +
(dateTimePicker16.Value - dateTimePicker15.Value) +
(dateTimePicker18.Value - dateTimePicker17.Value) +
(dateTimePicker20.Value - dateTimePicker19.Value) +
(dateTimePicker22.Value - dateTimePicker21.Value) +
(dateTimePicker24.Value - dateTimePicker23.Value) +
(dateTimePicker26.Value - dateTimePicker25.Value) +
(dateTimePicker28.Value - dateTimePicker27.Value)).ToString();
}
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
TotalLabel_Update();
}
private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
TotalLabel_Update();
}
...
private void dateTimePicker28_ValueChanged(object sender, EventArgs e)
{
TotalLabel_Update();
}
}
}
Tedious, right? Just like always. It's super ghett0, completely taped together, and probably looks like something somebody would do if they'd just discovered visual programming interfaces.
So, um, yeah. That's me.
Chapter 1: Starts and beginnings
The goal of this blog is to document my work while I'm learning to code again, and to show to other people so that they might be able to a) learn from it, or, more likely, b) yell at me because I've been slacking.
Let me begin by saying that I started programming when I was about 14 in C and C++ for my Macintosh running System 7. I think I was using Metrowerks Codewarrior, a trial copy that came with a book I bought from the closeout bin at Books-A-Million. Either because of my lack of experience, my lack of years, or the fact that, if I recall correctly, writing for Macs back then was impossible, I had a hard time of it. It went okay, though, and over the years I wrote a couple of little games that never really worked quite right from beginning to end. But whatever, I was learning.
I worked a lot in Java as well, still mainly in high school, and again wrote some games, wrote some simple programs to do this and that, and learned a bit along the way.
Fast forward five or ten years, and here I am. I've forgotten most of what I knew, and that might be a good thing. I'm going to try really hard over the next couple of months to see what I can do, and I'll try to document it here.
The primary point of this post, though, is to list my goals, which are--at this time--the following:
1. To work in Visual C# Express to learn the basics of contemporary Windows programming. A big sub-goal in this heading is to better understand the program flow inside the Windows Forms framework--something which is kind of weird to me right now. A major reason for working within this framework is that it makes the UI end of things so easy that it will free my mind to focus on the actual code, the actual algorithms rather than making sure the event handler or menu system is working.
1(a). To work with the XNA toolkit, once task 1 is well underway, to write a non-trivial game that doesn't look awful, will take a fair amount of time and effort on my part such that it will feel like an accomplishment, and hopefully something that is actually fun (or at least interesting) to play. More on this later.
2. To learn (or relearn) the fundamentals, be it basic searching and sorting, data handling, or really whatever. I have not decided the best source of information to go about learning this, although I do have several related textbooks, two Knuth books, and the whole wide interwebs to assist me in this matter. This is going to be the least fun and most important item to work on, so I really need to do it.
3. To learn (for the heck of it) to work with Lisp, possibly working from Structure and Interpretation of Computer Programs. This task is inspired by another blog, and I do not in any way expect to complete this task in nearly the extensive fashion that the linked person has done. This task, as you may notice, seems fairly unrelated to the other two. It may be, it may not. I think it will stretch my mind in a thoroughly different direction, and while this task will receive the least immediate attention of the three, I'd feel very accomplished to get somewhere with it.
That's enough for now. I'll be posting what I have of the programs I've written so far in the coming days.