Superfab Adventures in Programming!: I C What You Did There

WordPress — like, I imagine, most blog-writing software — uses categories for grouping posts. On day one, before I’d even written anything yet, I set up a whole list of categories for all the things I thought I’d write about. Some never got used and ended up in the trash bin, or lumped together with others when I realized I’d hardly ever use them on their own. Only one, though, has sat there intact but unused, just waiting for its day in the sun: “Dev Diary.” Today, I checked the Dev Diary category off for the first time — for this very post.

See, this is the beginning of something new. Something that’s sure to be very long and very bumpy — something which I shall call my Superfab Adventures in Programming!

A brief attempt at teaching myself C++ aside, I’m currently taking my first steps toward learning a programming language. The language? C. The class? Computing I. A little weird to be picking up a computer science minor as an English major (and as an almost-senior at that), but us artsy types are fickle like that. And anyway, I’m doing it for the art! Mostly I’m picking up the CS stuff because I want to make a roguelike. Just don’t tell my professor that.

Well, I’d like to do a lot more game design stuff in the future; not just a roguelike. A roguelike just seems like one of the easier places to start. A text adventure would be even easier, and I’ll probably end up experimenting with those first, but the roguelike is what I’ve got my sights set on. That’s the ultimate goal and what I’m hoping to do here is basically keep a journal of the trials and tribulations on my way there.

It’ll either end with a playable game or in my complete and utter failure. Either way, we’re gonna have a lot of fun!

And just for yucks:

So far we’ve learned a little about the basics — initializing variables, outputting text, requesting user input… if statements. My brain, of course, immediately began thinking about how to employ all that stuff in an RPG-type character creation screen. For instance, I think this fragment would work as an extremely basic and shoddy class select prompt:

(WordPress is not kind to formatting here.)

int class = 0;
int str = 10;
int dex = 10;
int wis = 10;

printf(“[1]Fighter\n”);
printf(“[2]Thief\n”);
printf(“[3]Mage\n”);
printf(“[4]Amateur Blogger\n\n”);
printf(“Choose your class: \n”);
scanf(“%d”, &class);

while( class < 1 || class > 4 )
{

printf(“That ain’t one of the options, bub.\n”);
printf(“Give it another shot: \n”);
scanf(“%d”, &class);

}

if( class == 1 ) // fighter starting stats
{

str += 5;
wis -= 3;
printf(“Awesome! Here’s your complimentary axe and viking helmet!\n”);

}

else if( class == 2 ) // thief starting stats
{

str -= 2;
dex += 4;
printf(“Oh! I see you like to stab things. I too enjoy stabbing things.\n”);

}

else if( class == 3 ) // mage starting stats
{

str -= 4;
dex -= 2;
wis += 7;
printf(“Sweet! Time to light some dudes on fire!\n”);

}

else if(class == 4)  // blogger starting stats
{

str -= 9;
dex -= 5;
printf(“Congrats! Your journey into obscurity begins here!\n”);

}

Of course, it explodes if you enter, say, a letter at the prompt. I’d love to know how to only allow the numbers 1 through 4 to be typed there and simply ignore any other input. But I think that lesson is a few weeks off.

Also, don’t worry. The Amateur Blogger class may look underpowered, but I assure you it’s the most fun to play!

Oh, and if anyone out there is actually good at this programming thing? I hope my total ignorance on the subject isn’t too infuriating. Maybe you could stick around and point out all the things I do wrong. I’d appreciate it, really.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s