View Full Version : Easiest graphics on C++ is...?


WAJ
05-09-02, 08:51 AM
Right, I'm new to C++ and I have been given a chellenge, and I have no idea how to go about doing it. I'm using Microsoft Visual C++ and I need to know the easiest way to create graphics on screen.

Specifically, a square. A 2d outlined square.

I know it's lame but I haven't done anything graphical before and I want to work up from the easiest :)

I'm going into a Computer Games Technology course this year and I want a head start (as far as programming knowledge goes).

Thanks for any help guys!

Rick
05-09-02, 01:08 PM
WAJ,
ZION TO RESCUE!!;)



#include"stdio.h"
#include"conio.h"
#include"graphics.h"
#include"alloc.h"
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm," c:\\turboc2\\bgi"); /*you can give your path,this function basically initializes the graphics mode,gm is for graphics mode,i had set gd=DETECT in previous statement to autodetect the mode you"re using,wether CGA,VGAHI etc...*/
rectangle(100,100,100,100);//the above coordinates are the two opposite points of a rectangle,manipulate them to your own use
closegraph();
}


anything else you wanna ask,like how to make GUI,point 'n shoot menus,some simple 2D games like Pacman,Mario etc,i"ll help you out...
(That is if i find time from my Multi-processor ordeal)

bye!

WAJ
05-09-02, 04:18 PM
Thanks, zion, that simple? Although what is the path you're talking about? Path to what?

As it stands it "cannot execute program".

You must excuse my ignorance of c++, i've no idea. If I get this working, I might move onto things like images (or complex shapes, i don't know what you can do), that all sounds groovy.

If there's one thing I've noticed about C based programs, is that they all seem to work a helluva lot smoother.

WAJ
05-09-02, 04:29 PM
Sorry, I did something wrong. But it turns out that I don't have graphics.h -- am I supposed to? And I still don't know what the path refers to.

Rick
05-09-02, 09:02 PM
you need graphics.h file for graphics.i was talking about path to graphics interface,in my case(Turboc 3.0 compiler)it is c:\\turboc2\\bgi",and these double slashes are essential,because a single slash becomes an escape sequence.

graphics is easy,very easy.
i have made a project to show a map of U.S with a menu,when you click a choice,you"ll get the result,there is railways,airways,roadways option to show it on the map,while blinking,it looks cool.:cool:




bye!

WAJ
05-10-02, 09:15 AM
Ah thanks, I'll have to look into that (although I can't now because I'm in school - MY LAST DAY!!!). I don't have any of the software here, but I can tell you that I've got Microsoft Visual Basic 6 (at home) and I have no idea what the graphics interface is or where it is or if I have one.

And since I don't seem to have grpahics.h, I'd better try to download it from somewhere.

itchy
05-10-02, 06:29 PM
You can't use graphics.h in Visual C++. You'll have to learn Windows programming or use the built in MFC classes. Try to search for some tutorial on MFC or look in Visual C++ help. Thats the best way I know of...

Ash711
05-11-02, 02:21 AM
hi everyone

if you dont want fuss with vc++ and mfc and etc... etc....

(i think it's not a good idea to start with it, you will have a lot of problem with vc++ if you dont have a good knowledge in c++ and class inheritances)

you should try a free c/c++ compiler:djggp
http://www.delorie.com/djgpp/

with a -relatively- good graphic library, still free and very simple to use:allegro
http://www.talula.demon.co.uk/allegro/

you will have a lot of examples that ship with it, from simple square (it takes something like 4 lines, much like zion code) to complete game with advanced controler and sound.
Once you played with that, made your own demos & games & won prize for your demos ;) you should try directX and mfc prog...
but honest, start with directX and you'll miss a lot of fun.

hopes it'll helps

WAJ
05-15-02, 07:04 PM
cor, thanks for that. I'll certainly look into it.

I'm just concerned that a lot of thing s are programmed in advanced c programmes such as visual c++ so i wanted to learn as much as that as i could before going to uni. But of course, you're right, i should work up to whatever level.

After all, I don't think next generation (or next next generation) games programmers should be dawdling with the petty stuff. But that's how it must be :D