Added an introduction screen (level 0).

This commit is contained in:
Sakse Dalum 2012-08-12 22:15:01 +02:00
parent 250a7528a3
commit 4a8a5b5d70
7 changed files with 63 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

Binary file not shown.

View File

@ -58,7 +58,7 @@ class Game(object):
def load(self):
graphics_dir = os.path.join(self.directory, "resources", "graphics")
self.loader = loader.Loader(graphics_dir)
self.loader = loader.Loader(self, graphics_dir)
self.loader.load()
self.level = None

View File

@ -49,6 +49,11 @@ class Level(object):
self.darkness = fadeout.Darkness(self.game, 0)
self.load()
def load(self):
pass
def set_darkness(self, darkness):
self.darkness.set_darkness(darkness)

40
robotgame/level0.py Normal file
View File

@ -0,0 +1,40 @@
# This file is part of ROBOTGAME
#
# ROBOTGAME is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# ROBOTGAME is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# ROBOTGAME. If not, see <http://www.gnu.org/licenses/>.
#
# ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '
#
# level0.py
# --------------------
# date created : Tue Aug 7 2012
# copyright : (C) 2012 Sakse Dalum
# maintained by : Sakse Dalum <don_s@hongabar.org>
"""
The zeroth level.
"""
import pygame
import level
class Level0(level.Level):
def update(self, e, t, dt):
if not self.paused:
for event in e:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
self.game.goto_level(1)
def draw(self, window):
window.blit(self.imgs['intro-screen'], (0, 0))

View File

@ -29,7 +29,7 @@ import os
import re
class Loader(object):
def __init__(self, directory):
def __init__(self, game, directory):
self.__dict__.update(locals())
self.imgs = {}
@ -56,11 +56,25 @@ class Loader(object):
self.imgs[o] = pygame.image.load(os.path.join(
self.directory, 'blocks', '%s.png' % o))
l = ['hole', 'well', 'wall', 'wall_outside']
l = ['hole', 'well', 'wall', 'wall_outside', 'intro-screen']
for o in l:
self.imgs[o] = pygame.image.load(os.path.join(
self.directory, '%s.png' % o))
# Special treatment
screen_size = self.game.window.get_size()
img_size = self.imgs['intro-screen'].get_size()
factors = (float(img_size[0]) / 1920, float(img_size[1]) / 1440)
self.imgs['intro-screen'] = pygame.transform.smoothscale(
self.imgs['intro-screen'],
(int(screen_size[0]*factors[0]),
int(screen_size[1]*factors[1])))
### Moat
l = ['moat_corner_north',
'moat_corner_south',
'moat_corner_north_flip',

View File

@ -59,7 +59,7 @@ class MainMenu(object):
for event in e:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
self.game.goto_level(1)
self.game.goto_level(0)
if event.key == pygame.K_ESCAPE:
self.game.stop()