Skip to content

Commit

Permalink
FIXED bugs in CMake build and raw PNG loading (thanks Enrico!)
Browse files Browse the repository at this point in the history
ADDED exit handler to worldtest.py (thanks Enrico!)
  • Loading branch information
Kai Sterker authored and Kai Sterker committed Jun 15, 2009
1 parent 816a7fa commit 6fc0be3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/gfx/sprite.cc
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/world/CMakeLists.txt
Expand Up @@ -54,7 +54,7 @@ set(adonthell_world_HEADERS
triangle3.h
vector3.h
world.h
zonw.h
zone.h
)


Expand Down
38 changes: 33 additions & 5 deletions 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 ()
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down

0 comments on commit 6fc0be3

Please sign in to comment.