summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-02-24 23:03:31 -0700
committerIra Rice <irarice@gmail.com>2009-02-24 23:03:31 -0700
commita1e483913672e55704e8fbafeff5ea0ccc0c9b07 (patch)
tree47cd4487c4b3e14d3bbb1b94c25cef4c55b10ef3 /src/gui/viewport.cpp
parente85269ffe1fe91f5cf44ccfec01252343643ef1d (diff)
downloadmana-a1e483913672e55704e8fbafeff5ea0ccc0c9b07.tar.gz
mana-a1e483913672e55704e8fbafeff5ea0ccc0c9b07.tar.bz2
mana-a1e483913672e55704e8fbafeff5ea0ccc0c9b07.tar.xz
mana-a1e483913672e55704e8fbafeff5ea0ccc0c9b07.zip
Cleaned up some code, as well as removed redundant talk client requesting
(which would happen from using the keyboard instead of the mouse). Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 9a7f6173..f655888c 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -111,19 +111,23 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
{
if (player_x > mPixelViewX + mScrollRadius)
{
- mPixelViewX += (player_x - mPixelViewX - mScrollRadius) / mScrollLaziness;
+ mPixelViewX += (player_x - mPixelViewX - mScrollRadius) /
+ mScrollLaziness;
}
if (player_x < mPixelViewX - mScrollRadius)
{
- mPixelViewX += (player_x - mPixelViewX + mScrollRadius) / mScrollLaziness;
+ mPixelViewX += (player_x - mPixelViewX + mScrollRadius) /
+ mScrollLaziness;
}
if (player_y > mPixelViewY + mScrollRadius)
{
- mPixelViewY += (player_y - mPixelViewY - mScrollRadius) / mScrollLaziness;
+ mPixelViewY += (player_y - mPixelViewY - mScrollRadius) /
+ mScrollLaziness;
}
if (player_y < mPixelViewY - mScrollRadius)
{
- mPixelViewY += (player_y - mPixelViewY + mScrollRadius) / mScrollLaziness;
+ mPixelViewY += (player_y - mPixelViewY + mScrollRadius) /
+ mScrollLaziness;
}
lastTick++;
}
@@ -166,8 +170,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
{
mMap->draw(graphics, (int) mPixelViewX, (int) mPixelViewY);
- // Find a path from the player to the mouse, and draw it. This is for debug
- // purposes.
+ // Find a path from the player to the mouse, and draw it. This is for
+ // debug purposes.
if (mShowDebugPath)
{
// Get the current mouse position
@@ -177,7 +181,8 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
int mouseTileX = mouseX / 32 + mTileViewX;
int mouseTileY = mouseY / 32 + mTileViewY;
- Path debugPath = mMap->findPath(player_node->mX, player_node->mY, mouseTileX, mouseTileY);
+ Path debugPath = mMap->findPath(player_node->mX, player_node->mY,
+ mouseTileX, mouseTileY);
graphics->setColor(gcn::Color(255, 0, 0));
for (PathIterator i = debugPath.begin(); i != debugPath.end(); i++)
@@ -186,7 +191,9 @@ void Viewport::draw(gcn::Graphics *gcnGraphics)
int squareY = i->y * 32 - (int) mPixelViewY + 12;
graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8));
- graphics->drawText(toString(mMap->getMetaTile(i->x, i->y)->Gcost), squareX + 4, squareY + 12, gcn::Graphics::CENTER);
+ graphics->drawText(toString(mMap->getMetaTile(i->x, i->y)->Gcost),
+ squareX + 4, squareY + 12,
+ gcn::Graphics::CENTER);
}
}
}
@@ -300,10 +307,12 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (being->mAction == Being::DEAD)
break;
- if (player_node->withinAttackRange(being) || keyboard.isKeyActive(keyboard.KEY_ATTACK))
+ if (player_node->withinAttackRange(being) ||
+ keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
player_node->setGotoTarget(being);
- player_node->attack(being, !keyboard.isKeyActive(keyboard.KEY_TARGET));
+ player_node->attack(being,
+ !keyboard.isKeyActive(keyboard.KEY_TARGET));
}
else
{