7 from stage
import Stage
8 from qwesprites
import *
12 size
= width
, height
= 640, 480
15 screen
= pygame
.display
.set_mode(size
16 , pygame
.DOUBLEBUF
# | pygame.FULLSCREEN
20 stage_file
="stage_00_game_menu.st"
21 ######################################################
22 STAGE
=Stage(stage_file
)
26 ######################################################
28 spriteTajundra
= STAGE
.Tajundra
30 ######################################################
36 reloj_juego
=pygame
.time
.Clock()
39 time_o
=pygame
.time
.get_ticks()
41 for ch
in STAGE
.simbolos
:
43 if ch
=='@': SpriteClass
=Tajundra
44 if ch
=='|': SpriteClass
=LanzaBolas
45 if ch
=='$': SpriteClass
=Dragon
48 for n
in range(0,len(STAGE
.simbolos
[ch
])):
52 pygame
.display
.update()
54 #STAGE.sprites+=[spriteTajundra, t2,]
66 cpu
=100-accum_idle
/10.0
67 print len(STAGE
.sprites
), "%.2f%%" % cpu
71 if frame
> cpu
-20 or frame
==0 or frame
==30:
72 x
,y
,w
,h
=spriteTajundra
.rect
75 if spriteTajundra
.dx
<0: vel
=-300
77 if keys
.has_key(pygame
.K_DOWN
): vely
=200
78 if keys
.has_key(pygame
.K_UP
): vely
=-200
79 Hacha(STAGE
,pos
,spriteTajundra
.dx
+vel
,vely
)
81 del STAGE
.sprites
[-1:]
83 for event
in pygame
.event
.get():
84 if event
.type == pygame
.QUIT
: Salir
=True
85 if event
.type == pygame
.KEYDOWN
:
86 if event
.key
==pygame
.K_ESCAPE
:
91 if event
.type == pygame
.KEYUP
:
92 if keys
.has_key(event
.key
):
94 if spriteTajundra
.alive
:
95 if event
.key
==pygame
.K_SPACE
:
96 sLife
=spriteTajundra
.Life
97 sMLife
=spriteTajundra
.MaxLife
98 if (fuerza
>4000): fuerza
=4000
99 fuerza
*=sLife
*sLife
/(sMLife
*sMLife
)
100 x
,y
,w
,h
=spriteTajundra
.rect
104 if keys
.has_key(pygame
.K_DOWN
): vely
=vel
/2
105 if keys
.has_key(pygame
.K_UP
): vely
=-vel
106 if spriteTajundra
.dx
<0: vel
=-vel
107 p
=Hacha(STAGE
,pos
,spriteTajundra
.dx
+vel
,vely
)
108 p
.Life
+=fuerza
/100.0-.5
111 if spriteTajundra
.alive
:
112 if keys
.has_key(pygame
.K_s
):
113 spriteTajundra
.alive
=False
114 spriteTajundra
.LevelFinished
=True
116 if spriteTajundra
.in_ground
:
118 if keys
.has_key(pygame
.K_LEFT
): spriteTajundra
.dx
-=15
119 if keys
.has_key(pygame
.K_RIGHT
): spriteTajundra
.dx
+=15
120 if keys
.has_key(pygame
.K_UP
): spriteTajundra
.dy
=-140
121 if keys
.has_key(pygame
.K_DOWN
): spriteTajundra
.dy
+=5
125 if spriteTajundra
.dy
<0:
126 if not keys
.has_key(pygame
.K_UP
): spriteTajundra
.dy
/=1.02
127 if keys
.has_key(pygame
.K_LEFT
): spriteTajundra
.dx
-=0.5
128 if keys
.has_key(pygame
.K_RIGHT
): spriteTajundra
.dx
+=0.5
130 if keys
.has_key(pygame
.K_UP
): spriteTajundra
.dy
/=1.02
131 if keys
.has_key(pygame
.K_DOWN
): spriteTajundra
.dy
+=2
135 if spriteTajundra
.LevelFinished
:
136 txtEndGame
=qweTextBIG(STAGE
,320,240,"Level Completed")
138 txtEndGame
=qweTextBIG(STAGE
,320,240,"Game Over")
139 qweTextBIG(STAGE
,320,300,"press return")
141 if keys
.has_key(pygame
.K_RETURN
):
142 if spriteTajundra
.LevelFinished
:
143 stage_file
=STAGE
.NextStage
145 for sprite
in STAGE
.sprites
:
150 STAGE
=Stage(stage_file
)
151 spriteTajundra
= STAGE
.Tajundra
152 for ch
in STAGE
.simbolos
:
154 if ch
=='@': SpriteClass
=Tajundra
155 if ch
=='|': SpriteClass
=LanzaBolas
156 if ch
=='$': SpriteClass
=Dragon
159 for n
in range(0,len(STAGE
.simbolos
[ch
])):
162 pygame
.display
.update()
168 time_aux
=pygame
.time
.get_ticks()
169 msec
=time_aux
-time_o
;
172 pygame
.time
.wait(idle
)
173 accum_idle
+=pygame
.time
.get_ticks()-time_aux
174 time_aux
=pygame
.time
.get_ticks()
175 msec
=time_aux
-time_o
;
178 msec
=reloj_juego
.tick(60)
180 if keys
.has_key(pygame
.K_SPACE
): fuerza
+=msec
182 STAGE
.fulldraw(screen
,msec
)