(Warning: noob code).
Is there a way to make this console program portable?
#1 Members - Reputation: 116
Posted 18 June 2012 - 09:09 AM
(Warning: noob code).
#2 Members - Reputation: 878
Posted 18 June 2012 - 03:36 PM
On unix based operating systems (linux, mac, etc) there is a library called ncurses, which can be used to manipulate the terminal in various ways (this library is not available on windows).
So, ultimately, I think you'll have to write a render function that will have two implementations: one for windows, using whatever you're using now, and one for unix based systems, using ncurses.
Small and simple Python 3.x media library: pslab
#3 Crossbones+ - Reputation: 1003
Posted 18 June 2012 - 03:44 PM
#4 Moderators - Reputation: 7470
Posted 18 June 2012 - 04:45 PM
[Work - ArenaNet] [Epoch Language] [Scribblings] [Journal - peek into my shattered mind]
#5 Members - Reputation: 116
Posted 18 June 2012 - 07:34 PM
First: So is there a way I could change the color of the console and set the cursor to the 0 position in the unix based OS' console without the use of external libraries? Or is using NCurses the only way?
Second: I had a lot of fun trying to make this program on the console, The challenges felt great to overcome, and the feeling I got when I first tried out the program was even better! Programming is amazing!!!! My goal is to try to emulate an event driven mini-rpg in the console. Is this too much or impossible? If anyone has an example of what I'm trying to do, please let me review it!!!! It would be great to see that I'm not alone!
Any advice or tips on what I should do next would be appreciated!
#7 Crossbones+ - Reputation: 3512
Posted 19 June 2012 - 01:40 AM
Going on what Goran said, you will do an operating system check at the start of your program and decide which function/functions you want to use to change colors. You will use your <Windows.h> functions if the OS is Windows and if not, use NCurses.
Uhh I am unsure how you will be doing an OS check within the program itself considering Windows and Linux do not run the same executable format. I think you meant conditional compilation as such:
#ifdef WIN32 #include <windows.h> #else #include <ncurses.h> #endif
Or something in that vein. So that when you build your program you get two outputs - one for Windows and one for Linux, and they will both use their respective libraries.
#8 Members - Reputation: 3678
Posted 19 June 2012 - 02:11 AM
Thanks for the cool advice! I like the OS check idea! I was trying to do as much as I could with the console without the use of NCurses, PDCurses, etc. I never used those libraries so I don't know how to work with them yet, but I'll look into it!
First: So is there a way I could change the color of the console and set the cursor to the 0 position in the unix based OS' console without the use of external libraries? Or is using NCurses the only way?
curses isn't really an external library, it is the standard library for console manipulation in UNIX (it is part of the UNIX specification), ncurses is the modern replacement for it and is part of Linux, BSD and OS X. (ncurses is backwards compatible with curses so if you include curses.h rather than ncurses.h and restrict yourself to the old curses API you should be able to build your app on any *nix system released after ~1983)
The voices in my head may not be real, but they have some good ideas!
#10 Crossbones+ - Reputation: 1003
Posted 19 June 2012 - 05:48 PM
Going on what Goran said, you will do an operating system check at the start of your program and decide which function/functions you want to use to change colors. You will use your <Windows.h> functions if the OS is Windows and if not, use NCurses.
Uhh I am unsure how you will be doing an OS check within the program itself considering Windows and Linux do not run the same executable format. I think you meant conditional compilation as such:#ifdef WIN32 #include <windows.h> #else #include <ncurses.h> #endif
Or something in that vein. So that when you build your program you get two outputs - one for Windows and one for Linux, and they will both use their respective libraries.
#11 Members - Reputation: 305
Posted 19 June 2012 - 06:42 PM
Certainly. For RPGs using the console, some fall into the Roguelike subcategory.Second: I had a lot of fun trying to make this program on the console, The challenges felt great to overcome, and the feeling I got when I first tried out the program was even better! Programming is amazing!!!! My goal is to try to emulate an event driven mini-rpg in the console. Is this too much or impossible? If anyone has an example of what I'm trying to do, please let me review it!!!! It would be great to see that I'm not alone!
Any advice or tips on what I should do next would be appreciated!
Typical attributes of a roguelike include:
1) Is an RPG.
2) Uses dynamically-created content (rather than content being created before the game, the game itself creates some or all of the content).
3) Uses text as a display - 'T' to represent a tree, for example.
4) Permadeath - That is, if your character dies, that game is over and your save is erased. This makes Roguelikes one of the few types of games that fully qualify as a challenge.
OTOH, you may be thinking of a text adventure - Zork is a classic example of a Text Adventure.
Typical attributes of a text adventure include:
1) It's a puzzle game.
2) Uses entirely pre-generated and often very deep content.
3) Everything is represented by descriptive text and/or relatively static pictures.
4) Commands are given in the form of short sentences usually with no more than one noun, verb and/or object.
Edited by Narf the Mouse, 19 June 2012 - 06:42 PM.
#12 Members - Reputation: 116
Posted 19 June 2012 - 07:23 PM
It pretty much puts down what I'm trying to do, but I understand where the OP is coming from. For instance, the console is not the best medium for event driven games.
Does anyone else think its a good idea for me to start working with graphics instead of the console?
#13 Members - Reputation: 305
Posted 19 June 2012 - 07:49 PM
Does the type of games we want to make, matter to the type of game you want to make? Should it? How and how much?Nice info Narf! I was snooping around the internet and came across this article. http://www.cplusplus...icles/G13hAqkS/
It pretty much puts down what I'm trying to do, but I understand where the OP is coming from. For instance, the console is not the best medium for event driven games.
Does anyone else think its a good idea for me to start working with graphics instead of the console?
#14 Members - Reputation: 116
Posted 19 June 2012 - 08:25 PM
I totally agree with you. I like what I've been doing. The challenges of trying to make the console work the way I want it to feel great to overcome!Does the type of games we want to make, matter to the type of game you want to make? Should it? How and how much?
Nice info Narf! I was snooping around the internet and came across this article. http://www.cplusplus...icles/G13hAqkS/
It pretty much puts down what I'm trying to do, but I understand where the OP is coming from. For instance, the console is not the best medium for event driven games.
Does anyone else think its a good idea for me to start working with graphics instead of the console?
I also have been wanting to get back into programming games with graphics like I did in high school (2005), but I've just recently got back into programming, and I've forgotten many things. I'm relearning everything one step at a time.
The reason I was trying to make a Roguelike style game in the console was that I thought doing so would make programming graphics games easier. In other words I dont have much confidence in my moving up to Graphical games.
So a little question. Based on the program I made in the console, does anything think I'm ready to move on to programming graphical games?
The program I made was pretty basic. I've also made text based RPG's in the console with a battle system, an inventory, some quests, and etc.
Any advice/constructive criticism would be very much appreciated!







