Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/SugarGame/game.py
blob: c1171932f0c79e4010958e3346aff4ed562c6ad8 (plain)
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
#! /usr/bin/env python

import pygame
from pygame.locals import *

import gtk, sys

BLANCO = (255, 255, 255)
NEGRO = (0, 0, 0)

class MiJuego():
    def __init__(self):
        pass

    def juego_loop(self):
        pygame.init()
        global x, y, fuente, texto
        x = gtk.gdk.screen_width()
        y = gtk.gdk.screen_height() - 55
        pygame.display.set_caption('Hello world!')
        
        fuente = pygame.font.SysFont(None, 48)
        texto = fuente.render('Hello world!', True, BLANCO, NEGRO)

        reloj = pygame.time.Clock()
        pantalla = pygame.display.get_surface()

        while 1:
            while gtk.events_pending():
                gtk.main_iteration()
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    exit("Juego finalizado")
                elif event.type == pygame.VIDEORESIZE:
                    pygame.display.set_mode(event.size, pygame.RESIZABLE)


            pantalla.fill(NEGRO)

            pantalla.blit(texto, ((x / 2) - (x / 10), (y / 2) - (y / 10)))
            pygame.display.flip()

            # Try to stay at 30 FPS
            reloj.tick(30)


if __name__ == "__main__":
    MiJuego()