You are not logged in.

#1 2008-06-22 01:14:16

magnum_opus
Member
Registered: 2005-01-26
Posts: 132

ncurses problem (probably)

http://nopaste.info/6950a0eb9b.html (note lines 150,151,153,155,156 lost a space there, probably need to add an extra space)

okay so I know C fair to middling-ly well and I sat down and wrote this psuedo roguelike I'm calling Library of Babel (after the story).
everything SEEMS to work like I expect it too, except the text display when you walk against a book ('B').
sometimes it works fine and most things are displayed as blank spaces and the letters that should appear do so, but other times every thing that should be a space is a '`' or an a with an accent, and the letters are completlely off.

I think it's an display problem because i can't see what in my code would make anything change between instances.
That said this is the first time I've ever used Ncurses (so please excuse what is probably very naive code).
also I'm not exactly a C genius so something may be going on that I'm not aware of.

Any Ideas?


Thanks for your time.

Offline

#2 2008-06-22 09:35:25

elgatofelix
Member
From: Chile
Registered: 2007-07-03
Posts: 137

Re: ncurses problem (probably)

nothjing better to do so i will try to solve it. so far i have this

displaypoem function
32 (0 case) + 64 (default)   = 96: ` 

// convert numbers to desired ASCII values 
  for (loop = 0; loop < 200; loop++)
    {
      switch (words[loop])
        {
        case 0:
          words[loop] = 32;
          break;
        case 27:
          words[loop] = 44;
          break;
        case 28:
          words[loop] = 46;
          break;
        case 29:
          words[loop] = 63;
          break;
        case 32:
            break;
        default:
          words[loop] += 64;
        }
    }

added the 32 case so it wont add 64 and print ` (the other weird characters originated from this one)

Last edited by elgatofelix (2008-06-22 09:56:28)


Are u listening?

Offline

#3 2008-06-22 15:22:07

magnum_opus
Member
Registered: 2005-01-26
Posts: 132

Re: ncurses problem (probably)

okay, cool thanks. file that under things about C i didn't know.

I didn't think it would trigger more than once in a switch statement.

you rock man.

Offline

Board footer

Powered by FluxBB