Graphics.h displaying graphics with intermitences..

closed account (zTMNhbRD)
Hi .I;m new 'to graphics' in c++.That's why i start with graphics.h lib.Yet when i'm tryimg to display , for example a rectangle and move it in a loop , it keeps appearing and disapearing.I put and a delay time... I don't know what to do.Plaese help me...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<iostream>
#include<graphics.h>
#include<windows.h>
int run=true;
int x=100;
int y=70;

int main(){
 initwindow(400,400,"test");
 
 while(run==true){
   if(GetAsyncKeyState(VK_UP)){
     rectangle(x,y--,x+20,y-20);
     delay(10);
   }
  }
while(!kbhit()){
  delay(200);
}
return 0;
}
Last edited on
You are mixing WinAP with an ancient compiler.
It isn't going to behave nicely.

Either just use the <graphics.h> and <conio.h> facilities only or drop them for Win32.

Because of its age, you might also want to be running it on an emulator that handles the old 16-bit graphics stuff.


The age of your compiler really is an issue. You should get TDM-GCC or Microsoft's VS Community Edition and start using them instead.
http://tdm-gcc.tdragon.net/
https://www.visualstudio.com/ (click the "Download Community 2015" button)

If you get TDM's MinGW, there is a <graphics.h> replacement called WinBGIm.
http://winbgim.codecutter.org/

There are gazillions of other options for graphics libraries. Google can help.


Sorry there isn't a simpler answer.
Topic archived. No new replies allowed.