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 |
#include<iostream> #include"Player.hpp" #include<list> using namespace std; list<Player> m_Pl; int main() { int x; int y; Player *Omos; Omos=new Player; Omos->Init(4,10,10); x=0; y=0; cin >>x; cin>>y; cout << x << y << endl; Player *Hero; Hero=new Player; Player *Enemy; Enemy=new Player; Hero->Init(1,100,200); Enemy->Init(2,50,50); m_Pl.push_back(*Omos); m_Pl.push_back(*Hero); m_Pl.push_back(*Enemy); list<Player>::iterator ItFind; for(ItFind=m_Pl.begin(); ItFind!=m_Pl.end();) { if(ItFind->Check(x,y)==true) { Enemy->Setit(ItFind->GetPlayer()); ItFind->UseIT(); } ItFind++; } for(ItFind=m_Pl.begin(); ItFind!=m_Pl.end();) { ItFind->UseIT(); ItFind++; } return 0; } |
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 |
#ifndef CPLAYER_HPP #define CPLAYER_HPP #include<iostream> using namespace std; class Player { public: void Init(int Number, int X, int Y); Player *GetPlayer(){return this;} void Setit(Player *muh); void Show(); void ShowNumber(); bool Check(int targx, int targy); bool LikeTrue(); void UseIT(); private: int PlayerNummer; Player *Mogo; int x; int y; bool itset; }; #endif // CPLAYER_HPP |
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 |
#include "Player.hpp" void Player::Init(int Number, int X, int Y) { PlayerNummer=Number; x=X; y=Y; itset=false; Mogo=NULL; } void Player::Setit(Player *muh) { Mogo=muh; } void Player::Show() { if(Mogo!=NULL) { Mogo->ShowNumber(); } cout << "QAufgerufen" << endl; } void Player::ShowNumber() { cout << "NUMMER " << PlayerNummer << endl; } bool Player::Check(int targx, int targy) { if(targx==x && targy==y) { return true; } return false; } void Player::UseIT() { if(Mogo!=NULL) { cout << "Target wird beschossen" << endl; } else { cout << "kein Target" << endl; } } |
nur eben wegen den float werten, es handelt sich bei allen um int werte
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
list<Player>::iterator ItFind; for(ItFind=m_Pl.begin(); ItFind!=m_Pl.end();) { if(ItFind->Check(Hero->getx(),Hero->gety())==true) { Hero->Setit(ItFind->GetPlayer()); } ItFind++; } |
C-/C++-Quelltext |
|
1 |
Hero->Setit(ItFind->GetPlayer()); |
Administrator
Community-Fossil
Beruf: Teamleiter Mobile Applikationen & Senior Software Engineer
Werbeanzeige