Author Topic: Need some total newbie help...  (Read 14297 times)

Rembo

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
    • Email
Need some total newbie help...
« on: April 19, 2011, 10:13:25 PM »
I've recently taken up programming again, both in the little spare time I have and as a course I'm following. Trying to make my self-teaching interesting I'm trying to make a tiny little roguelike to expand my abilities in a 'fun' way  :P I'm running into some very basic problems though, and searching the net doesn't seem to get me anywhere...

Here goes noob-deadlock 1: I'm trying to compile the simple roguelike found here http://pastebin.com/f76161be3. on C++ using VC++ 2010. I've already added the int that appears to be missing (or not... I don't know), placed curses.h, panel.h and pdcurses.lib in a directory that I\v added to the project properties include dirs, and added pdcurses.lib to external dependencies.

It gives me the error: LINK : fatal error LNK1104: cannot open file 'curses.lib'

I'm really at a loss at this point, since this is, contraryb to my earlier statement, far from noob-deadlock #1 for me, including errors about unresolved externals pointing me to functions defined in curses...So basically, I think a little help on this one might... well... help

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Need some total newbie help...
« Reply #1 on: April 20, 2011, 12:07:25 AM »
You seem to be linking to curses.lib not pdcurses.lib?  Change your linker settings to link to the correct file. (project/properties/linker/input)  You can also set the Additional Library Directories to inlude you directory where your lib files are.

Cheers, good luck. 
Also dont forget that google is your friend.  Quite often you can paste the exact error in search and find an answer.
Also you can look at Microsofts MSDN for more help on specific errors, like LNK1104
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Need some total newbie help...
« Reply #2 on: April 20, 2011, 12:30:34 AM »
Ok just ran it myself. (visual studio 9 professional)

  • Step one- start a new console app project and replace main code with the code from Ido.
  • Step two  - download pdcurses3.4
  • Step three - extract into project directory
  • Step four - add "./pdcurses34/include" to properties/c/c++/General/additional include directory
  • Step five - add "pdcurses.lib" to properties/linker/input
  • Step six - add "./pdcurses34/" to properties/linker/general/additional library directory
  • Step seven - add "int" in front of main in code file
  • Step eight - build.
  • Step nine - run - (press a key to get the graphics to display)
  • Step ten - download libtcod and use that instead :)

Cheers.  If you can get this working this is your first step to creating a curses based roguelike.  There are roguelike libraries out there (as I mentioned in step 10) that may help you bypass a lot of the crap associated with creating a roguelike.
« Last Edit: April 20, 2011, 12:37:41 AM by corremn »
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike

Rembo

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
    • Email
Re: Need some total newbie help...
« Reply #3 on: April 20, 2011, 08:36:54 AM »
Wow, speedy replies  ;D It's morning over here now, so I've got to get to work, butI'm testing this stuff out first thing tonight  :P  Thanks a lot already!


//EDIT\\

By Jove, it worked! Thanks a lot! First step taken and all that  :)

Going to look into libtcod, as it seems to be one of the better RL libraries I've come across. Especially the 24bit colour, and AA functions seem quite useful, looking at output alone.

The point of getting curses to work, and working with curses is actually to familiarize myself more with C++, the design process and the code hoops one has to jump through when programming. I thought roguelikes might be an realistic though hard example of a complex unit of code, which I'm craving after so many usefull but ultimately pointless excercises...
« Last Edit: April 20, 2011, 09:59:12 PM by Rembo »

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Need some total newbie help...
« Reply #4 on: April 21, 2011, 01:44:30 AM »
Yeah, after tinkering with the code for a few minutes I got doors, enemies with random movement, hidden map, and circular FOV (you can see through walls though) working.

So actually this code is a great place to start working on a roguelike. You can get a lot of the basics done, which will teach you a lot about roguelike game structure. I think it is a great place to start, you will learn lots, and even release a game that will be quite playable.  If you wanted to move onto libtcod later when you want to do more advanced things, like proper FOV, FOW, and LOS + more.
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike

Rembo

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
    • Email
Re: Need some total newbie help...
« Reply #5 on: April 25, 2011, 07:58:48 PM »
Another question: any pointers when it comes to randomization? As in: any libraries or functions, or random number generators you could recommend? Or would you rather recommend I stick to the rand() function?

dephbokks

  • Newcomer
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Need some total newbie help...
« Reply #6 on: April 25, 2011, 11:10:52 PM »
Another question: any pointers when it comes to randomization? As in: any libraries or functions, or random number generators you could recommend? Or would you rather recommend I stick to the rand() function?

You prolly do not want the rand() function.  In a polished rl you prolly want to use something like Mersenne Twister: http://en.wikipedia.org/wiki/Mersenne_twister. The link also has implementations in various languages. Also, for coherent noise, I like libNoise: http://libnoise.sourceforge.net/.

Rembo

  • Newcomer
  • Posts: 5
  • Karma: +0/-0
    • View Profile
    • Email
Re: Need some total newbie help...
« Reply #7 on: April 26, 2011, 02:47:56 PM »
Thanks for all the great suggestions guys!

First off, I'm goin to ask (formally  :P) if it's okay to ask for miscelaneous help and info on this thread, so as not to clutter this fine board with my jammering.

If the answer to the above is negative, disregard the following jammering :P

EDIT 22:00 2/5

After a lot more tinkering and stuff I've run into another problem. I've been trying to implement a map that's a vector of vectors of chars, in preparation for making my own class/type for mapTiles. I've also been trying to keep every variable and function pertaining to certain areas of the game, like map display, input etc, in separate header files with their own cpp files. The problem I'm running into now is this:
I've declared a vec of vec of chars in Map.h, but unless I make this a 'static', no code in other files seems to be able to access it. Even then it seems to be read only, though i think this is caused by a scope/reference problem... Any ideas,. or do i need to be more specific?
« Last Edit: May 02, 2011, 08:04:51 PM by Rembo »

Darren Grey

  • Rogueliker
  • ***
  • Posts: 2027
  • Karma: +0/-0
  • It is pitch black. You are likely to eat someone.
    • View Profile
    • Games of Grey
Re: Need some total newbie help...
« Reply #8 on: May 06, 2011, 12:40:44 PM »
Feel free to fill the thread with questions - that's partly what the forums are for.

Being relatively unversed in C++ I don't know the solution to your problem, but you'll likely need to give more specific details anyway, in particular showing how you're declaring the vectors and how you're referencing them in other files.

If I were you I'd also do a bit of testing with various circumstances to see where exactly the break occurs.  Can you reference the vectors fine in other functions within the same file?  Can you reference more simple vectors or arrays?  This sort of testing usually highlights the exact problem, which is usually something very simple but overlooked  ;)

Xan

  • Rogueliker
  • ***
  • Posts: 78
  • Karma: +0/-0
    • View Profile
Re: Need some total newbie help...
« Reply #9 on: May 06, 2011, 03:00:11 PM »
If you're declaring it in a header file, you should be marking it as extern, and declaring it internally in some other source file (probably Map.cpp).

corremn

  • Rogueliker
  • ***
  • Posts: 700
  • Karma: +0/-0
  • SewerJack Extraordinaire
    • View Profile
    • Demise RogueLike Games
Re: Need some total newbie help...
« Reply #10 on: May 10, 2011, 03:03:36 AM »
This is a standard problem encountered in c++ newbies, and with c++ there are lots of answers.
 First you have to understand that headers are not designed for storing variables, it is more letting other code know that a variable exists and the variable is defined elsewhere.  This is called forward declaration as you need to provide the "definition" elsewhere.

I.e you can use the extern term in your header to let your code know that the variable is actually defined in a c file somewhere.  This is more of a 'c' work around.  This will let your code access the variable even though is it instantiated in another c file.

Code: [Select]
extern int map[10][10] ; //in header file.
int map[10][10]; //in a c file.
map[1][5] =1; //in another c file that includes your header file.

You can also use static keyword as well, as you discovered. This lets the compiler know that there is only one instance of this variable so it can safely be shared among code.  

If it is part of a class, you would then similarly need an instance of the class to access it, unless it is once again static.

This probably will lead you to another problem down the track, getting access to the class that has the variable.  I.e your monster class will need access to your dungeon class which contains your map variable.  But since you have not mentioned about classes I will leave that for another time.
« Last Edit: May 10, 2011, 03:10:59 AM by corremn »
corremn's Roguelikes. To admit defeat is to blaspheme against the Emperor.  Warhammer 40000 the Roguelike