added renderer
This commit is contained in:
parent
486f7e6029
commit
6f63bc97ca
5 changed files with 23 additions and 14 deletions
3
hr.py
3
hr.py
|
@ -21,6 +21,7 @@ import pyglet
|
|||
from lib.mapset import *
|
||||
from lib.interface import *
|
||||
from lib.mapview import *
|
||||
from lib.render import *
|
||||
from lib.window import Window
|
||||
import sys
|
||||
|
||||
|
@ -37,7 +38,9 @@ class LoadScreen(object):
|
|||
self.label.text = "INITIATING MAPVIEW..."
|
||||
mapview = MapView(mapset, self.window)
|
||||
interface = Interface(self.window)
|
||||
renderer = Renderer(self.window, mapview, interface)
|
||||
self.window.pop_handlers()
|
||||
self.window.push_handlers(renderer)
|
||||
self.window.push_handlers(mapview)
|
||||
self.window.push_handlers(interface)
|
||||
self.window.push_handlers(self.window.keys)
|
||||
|
|
|
@ -159,7 +159,7 @@ def extract(filename):
|
|||
(exp, ) = struct.unpack("<I", h3m_data.read(4))
|
||||
(isSecSkill, ) = struct.unpack("<B", h3m_data.read(1))
|
||||
if isSecSkill == 0x01:
|
||||
(skills_count) = struct.unpack("<I", h3m_data.read(4))
|
||||
(skills_count, ) = struct.unpack("<I", h3m_data.read(4))
|
||||
for i in range(skills_count):
|
||||
(skill_id, ) = struct.unpack("<B", h3m_data.read(1))
|
||||
(skill_lvl, ) = struct.unpack("<B", h3m_data.read(1))
|
||||
|
|
|
@ -36,3 +36,20 @@ class Interface(object):
|
|||
pass
|
||||
else:
|
||||
return pyglet.event.EVENT_HANDLED
|
||||
|
||||
def on_mouse_drag(self, x, y, dx, dy, buttons, modifiers):
|
||||
if IF_LEFT < x < (self.window.width-IF_RIGHT):
|
||||
pass
|
||||
else:
|
||||
return pyglet.event.EVENT_HANDLED
|
||||
if IF_BOTTOM < y < (self.window.height-IF_TOP):
|
||||
pass
|
||||
else:
|
||||
return pyglet.event.EVENT_HANDLED
|
||||
|
||||
def draw(self):
|
||||
pyglet.gl.glColor4f(1, 0, 1, 1)
|
||||
pyglet.gl.glRectf(0, 0, self.window.width, IF_BOTTOM)
|
||||
pyglet.gl.glRectf(self.window.width-IF_RIGHT, 0, self.window.width, self.window.height)
|
||||
pyglet.gl.glRectf(0, self.window.height-IF_TOP, self.window.width, self.window.height)
|
||||
pyglet.gl.glRectf(0, 0, IF_LEFT, self.window.height)
|
||||
|
|
|
@ -127,21 +127,10 @@ class MapView(object):
|
|||
self.view_x = mod_x - self.tile_size - (self.tile_size - 32) // 4
|
||||
self.view_y = mod_y - self.tile_size - ((self.tile_size - 32) * 3) // 2
|
||||
|
||||
def on_draw(self):
|
||||
pyglet.gl.glClear(pyglet.gl.GL_COLOR_BUFFER_BIT)
|
||||
pyglet.gl.glPushMatrix()
|
||||
def draw(self):
|
||||
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)
|
||||
self.batch.draw()
|
||||
pyglet.gl.glPopMatrix()
|
||||
pyglet.gl.glLoadIdentity()
|
||||
pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
|
||||
pyglet.gl.glColor4f(1, 0, 1, 1)
|
||||
pyglet.gl.glRectf(0, 0, self.window.width, IF_BOTTOM)
|
||||
pyglet.gl.glRectf(self.window.width-IF_RIGHT, 0, self.window.width, self.window.height)
|
||||
pyglet.gl.glRectf(0, self.window.height-IF_TOP, self.window.width, self.window.height)
|
||||
pyglet.gl.glRectf(0, 0, IF_LEFT, self.window.height)
|
||||
self.label.draw()
|
||||
|
||||
def _move(self, dx, dy):
|
||||
# new map position
|
||||
|
|
|
@ -29,7 +29,7 @@ class Window(pyglet.window.Window):
|
|||
self.fps = pyglet.clock.ClockDisplay()
|
||||
pyglet.clock.schedule(lambda dt: None)
|
||||
|
||||
def on_draw(self):
|
||||
def draw(self):
|
||||
self.fps.draw()
|
||||
|
||||
def on_key_press(self, symbol, modifiers):
|
||||
|
|
Loading…
Reference in a new issue