Valaki megtudna mondani hogy kell mackofejet rajzolni c++ban?
Ha a Hello World-ig eljutottál, akkor onnantól csak kreativitás kérdése. Nyiss egy Jegyzettömböt, válassz pár szimpatikus karaktert, pakolj közéjük space-eket. Ha kialakult a "rajz", pakold köré a cout-ot.
De rá is kereshetsz "ascii bear"-re, ha nincs ötleted.
C++ban nincs grafikus könyvtér.
Kész is a feladat.
Használj grafikus könyvtárakat:
SDL
OpenGl (ezzel térben is megrajzolhatod)
DirectX (csak Windowsra)
Xlib (csak Unixra)
Egy SDL példa:
#include <SDL.h>
#include <SDL_gfxPrimitives.h>
#include <math.h>
int main(int argc, char *argv[]) {
SDL_Event ev;
SDL_Surface *screen;
int x, y, r;
/* SDL inicializálása és ablak megnyitása */
SDL_Init(SDL_INIT_VIDEO);
screen=SDL_SetVideoMode(500, 500, 0, SDL_ANYFORMAT);
if (!screen) {
fprintf(stderr, "Nem sikerult megnyitni az ablakot!\n");
exit(1);
}
SDL_WM_SetCaption("SDL peldaprogram", "SDL peldaprogram");
//Itt lehet rajzolni
r = 20;
aacircleRGBA(screen, 50, 50, r, 255, 0, 0, 255);
filledCircleRGBA(screen, 50, 50, r/2, 255, 0, 0, 255);
aacircleRGBA(screen, 450, 50, r, 255, 0, 0, 255);
filledCircleRGBA(screen, 450, 50, r/2, 255, 0, 0, 255);
aacircleRGBA(screen, 50, 450, r, 255, 0, 0, 255);
filledCircleRGBA(screen, 50, 450, r/2, 255, 0, 0, 255);
aacircleRGBA(screen, 450, 450, r, 255, 0, 0, 255);
filledCircleRGBA(screen, 450, 450, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 250, 50, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 240, 30, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 260, 30, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 50, 250, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 30, 240, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 30, 260, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 250, 450, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 240, 470, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 260, 470, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 450, 250, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 470, 240, r/2, 0, 0, 255, 255);
filledCircleRGBA(screen, 470, 260, r/2, 0, 0, 255, 255);
filledEllipseRGBA(screen, 150, 50, r, r/2, 0, 255, 0, 255);
filledEllipseRGBA(screen, 350, 50, r, r/2, 0, 255, 0, 255);
filledEllipseRGBA(screen, 150, 450, r, r/2, 0, 255, 0, 255);
filledEllipseRGBA(screen, 350, 450, r, r/2, 0, 255, 0, 255);
filledEllipseRGBA(screen, 50, 150, r/2, r, 0, 255, 0, 255);
filledEllipseRGBA(screen, 450, 150, r/2, r, 0, 255, 0, 255);
filledEllipseRGBA(screen, 50, 350, r/2, r, 0, 255, 0, 255);
filledEllipseRGBA(screen, 450, 350, r/2, r, 0, 255, 0, 255);
filledCircleRGBA(screen, 100, 200, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 200, 100, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 400, 300, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 300, 400, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 100, 300, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 300, 100, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 400, 200, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 200, 400, r/2, 255, 0, 0, 255);
filledCircleRGBA(screen, 100, 185, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 200, 85, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 400, 285, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 300, 385, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 100, 285, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 300, 85, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 400, 185, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 200, 385, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 85, 195, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 185, 95, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 385, 295, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 285, 395, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 85, 295, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 285, 95, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 385, 195, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 185, 395, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 115, 195, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 215, 95, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 415, 295, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 315, 395, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 115, 295, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 315, 95, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 415, 195, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 215, 395, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 110, 215, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 210, 115, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 410, 315, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 310, 415, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 110, 315, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 310, 115, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 410, 215, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 210, 415, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 90, 215, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 190, 115, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 390, 315, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 290, 415, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 90, 315, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 290, 115, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 390, 215, r/2, 255, 255, 0, 255);
filledCircleRGBA(screen, 190, 415, r/2, 255, 255, 0, 255);
/* szoveg */
// stringRGBA(screen, 110, 350, "Kilepeshez: piros x az ablakon", 255, 255, 255, 255);
/* eddig elvegzett rajzolasok a kepernyore */
SDL_Flip(screen);
/* varunk a kilepesre */
while (SDL_WaitEvent(&ev) && ev.type!=SDL_QUIT) {
}
/* ablak bezarasa */
SDL_Quit();
return 0;
}
Kapcsolódó kérdések:
Minden jog fenntartva © 2024, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!