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 |
void AdventurePlayer::checkCollisions() { /// Collision mit Objekten for(unsigned int x = 0;x<actual_Level.objects.size();x++) { for(unsigned int y = 0;y<actual_Level.objects[x].size();y++) { /// Falls eine Kollision stattgefunden hat Rect r(joe.r.x+joe.fx,joe.r.y+joe.fy,joe.r.w,joe.r.h); if(collision(r,actual_Level.objects[x][y].r,2)) { determineCase(x,y); // Dort wird entschieden, je nach Typ des Objekts, was passieren soll } } } /// Update Position joe.updatePosition(); } void AdventurePlayer::CC_Case_01(int x, int y) { /// Potenzielles Rechteck Rect r(joe.r.x+joe.fx,joe.r.y+joe.fy,joe.r.w,joe.r.h); GameObject go = actual_Level.objects[x][y]; /// X if(r.x+r.w/2<go.r.x+go.r.w/2) { int distance = (r.x+r.w)-(go.r.x); joe.Move(-distance,0); } else { int distance = (go.r.x+go.r.w)-(r.x); joe.Move(+distance,0); } /// Y if(r.y+r.h/2<go.r.y+go.r.h/2) { int distance = (r.y+r.h)-(go.r.y); joe.Move(0,-distance); } else { int distance = (go.r.y+go.r.h)-(r.y); joe.Move(0,+distance); } joe.updatePosition(); } |
Noodle
unregistriert
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 |
void AdventurePlayer::CC_Case_01(int x, int y) { int t = 2; Rect r(joe.r.x+joe.fx,joe.r.y+joe.fy,joe.r.w,joe.r.h); GameObject go = actual_Level.objects[x][y]; Line l1(go.r.x,go.r.y,go.r.x+go.r.w,go.r.y); /// Oben Line l2(go.r.x+go.r.w,go.r.y,go.r.x+go.r.w,go.r.y+go.r.h); /// Rechts Line l3(go.r.x,go.r.y+go.r.h,go.r.x+go.r.w,go.r.y+go.r.h); /// Unten Line l4(go.r.x,go.r.y,go.r.x,go.r.y+go.r.h); /// Links /// Oben if(l1.y>r.y&&l1.y<r.y+r.h) { joe.Move(0,-joe.fy); } /// Unten else if(l3.y>r.y&&l3.y<r.y+r.h) { joe.Move(0,-joe.fy); /// Erlauben zu springen joe.fUp = 0; joe.jumping = false; } /// Rechts if(l2.x>r.x&&l2.x<r.x+r.w) { joe.Move(-joe.fx,0); } /// Links else if(l4.y>r.y&&l4.y<r.y+r.h) { joe.Move(-joe.fx,0); } } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Developer_X« (12.07.2011, 08:23)
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 |
void AdventurePlayer::CC_Case_01(int x, int y) { Rect r(joe.r.x+joe.fx,joe.r.y+joe.fy,joe.r.w,joe.r.h); GameObject go = actual_Level.objects[x][y]; Line l1(r.x,r.y,r.x+r.w,r.y); /// Oben Line l2(r.x+r.w,r.y,r.x+r.w,r.y+r.h); /// Rechts Line l3(r.x,r.y+r.h,r.x+r.w,r.y+r.h); /// Unten Line l4(r.x,r.y,r.x,r.y+r.h); /// Links /// Oben if(l1.y>go.r.y&&l1.y<go.r.y+go.r.h) { joe.Move(0,-joe.fy); } /// Unten else if(l3.y>go.r.y&&l3.y<go.r.y+go.r.h) { joe.Move(0,-joe.fy); joe.fUp = 0; joe.jumping = false; } if(joe.jumping==true) { /// Rechts if(l2.x>go.r.x&&l2.x<go.r.x+go.r.w) { joe.Move(-joe.fx,0); } /// Links else if(l4.y>go.r.y&&l4.y<go.r.y+go.r.h) { joe.Move(-joe.fx,0); } } } |
Werbeanzeige