Title: WinBGI example
Xception - June 27, 2003 02:50 PM (GMT)
A small example: controlling a ball with the cursor keys using the winbgi library which comes with Dev-C++ (or must be downloaded and installed seperately?)
I compiled as Win32 Gui project, but Console project works also.
Who said C++ would be difficult?
| CODE |
#define isKey(k) GetAsyncKeyState(k) #include <winbgim.h>
int x,y; // position of ball
int main() { initwindow(640,480); //open a 640x480 graphics window do // loop { setvisualpage(1); // double setactivepage(0); // buffer clearviewport(); // clear background if (isKey(VK_LEFT)) x-=2; // check for cursor keys and move ball if (isKey(VK_RIGHT)) x+=2; if (isKey(VK_UP)) y-=2; if (isKey(VK_DOWN)) y+=2; fillellipse(x+120,y+120,18,18); // draw ball delay(10); // delay } while(!isKey(VK_ESCAPE)); // until Escape key pressed closegraph(); //close graphics window return 0; }
|
ih8censorship - June 27, 2003 03:46 PM (GMT)
| QUOTE |
using the winbgi library which comes with Dev-C++ (or must be downloaded and installed seperately?)
|
yup i got a "library does not exist" error so ya must have to download it seperatly when your using dev c++. ill download it sometime cause i really wanna see this code in action :)
Xception - June 27, 2003 04:06 PM (GMT)
I have an older version of Dev-C++ and I thought the WinBGI library was now in the package as default. I used the update tool of Dev-C++ and installed this library yesterday. It's easy to use and you don't have to know anything about Windows programming, you open a new window with only one function. Maybe we could make a small game competition using this library?
Shadow of the Moon - June 27, 2003 05:54 PM (GMT)
I'm updating now. Is it that easy to use? I sure am glad we have you around here Xception.
--EDIT--
I can't get that stupid vUpdate to work. :(
Dragon - June 27, 2003 05:59 PM (GMT)
Where can I get the library?
Xception - June 27, 2003 06:38 PM (GMT)
| QUOTE |
Is it that easy to use?
|
Very easy, look at my code. But it's only a wrapper around the Windows GDI, so don't expect a powerful graphics engine. But if you don't know how to write Win32 Gui programs or if you too lazy then you can easily create them with this library.
Shadow of the Moon - June 27, 2003 07:10 PM (GMT)
I finally got it to work :)
I'm gonna play around with this for a while. Thanks Xception ^_^