[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2455 - in trunk: data/data src src/worldobjs
From: |
David Philippi at BerliOS |
Subject: |
[Pingus-CVS] r2455 - in trunk: data/data src src/worldobjs |
Date: |
Fri, 7 Oct 2005 17:22:45 +0200 |
Author: torangan
Date: 2005-10-07 17:22:43 +0200 (Fri, 07 Oct 2005)
New Revision: 2455
Modified:
trunk/data/data/traps.xml
trunk/src/pingus_level_impl.hxx
trunk/src/pingus_main.cxx
trunk/src/pingus_main.hxx
trunk/src/pingus_menu.cxx
trunk/src/pingus_menu.hxx
trunk/src/worldobjs/guillotine.cxx
trunk/src/worldobjs/guillotine.hxx
trunk/src/xml_pingus_level.cxx
Log:
applied patch from Jason Green
Modified: trunk/data/data/traps.xml
===================================================================
--- trunk/data/data/traps.xml 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/data/data/traps.xml 2005-10-07 15:22:43 UTC (rev 2455)
@@ -10,52 +10,60 @@
<sprite name="smasher">
<image file="../images/traps/smasher.png">
- <grid array="6,1" height="189" width="282" x="0" y="0" />
+ <grid pos="0,0" size="282,189" array="6,1" />
</image>
</sprite>
<sprite name="hammer">
- <animation loop="no"/>
+ <animation speed="60" loop="no" />
<image file="../images/traps/hammer.png">
- <grid array="13,1" height="181" width="151" x="0" y="0" />
+ <grid pos="0,0" size="151,181" array="13,1" />
</image>
</sprite>
<sprite name="fake_exit">
<translation origin="bottom_center"/>
<image file="../images/traps/fake_exit.png">
- <grid array="9,1" height="112" tcol="0" width="75" x="0" y="0" />
+ <grid pos="0,0" size="75,112" array="9,1" />
</image>
</sprite>
<sprite name="spike">
<image file="../images/traps/spike.png">
- <grid array="14,1" height="32" tcol="0" width="32" x="0" y="0" />
+ <grid pos="0,0" size="32,32" array="14,1" />
</image>
</sprite>
- <sprite name="guillotinekill">
- <image file="../images/traps/guillotinekill.png">
- <grip array="12,2" height="96" tcol="0" width="80" x="0" y="0" />
- </image>
- </sprite>
-
+ <section name="guillotinekill">
+ <sprite name="left">
+ <image file="../images/traps/guillotinekill.png">
+ <grid pos="0,0" size="80,96" array="12,1" />
+ </image>
+ </sprite>
+
+ <sprite name="right">
+ <image file="../images/traps/guillotinekill.png">
+ <grid pos="0,96" size="80,96" array="12,1" />
+ </image>
+ </sprite>
+ </section>
+
<sprite name="guillotineidle">
<image file="../images/traps/guillotineidle.png">
- <grip array="7,1" height="96" tcol="0" width="80" x="0" y="0" />
+ <grid pos="0,0" size="80,96" array="7,1" />
</image>
</sprite>
-
+
<sprite name="laser_exit">
<image file="../images/traps/laser_exit.png">
- <grid array="6,1" height="60" tcol="0" width="75" x="0" y="0" />
+ <grid pos="0,0" size="75,60" array="6,1" />
</image>
</sprite>
<sprite name="bumper">
<translation origin="bottom_center"/>
<image file="../images/traps/bumper.png">
- <grid array="6,1" height="102" tcol="0" width="60" x="0" y="0" />
+ <grid pos="0,0" size="60,102" array="6,1" />
</image>
</sprite>
Modified: trunk/src/pingus_level_impl.hxx
===================================================================
--- trunk/src/pingus_level_impl.hxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/pingus_level_impl.hxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -33,6 +33,15 @@
class PingusLevelImpl
{
public:
+
+ // Set defaults in constructor
+ PingusLevelImpl()
+ : ambient_light(CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f)),
+ music("none")
+ {
+ // Do nothing
+ }
+
std::string resname;
std::string levelname;
Modified: trunk/src/pingus_main.cxx
===================================================================
--- trunk/src/pingus_main.cxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/pingus_main.cxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -121,6 +121,7 @@
{
show_credits = false;
blitter_test = false;
+ refresh_rate = 60;
}
PingusMain::~PingusMain()
@@ -197,6 +198,8 @@
_("Start in Window Mode"));
argp.add_option('f', "fullscreen", "",
_("Start in Fullscreen"));
+ argp.add_option('R', "refresh-rate", "",
+ _("Set the refresh rate in fullscreen (default: 60)"));
argp.add_option('d', "datadir", _("PATH"),
_("Set the path to load the data files to 'path'"));
argp.add_option('l', "level", _("FILE"),
@@ -278,6 +281,7 @@
{"geometry", required_argument, 0, 'g'},
{"quick-play", no_argument, 0, 'q'},
{"fullscreen", no_argument, 0, 'f'},
+ ("refresh-rate", required_argument, 0, 'R'),
{"window", no_argument, 0, 'w'},
{"disable-swcursor", no_argument, 0, 345},
{"enable-swcursor", no_argument, 0, 346},
@@ -414,6 +418,11 @@
fullscreen_enabled = true;
break;
+ case 'R': // --refresh-rate
+ sscanf(argp.get_argument().c_str(), "%d", &refresh_rate);
+ std::cout << "Pingus: Refresh rate is " << refresh_rate << std::endl;
+ break;
+
case 'w': // --window
fullscreen_enabled = false;
break;
@@ -659,7 +668,8 @@
std::cout << _("fullscreen: ")
<< (fullscreen_enabled ? _(" enabled") : _("disabled"))
<< std::endl;
-
+ std::cout << _("refresh rate: ") << refresh_rate << std::endl;
+
std::cout << std::endl;
}
@@ -863,8 +873,15 @@
<< screen_width << "x" << screen_height << std::endl;
}
- window = new CL_DisplayWindow(PACKAGE_STRING,
- screen_width, screen_height,
fullscreen_enabled, false);
+ CL_DisplayWindowDescription window_desc;
+ window_desc.set_size(CL_Size(screen_width, screen_height));
+ window_desc.set_title(PACKAGE_STRING);
+ window_desc.set_fullscreen(fullscreen_enabled);
+ window_desc.set_allow_resize(false);
+ window_desc.set_refresh_rate(refresh_rate);
+
+ window = new CL_DisplayWindow(window_desc);
+
sound = new CL_SoundOutput(44100);
CL_Display::clear();
Modified: trunk/src/pingus_main.hxx
===================================================================
--- trunk/src/pingus_main.hxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/pingus_main.hxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -47,7 +47,8 @@
std::string worldmapfile;
std::string resolution;
-
+ int refresh_rate;
+
CL_Slot on_button_press_slot;
CL_Slot on_button_release_slot;
Modified: trunk/src/pingus_menu.cxx
===================================================================
--- trunk/src/pingus_menu.cxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/pingus_menu.cxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -18,19 +18,26 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <ClanLib/Display/display.h>
+#include <ClanLib/core.h>
+#include <ClanLib/gui.h>
+#include <ClanLib/guistylesilver.h>
#include <config.h>
#include "gettext.h"
#include "menu_button.hxx"
#include "resource.hxx"
#include "debug.hxx"
+#include "globals.hxx"
#include "sound/sound.hxx"
#include "stat_manager.hxx"
+#include "start_screen.hxx"
#include "story_screen.hxx"
#include "story.hxx"
#include "worldmap/manager.hxx"
#include "gui/screen_manager.hxx"
#include "pingus_menu_manager.hxx"
#include "gui/gui_manager.hxx"
+#include "plf_res_mgr.hxx"
+#include "path_manager.hxx"
namespace Pingus {
@@ -74,6 +81,8 @@
slots.push_back(story_button->sig_click().connect(this,
&PingusMenu::do_start));
slots.push_back(multiplayer_button->sig_click().connect(this,
&PingusMenu::setup_main_menu));
+
+ slots.push_back(contrib_button->sig_click().connect(this,
&PingusMenu::setup_contrib_menu));
}
void
@@ -99,6 +108,45 @@
}
void
+PingusMenu::setup_contrib_menu()
+{ // Remove buttons and select a level to play
+ gui_manager->remove(contrib_button);
+ gui_manager->remove(story_button);
+ gui_manager->remove(multiplayer_button);
+
+ // Create a Clanlib GUIManager using the silver style
+ CL_ResourceManager *resources = new
+ CL_ResourceManager(path_manager.complete("GUIStyleSilver/gui.xml"));
+ CL_StyleManager_Silver *style = new CL_StyleManager_Silver(resources);
+ CL_GUIManager *gui = new CL_GUIManager(style);
+ CL_FileDialog *filedialog = new CL_FileDialog("Levels", "", "*.pingus",
gui, style);
+
+ // This next line is a workaround until ClanLib applies my patch to
their SVN
+ // set_dir should do this automatically.
+ CL_Directory::change_to(path_manager.complete("levels"));
+
+ filedialog->set_dir(path_manager.complete("levels"));
+ filedialog->run();
+ const std::string filename = filedialog->get_file();
+ pout(PINGUS_DEBUG_LOADING) << "PingusMenu: Chose filename: " << filename <<
std::endl;
+
+ // Clean up ClanLib stuff
+ delete filedialog;
+ delete gui;
+ delete style;
+ delete resources;
+
+ // Launch level
+ if (filename != "")
+ do_contrib(filename);
+
+ // Reset menu
+ gui_manager->add(contrib_button);
+ gui_manager->add(story_button);
+ gui_manager->add(multiplayer_button);
+}
+
+void
PingusMenu::preload ()
{
if (!is_init)
@@ -138,6 +186,14 @@
}
}
+void PingusMenu::do_contrib(const std::string &levelfile)
+{ // Launch the specified level - don't bother checking for it, it has to exist
+ Sound::PingusSound::play_sound ("letsgo");
+ ScreenManager::instance()->push_screen
+ (new StartScreen(PLFResMgr::load_plf_from_filename(levelfile)),
+ true);
+}
+
void
PingusMenu::on_resize(int w, int h)
{
Modified: trunk/src/pingus_menu.hxx
===================================================================
--- trunk/src/pingus_menu.hxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/pingus_menu.hxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -58,11 +58,14 @@
void on_resize (int w, int h);
+ // These functions setup the different menus
void setup_main_menu();
void setup_game_menu();
-
+ void setup_contrib_menu();
+
void do_quit();
void do_start();
+ void do_contrib(const std::string&);
public:
PingusMenu (PingusMenuManager* m);
Modified: trunk/src/worldobjs/guillotine.cxx
===================================================================
--- trunk/src/worldobjs/guillotine.cxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/worldobjs/guillotine.cxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -28,21 +28,16 @@
namespace WorldObjs {
Guillotine::Guillotine(const FileReader& reader)
- : surface (Resource::load_sprite("traps/guillotinekill")),
- idle_surf(Resource::load_sprite("traps/guillotineidle")),
+ : sprite_kill_right (Resource::load_sprite("traps/guillotinekill/right")),
+ sprite_kill_left (Resource::load_sprite("traps/guillotinekill/left")),
+ sprite_idle (Resource::load_sprite("traps/guillotineidle")),
killing(false)
{
reader.read_vector("position", pos);
-
- counter.set_size(surface.get_frame_count()/2);
- counter.set_type(GameCounter::once);
- counter.set_speed(0.7);
- counter = 0;
-
- idle_counter.set_size(idle_surf.get_frame_count());
- idle_counter.set_type(GameCounter::loop);
- idle_counter.set_speed(0.3);
- idle_counter = 0;
+
+ sprite_kill_right.set_play_loop(false);
+ sprite_kill_left.set_play_loop(false);
+ sprite_idle.set_play_loop(true);
}
void
@@ -50,11 +45,11 @@
{
if (killing) {
if (direction.is_left())
- gc.color().draw(surface, pos, counter);
+ gc.color().draw (sprite_kill_left, pos);
else
- gc.color().draw (surface, pos, counter + 12);
+ gc.color().draw (sprite_kill_right, pos);
} else {
- gc.color().draw (idle_surf, pos, idle_counter);
+ gc.color().draw (sprite_idle, pos);
}
}
@@ -68,19 +63,23 @@
void
Guillotine::update ()
{
- if (counter.finished()) {
- counter = 0;
+ // Only have to check one sprite because they update simultaneously
+ if (sprite_kill_left.is_finished())
killing = false;
- }
PinguHolder* holder = world->get_pingus();
for (PinguIter pingu = holder->begin (); pingu != holder->end (); ++pingu)
catch_pingu(*pingu);
if (killing) {
- ++counter;
+ // Update both sprites so they finish at the same time.
+ sprite_kill_left.update();
+ sprite_kill_right.update();
+ // FIXME: Should be a different sound
+ if (sprite_kill_left.get_current_frame() == 7)
+ WorldObj::get_world()->play_sound("splash", pos);
} else {
- ++idle_counter;
+ sprite_idle.update();
}
}
@@ -95,6 +94,8 @@
killing = true;
pingu->set_status(PS_DEAD);
direction = pingu->direction;
+ sprite_kill_left.restart();
+ sprite_kill_right.restart();
}
}
}
Modified: trunk/src/worldobjs/guillotine.hxx
===================================================================
--- trunk/src/worldobjs/guillotine.hxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/worldobjs/guillotine.hxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -37,12 +37,11 @@
class Guillotine : public WorldObj
{
private:
- CL_Sprite surface;
- CL_Sprite idle_surf;
+ CL_Sprite sprite_kill_right;
+ CL_Sprite sprite_kill_left;
+ CL_Sprite sprite_idle;
Vector pos;
Direction direction;
- GameCounter counter;
- GameCounter idle_counter;
bool killing;
Modified: trunk/src/xml_pingus_level.cxx
===================================================================
--- trunk/src/xml_pingus_level.cxx 2005-10-05 11:59:11 UTC (rev 2454)
+++ trunk/src/xml_pingus_level.cxx 2005-10-07 15:22:43 UTC (rev 2455)
@@ -68,9 +68,6 @@
}
else if (node.get_tag_name() == "head")
{
- // FIXME: Move default stuff to pingus_level_impl
- impl->ambient_light = CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f);
-
XMLFileReader reader(node);
reader.read_string("levelname", impl->levelname);
reader.read_string("description", impl->description);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2455 - in trunk: data/data src src/worldobjs,
David Philippi at BerliOS <=