Jump to content
  • Advertisement
Sign in to follow this  
MikeWhiskyTango

Converting a C++ console game to SDL?

This topic is 3087 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have created a submarine game in visual express as a project to teach myself C++. I would quickly describe the game as a cross between a RPG and RTS. It is not a shoot ‘em up, nor does it really require any graphics, since the player is inside a sub. It is based on real world submarine tactics and sonar useage etc. It is one player versus an enemy sub which is controlled by AI, its ability dependent on the randomly generated captains skills at the start of each game scenario. The distance between the subs is a factor but again no graphics are needed and the changing distance after the start of the game is not known to the player until a strong sonar contact is made on the enemy sub and then the range is displayed . Players enter depth and speed and sonar type etc and can make tactical manoeuvres. All this works well as a C++ console application.
I decided then to create graphics for it, and downloaded SDL and installed it. I read the Lazy Foo, Cone 3D, Aarron tutorials but the games were Tetris and starships shooting etc which is not the style of game I am creating. Nevertheless, I created a sonar-panel with buttons to push, ie; launch torpedo etc with various depth and speed displays and a ‘screen’ where I want the game program to interact with the player ie; ask the player to input various selections etc. All these graphics I drew up in Designer and exported as a PNG as a background into the SDL program. I also made a sprite sheet with key buttons which light up when pressed etc.
My problem is this. I now have two separate programs, one is the original completed console based sub game with all its couts and cins , AND then I also have a SDL program with the background and sprite buttons I created etc. What I don't understand is how to actually amalgamate the two and get my sub game actually working in the SDL as it does on the console? The console game has a lot of cout, but the SDL seems to require a long function just to get one line of text to appear. For instance, in the SDL program I want the player to press the button to launch a torpedo or change depth or change speed or heading etc. In the console app this was easily performed as a cout and cin. And, although I can see the KEYDOWN event in the SDL program I just cannot see how to make it do the same thing as in the console application. Does the keydown code need to be coded every time the player is required to make a keypress in all the functions? The same as for cout, in the SDL, each time text is to appear on screen does it require all the code associated with it as to position, and colour etc,
I feel really frustrated at not making the connection here, any help would be great thank you.

Share this post


Link to post
Share on other sites
Advertisement
I know this feeling, there are times I wish sdl had some built in text support too so I could quickly display some variables etc that I want to look at without having to go into debug mode. Anyway I think your best bet would be to use SDL_ttf(look it up in google) to help render text to the screen, create a class or functions that will take a string and then just place the rendered text to the screen.

Share this post


Link to post
Share on other sites
I have already installed SDL ttf and got text to appear on my SDL program. Its the actual reprogramming of all the original cout's (in the console app.) into the SDL program and getting them to appear when required that confuses me. Ideally inside a text box would be great.

Share this post


Link to post
Share on other sites
Right I think what you might want to look at then is using some kind of gui api like guichan or cegui then which gives you things like textbox widgets etc and works with SDL.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!