Skip to content

Commit

Permalink
itempickuppoint is now in center of item
Browse files Browse the repository at this point in the history
  • Loading branch information
xy124 committed May 26, 2011
1 parent 7cd9b43 commit 7700d48
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 0 additions & 2 deletions source/AttackAnimations/CAA_DragonFire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ void CAA_DragonFire::render() {

void CAA_DragonFire::update() {
if (getLastCollisionX().bIsCollision) {
//TODO: why is biscollision never true?
CBlockKoord blockKoord;
CVec vec = CVec( getRect().x+(m_bOrientation == OLEFT ? -3.0f : getRect().w+3.0f), //x
getRect().y + 50.0f); //y
Expand All @@ -56,7 +55,6 @@ void CAA_DragonFire::update() {
m_pGame->BuildBlock(blockKoord, CBlock::AIR, m_WormID, m_TeamID);
}

//TODO: set itempickpoint in middle of item not on left top corner!
//TODO: save map in xml...


Expand Down
12 changes: 9 additions & 3 deletions source/Vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ class CVec { //real Koords in Pixels!
x = X;
y = Y;
}
CVec(const FloatRect &fr) {
x = fr.x;
y = fr.y;
CVec(const FloatRect &fr, bool getCenter = false) {
if (getCenter) {
x = fr.x+(fr.w/2.0f);
y = fr.y+(fr.h/2.0f);
} else {
x = fr.x;
y = fr.y;
}
}
CVec(const CBlockKoord &blockKoord) {
x = BLOCKSIZE*blockKoord.x;
Expand Down Expand Up @@ -96,6 +101,7 @@ class CVec { //real Koords in Pixels!
return old;
}


};

#endif
5 changes: 3 additions & 2 deletions source/Worm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void CWorm::update() {
bool CWorm::isAlive() {
return m_Alive;
}

//TODO: draw icons of build items with .....
void CWorm::ProcessPickDropItem() {
//for all items in range: pick them up, if no item selected
if ((g_pFramework->isNewEvent()) && (g_pFramework->KeyDown(m_pSettings->KeyPickDropItem))) {
Expand All @@ -335,9 +335,10 @@ void CWorm::ProcessPickDropItem() {
for (it = m_pGame->m_pItems.begin(); it != m_pGame->m_pItems.end(); ++it) {
if ((*it)->getOwner() == NULL) { //nobody owns it
//calculate distance to item:
CVec posItem = CVec((*it)->getRect());
CVec posItem = CVec((*it)->getRect(), true);
CVec dist = CVec(getRect());
dist -= posItem;

if (dist.quad_abs() < QUADMAXITEMPICKUPDIST) { //in range...., so its mine now!
(*it)->setOwner(this);
m_pItems.push_back((*it));
Expand Down

0 comments on commit 7700d48

Please sign in to comment.