سلام.

خوب تقریبا توی مدرسه فصل گرافیک سی‌پلاس‌پلاس تموم شد.

از نظر من گرافیک توی زبانهای c++ و از این مدل زبان ها چیز جالبی نیست.

ولی خوب یک نمونه بازی ساده باهاش نوشتم که یه نمونه‌ی عملی باشه.

این بازی از این قراره که یک توپ توی صفحه داریم که اینطرف و اون طرف بره، فرد بازی کننده مسئول خالی کردن باد این توپ هست، یعنی باید روی این توپ کلیک کنه تا بادش خالی بشه، به مدت یک دقیقه هم وقت دارید باد توپ رو خالی کنید.

البته هرچقدر باد توپ کمتر میشه سرعت توپ بیشتر میشه و همچنین چون کوچیکتره کلیک کردن روش هم سخت تر هست.

کدش رو میزارم. خودتون کامپایلش کنید! :)

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

using namespace std;
int main()
{
    int x,y,mx,my,width,height,s = 0,st,rc, r = 100,d=200;
    initwindow(1000,700,"",-3,-3);
    srand(time(NULL));
    st = time(NULL);
    width = getmaxx();
    height = getmaxy();
    x = rand()%width;
    y = rand()%height;
    mx = rand()%50-25;
    my = rand()%50-25;
        setfillstyle(1,15);
        fillellipse(x,y,r,r);
    setwritemode(XOR_PUT);
    outtext("score: ");
    while(!kbhit() && time(NULL)-st <= 60 && r > 0)
    {
        fillellipse(x,y,r,r);
        x += mx;
        y += my;
        if(x < r) {
            x = r;
            mx *= -1;
        }
        if(x > width-r) {
            x = width-r;
            mx *= -1;
        }
        if(y < r) {
            y = r;
            my *= -1;
        }
        if(y > height-r) {
            y = height-r;
            my *= -1;
        }
        if(ismouseclick(WM_LBUTTONDOWN)) {
            clearmouseclick(WM_LBUTTONDOWN);
            if(((mousex()-x)*(mousex()-x))+((mousey()-y)*(mousey()-y)) <= r*r) {
                setcolor(15);
                outtext("X");
                rc = rand()%15+1;
                setfillstyle(1,rc);
                if( mx >= 0) mx += rand()%2; else mx -= rand()%2; 
                if( my >= 0) my += rand()%1; else my -= rand()%1; 
                r -= rand()%10;
                if( r < 1) r = 0;
                d -= rand()%3;
            }
        }
        fillellipse(x,y,r,r);
        delay(d);
    }
    if( r > 0) {
        outtextxy(40,20,"vaghte shoma tamam shod...");
    } else {
        outtextxy(40,20,"shoma barande shodid...");
    }
    getch();
    return 0;
}