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 |
#include <SDL.h> #include<SDL_image.h> int main(int argc ,char** argv) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Surface* screen_ ; screen_ = SDL_SetVideoMode(640,480,32,SDL_DOUBLEBUF); int i = 1; bool run = true; SDL_Surface* image[50]; image[i] = IMG_Load("explo.jpg"); // 32x32 - 128x32 SDL_Rect imagePosition; imagePosition.x = 100; // hier später (rand() 1 % 100)... imagePosition.y = 100; SDL_Rect rect; rect.x = 128; rect.y = 128; SDL_Rect rects[500]; // rects position ?? while(run) { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: run =false; break; } } SDL_FillRect(screen_, 0, SDL_MapRGB(screen_->format, 0, 0, 255)); //SDL_BlitSurface(image,&rects[frame],screen_,&rect); -> youtube tutorial abgetippt (animation sdl 8) :-) - nicht wichtig // SDL_BlitSurface(image, 0, screen_, &imagePosition); SDL_BlitSurface(image[i], &rects[i], screen_, &rect); // <- hier zum testen i++; imagePosition.y += 1; SDL_Flip(screen_); } SDL_FreeSurface(image[i]); SDL_Quit(); return 0; } |
C-/C++-Quelltext |
|
1 2 3 |
//pseudo-code bild[i] = sdl_blitsurface("bild",0,screen,bild[i].x,bild[i].y) |
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 |
#include <SDL.h> #include<SDL_image.h> int main(int argc ,char** argv) { SDL_Init(SDL_INIT_EVERYTHING); SDL_Surface* screen_ ; SDL_Surface* multi_pic[50]; screen_ = SDL_SetVideoMode(640,480,32,SDL_DOUBLEBUF); int i = 1; bool run = true; SDL_Surface* image = IMG_Load("bild.jpg"); SDL_Rect multi_rect[50]; multi_rect[i].x = rand() % 200 + 100; multi_rect[i].y = rand() % 300 + 100; while(run) { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: run =false; break; } } SDL_FillRect(screen_, 0, SDL_MapRGB(screen_->format, 0, 0, 255)); i++; //multi_pic[i] = SDL_BlitSurface(image, 0, screen_, &multi_rect[i]); // <- hier zum testen SDL_Flip(screen_); } SDL_FreeSurface(image); SDL_Quit(); return 0; } |
C-/C++-Quelltext |
|
1 |
while(run)
|
C-/C++-Quelltext |
|
1 |
SDL_FillRect(screen_, 0, SDL_MapRGB(screen_->format, 0, 0, 255)); |
C-/C++-Quelltext |
|
1 |
SDL_BlitSurface(image, 0, screen_, &multi_rect[i]); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
... Int test[50]; ... SDL_Rect multi_rect[50]; multi_rect[i].x = rand() % 200 + 100; multi_rect[i].y = rand() % 300 + 100; SDL_FillRect(screen_, 0, SDL_MapRGB(screen_->format, 0, 0, 255)); test[i]=SDL_BlitSurface(image, 0, screen_, &multi_rect[i]); i++; |
C-/C++-Quelltext |
|
1 2 3 4 |
SDL_BLITSURFACE test[50]; ... test[i] = ??? ... |
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 |
#include <SDL.h> #include<SDL_image.h> SDL_Surface* screen_ ; SDL_Surface* image; int main(int argc ,char** argv) { SDL_Init(SDL_INIT_EVERYTHING); screen_ = SDL_SetVideoMode(800,600,32,SDL_DOUBLEBUF); image = IMG_Load("astro.bmp"); // 32x32 - 128x32 //multi_pic[i]= SDL_BlitSurface(image, 0, screen_, &multi_rect[i]); int i = 1; int multi_pic[i]; SDL_Rect multi_rect[100]; multi_rect[i].x = rand() % 500 + 10; multi_rect[i].y = rand() % 600 + 100; bool run = true; while(run) { SDL_Event event; while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: run =false; break; } } //multi_rect[i].y ++; i++; //SDL_FillRect(screen_, 0, SDL_MapRGB(screen_->format, 0, 0, 255)); multi_pic[i]=SDL_BlitSurface(image, 0, screen_, &multi_rect[i]; SDL_Flip(screen_); } SDL_FreeSurface(image); SDL_Quit(); return 0; } |
Werbeanzeige