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 104 |
#include "LXCollision.hpp" void LXCollision::Init(CPlayer *Playly,CTMng *TileMng,LXPhysX2D *HandlePhysX) { MyTileMNG=TileMng; MyPhysX=HandlePhysX; MyPlayer=Playly; } void LXCollision::SetCollisionData() { vector<CTile> ThisTiles; vector<CTile>::iterator ItColli; ThisTiles=MyTileMNG->GetVektor(); SDL_Rect First; First=MyPlayer->GetExaktRect(); SDL_Rect Second; for(ItColli=ThisTiles.begin();ItColli!=ThisTiles.end();) { bool left=false; bool right=false; bool top=false; bool bottom=false; Second=ItColli->GetRect(); if(CheckDifferenceFlall(First,Second)==true) { MyPhysX->SetFalling(true); } if(CheckCollisionLeft(First,Second)==true) { left=true; } if(CheckCollisionRight(First,Second)==true) { right=true; } if(CheckCollisionTop(First,Second)==true) { top=true; } if(CheckCollisionBottom(First,Second)==true) { bottom=true; } ItColli++; MyPlayer->SetPlayer(left,right,top,bottom); } } bool LXCollision::CheckCollisionLeft(SDL_Rect first, SDL_Rect second) { return false; } bool LXCollision::CheckCollisionRight(SDL_Rect first, SDL_Rect second) { return false; } bool LXCollision::CheckCollisionTop(SDL_Rect first, SDL_Rect second) { if(first.y+first.h+5>second.y&&first.x<second.x+second.w&&first.x+first.w>second.x) { MyPhysX->SetFalling(false); } if(first.y<second.y+second.h&&first.y+first.h>second.y&&first.x<second.x+second.w&&first.x+first.w>second.x) { return true; } return false; } bool LXCollision::CheckCollisionBottom(SDL_Rect first, SDL_Rect second) { return false; } bool LXCollision::CheckDifferenceFlall(SDL_Rect first,SDL_Rect second ) { return false; } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
bool LXCollision::CheckCollisionTop(SDL_Rect first, SDL_Rect second) { if(first.y+first.h+5>second.y&&first.x<second.x+second.w&&first.x+first.w>second.x) { MyPhysX->SetFalling(false); } if(first.y<second.y+second.h&&first.y+first.h>second.y&&first.x<second.x+second.w&&first.x+first.w>second.x) { return true; } return false; } |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »leridan« (15.05.2013, 20:40)
Werbeanzeige