[Supertux-Commit] r5420 - in trunk/supertux: data/images/engine/menu src/gui

grumbel at millhouse.dreamhost.com grumbel at millhouse.dreamhost.com
Mon May 5 13:08:42 PDT 2008


Author: grumbel
Date: 2008-05-05 13:08:41 -0700 (Mon, 05 May 2008)
New Revision: 5420

Modified:
   trunk/supertux/data/images/engine/menu/frame.png
   trunk/supertux/src/gui/menu.cpp
Log:
Added scrolling to the menu (a little crude, but working)

Modified: trunk/supertux/data/images/engine/menu/frame.png
===================================================================
(Binary files differ)

Modified: trunk/supertux/src/gui/menu.cpp
===================================================================
--- trunk/supertux/src/gui/menu.cpp	2008-05-05 19:03:41 UTC (rev 5419)
+++ trunk/supertux/src/gui/menu.cpp	2008-05-05 20:08:41 UTC (rev 5420)
@@ -342,6 +342,13 @@
 void
 Menu::update()
 {
+  int menu_height = get_height();
+  if (menu_height > SCREEN_HEIGHT)
+    { // Scrolling
+      int scroll_offset = (menu_height - SCREEN_HEIGHT) / 2 + 32;
+      pos_y = SCREEN_HEIGHT/2 - scroll_offset * ((float(active_item) / (items.size()-1)) - 0.5f) * 2.0f;
+    }
+
   effect_progress = (real_time - effect_start_time) * 6.0f;
 
   if(effect_progress >= 1.0f) {




More information about the Supertux-Commit mailing list