File: level001.py

package info (click to toggle)
krank 0.7%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 67,660 kB
  • ctags: 320
  • sloc: python: 3,330; sh: 31; makefile: 14
file content (39 lines) | stat: -rw-r--r-- 1,190 bytes parent folder | download | duplicates (4)
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

import k
from Part import *

def init():
    k.sound.loadTheme('space')
    k.sound.music()
    k.world.setBackground('nasirkhan02')

    cx, cy, w, h = k.world.rect.centerx, k.world.rect.centery, k.world.rect.width, k.world.rect.height
    
    # particles
    parts = [(w*1/3, cy), (w*2/3, cy)]
        
    if k.config.stage == 2:
        parts.extend([(cx, h*1/3), (cx, h*2/3)]) 
    elif k.config.stage == 3:
        parts.extend([(cx-w*1/12, h*1/3), (cx-w*1/12, h*2/3), (cx+w*1/12, h*1/3), (cx+w*1/12, h*2/3)]) 
    
    for i in range(len(parts)):
        k.particles.add(Particle({'pos': parts[i], 'color': 'white'}))

    # stones
    stones = []
    xd, yd = 80, 60 
    if k.config.stage >= 2:
        stones.extend([(cx, cy-yd), (cx, cy+yd), (cx-xd, cy), (cx+xd, cy)])
    if k.config.stage >= 3:
        stones.extend([(cx-xd, cy-yd), (cx+xd, cy-yd), (cx-xd, cy+yd), (cx+xd, cy+yd)])

    for i in range(len(stones)):
        k.particles.add(Stone({'pos': stones[i], 'color': 'white'}))
    
    # magnet 
    n = min(6, k.config.stage*2)
    k.particles.add (Magnet({'pos': (cx, cy), 'color': 'white', 'num': n}))
    
    # simple player
    k.player.setPos((cx, cy+h*1/4))