Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
#include <SDL/SDL.h> #include <iostream> using namespace std; int main(int argc, char *argv[]) { if(SDL_Init(SDL_INIT_EVERYTHING)<0) return -1; SDL_Surface* display; if((display = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF))==0) return -2; SDL_WM_SetCaption("LERIX PRODUCTIONS", NULL); bool isRunning = true; SDL_Event Event; int Map[10][10]={ {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1} }; SDL_Surface *eplogo; SDL_Surface *eplogo2; eplogo = SDL_LoadBMP("Grassland.bmp"); eplogo2 = SDL_LoadBMP("Weg.bmp"); SDL_Rect Coords; Coords.x = 0; Coords.y=0; Coords.h = 50; Coords.w = 50; SDL_Rect rect; rect.x=0; rect.y=0; rect.h=50; rect.w=50; for(int i=0; i<9; i++) { for(int j=0; j<9; j++) { if(Map[i][j]==1) { SDL_BlitSurface(eplogo,&Coords , display, &rect); rect.x+=50; } else if(Map[i][j]==0) { SDL_BlitSurface(eplogo2,&Coords , display, &rect); rect.x+=50; } } rect.x=0; rect.y +=50; } while(isRunning) { while(SDL_PollEvent(&Event)) { if(Event.type == SDL_QUIT) { isRunning = false; } } SDL_Flip(display); } SDL_FreeSurface(eplogo); SDL_FreeSurface(eplogo2); SDL_Quit(); return 0; } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »leridan« (12.02.2013, 09:39)
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
#include <SDL/SDL.h> #include <iostream> #include <string> using namespace std; int main(int argc, char *argv[]) { if(SDL_Init(SDL_INIT_EVERYTHING)<0) return -1; SDL_Surface* display; if((display = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE|SDL_DOUBLEBUF))==0) return -2; SDL_WM_SetCaption("LERIX PRODUCTIONS", NULL); bool isRunning = true; SDL_Event Event; int Map[10][10]={ {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1}, {1,1,1,1,1,0,1,1,1} }; SDL_Surface *eplogo; SDL_Surface *eplogo2; eplogo = SDL_LoadBMP("Grassland.bmp"); eplogo2 = SDL_LoadBMP("Weg.bmp"); SDL_Rect Coords; Coords.x = 0; Coords.y=0; Coords.h = 50; Coords.w = 50; SDL_Rect rect; rect.x=0; rect.y=0; rect.h=50; rect.w=50; for(int i=0; i<9; i++) { for(int j=0; j<9; j++) { if(Map[i][j]==1) { SDL_BlitSurface(eplogo,&Coords , display, &rect); rect.x+=50; } else if(Map[i][j]==0) { SDL_BlitSurface(eplogo2,&Coords , display, &rect); rect.x+=50; } } rect.x=0; rect.y +=50; } while(isRunning) { while(SDL_PollEvent(&Event)) { if(Event.type == SDL_QUIT) { isRunning = false; } } SDL_Flip(display); } SDL_FreeSurface(eplogo); SDL_FreeSurface(eplogo2); SDL_Quit(); return 0; } void ZeicheMap(int map[][],class &surface, struct &coords, struct &rect) { for(int i=0; i<9; i++) { for(int j=0; j<9; j++) { if(Map[i][j]==1) { SDL_BlitSurface(eplogo,&Coords , display, &rect); rect.x+=50; } else if(Map[i][j]==0) { SDL_BlitSurface(eplogo2,&Coords , display, &rect); rect.x+=50; } } rect.x=0; rect.y +=50; } } |
C-/C++-Quelltext |
|
1 |
void ZeicheMap(int map[][],class &surface, struct &coords, struct &rect) |
Habe das immernoch nicht drauf, wie ich was übergeben muss.
tue mich noch schwer mit Zeigern, und den verschiedenen typen übergeben.
Werbeanzeige