File: menu_levels2.py

package info (click to toggle)
krank 0.7%2Bdfsg2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 68,092 kB
  • sloc: python: 3,421; sh: 31; makefile: 11
file content (55 lines) | stat: -rw-r--r-- 2,041 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import k, levels
from Krank  import *
from Part import *

def init():
    k.world.setBackground('menu-levels')
    
    cx, w, h = k.world.rect.centerx, k.world.rect.width, k.world.rect.height
        
    num = min(levels.numLevels-20, k.config.numAvailableLevels()-10)
    max = min(levels.numLevels, k.config.numAvailableLevels())
    pos = []
    cols = 5
    rows = math.ceil(num/cols)

    icons = []
    for i in range(num):
        row, col = math.floor((i%cols))+1.5, math.floor((i/cols))+0.8
        pos.append((row*w/(cols+2), col*h/4.7))
        
        icon = pygame.image.load('levels/unera-icons/level%03d.tga' % (10+i+1))
        if h < 768:
            icon = pygame.transform.scale(icon, (88, 66))
        icons.append(icon)
        
    for i in range(num):
        k.particles.add(Switch({ 'text': '%d' % (10+i+1),
                                 'action': 'k.level.startExit(%d)' % (10+i),
                                 'align': 'bottom',
                                 'size': 'small', 
                                 'offset': icons[i].get_height()*0.6,
                                 'radius': icons[i].get_height()/8,
                                 'image': icons[i],
                                 'pos': pos[i]}))

    k.particles.add(Switch({ 'text': 'Back',
                             'align': 'bottom',
                             'action': 'k.level.menuExit("menu_levels")',
                             'size': 'small', 
                             'pos': vector((cx, h*0.81))}))
        
    if max > 20:
        k.particles.add(Switch({ 'text': 'Next 10',
                                 'align': 'bottom',
                                 'action': 'k.level.menuExit("menu_levels3")',
                                 'size': 'small', 
                                 'pos': vector((cx+2*w/7, h*0.61))}))
        
    # player
    k.player.setPos(vector((cx, h*0.61)))
    k.player.setTailNum(2, -1)

    k.screen.blit(k.world.image, k.world.rect)    
    pygame.display.update()