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 91 92 93 94 95 96 97 98 99 100 101 102 103 |
#include <iostream> #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "zweitesbild.h" const int framepersecond = 10; using namespace std; int zahl; SDL_Event event; int main( int argc, char* args[]) { bool quit = false; SDL_Init(SDL_INIT_EVERYTHING); cout << "welches Bild wollen laden ?" << endl; cin >> zahl; switch(zahl) { case 1: if(zahl = 1) { animation ani; ani.loadimages(); ani.clips(); while( quit == false ) { ani.start(); while( SDL_PollEvent( &event ) ) { //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } ani.Move2(); ani.Move(); ani.show(); ani.update(); if( ani.getticks() < 1000 / framepersecond ) { SDL_Delay( ( 5500 / framepersecond ) - ani.getticks() ); } } return 0; } case 2: if(zahl = 2) { zweitesbild anii; anii.loadimages(); anii.clips(); while( quit == false ) { anii.start(); while( SDL_PollEvent( &event ) ) { //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } anii.Move(); anii.show(); anii.update(); if( anii.getticks() < 1000 / framepersecond ) { SDL_Delay( ( 5500 / framepersecond ) - anii.getticks() ); } } return 0; } } } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »killermiller« (19.06.2013, 15:19)
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
C-/C++-Quelltext |
|
1 |
if(zahl = 1) |
C-/C++-Quelltext |
|
1 |
if(zahl = 2) |
Alter Hase
Beruf: Softwareentwickler (aktuell Web/Node); Freiberuflicher Google Proxy
C-/C++-Quelltext |
|
1 2 3 |
switch(zahl) case 1: if(zahl = 1) |
Ich finde ja das
C-/C++-Quelltext
1 2 3 switch(zahl) case 1: if(zahl = 1)
wesentlich interessanter...
Direkt danach wird das case 2: ausgeführt, da switch nur in den richtigen Zweig springt, danach nicht aber heraus - genau dafür ist das break da, das du vergessen hast.
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 |
#include <iostream> #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "zweitesbild.h" const int framepersecond = 10; using namespace std; int zahl ; SDL_Event event; int main(int argc, char* args[]) { bool quit = false; SDL_Init(SDL_INIT_EVERYTHING); cout << "welches Bild wollen laden ?" << endl; cin >> zahl; if(zahl == 1) { animation ani; ani.loadimages(); ani.clips(); while( quit == false ) { ani.start(); while( SDL_PollEvent( &event ) ) { //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } ani.Move2(); ani.Move(); ani.show(); ani.update(); if( ani.getticks() < 1000 / framepersecond ) { SDL_Delay( ( 5500 / framepersecond ) - ani.getticks() ); } } } if(zahl == 2) { zweitesbild anii; anii.loadimages(); anii.clips(); while( quit == false ) { anii.start(); while( SDL_PollEvent( &event ) ) { //If the user has Xed out the window if( event.type == SDL_QUIT ) { //Quit the program quit = true; } } anii.Move(); anii.show(); anii.update(); if( anii.getticks() < 1000 / framepersecond ) { SDL_Delay( ( 5500 / framepersecond ) - anii.getticks() ); } } } return 0; } |
Werbeanzeige