bulk commit
This commit is contained in:
parent
30343b5869
commit
e17d4282ac
4 changed files with 23 additions and 16 deletions
7
hr.py
7
hr.py
|
@ -45,15 +45,14 @@ class LoadScreen(object):
|
||||||
self.window.push_handlers(interface)
|
self.window.push_handlers(interface)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA,
|
||||||
|
pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)
|
||||||
|
window = Window(width=1024, height=768)
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
sys.exit("specify the map you want to load from the map folder\nusage: python hr.py \"A Viking We Shall Go\"")
|
sys.exit("specify the map you want to load from the map folder\nusage: python hr.py \"A Viking We Shall Go\"")
|
||||||
|
|
||||||
if not os.path.exists(os.path.join(pyglet.resource._default_loader._script_home,"maps","%s.h3m" % sys.argv[1])):
|
if not os.path.exists(os.path.join(pyglet.resource._default_loader._script_home,"maps","%s.h3m" % sys.argv[1])):
|
||||||
sys.exit("cannot find file %s" % os.path.join(pyglet.resource._default_loader._script_home,"maps","%s.h3m" % sys.argv[1]))
|
sys.exit("cannot find file %s" % os.path.join(pyglet.resource._default_loader._script_home,"maps","%s.h3m" % sys.argv[1]))
|
||||||
|
|
||||||
pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA,
|
|
||||||
pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)
|
|
||||||
window = Window(width=1024, height=768)
|
|
||||||
window.push_handlers(LoadScreen(window, sys.argv[1]))
|
window.push_handlers(LoadScreen(window, sys.argv[1]))
|
||||||
img = pyglet.resource.image("data/cursors/cradvntr.def/0.png")
|
img = pyglet.resource.image("data/cursors/cradvntr.def/0.png")
|
||||||
window.set_mouse_cursor(pyglet.window.ImageMouseCursor(img, 0, 40))
|
window.set_mouse_cursor(pyglet.window.ImageMouseCursor(img, 0, 40))
|
||||||
|
|
|
@ -23,27 +23,24 @@ from lib import h3m
|
||||||
import os
|
import os
|
||||||
|
|
||||||
class OrderedTextureGroup(pyglet.graphics.Group):
|
class OrderedTextureGroup(pyglet.graphics.Group):
|
||||||
def __init__(self, order, texture, parent=None):
|
def __init__(self, order, texture):
|
||||||
super(OrderedTextureGroup, self).__init__(parent)
|
super(OrderedTextureGroup, self).__init__()
|
||||||
self.texture = texture
|
self.texture = texture
|
||||||
self.order = order
|
self.order = order
|
||||||
|
|
||||||
def set_state(self):
|
def set_state(self):
|
||||||
pyglet.gl.glEnable(self.texture.target)
|
pyglet.gl.glBindTexture(pyglet.gl.GL_TEXTURE_2D, self.texture.id)
|
||||||
pyglet.gl.glBindTexture(self.texture.target, self.texture.id)
|
|
||||||
|
|
||||||
def unset_state(self):
|
def unset_state(self):
|
||||||
pyglet.gl.glDisable(self.texture.target)
|
pass
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self):
|
||||||
return hash((self.order, self.texture.target, self.texture.id, self.parent))
|
return hash((self.order, self.texture.id))
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return (self.__class__ is other.__class__ and
|
return (self.__class__ is other.__class__ and
|
||||||
self.order == other.order and
|
self.order == other.order and
|
||||||
self.texture.target == other.texture.target and
|
self.texture.id == other.texture.id)
|
||||||
self.texture.id == other.texture.id and
|
|
||||||
self.parent == self.parent)
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '%s(order=%d, id=%d)' % (self.__class__.__name__, self.order, self.texture.id)
|
return '%s(order=%d, id=%d)' % (self.__class__.__name__, self.order, self.texture.id)
|
||||||
|
@ -93,7 +90,7 @@ class Animation(object):
|
||||||
|
|
||||||
class Animation_Object(object):
|
class Animation_Object(object):
|
||||||
def __init__(self, animation, group=None):
|
def __init__(self, animation, group=None):
|
||||||
if group:
|
if group != None:
|
||||||
self.texgroup = group
|
self.texgroup = group
|
||||||
else:
|
else:
|
||||||
self.texgroup = animation.texgroup
|
self.texgroup = animation.texgroup
|
||||||
|
@ -179,7 +176,7 @@ class MapSet(object):
|
||||||
for x, tile in enumerate(line):
|
for x, tile in enumerate(line):
|
||||||
if tile[0] == -1: #edge
|
if tile[0] == -1: #edge
|
||||||
if "edg" not in list(tile_textures.keys()):
|
if "edg" not in list(tile_textures.keys()):
|
||||||
tile_textures["edg"] = [self.load_map_object('data/advmap_tiles/edg.def/%d.png'%i, 1000) for i in range(36)]
|
tile_textures["edg"] = [self.load_map_object('data/advmap_tiles/edg.def/%d.png'%i, 100) for i in range(36)]
|
||||||
self.__tiles[x,y] = [tile_textures["edg"][tile[1]]]
|
self.__tiles[x,y] = [tile_textures["edg"][tile[1]]]
|
||||||
elif tile[0] == 0: #dirt
|
elif tile[0] == 0: #dirt
|
||||||
if "dirttl" not in list(tile_textures.keys()):
|
if "dirttl" not in list(tile_textures.keys()):
|
||||||
|
|
|
@ -131,7 +131,9 @@ class MapView(object):
|
||||||
def draw(self):
|
def draw(self):
|
||||||
pyglet.gl.glTranslatef(self.view_x+IF_LEFT, self.view_y+IF_BOTTOM, 0)
|
pyglet.gl.glTranslatef(self.view_x+IF_LEFT, self.view_y+IF_BOTTOM, 0)
|
||||||
pyglet.gl.glScalef(self.tile_size/32.0, self.tile_size/32.0, 0.0)
|
pyglet.gl.glScalef(self.tile_size/32.0, self.tile_size/32.0, 0.0)
|
||||||
|
pyglet.gl.glEnable(pyglet.gl.GL_TEXTURE_2D)
|
||||||
self.batch.draw()
|
self.batch.draw()
|
||||||
|
pyglet.gl.glDisable(pyglet.gl.GL_TEXTURE_2D)
|
||||||
|
|
||||||
def _move(self, dx, dy):
|
def _move(self, dx, dy):
|
||||||
# new map position
|
# new map position
|
||||||
|
|
9
setup.py
Normal file
9
setup.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from distutils.core import setup
|
||||||
|
from distutils.extension import Extension
|
||||||
|
from Cython.Distutils import build_ext
|
||||||
|
|
||||||
|
setup(
|
||||||
|
cmdclass = {'build_ext': build_ext},
|
||||||
|
ext_modules = [Extension("blit_into", ["lib/blit_into.pyx"]),
|
||||||
|
Extension("batch", ["lib/batch.pyx"])]
|
||||||
|
)
|
Loading…
Reference in a new issue