Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //graphics.c
- #include <SDL.h>
- #include <SDL_gfxPrimitives.h>
- #include <math.h>
- #include <SDL_image.h>
- #include <SDL_ttf.h>
- #include <stdlib.h>
- #include <stdbool.h>
- typedef struct Kerdes
- {
- int nehezseg;
- char kerdes[50];
- char A[30];
- char B[30];
- char C[30];
- char D[30];
- char helyes;
- char kategoria[30];
- } Kerdes;
- Kerdes* beolvas()
- {
- FILE *fajl;
- fajl=fopen("loim.txt", "r");
- Kerdes **tomb=(Kerdes**) malloc(15*sizeof(Kerdes));
- char sor[128];
- fgets(sor, 128, fajl);
- //bool megfelelo=false;
- int i;
- for(i=0; i<4; ++i)
- {
- tomb[i]=(Kerdes*) malloc(sizeof(Kerdes));
- sscanf(fgets(sor,255,fajl),"%d\t%[^\t]\t%[^\t]\t%[^\t]\t%[^\t]\t%[^\t]\t%c\t%s", &(tomb[i]->nehezseg), &(tomb[i]->kerdes), &(tomb[i]->A), &(tomb[i]->B), &(tomb[i]->C), &(tomb[i]->D), &(tomb[i]->helyes), &(tomb[i]->kategoria));
- printf(stdout,"%d %s %s", tomb[i]->nehezseg, tomb[i]->kerdes, tomb[i]->A);
- }
- return tomb;
- }
- int main(int argc, char *argv[])
- {
- SDL_Event ev;
- graphics();
- while (SDL_WaitEvent(&ev) && ev.type != SDL_QUIT)
- {
- }
- /* varunk a kilepesre */
- /* ablak bezarasa */
- return 0;
- }
- //main.c
- #include <SDL.h>
- #include <SDL_gfxPrimitives.h>
- #include <math.h>
- #include <SDL_image.h>
- #include <SDL_ttf.h>
- #include <stdbool.h>
- #include <string.h>
- short int ACx[6]= {67, 92, 317, 343, 311, 97};
- short int BDx[6]= {346, 371, 596, 622, 596, 371};
- short int ABy[6]= {644, 626, 626, 644, 662, 662};
- short int CDy[6]= {692, 674, 674, 692, 710, 710};
- short int Kx[6]= {67, 92, 596, 622, 596, 92};
- short int Ky[6]= {584, 556, 556, 584, 612, 612};
- Uint32 fekete=0x000000FF;
- Uint32 sarga=0xe58328FF;
- Uint32 kek=0x1613d3FF;
- Uint32 zold=0x33cc33FF;
- typedef struct Kerdes
- {
- int nehezseg;
- char kerdes[50];
- char A[30];
- char B[30];
- char C[30];
- char D[30];
- char helyes;
- char kategoria[30];
- } Kerdes;
- typedef struct Doboz
- {
- short int X[6];
- short int Y[6];
- Uint32 szin;
- } Doboz;
- void hatter_betolt(SDL_Surface *hova)
- {
- SDL_Surface *hatter=IMG_Load("hatter.jpg");
- SDL_Rect src= {620, 280, 720, 720};
- SDL_Rect dest= {0, 0, 720, 720};
- SDL_BlitSurface(hatter, &src, hova, &dest);
- SDL_FreeSurface(hatter);
- }
- void doboz_rajzol(SDL_Surface *hova, short* eredetiX, short *eredetiY, Uint32 *szin)//kék polygon kitöltéséhez feketével generál koordinátákat
- {
- filledPolygonColor(hova, eredetiX, eredetiY, 6, szin);
- polygonColor(hova, eredetiX, eredetiY, 6, 0x1613d3FF);
- aapolygonRGBA(hova, eredetiX, eredetiY, 6, 0,0,255,255);
- SDL_Flip(hova);
- }
- void kerdes_kiir(SDL_Surface *hova, Kerdes *kiir)
- {
- short int ACx[6]= {67, 92, 317, 343, 311, 97};
- short int BDx[6]= {346, 371, 596, 622, 596, 371};
- short int ABy[6]= {644, 626, 626, 644, 662, 662};
- short int CDy[6]= {692, 674, 674, 692, 710, 710};
- short int Kx[6]= {67, 92, 596, 622, 596, 92};
- short int Ky[6]= {584, 556, 556, 584, 612, 612};
- SDL_Surface *szovegdobozba; //mi kerül a szövegdobozba (6 csúcsú polygon)
- SDL_Rect src= {0, 0, 720, 720};
- SDL_Rect dest= {92, 637, 720, 720};
- TTF_Font *font;
- SDL_Color feher= {255, 255, 255};
- SDL_Color sarga= {255,153,51};
- TTF_Init();
- font=TTF_OpenFont("Arial.ttf", 14);
- dest.x=ACx[1];
- dest.y=ABy[0]-7; //vonal közepétől a font magasságának fele
- szovegdobozba = TTF_RenderUTF8_Blended(font, "● A: ", sarga );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x+=30;
- szovegdobozba = TTF_RenderUTF8_Blended(font, kiir->A, feher );
- fprintf(stdout, "%s", kiir->A);
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x=BDx[1];
- dest.y=ABy[0]-7;
- szovegdobozba = TTF_RenderUTF8_Blended(font, "● B: ", sarga );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x+=30;
- szovegdobozba = TTF_RenderUTF8_Blended(font, kiir->B, feher );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x=ACx[1];
- dest.y=CDy[0]-7;
- szovegdobozba = TTF_RenderUTF8_Blended(font, "● C: ", sarga );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x+=30;
- szovegdobozba = TTF_RenderUTF8_Blended(font, kiir->C, feher );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x=BDx[1];
- dest.y=CDy[0]-7;
- szovegdobozba = TTF_RenderUTF8_Blended(font, "● D: ", sarga );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x+=30;
- szovegdobozba = TTF_RenderUTF8_Blended(font, kiir->D, feher );
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- dest.x=92+(504-strlen(kiir->kerdes)*6.25)/2;
- dest.y=577;
- szovegdobozba=TTF_RenderUTF8_Blended(font, kiir->kerdes, feher);
- SDL_BlitSurface(szovegdobozba,&src,hova,&dest);
- SDL_Flip(hova);
- free(font);
- free(szovegdobozba);
- free(hova);
- }
- int graphics(void)
- {
- SDL_Surface *screen, *hatter, *szoveg;
- SDL_Event kattintas;
- SDL_Init(SDL_INIT_VIDEO | 0x1000000);
- screen = SDL_SetVideoMode(720, 720, 0, SDL_ANYFORMAT); //960 széles lesz később bekerülő oldalsó sáv miatt
- Kerdes **kerdestomb;
- kerdestomb=beolvas();
- SDL_Rect hova= {0,0,100,12};
- TTF_Font *font;
- hatter_betolt(screen);
- doboz_rajzol(screen, ACx, ABy, fekete);
- doboz_rajzol(screen, BDx, ABy, fekete);
- doboz_rajzol(screen, ACx, CDy, fekete);
- doboz_rajzol(screen, BDx, CDy, fekete);
- doboz_rajzol(screen, Kx, Ky, fekete);
- lineColor(screen, 0, 644, 67, 644, kek);
- lineColor(screen, 0, 584, 67, 584, kek);
- lineColor(screen, 0, 692, 67, 692, kek);
- lineColor(screen, 622, 692, 720, 692, kek);
- lineColor(screen, 622, 584, 720, 584, kek);
- lineColor(screen, 622, 644, 720, 644, kek);
- kerdes_kiir(screen, kerdestomb[2]);
- //free(kerdestomb);
- SDL_WM_SetCaption("Legyen Ön is Milliomos", "Legyen Ön is Milliomos");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment