summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-02-06 18:17:09 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-02-06 18:17:09 +0000
commit5ec4143bde0fd67c7aca841804a5d165c794bdf0 (patch)
tree4ecfaf02a2f1831d545d21de3385b34b6c8c4388 /src/gui/minimap.cpp
parent49ea67bae1d2969c21005c06bb764f3c6b479e9c (diff)
downloadmana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.tar.gz
mana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.tar.bz2
mana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.tar.xz
mana-client-5ec4143bde0fd67c7aca841804a5d165c794bdf0.zip
Added minimal minimap
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp
new file mode 100644
index 00000000..a1104b8a
--- /dev/null
+++ b/src/gui/minimap.cpp
@@ -0,0 +1,84 @@
+/*
+ * The Mana World
+ * Copyright 2004-2005 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $IdS
+ */
+
+#define MINIMAP_W 100
+#define MINIMAP_H 100
+
+#include "minimap.h"
+#include "../being.h"
+
+Minimap::Minimap()
+{
+ setSize(MINIMAP_W, MINIMAP_H);
+ setPosition(20, 20);
+
+ mapBackground = SDL_AllocSurface(SDL_SWSURFACE, MINIMAP_W, MINIMAP_H,
+ (screen->format->BytesPerPixel*8), 0, 0, 0, 0);
+ Uint32 mapColor = SDL_MapRGB(screen->format, 255, 255, 255);
+ SDL_Rect sourceRect;
+ sourceRect.x = sourceRect.y = 0;
+ sourceRect.w = MINIMAP_W;
+ sourceRect.h = MINIMAP_H;
+ if ( mapBackground )
+ {
+ SDL_FillRect(mapBackground, &sourceRect, mapColor);
+ SDL_SetAlpha(mapBackground, SDL_SRCALPHA, 120);
+ }
+}
+
+void Minimap::draw(gcn::Graphics *graphics)
+{
+ int x, y;
+
+ getAbsolutePosition(x, y);
+
+ if ( (mapBackground->w != getWidth()) || (mapBackground->h != getHeight()) )
+ {
+ SDL_FreeSurface(mapBackground);
+ mapBackground = SDL_AllocSurface(SDL_SWSURFACE, getWidth(), getHeight(),
+ (screen->format->BytesPerPixel*8), 0, 0, 0, 0);
+ Uint32 mapColor = SDL_MapRGB(screen->format, 52, 149, 210);
+ SDL_Rect sourceRect;
+ sourceRect.x = sourceRect.y = 0;
+ sourceRect.w = getWidth();
+ sourceRect.h = getHeight();
+ if ( mapBackground )
+ {
+ SDL_FillRect(mapBackground, &sourceRect, mapColor);
+ SDL_SetAlpha(mapBackground, SDL_SRCALPHA, 120);
+ }
+
+ }
+
+ SDL_Rect screenRect;
+ screenRect.w = getWidth();
+ screenRect.h = getHeight();
+ screenRect.x = x;
+ screenRect.y = y;
+ if ( mapBackground ) SDL_BlitSurface(mapBackground, NULL, screen, &screenRect);
+
+ graphics->drawRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight()));
+ graphics->setColor(gcn::Color(209, 52, 61));
+ graphics->fillRectangle(gcn::Rectangle(player_node->x /2,
+ player_node->y / 2, 3, 3));
+} \ No newline at end of file