File: gamecreds.py

package info (click to toggle)
solarwolf 1.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,348 kB
  • ctags: 371
  • sloc: python: 2,640; makefile: 56; sh: 31
file content (121 lines) | stat: -rw-r--r-- 2,851 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
"gamemenu handler. main menu"

import math, os
import pygame
from pygame.locals import *
import game, gfx, snd
import gameplay



credits = (
    ('Developer', ('Pete Shinners',)),
    ('Quality Assurance', ('David Clark',)),
    ('Graphics Assistance', ('Kevin Turner',)),
    ('Special Thanks', ('Guido van Rossom', 'Sam Lantinga')),
)

licenseinfo = ('This program is free software. You are encouraged to make',
               'copies and/or modify it, subject to the of the LGPL.',
               'See "lgpl.txt" file for details.')


fonts = []
images = []

def load_game_resources():
    global fonts, images
    fontname = None
    fonts.append((pygame.font.Font(fontname, 25), (50, 50, 200)))
    fonts.append((pygame.font.Font(fontname, 40), (100, 100, 250)))

    img = gfx.load('oldsolarfox.png')
    r = img.get_rect()
    r.bottomright = gfx.rect.bottomright
    images.append((img, r))

    img = gfx.load('credrules.gif')
    r = img.get_rect().move(220, 20)
    images.append((img, r))

    img = gfx.load('python.gif')
    r = img.get_rect().move(620, 40)
    images.append((img, r))

    img = gfx.load('pygame.gif')
    r = img.get_rect().move(618, 140)
    images.append((img, r))

    img = gfx.load('sdl.gif')
    r = img.get_rect().move(636, 270)
    images.append((img, r))

    img = gfx.load('menu_creds_on.gif')
    r = img.get_rect().move(20, 5)
    images.append((img, r))

    font = pygame.font.Font(None, 14)
    top = 560
    mid = 400
    for l in licenseinfo:
        txt = gfx.text(font, (50, 150, 150), l, (mid, top))
        top += txt[1].height
        images.append(txt)

    
    snd.preload('select_choose')


class GameCreds:
    def __init__(self, prevhandler):
        self.prevhandler = prevhandler
        self.done = 0
        self.top = 120
        self.center = gfx.rect.centerx - 120
        self.text = []
        for cred in credits:
            self.createtext(cred[0], 0)
            for peop in cred[1]:
                self.createtext(peop, 1)
            self.top += 30
        self.text.extend(images)

    def createtext(self, text, size):
        f, c = fonts[size]
        t = gfx.text(f, c, text, (self.center, 0))
        t[1].top = self.top
        self.top = t[1].bottom
        self.text.append(t)
        

    def quit(self):
        game.handler = self.prevhandler
        self.done = 1
        snd.play('select_choose')


    def input(self, i):
        self.quit()

    def event(self, e):
        pass


    def run(self):
        for cred in self.text:
            r = cred[1]
            self.background(r)
            gfx.dirty(r)

        gfx.updatestars(self.background, gfx)

        if not self.done:
            for cred, pos in self.text:
                gfx.surface.blit(cred, pos)


    def background(self, area):
        return gfx.surface.fill((0, 0, 0), area)