Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

curses roguelike starter code

Name: Anonymous 2012-06-11 9:55

found an old roguelike tutorial that teaches the basics but its code was written for some simplified windows console library. i redid the tutorial using curses for a game im working on. here is the code if anyone wants a template to experiment with roguelike stuff.

#include <curses.h>

// Map dimensions
#define MAP_WIDTH  20
#define MAP_HEIGHT 15

// Tile definitions
#define TILE_FLOOR 0
#define TILE_WALL  1
#define TILE_GRASS 2
#define TILE_OPENDOOR 3

// Map array
int MapArray[MAP_HEIGHT][MAP_WIDTH] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

// Map drawing function
void DrawMap( void ) {
  for( int y = 0; y < MAP_HEIGHT; y++ ) {
   
    // Jump to next line
    move( y, 0 );
    for( int x = 0; x < MAP_WIDTH; x++ ) {
      switch( MapArray[y][x] ) {

        // Draw tiles
        case TILE_FLOOR:
          attron( COLOR_PAIR(3) );
          addch('.');
          attroff( COLOR_PAIR(3) );
        break;

        case TILE_WALL:
          addch('#');
        break;
      }
    }
  }
}

// Collision detect function
bool IsPassable( int MapX, int MapY ) {

  // Make area outside map impassible
  if( MapX < 0 || MapX >= MAP_WIDTH || MapY < 0 || MapY >= MAP_HEIGHT )
  return false;

  // Store the value of the tile specified
  int TileValue = MapArray[MapY][MapX];

  // Return true if it's passable
  if( TileValue == TILE_FLOOR || TileValue == TILE_GRASS || TileValue == TILE_OPENDOOR )
  return true;

  // If execution gets here, it's not passable
  return false;
}


int main( void ) {

  // Init curses
  keypad( initscr(), 1 );
  curs_set( 0 );

  // Init colors
  start_color();
  init_pair( 1, COLOR_RED, COLOR_BLACK );
  init_pair( 2, COLOR_YELLOW, COLOR_BLACK );
  init_pair( 3, COLOR_GREEN, COLOR_BLACK );
  init_pair( 4, COLOR_BLUE, COLOR_BLACK );

  // Init start position
  int PlayerX = 4;
  int PlayerY = 4;

  // Game Loop
  while( true ) {

    // Refresh screen
    refresh();

    // Draw map
    DrawMap();
   
    // Draw player
    attron( COLOR_PAIR(2) );
    mvaddch( PlayerY, PlayerX, '@' );
    attroff( COLOR_PAIR(2) );

    // Wait for input
    char PlayerKey = getch();

    // Process input
    switch( PlayerKey ) {

      case 'k': // Up
        if( IsPassable( PlayerX, PlayerY - 1 ) ) {
          PlayerY--;
        }
      break;

      case 'j': // Down
        if( IsPassable( PlayerX, PlayerY + 1 ) ) {
          PlayerY++;
        }
      break;

      case 'h': // Left
        if( IsPassable( PlayerX - 1, PlayerY ) ) {
          PlayerX--;
        }
      break;

      case 'l': // Right
        if( IsPassable( PlayerX + 1, PlayerY ) ) {
          PlayerX++;
        }
      break;

      case 'q': // Quit
      return endwin();
    }
  }
}

Name: Anonymous 2012-06-11 10:23

just stop fiddling and learn DirectX. you know that's what you want to do anyway.

Name: Anonymous 2012-06-11 10:38

>>2

stop saging actual programming threads with bad trolls

Name: Anonymous 2012-06-11 11:56

>>3
This. OpenGL 4.x is way better than DirectX.

Name: Anonymous 2012-06-11 12:40

>>4
not for vidya though

Name: mjk 2012-06-11 16:23

>>5
Really? What feature of DirectX 11 isn’t available with OpenGL 4.1 + CUDA or OpenCL?
NVIDIA’s OpenGL can inter-operate with buffers and textures for either CUDA or OpenCL or DirectX or even OptiX. DirectX 11 can only interop with DirectX buffers and surfaces. This seems like a situation where OpenGL is clearly MORE functional than Direct3D. You can look at the NV_gpu_program5, NV_shader_buffer_load, and ARB_texture_buffer_object extensions to see how an OpenGL shader can read, and yes, even STORE to buffers.
OpenGL has plenty of features not available in DirectX 11 such as line stipple, accumulation buffers, immediate mode, display lists, smooth lines, access to shaders through both high-level shading languages (Cg or GLSL) as well as assembly language (NV_gpu_program5, NV_gpu_program4, ARB_fragment_program, etc.). And this all comes with cross-operating system portability, something DirectX 11 will never offer.
For example, OpenGL 4.1′s entire feature set, including programmable geometry and tessellation shaders and all the other DirectX 10 and 11 features are available on Windows XP as well as Vista and Windows 7.
OpenGL 4.1 supports both OpenGL and Direct3D conventions. So in Direct3D, you are stuck with the Direct3D provoking vertex or shader window origin convention, but with OpenGL 4.1 you can now pick your convention.
NVIDIA OpenGL has lots of ways it surpasses DirectX 11 in functionality such as support for bindless graphics (NV_vertex_buffer_unified_memory & NV_shader_buffer_load), arbitrary texture format swizzling EXT_texture_swizzle), Serial Digital Interface (SDI) video support (NV_present_video) including video capture (NV_video_capture).
BTW, you can get the actual PowerPoint slides from here: http://www.slideshare.net/Mark_Kilgard/opengl-4-for-2010
(This slides are corrected and slightly expanded from the recorded presentation. For example, they include code for implementing adaptive PN triangles.)

Name: Anonymous 2012-06-11 17:47

>>6
Mark J. Kilgard

Nvidia is a bad company and you should feel bad.

Name: Anonymous 2012-06-11 18:41

everyone on /prog/ is 16 years old and never played nethack

Name: Anonymous 2012-06-11 18:47

>>1
Reposting your code with code tags, OP. In the name of all that is holy, use them in the future.

#include <curses.h>

// Map dimensions
#define MAP_WIDTH  20
#define MAP_HEIGHT 15

// Tile definitions
#define TILE_FLOOR 0
#define TILE_WALL  1
#define TILE_GRASS 2
#define TILE_OPENDOOR 3

// Map array
int MapArray[MAP_HEIGHT][MAP_WIDTH] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

// Map drawing function
void DrawMap( void ) {
  for( int y = 0; y < MAP_HEIGHT; y++ ) {
  
    // Jump to next line
    move( y, 0 );
    for( int x = 0; x < MAP_WIDTH; x++ ) {
      switch( MapArray[y][x] ) {

        // Draw tiles
        case TILE_FLOOR:
          attron( COLOR_PAIR(3) );
          addch('.');
          attroff( COLOR_PAIR(3) );
        break;

        case TILE_WALL:
          addch('#');
        break;
      }
    }
  }
}

// Collision detect function
bool IsPassable( int MapX, int MapY ) {

  // Make area outside map impassible
  if( MapX < 0 || MapX >= MAP_WIDTH || MapY < 0 || MapY >= MAP_HEIGHT )
  return false;

  // Store the value of the tile specified
  int TileValue = MapArray[MapY][MapX];

  // Return true if it's passable
  if( TileValue == TILE_FLOOR || TileValue == TILE_GRASS || TileValue == TILE_OPENDOOR )
  return true;

  // If execution gets here, it's not passable
  return false;
}


int main( void ) {

  // Init curses
  keypad( initscr(), 1 );
  curs_set( 0 );

  // Init colors
  start_color();
  init_pair( 1, COLOR_RED, COLOR_BLACK );
  init_pair( 2, COLOR_YELLOW, COLOR_BLACK );
  init_pair( 3, COLOR_GREEN, COLOR_BLACK );
  init_pair( 4, COLOR_BLUE, COLOR_BLACK );

  // Init start position
  int PlayerX = 4;
  int PlayerY = 4;

  // Game Loop
  while( true ) {

    // Refresh screen
    refresh();

    // Draw map
    DrawMap();
  
    // Draw player
    attron( COLOR_PAIR(2) );
    mvaddch( PlayerY, PlayerX, '@' );
    attroff( COLOR_PAIR(2) );

    // Wait for input
    char PlayerKey = getch();

    // Process input
    switch( PlayerKey ) {

      case 'k': // Up
        if( IsPassable( PlayerX, PlayerY - 1 ) ) {
          PlayerY--;
        }
      break;

      case 'j': // Down
        if( IsPassable( PlayerX, PlayerY + 1 ) ) {
          PlayerY++;
        }
      break;

      case 'h': // Left
        if( IsPassable( PlayerX - 1, PlayerY ) ) {
          PlayerX--;
        }
      break;

      case 'l': // Right
        if( IsPassable( PlayerX + 1, PlayerY ) ) {
          PlayerX++;
        }
      break;

      case 'q': // Quit
      return endwin();
    }
  }
}

Name: Anonymous 2012-06-11 19:26

Here's a better version that loads 40x20 character maps (easily changeable) from a plaintext file into the array and colorizes the map by character. Also there's working doors and improved movement code.



#include <curses.h>
#include <fstream>
using namespace std;

// Map dimensions
#define MAP_WIDTH  41
#define MAP_HEIGHT 20

// Map array
char MapArray[MAP_HEIGHT][MAP_WIDTH];

// Map drawing function
void DrawMap( void ) {
  for( int y = 0; y < MAP_HEIGHT; y++ ) {
    for( int x = 0; x < MAP_WIDTH; x++ ) {
      if( MapArray[y][x] == '*' ) // Green grass
        attron( COLOR_PAIR(3) );
      if( MapArray[y][x] == '~' ) // Blue water
        attron( COLOR_PAIR(4) );
      if( MapArray[y][x] == 'Y' ) // Brown tree
        attron( COLOR_PAIR(2) );
      if( MapArray[y][x] == '^' ) // Red mountain
        attron( COLOR_PAIR(1) );
      mvaddch(y, x, MapArray[y][x]);
      attroff( COLOR_PAIR(2) );   // Reset color
    }
  }
}

// Collision detect function
bool IsPassable( int MapX, int MapY ) {

  // Make area outside map impassible
  if( MapX < 0 || MapX >= MAP_WIDTH || MapY < 0 || MapY >= MAP_HEIGHT )
  return false;

  int Ch = MapArray[MapY][MapX];

  // Check which characters are passible.
  if( Ch == '.' || Ch == '*' || Ch == '/' )
  return true;

  // Otherwise not passible
  return false;
}


int main( void ) {

  // Init curses
  keypad( initscr(), 1 );
  curs_set( 0 );

  // Init colors
  start_color();
  init_pair( 1, COLOR_RED, COLOR_BLACK );
  init_pair( 2, COLOR_YELLOW, COLOR_BLACK );
  init_pair( 3, COLOR_GREEN, COLOR_BLACK );
  init_pair( 4, COLOR_BLUE, COLOR_BLACK );
  init_pair( 5, COLOR_CYAN, COLOR_BLACK );

  // Load map
  ifstream file;
  file.open( "maps/start.map" );
  for(int y = 0; y < MAP_HEIGHT; y++) {
    for(int x = 0; x < MAP_WIDTH; x++) {
      file.get(MapArray[y][x]);
    }
  }
  file.close();

  // Init start position
  int PlayerX = 11;
  int PlayerY = 7;
 
 // Game Loop
  while( true ) {

    // Refresh screen
    refresh();

    // Draw map
    DrawMap();
   
    // Draw player
    attron( COLOR_PAIR(5) );
    mvaddch( PlayerY, PlayerX, '@' );
    attroff( COLOR_PAIR(5) );

    // Wait for input
    char PlayerKey = getch();

    // Process the input
    int DeltaX, DeltaY;

    switch( PlayerKey ) {

      // Move up
      case 'k':
        DeltaX = 0;
        DeltaY = -1;
        break;

      // Move left
      case 'h':
        DeltaX = -1;
        DeltaY = 0;
        break;

      // Move right
      case 'l':
        DeltaX = 1;
        DeltaY = 0;
        break;

      // Move down
      case 'j':
        DeltaX = 0;
        DeltaY = 1;
        break;

      // Quit
      case 'q':
        return endwin();
    }

    // Check if direction is passable
    if( IsPassable(PlayerX + DeltaX, PlayerY + DeltaY) ) {
      PlayerX += DeltaX;
      PlayerY += DeltaY;
    }

    // Open doors
    if( MapArray[PlayerY + DeltaY][PlayerX + DeltaX] == '+' ) {
      MapArray[PlayerY + DeltaY][PlayerX + DeltaX] = '/';
    }
  }
}

Name: Anonymous 2012-06-11 19:41

>>10
Segfaults when I try to move the character.

Name: Anonymous 2012-06-11 19:43

>>11
Just kidding. However the character does not actually move.

Name: Anonymous 2012-06-11 19:53

>>12

it uses the traditional h,j,k,l control scheme because i was too lazy to look up the scan codes

Name: Anonymous 2012-06-11 19:58

>>13
I should clarify that even with this control scheme, the character doesn't move. I assume it is working on your end so it's probably an issue on my side.

With that said, good luck with your roguelike.

Name: Anonymous 2012-06-11 20:50

just to clarify this loads maps from an external file to allow editing without recompiling.

create maps/start.map in the folder of the executable

paste this:

^^*^*^^^********************************
^*^^^^**********************Y***********
^^^***************Y******Y**************
*^********************************Y*****
^^*****#######*********Y****************
^******#.....#**************Y***********
*******#.....#**************************
*******#.....#**************************
**Y****###+###*******~~~~~*********Y****
*******************~~~~~~~~*************
*******************~~~~~~~~*************
*********************~~~~~***Y**********
****Y***********************************
****************************************
***********************************Y****
****************************************
*********************####+#####*********
***************Y*****#........#*********
****Y****************#........#*********
*********************##+###...#**Y******
************Y********#....#...#*********
*********************#....#...#*******Y*
*******Y*************##########*********
****************************************


or create your own map via a text editor or JavE. after i write the dungeon and terrain algos ill change it so it loads and saves the maps to files so everything stays put.

Name: Anonymous 2012-06-11 21:34

>>13
h j k l is shit

C-f, C-b, C-n, C-p FTW

Name: Anonymous 2012-06-12 0:02

http://www.assembla.com/spaces/consolerpg/wiki this is a roguelike I had worked on in the past, needs work obviously but a bunch of it is already written, just use what is inside the Working folder in branches

Name: Anonymous 2012-06-12 0:31

system("PAUSE");
Platform-dependent code detected.

Name: Anonymous 2012-06-12 1:25

>>18
That's like saying POSIX is platform-dependent.  Non-Windows compliant systems are shit and noone uses them.  Fuck you.

Name: Anonymous 2012-06-12 1:26

>>19
Why are you so mad? You should improve your code, otherwise no one will want to use it.

Name: Anonymous 2012-06-12 7:31

>>19
You know that 'P' ins POSIX? You know what it stands for? FUCKING PORTABLE. You know what POSIX is? It's a FUCKING STANDARD.

Name: Anonymous 2012-06-12 7:57

>>19
5/10

Name: Lambda A. Calculus 2012-06-12 10:51

>>18
EEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

It's not system dependent, system is PART OF THE STANDARD!

u stupid ...
EEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

... retoid!

Name: Anonymous 2012-06-12 11:27

>>23
And what the command-line program 'pause'? Is 'pause' part of THE STANDARD?

NO!.

Name: Anonymous 2012-06-12 11:31

It's unforgivable to program in POSIX modo unless you're an elementary school kid.

Name: Anonymous 2012-06-12 14:59

here is a working version of the code with a hardcoded map for simplicity and placeholders for text windows and all that. to person talking about 'pause', i dont know where you saw that because this code depends on nothing but curses, which is available on any platform.


#include <curses.h>

// Map dimensions
#define MAP_WIDTH  40
#define MAP_HEIGHT 24

// Map array
char MapArray[MAP_HEIGHT][MAP_WIDTH + 1]={

"^^*^*^^^********************************",
"^*^^^^**********************Y***********",
"^^^***************Y******Y**************",
"*^********************************Y*****",
"^^*****#######*********Y****************",
"^******#.....#**************Y***********",
"*******#.....#**************************",
"*******#.....#**************************",
"**Y****###+###*******~~~~~*********Y****",
"*******************~~~~~~~~*************",
"*******************~~~~~~~~*************",
"*********************~~~~~***Y**********",
"****Y***********************************",
"****************************************",
"***********************************Y****",
"****************************************",
"*********************####+#####*********",
"***************Y*****#........#*********",
"****Y****************#........#*********",
"*********************##+###...#**Y******",
"************Y********#....#...#*********",
"*********************#....#...#*******Y*",
"*******Y*************##########*********",
"****************************************"
};

// Map drawing function
void DrawMap( void ) {
  for( int y = 0; y < MAP_HEIGHT; y++ ) {
    for( int x = 0; x < MAP_WIDTH; x++ ) {
      if( MapArray[y][x] == '*' ) // Green grass
        attron( COLOR_PAIR(3) );
      if( MapArray[y][x] == '~' ) // Blue water
        attron( COLOR_PAIR(4) );
      if( MapArray[y][x] == 'Y' ) // Brown tree
        attron( COLOR_PAIR(2) );
      if( MapArray[y][x] == '^' ) // Red mountain
        attron( COLOR_PAIR(1) );
      if( MapArray[y][x] == '+' ) // Brown door closed
        attron( COLOR_PAIR(2) );
      if( MapArray[y][x] == '/' ) // Brown door open
        attron( COLOR_PAIR(2) );
      mvaddch(y, x, MapArray[y][x]);
      attroff( COLOR_PAIR(2) );   // Reset color
    }
  }
}

// Collision detect function
bool IsPassable( int MapX, int MapY ) {

  // Make area outside map impassible
  if( MapX < 0 || MapX >= MAP_WIDTH || MapY < 0 || MapY >= MAP_HEIGHT )
  return false;

  int Ch = MapArray[MapY][MapX];

  // Check which characters are passible.
  if( Ch == '.' || Ch == '*' || Ch == '/' )
  return true;

  // Otherwise not passible
  return false;
}


int main( void ) {

  // Init curses
  keypad( initscr(), 1 );
  curs_set( 0 );

  // Init colors
  start_color();
  init_pair( 1, COLOR_RED, COLOR_BLACK );
  init_pair( 2, COLOR_YELLOW, COLOR_BLACK );
  init_pair( 3, COLOR_GREEN, COLOR_BLACK );
  init_pair( 4, COLOR_BLUE, COLOR_BLACK );
  init_pair( 5, COLOR_CYAN, COLOR_BLACK );
  init_pair( 6, COLOR_MAGENTA, COLOR_BLACK );

  // Init start position
  int PlayerX = 9;
  int PlayerY = 5;
 
 // Game Loop
  while( true ) {

    // Refresh screen
    refresh();

    // Draw map
    DrawMap();
   
    // Draw player
    attron( COLOR_PAIR(5) );
    mvaddch( PlayerY, PlayerX, '@' );
    attroff( COLOR_PAIR(5) );

    // Info screen
    mvprintw(0, 41, "[name] the [title]");

    attron( COLOR_PAIR(1) );
    mvprintw(2, 41, "Life: xxx/xxx");
    attroff( COLOR_PAIR(1) );

    attron( COLOR_PAIR(2) );
    mvprintw(3, 41, "Level: xx");
    attroff( COLOR_PAIR(2) );

    attron( COLOR_PAIR(3) );
    mvprintw(2, 66, "Mana: xxx/xxx");
    attroff( COLOR_PAIR(3) );

    attron( COLOR_PAIR(5) );
    mvprintw(3, 66, "Exp: xxxxxxxx");
    attroff( COLOR_PAIR(5) );

    // Inventory screen
    mvprintw(5, 41, "---------------------------- Inventory");

    // Message screen
    mvprintw(16,41, "----------------------------- Messages\n");
    // Wait for input
    char PlayerKey = getch();

    // Process the input
    int DeltaX, DeltaY;

    switch( PlayerKey ) {

      // Move up
      case 'k':
        DeltaX = 0;
        DeltaY = -1;
        break;

      // Move left
      case 'h':
        DeltaX = -1;
        DeltaY = 0;
        break;

      // Move right
      case 'l':
        DeltaX = 1;
        DeltaY = 0;
        break;

      // Move down
      case 'j':
        DeltaX = 0;
        DeltaY = 1;
        break;

      // Quit
      case 'q':
        return endwin();
    }

    // Check if direction is passable
    if( IsPassable(PlayerX + DeltaX, PlayerY + DeltaY) ) {
      PlayerX += DeltaX;
      PlayerY += DeltaY;
    }

    // Open doors
    if( MapArray[PlayerY + DeltaY][PlayerX + DeltaX] == '+' ) {
      MapArray[PlayerY + DeltaY][PlayerX + DeltaX] = '/';
    }
  }
}

Name: Anonymous 2012-06-12 19:40

>>26
He was talking about the other faggot who posted a link to their repo.

Name: Lambda A. Calculus 2012-06-13 0:06

>>24
AS FAR AS C'S CONCERNED YOU AIN'T PART OF THE STANDARD.

Don't change these.
Name: Email:
Entire Thread Thread List