Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/run.py
diff options
context:
space:
mode:
Diffstat (limited to 'run.py')
-rwxr-xr-xrun.py164
1 files changed, 164 insertions, 0 deletions
diff --git a/run.py b/run.py
new file mode 100755
index 0000000..9682b3d
--- /dev/null
+++ b/run.py
@@ -0,0 +1,164 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+# filename: run.py
+#
+# Ceibal Rol
+# Copyright (C) 2008,2009 Gabriel Balbuena
+#
+# This program 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.
+#
+# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Contact information:
+# Ceibal Jam http://ceibaljam.org
+
+import pygame
+from pygame.locals import *
+
+from universe import Map
+from entity import Player
+from menu import Menu
+
+from ogre import Ogre
+
+SCREEN_SIZE = (640, 480)
+
+
+def start_game():
+
+ fullscreen = False
+
+ pygame.display.init()
+ screen = pygame.display.set_mode(SCREEN_SIZE) # re init screen
+ clock = pygame.time.Clock()
+
+ #--------------------------------------------------------------------
+ map = Map('./data/maps/map1.level')
+ player = Player(map)
+
+ ogre = Ogre(map)
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ allSprites = pygame.sprite.Group(ogre)
+ #--------------------------------------------------------------------
+
+ exit = False
+
+ #----------------------------------------------------------------------------------------------------- - - -
+ while not exit:
+ clock.tick(60)
+ #--------------------------------------------------------------------
+ for event in pygame.event.get():
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ if event.type == QUIT:
+ exit()
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ elif event.type == KEYDOWN:
+ if event.key == K_f:
+ fullscreen = not fullscreen
+ if fullscreen:
+ screen = pygame.display.set_mode(SCREEN_SIZE,0,32)
+ else:
+ screen = pygame.display.set_mode(SCREEN_SIZE,FULLSCREEN,32)
+ if event.key == pygame.K_UP:
+ ogre.moving = True
+ ogre.speed += 50/3
+ ogre.turnUp()
+ elif event.key == pygame.K_DOWN:
+ ogre.moving = True
+ ogre.speed += 50/3
+ ogre.turnDown()
+ elif event.key == pygame.K_LEFT:
+ ogre.moving = True
+ ogre.speed += 50/3
+ ogre.turnLeft()
+ elif event.key == pygame.K_RIGHT:
+ ogre.moving = True
+ ogre.speed += 50/3
+ ogre.turnRight()
+
+ if ogre.speed > 0:
+ if ogre.speed > 25:
+ ogre.speed = 25
+
+ ogre.speed = ogre.speed - 1
+
+ if ogre.speed == 0:
+ ogre.moving = False
+
+ #map = map.mirar_a(ogre.rect) re implementar
+ #--------------------------------------------------------------------
+ map.update()
+ # actualiza la posicion de la camara
+ # se actualiza el personaje todo el tiempo,
+ # de modo que este pueda alterar la posicionn de la camara.
+ #player.update()
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+ map.imprimir(screen)
+ #player._print(screen)
+ #ogre._print(screen)
+ #--------------------------------------------------------------------
+ allSprites.clear(screen, map.field)
+ allSprites.update()
+ allSprites.draw(screen)
+ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ pygame.display.update()
+ #--------------------------------------------------------------------
+ #----------------------------------------------------------------------------------------------------- - - -
+def show_options(): print " menu de opciones "
+
+def creditos(): print " desplegando creditos "
+
+def exit_game():
+ import sys
+ sys.exit(0)
+
+if __name__ == '__main__':
+
+ exit = False
+
+ options = [
+ ("Jugar", start_game),
+ ("Opciones", show_options),
+ ("Creditos", creditos),
+ ("Salir", exit_game)
+ ]
+
+ pygame.init()
+ pygame.display.set_caption("Ceibal Rol - PreAlpha 0.0.8")
+
+ screen = pygame.display.set_mode(SCREEN_SIZE) # init screen
+
+ background = pygame.image.load("./data/menu/fondo.png").convert()
+ background = pygame.transform.scale(background, SCREEN_SIZE)
+ #background = pygame.transform.smoothscale(background, SCREEN_SIZE)
+
+ logo = pygame.image.load("./data/menu/logo.png").convert_alpha()
+
+
+ menu = Menu(options)
+
+ while not exit:
+ for e in pygame.event.get():
+ if e.type == QUIT:
+ exit = True
+
+ #-Menu - - - - - - - - - - - - - - - -
+ screen.blit(background, (0, 0))
+ screen.blit(logo, (30, 0))
+
+ menu.update()
+ menu._print(screen)
+ #- - - - - - - - - - - - - - - - - - -
+
+ pygame.display.flip()
+ pygame.time.delay(10)