Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - jamms87

Pages: [1]
1
Programming / Re: Just starting out, help appreciated.
« on: February 11, 2012, 02:17:54 PM »
That solved it, thanks very much.

2
Programming / Just starting out, help appreciated.
« on: February 11, 2012, 01:48:40 PM »
Hello, I just started out using a tutorial that described how to create the basics of a roguelike using c++ and running the code through the command prompt. I finished the tutorial and started fiddling about on my own and have hit a bug I can't seem to work out.

I have set up a function which allows the player to open doors if they have a key, it works fine. I then tried to set up a way of opening doors using magic, rather than put the code in again I thought I could just do as I have below (ignore everything other than the OpenDoorCommand bit). It works in the sense that the door opens however when the user selects option 3 the map, UI and player disappear until they select which direction the door is in.

Any tips or suggestions would be much appreciated.

Code: [Select]
void ManaCommand( void )
{
   
// Draw some notification to the user
console.SetPosition( 60, 2 );
console << "1. Damage Enemy.";
console.SetPosition( 60, 4 );
console << "2. Heal yourself.";
console.SetPosition( 60, 6 );
console << "3. Open Door.";
console.SetPosition( 60, 8 );
console << "4. Chop Tree";

// Let the user decide where to look
char nKey = getch();
int nDeltaX = 0;
int nDeltaY = 0;

// Clear the screen to get rid of the notification text
console.Clear();

// Compute which tile the user specified
switch( nKey )
{
// Damage Enemy
case '1':
nDeltaX = 0;
nDeltaY = 1;
break;

// Heal yourself
case '2':
nDeltaX = -1;
nDeltaY = 0;
break;

// Open Door
case '3':
    OpenDoorCommand();
    break;
// Chop Tree
case '4':
ChopTreeCommand();
                break;

// Not a valid direction
default:
// No direction specified, so abort
console.Clear();
return;


}

Pages: [1]