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<stdlib.h> #include<stdio.h> #include<conio2.h> #include<conio.h> #include<iostream> #include<windows.h> #include<dos.h> #include<time.h> #include<list> using namespace std; void gotoxy(int x,int y){......} void clrscr(){.......} class Geschoss{ private: int m_x; int m_y; public: bool m_statusG; int Bewegung(); Geschoss(int x,int y){ m_x=x; m_y=y; } }; int Geschoss::Bewegung(){ do{ clrscr(); gotoxy(m_x,m_y); cout<<"*"; m_y--; clrscr(); }while(m_y>=1); return 0; }; int main(){ int x=20, y=22; list<Geschoss> kugeln; list<Geschoss>::iterator iter; while(1){ if(GetAsyncKeyState(0x57)){kugeln.push_back(Geschoss(x,y));} if(GetAsyncKeyState(0x1B)){exit(0);} if(GetAsyncKeyState(0x41)){x--;} if(GetAsyncKeyState(0x44)){x++;} for (iter = kugeln.begin(); iter != kugeln.end(); ++iter){ iter->Bewegung();} Sleep(50); } _getch(); } |
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 |
#include<stdlib.h> #include<stdio.h> #include<conio2.h> #include<conio.h> #include<iostream> #include<windows.h> #include<dos.h> #include<time.h> #include<list> using namespace std; void gotoxy(int x,int y){...} void clrscr(){..} class Geschoss { private: int m_x; int m_y; public: bool m_statusG; bool Bewegung(); Geschoss(int x,int y) { m_x=x; m_y=y-1; } }; bool Geschoss::Bewegung() { gotoxy(m_x,m_y); cout<<"*"; m_y--; if(m_y>=0) return true; else return false; }; int main() { int x=20, y=22; list<Geschoss> kugeln1; list<Geschoss> kugeln2; list<Geschoss>::iterator iter; for(;;) { if (GetAsyncKeyState(0x57)) { kugeln1.push_back(Geschoss(x,y)); } if (GetAsyncKeyState(0x1B)) { exit(0); } if (GetAsyncKeyState(0x41)) { x--; } if (GetAsyncKeyState(0x44)) { x++; } clrscr(); gotoxy(x,y); cout<<"ö"; for (iter = kugeln1.begin(); iter != kugeln1.end(); ++iter) { if(iter->Bewegung()) kugeln2.push_back(*iter); } swap(kugeln2,kugeln1); kugeln2.clear(); Sleep(50); } _getch(); } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
if (GetAsyncKeyState(0x57)) { if ( timer <= 0.0f ) { kugeln1.push_back(Geschoss(x,y)); timer = 2.0f; } } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
bool framefunc() { g_fCurrenTime = timeGetTime(); (...) return false; } bool Renderfunc() { g_fElapsedTime = timeGetTime(); //Zeit Differenz ausrechnen! g_fTime = static_cast<float>((g_fElapsedTime-g_fCurrenTime)/1000.0f); (..) return true; } |
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 |
int main(){ time_t timer; time_t timer2; timer=time(0); timer2=time(0); while(1){ Sleep(70); if(GetAsyncKeyState(0x41)){x--;} if(GetAsyncKeyState(0x57)){ if(timer2>=timer+2){ kugeln1.push_back(Geschoss(x,y)); timer = time(0); timer2 = time(0); } } . . . . . . . }das hier geht aber nicht :( mfg |
Werbeanzeige