Hi guys, I have started to learn c++ yesterday, and now i have little problem due to lack of knowledge.

I developed this simple code:

#include <cstdlib>
#include <iostream>
#include <winbgim.h>

using namespace std;

int main()
    int gdriver = 9, gmode = 2;
    initgraph(&gdriver, &gmode, "");
    while (!kbhit())
    return 0;

Question is how can i made this onclick circle to stay on screen on spot where we clicked it?

cleardevice() clear all screen, so i need something else.

Thx ahead,

If you are trying to learn c++ with Tubro C++ then forget it. That compiler is non-standard and too old to do anyone any good. Get a modern free compiler such as Code::Blocks or Microsoft VC++ 2008 Express if you want to learn c++ the modern way.

And what you posted isn't really c++.

I use devC++ compiler, and i started with one c++ book written in croatian (my native language).

What exectly isnt c++, and what should i change? Meaby switch on some good and veryfied book for begginers in English?

Please read the Read Me threads at the beginning of this c++ board for hints and suggestions. If you want to learn c++ don't jump directly into the fire. The book you are reading doesn't appear to be for beginners, but more advanced.

As for your original specific question -- I have no idea.

I am not an expert and I don't fully understand the code there. But, I completed a game written in Pascal where I had to clear only selected pixels on screen. Like all the pixels between (25, 25) and (56, 56).

What I used was clearviewport() in pascal, I did some research for you but couldn't really find a suitable guide. But, I did find that a similar function setviewport() is available in C++.

Setviewport(x1, y1, x2, y2);

It will basicallly set your "screen" to those given coordinated. Imagine drawing a rectangle with its top-left point equal to (x1, y1) and bottom right point equal to (x2, y2);

Originally, when you use cleardevice(); the "screen" it will clear can be set like : setviewport(0, 0, getmaxx, getmaxy); {ALL the pixels}

Now what you can do is, setviewport to a portion of the screen and clear only that portion using cleardevice().

p.s. I am not sure if this is what you are asking but I think it may help....

This article has been dead for over six months. Start a new discussion instead.