diff --git a/src/gfx/sprite.cc b/src/gfx/sprite.cc index 44a5c09..c6fb640 100644 --- a/src/gfx/sprite.cc +++ b/src/gfx/sprite.cc @@ -185,7 +185,7 @@ namespace gfx bool sprite::load (const std::string & filename) { const std::string & file = (filename.length() != 0) ? filename : m_filename; - bool retval; + bool retval = false; // load raw png as one animation, one frame sprite if (file.find (".png", file.size() - 4) != std::string::npos) @@ -196,6 +196,7 @@ namespace gfx animation_list cur_animation; cur_animation.push_back (new animation_frame (surfaces->get_surface (full_path, false, false), 0)); m_states["default"] = cur_animation; + retval = true; } } else diff --git a/src/world/CMakeLists.txt b/src/world/CMakeLists.txt index b14f057..e259f9e 100644 --- a/src/world/CMakeLists.txt +++ b/src/world/CMakeLists.txt @@ -54,7 +54,7 @@ set(adonthell_world_HEADERS triangle3.h vector3.h world.h - zonw.h + zone.h ) diff --git a/test/worldtest.py b/test/worldtest.py index b791913..72853d7 100644 --- a/test/worldtest.py +++ b/test/worldtest.py @@ -1,18 +1,43 @@ -from adonthell import world, gfx, event, base +from adonthell import world, gfx, input, event, base import adonthell.main import sys +## Our exit variable +letsexit = 0 + +def handle_keys (ev): + global letsexit + print("in handle keys") + if ev.type() == input.keyboard_event.KEY_PUSHED: + if ev.key() == input.keyboard_event.ESCAPE_KEY: + letsexit = 1 + print "Escape pressed, leaving..." + return 1 + class App (adonthell.main.AdonthellApp): def worldtest (self): + global handle_keys # -- need gfx backend for graphics - self.init_modules (self.GFX) + self.init_modules (self.GFX| self.INPUT) # -- add data directory to python search path sys.path.insert (0, "data") # -- need this for SDL backend to work - gfx.screen.set_video_mode (640, 480) + #gfx.screen.set_video_mode (640, 480) + #gfx.screen.set_video_mode (1024, 768) + gfx.screen.set_video_mode (1280, 1024) + + + ## Create our input_listener and connect the callback + ## to handle keyboard events + il = input.listener() + il.connect_keyboard_function(handle_keys) + + ## Add the listener to the manager + input.manager.add(il) + # -- create world wrld = world.area () @@ -55,7 +80,7 @@ def worldtest (self): cur_mov = 0 # -- main loop - while 1: + while not letsexit: if i in mov: # -- let character walk chr.remove_direction(cur_mov) @@ -71,7 +96,10 @@ def worldtest (self): # -- process map view view.update () view.draw (0, 0) - + + # update keys + input.manager.update() + # -- debugging chr.debug_collision(0, 0) print chr.x(), chr.y(), chr.z()