making a windowed program

I did a little game coding with my compiler, but it only runs on console, how do I make it a window application so it can be more fun to play?
Well, you could always use Win32, but if you don't feel like jumping into something that big, there are other Libraries / APIs to do so. SFML, Qt, SDL... there is a lot. But in my experience, if you aren't good with setting up external libraries, than I would just download the Qt Creator with MinGW.

Btw, you may want to add more information
Thank you so much @AceDwg45 that was helpful....I downloaded qt creator and the inbuilt tutorial I read was directed to what I want.
for game creation, i suggest you SFML library
it is designed for games
and it is very easy to learn
SFML library fir games design Ok. Pls which library is for arithmetics/solving equations?
You can use really anything for arithmetic. Just basic C++ with no headers can do basic arithmetic. If you need more advanced stuff, just include <cmath> at the top of your project. It is built in to pretty much all compilers.
Ok, thanks again.
One note if I may:
If you are doing math calculation with float/double don't forget about rounding error: (about half way to the text)
http://www.learncpp.com/cpp-tutorial/25-floating-point-numbers/
<cmath>'s Pi is a lie. (but still pretty decent)
@vlkon I tried that and the msg was expected constructor, destructor, or type conversion before ';' token



#include <iostream>
#include <iomanip>
using namespace std;
setprecision ();
int main () {
cout<<setprecision(16)<<endl;
double a = 22/7;
cout<<a<<endl;
return 0;
}
setprecision (); <- remove this line before main. setprecision is in the <iomanip> header - you don't need to declare it separately.

22/7 will give you an integer division result - 22.0/7.0 will give you a double result.
qt is a widely used program for user interfaces, however, I'm not sure it's the direction you want to go for gaming. For loaders, menu screens, etc it's great but for gaming itself it's better to go for a graphical library.

That stated, I'd recommend SDL. It eases you in quite nicely, even in regards to learning external api's, and has quite a bit of depth to explore as you learn things! It gives you a foundation of working with graphical api's, is built using open gl/el, and can work side by side with open gl/el.

Look up lazyfoo if you intend to go this route, his tutorials are excellent, even though a little outdated. Start from SDL1.3, and once you have the basics down switch to 2.0, learn about rendering, then if you feel bold, dive into opengl, and start learning about pipelines.

The nice thing about SDL is it's cross platform(windows, linux, ios, etc), and has open doors to more advanced methods that professional game studios use.

TL;DR if you want to learn something that will help you later on if you want to get into graphical programming, or something that won't lock you in with just one operating system then check out sdl.
@wildblue I remove the setprecision () ; declaration and it worked fine, just that the output wasn't what I was expecting.
Output: 3.142857............
But 22/7 should give me the value for pie=3.14159...........
22/7 is just an approximation for pi.

http://en.wikipedia.org/wiki/Pi
#define PI 3.1415926535897932384626433832795028841971693993751058209
Last edited on
Even with this I don't get the exact value of PI in return.

#include <iostream>
#include <iomanip>
#define PI 3.1415926535897932384626433832795028841971693993751058209
using namespace std;
int main () {
cout<<setprecision(100)<<endl;
double a = PI * 1.0;
cout<<a<<endl;
return 0;
}

Output : 3.141592653589793115997963468544185161590576171875


Why?
Topic archived. No new replies allowed.