Добрый день :) Решил приняться за классы. Вроде все правильно, но вот при запуске вылетает.. Подскажите, где здесь ошибки. Питон 1.4.5, E50
#-*-coding:utf-8-*-
import appuifw as a
import graphics as g
import e32
import codecs
class Main:
def redraw(self,rect=None):
self.canvas.blit(self.back)
self.canvas.blit((-5,-5), self.sea)
self.canvas.blit((-self.cur_x, -self.cur_y), self.cursor, mask=self.mask)
def __init__(self):
self.canvas=a.Canvas(redraw_callback=self.redraw)
a.app.body=self.canvas
a.app.screen='full'
self.path='c:\\tmp'
self.state=1
#self.lang()
#self.load()
self.init_var()
self.init_images()
def init_var(self):
self.def_x=240
self.def_y=320
self.real_x,self.real_y=self.canvas.size()
self.draw_x=20
self.draw_y=20
self.len=20
self.cur_pos_x=0
self.cur_pos_y=0
self.cur_x=26
self.cur_y=26
self.array=[]
self.var_ship=3
self.index=0
def init_images(self):
self.back=g.Image.open(self.path+'\\images\\back.jpg')
self.sea=g.Image.open(self.path+'\\images\\sea.jpg')
self.mask=g.Image.new((20,20), fill=0x808080)
self.cursor==g.Image.new((20,20), fill=0xffff00)
self.ship[0]=g.Image.new((20,20), fill=0xff0000)
self.ship[1]=g.Image.new((20,41), fill=0xff0000)
self.ship[2]=g.Image.new((20,62), fill=0xff0000)
self.ship[3]=g.Image.new((20,84), fill=0xff0000)
def redraw_cur(self):
self.canvas.blit((-self.cur_x, -self.cur_y), self.cursor, mask=self.mask)
def load():
pass
def lang(self):
file=codecs.open(self.path+'\\lang.ini','r','utf-8')
tmp=file.read()
self.lang=tmp.split('\r\n')
return self.lang
def press(self,value):
if value=='right':
if self.cur_pos_x<10:
self.cur_pos_x+=1
self.cur_x+=((self.len + 1)*self.cur_pos_x)
self.lredraw_cur()
if value=='left':
if self.cur_pos_x>0:
self.cur_pos_x-=1
self.cur_x-=((self.len + 1)*self.cur_pos_x)
self.lredraw_cur()
if value=='down':
if self.cur_pos_y<10:
self.cur_pos_y+=1
self.cur_y+=((self.len + 1)*self.cur_pos_y)
self.lredraw_cur()
if value=='up':
if self.cur_pos_y>0:
self.cur_pos_y-=1
self.cur_y-=((self.len + 1)*self.cur_pos_y)
self.lredraw_cur()
if value=='5':
if self.state==0:
pass
if self.state==1:
self.array[self.index][0]=self.cur_pos_x
self.array[self.index][1]=self.cur_pos_y
self.sea.blit((-self.cur_x,-self.cur_y), self.ship[self.var_ship])
# if self.state==2:
f=Main()
self.canvas.bind(15, lambda:f.press('right'))
self.canvas.bind(14, lambda:f.press('left'))
self.canvas.bind(17, lambda:f.press('down'))
self.canvas.bind(16, lambda:f.press('up'))
self.canvas.bind(55, lambda:f.press('5'))
lock=e32.Ao_lock()
a.app.exit_key_handler=lambda:lock.signal()
lock.wait()