Please note that today a new pre-alpha version has been released !!!!
Many changes but attention only download 1stEd for installing on phone the 2ndEd has an error in the file !
There are other apps : Tetris , ball , keyviewer , image viewer :-)
There are new modules :
1) an advanced camera module (flash , exposure mode etc :-) for supported models !
2) calendar db access
3) audio (play and record sound )
4) telephone (dial number and hang up)
5) image (load , save , resize )
There are also changes in the api (no use of app.screen = appuifw.MAIN_PANE now it becomes app.screen = 'full' ;-)
I can't find the 1st edition for phone to download.
I download all 3 packages available
- 1st ed (1.2) SDK
- 2nd ed (2.0) SDK
- 2nd ed (2.0) Phone
But can't find any tetris example.
Can you post the tetris example here?
I install the 2nd ed on my phone just fine. What's the problm? (or have they fixed it?)
class Keyboard(object):
def __init__(self,onevent=lambda:None):
self._keyboard_state={}
self._downs={}
self._onevent=onevent
def handle_event(self,event):
if event['type'] == appuifw.EEventKeyDown:
code=event['scancode']
if not self.is_down(code):
self._downs[code]=self._downs.get(code,0)+1
self._keyboard_state[code]=1
elif event['type'] == appuifw.EEventKeyUp:
self._keyboard_state[event['scancode']]=0
self._onevent()
def is_down(self,scancode):
return self._keyboard_state.get(scancode,0)
def pressed(self,scancode):
if self._downs.get(scancode,0):
self._downs[scancode]-=1
return True
return False
running=1
def quit():
global running
running=0
appuifw.app.exit_key_handler=quit
class Playfield(object):
def __init__(self,size,draw,bordercolor=0xc0c0c0):
self._data={}
self._size=size
self._draw=draw
for x in range(0,size[0]):
for y in range(0,size[1]):
self[(x,y)]=0
# Initialize playing field borders
for y in range(-1,size[1]+1):
self[(-1,y)]=bordercolor
self[(size[0],y)]=bordercolor
for x in range(-1,size[0]+1):
self[(x,-1)]=bordercolor
self[(x,size[1])]=bordercolor
self.draw()
def __getitem__(self,loc):
return self._data.setdefault(tuple(loc),0)
def __setitem__(self,loc,value):
self._data[loc]=value
self.update_loc(loc)
def remove_row(self,row):
for x in range(0,self._size[0]):
self[(x,0)]=0
for y in range(row,0,-1):
for x in range(0,self._size[0]):
self[(x,y)]=self[(x,y-1)]
def row_is_full(self,row):
for x in range(0,self._size[0]):
if not self[(x,row)]:
return False
return True
def update_loc(self,loc):
w=8
x,y=((loc[0]+1)*w,(loc[1]+1)*w)
self._draw.rectangle((x,y,x+w,y+w),None,self[loc])
def draw(self):
w=8
for loc in self._data:
self.update_loc(loc)
# with draw.rectangle((x,y,x+w,y+w),fill=self[loc]) 472 ms
# without 89 ms
# draw.rectangle((x,y,x+w,y+w),fill=0xff0000,outline=0x00ff00) 375 ms
# draw.rectangle((x,y,x+w,y+w)) without params setting, kw parsing 125 ms
class Piece(object):
def __init__(self,squares,color):
self._squares=squares
self._color=color
def fits_in(self,loc,angle,field):
for s in self._squares[angle]:
if field[(s[0]+loc[0],s[1]+loc[1])]:
return False
return True
def put_to(self,loc,angle,field):
for s in self._squares[angle]:
field[(s[0]+loc[0],s[1]+loc[1])]=self._color
def remove_from(self,loc,angle,field):
for s in self._squares[angle]:
field[(s[0]+loc[0],s[1]+loc[1])]=0
while playing:
lines=0
level=1
x,y=3,0
angle=0
piece=pieces[random.randint(0,len(pieces)-1)]
drop_interval=0.5
draw.clear(0x000000)
draw.blit(logo,target=(106,100))
draw_score(draw)
field=Playfield(fieldsize,draw)
previous_drop=time.clock()
e32.ao_sleep(drop_interval,lock.signal)
running=1
while running:
piece.remove_from((x,y),angle,field)
while keyboard.pressed(EScancodeLeftArrow) and piece.fits_in((x-1,y),angle,field):
x-=1
lock.signal()
while keyboard.pressed(EScancodeRightArrow) and piece.fits_in((x+1,y),angle,field):
x+=1
lock.signal()
while keyboard.pressed(EScancodeUpArrow) and piece.fits_in((x,y),(angle-1)%4,field):
angle=(angle-1)%4
if keyboard.pressed(EScancodeDownArrow):
while piece.fits_in((x,y+1),angle,field):
y+=1
if time.clock()-previous_drop >= drop_interval:
if piece.fits_in((x,y+1),angle,field):
y+=1
else:
piece.put_to((x,y),angle,field)
removed_lines=0
for y in range(fieldsize[1]):
if field.row_is_full(y):
field.remove_row(y)
removed_lines += 1
if removed_lines:
lines += removed_lines
level=int(lines/10)+1
drop_interval=0.5*(0.85**(level-1))
draw_score(draw)
x,y=3,0
angle=0
piece=pieces[random.randint(0,len(pieces)-1)]
if not piece.fits_in((x,y),angle,field):
appuifw.note(u'Game over!','info')
running=0
previous_drop=time.clock()
e32.ao_sleep(drop_interval,lock.signal)
piece.put_to((x,y),angle,field)
start_draw=time.clock()
handle_redraw(())
end_draw=time.clock()
draw_time += end_draw-start_draw
draw_count += 1
e32.ao_yield()
lock.wait()
playing=appuifw.query(u'Play again?','query')
print "%d draws, %f s total, avg time %f ms"%(draw_count,
draw_time,
draw_time/draw_count*1000)
appuifw.app.screen='normal'
and where can I download it ? There are just those: S60 v1 SDK (there's just an udeb build that doesn't work - that doesn't surprise me, but I had to try everything...), S60 v2 SDK (again just udeb) and S60 v2 Phone (That's for 2.0 and really doesn't work on my 1.0 device)