Link Bar

Home | Games | Programming | Tutorials | Donate | Legal (These are mostly empty right now. Placeholders!)

warning code

This website contains adult content.

Tuesday, March 13, 2012

Day 22: "Hula" Open-Source Beta!

I got the "help" button working.  Turns out, back when I had thrown a "}" in at the end (because one was missing), I should have put it before the Help subroutine, because that's where it was missing from.  But I put it in after the Help subroutine, which subordinated it to the Inventory subroutine.  Dammit.

I don't want to admit how long it took me to figure that out.

I also think I've figured out what's causing playerLevel to start out at minus two billion, even though I know by math that it's supposed to start out at zero.  See, the exact player level on a new game is -2,147,483,648.  Recognize that number?  Yup, it's -231, the lowest number that can be displayed in 32-bit number-crunching.  I wanted "XP to next level" to always be twice what it was the last level - which is given by the function:
[LEVEL] = log2(([XP] + 1) / 2) +1
At zero XP, then, you're level zero, because log2 of 1/2 is -1 (and then add one to make it zero).  Take one action, and BAM, you're level one.  Two more actions and you're level two, and so on and so forth.  For some reason, though - probably because of how the logarithm function works under the hood - it's making it (for all intents and purposes) negative infinity.  This could be caused by the fact that I'm calculating the binary logarithm as "log2n = log10n / log102," which is mathematically correct but might be causing the 'puter to throw a fit.  Hmm.

Anyway, that's a headache for another day.  Here's the Hula beta, source code below the jump.  Also, I learned how to make the binary logarithm function here on Stack Overflow, since Microsoft decided to excise it from cmath.  Because who would ever want to take a binary logarithm of something?  Huge dorks and lesser dweebs1, that's who.

Notes:
1.  I swear by the stars that I got this from Strong Bad, but I can't find it right now.

Monday, March 12, 2012

Day 21: "Hula" in development!

...and already in tiny Development Hell!

Alert Readers and long-time fans will recall that, like, three weeks ago, I came up with a cockamamie scheme to make a simple game with the little bit of knowledge that I had at the time.  Of course, like all my ideas, it worked perfectly in my head and then immediately went to Hell as soon as I started trying to make it happen.  Well, now that Noob Game is launched and complete, I figured I could just make a Big Boy Hula (to Noob Game's Playskool) and thereby force myself to make legit versions of all the things I conveniently worked around in Noob Game.  For example, rather than having exactly one NPC per area and governing all aspects of NPC interaction based on player location, I will need to figure out a way to make "real" NPCs which can be present in arbitrary quantities.

I'm some 300-odd lines of code in, after drawing up a little design document over the weekend and coding like one of those typewriter monkeys you hear about in misunderstandings of probability and the infinite.  I've got a game world, experience mostly works (but you start at level minus two billion, which should be zero, and then proceed to level one as intended), and all the buttons work except the "help" button which tells you what the buttons are.  But whatever.  I'm continuing to learn, and that's what counts, right?

Tomorrow, I'll be reading the full chapter 2 from TECS at the temp agency, and either I'll start on the project or I'll tinker around some more in Hula and put up a public beta.  Fun times!

Friday, March 9, 2012

Day 20: "Noob Game" launched!

Early update today, since I stayed up writing my tutorial.  Feels good to be ahead of schedule for a change!  Now if only I can find some work today...

Noob Game can be downloaded on the free right here!  Below the jump is a tutorial on how to write this game (or something like it) all by yourself in C++.  But be warned:  the source code contains spoilers.  Because I know you're super-concerned about those.

GAMES?!

Indeed, games!

This is my central game download page, where you can find all the games I've made.

Noob Game:  This is the first game I ever made all by myself.  It's short & shitty, but it's got all the right elements for a game:  NPCs, dialogue, levels, and quests.  Can you slay the vicious troll of Pro Mountain?  Will you anger the gods and live to tell the tale, venturing forth into the Wild Blue Yonder?  Or will you be whupped soundly by the Noob Trainer and perhaps killed by a guard for attacking a civilian?  YOU DECIDE!  (Note:  the link is to a naked .exe file on Dropbox; your 'puter may turn up its nose at it, but I assure you that there are no viruses).

More coming soon!

Thursday, March 8, 2012

Day 19: A quest! And a world!

So I recoded everything from scratch in a new project called "Noob Game," rather than keep everything in "Hello World."

You start in Noob Camp and can talk to the Noob Trainer, who gives you a quest to take some Noob Shit to Noob Town.  If you keep trying to talk to the Noob Trainer, he tells you to get going.  You can then turn the Noob Shit in to the Noob Civilian, who gives you a gold piece.  Now you're on a first-name basis with the Noob Trainer!  That's some status right there!

The source code is beneath the jump, for anyone who is curious and/or wants to compile and play this pile of a game before I "officially" release it.  There are still a few bugs, like levels don't work right (also, attacking is a lie and does not work), but I have ideas of how to fix them and just wanted to put something up on the blog before midnight.

EDIT:  Uhh... finished the game?  Compiled and released before midnight.  Lots more quest, figured a couple neat new things out, posting a tutorial tomorrow.  Who knows of a nice free place to make .exe files available for download?

DOUBLE-EDIT:  Aaaaand... BAM!


Wednesday, March 7, 2012

Day 18: A game, at last!

It's not much, but I have the rudiments of a game here, now.  Thanks to Zachary's superior tutelage, I now have a game with a functioning victory condition, failure condition, and means of quitting.  You can't save, or talk to anyone, or do anything besides win/lose/quit... but still!  I have something functional here, and now it's just a matter of scaling it up until I get something worth distributing.

For those of you playing along at home, this is how Noob Game works (so far):
#include "stdafx.h"
#include "HelloWorld.h" //this header is empty at the moment, but I have a feeling I'll be using it eventually
using namespace std;
int _tmain(int argc, _TCHAR* argv[]) //this is the main function!
/* If I'm reading it right, the main function is simply an integer (albeit a really, really big one in binary).  What this means is that any possible game state could also be represented as an integer, Library of Babel-style, such that there is a set of integers which in aggregate represent all possible game states.  Whoah. */
{
cout<<"One Man Show"<<std::endl;
cout<<"Welcome to Noob Game.  Enter 1 to win, 2 to lose, or 3 to quit."<<std::endl;
char choiceOne[100];
std::cin.getline(choiceOne,100);
if(choiceOne [0]=='1'){
std::cout<<"You win!  Thank you for playing!"<<std::endl;
}
else {
if(choiceOne [0]=='2'){
std::cout<<"You lose!  Please play another time."<<std::endl;
}
else {
if(choiceOne [0]=='3')[
std::cout<<"You quit!  Fuckin' quitter."<<std::endl;
}}}
std::cout<<"The game is over.  Enter anything to close."<<std::endl;
std::cin.getline(choiceOne,100);
;
return 0;
}
And that's it!  I have extra comments in there & stuff, but I don't really care about that on such a small program.  I compiled it and ran the .exe on my computer many times!  It works!  Well, entering "4" or anything else besides 1, 2, or 3 will simply advance to ending the game, but as far as I'm concerned right now, entering unacceptable input is a failure condition.

I'm working on a replay module right now; I'll probably have to learn something else to make it work the way I want to, since I can't use "goto" any more.  Or at least shouldn't...

Anyway, even that was the result of an embarrassingly long session of poking, prodding, and just trying different things.  I'm going to go back to doing that now; just wanted to share that I've actually got something!  The simple fact that I'm using a program I created myself, no matter how rudimentary, is giving me a bit of a rush.

Tuesday, March 6, 2012

Day 17: Program runs!

Well, after much hemming and hawing, I finally sat through the MS Visual Studio tutorial and followed along instead of just watching it.  Within minutes, I got this:
Fig. 1  A window that asks for a 1 and everything!

It works!  Working code!  But then when I entered "Hot cha!" as you can see above in Figure 1, I got a run-time check failure - apparently, some stack around the memory of "myLine" was corrupted.  I can Break or Continue, and I don't know what those mean.  Glad I can JFGI before I decide!

OK, I didn't find anything in two minutes and I'm too excited, so I clicked "break."  Apparently, breaking things is the wrong thing to do.  I don't know how I could have possibly known this in my previous life experience.  Now I can't close the window.  I ctrl+alt+deleted and tried to end the process, and it just won't die.

I was all set to reboot, and then VC++ asked me if I wanted to stop debugging when I closed it.  Then the window closed on its own.  Not spooky at all.  This magic box is haunted.

Back up and running, and the machine tells you you've played even when you press 2.  Hmm... I thought that maybe that "if(myLine[100]=1" bit might mean "if it's true," so I tried putting the 1 in quotes, and got, "1>c:\users\d\documents\visual studio 2010\projects\helloworld\helloworld\helloworld.cpp(23): error C2440: '=' : cannot convert from 'const char [2]' to 'char'; 1> There is no context in which this conversion is possible."  That's at least intelligible, but it doesn't fix my problem.

OK, that's it for today.  I also did a bunch of art stuff, but it's sketches at this point and nothing really presentable.  Toodles!