Created
April 30, 2013 22:01
-
-
Save daryo918/5492282 to your computer and use it in GitHub Desktop.
pygame menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# vim: set fileencoding=utf-8 : | |
import pygame | |
import sys | |
from pygame.locals import * | |
import os | |
import hola | |
class mouse(pygame.sprite.Sprite): | |
def __init__(self): | |
#clase de la mira que interactuara con el menu o texto | |
pygame.sprite.Sprite.__init__(self) | |
self.img = pygame.image.load("centromira.png") | |
# desaparece todo lo blanco y lo hace tranparente | |
self.rect = self.img.get_rect() | |
self.rect.centerx=100 | |
self.rect.centery=100 | |
self.img.set_colorkey((255,255,255)) | |
class opcionz(pygame.sprite.Sprite): | |
def __init__(self): | |
pygame.sprite.Sprite.__init__(self) | |
self.img=pygame.image.load("vv.png") | |
self.rect = self.img.get_rect() | |
self.rect.centerx=250 | |
self.rect.centery=130 | |
def colision(self,objeto): | |
if self.rect.colliderect(objeto.rect): | |
os.system("entidad3d.exe -name -jugador -map house -pickmode") | |
sys.exit() | |
class salir(pygame.sprite.Sprite): | |
def __init__(self): | |
pygame.sprite.Sprite.__init__(self) | |
self.img=pygame.image.load("salir.png") | |
self.rect = self.img.get_rect() | |
self.rect.centerx=250 | |
self.rect.centery=350 | |
def colision(self,objeto): | |
if self.rect.colliderect(objeto.rect): | |
sys.exit(0) | |
class minijuegos(pygame.sprite.Sprite): | |
def __init__(self): | |
pygame.sprite.Sprite.__init__(self) | |
self.img=pygame.image.load("minijuegos.png") | |
self.rect=self.img.get_rect() | |
self.rect.centerx=250 | |
self.rect.centery=200 | |
def colision(self,objeto): | |
if self.rect.colliderect(objeto.rect): | |
os.system("call echo minijuegos ") | |
class credito(pygame.sprite.Sprite): | |
def __init__(self): | |
pygame.sprite.Sprite.__init__(self) | |
self.img=pygame.image.load("creditos.png") | |
self.rect=self.img.get_rect() | |
self.rect.centerx=250 | |
self.rect.centery=270 | |
def colision(self,objeto): | |
if self.rect.colliderect(objeto.rect): | |
hola.main() | |
def main(): | |
pygame.init() | |
pantalla = pygame.display.set_mode((480,457),0) | |
pygame.display.set_caption("future caos") | |
fondo = pygame.image.load("zombies.jpg") | |
fuente = pygame.font.Font("Death.ttf",40) | |
mira= pygame.image.load("mira.bmp") | |
mira.set_colorkey((255,255,255)) | |
text = "FUTURE CAOS" | |
mensaje = fuente.render(text, 2, (255, 0, 0)) | |
gato = mouse() | |
salida = salir() | |
minijuego=minijuegos() | |
# coor seran las coordenadas de los disparos circulos negros | |
coor={} | |
n=0 | |
creditos = credito() | |
jugkar=opcionz() | |
# cuando dispara se vuelve verdadero y si ademas lleva 10 bucles o frames n=10 pone la mira como antes del disparo | |
xsd=False | |
color= (0,0,0) | |
reloj = pygame.time.Clock() | |
while 1: | |
# esta parte es para producir el efecto de la mira en movimiento por el disparo | |
n+=1 | |
if n == 10 and xsd == True: | |
gato.rect.centery+=10 | |
xsd=False | |
jugkar.colision(gato) | |
salida.colision(gato) | |
creditos.colision(gato) | |
minijuego.colision(gato) | |
pos_mouse = pygame.mouse.get_pos() | |
mov_mouse = pygame.mouse.get_rel() | |
click = pygame.mouse.get_pressed() | |
# el mouse se vuelve invisible y puedo poner un objeto como la mira | |
pygame.mouse.set_visible(0) | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
sys.exit(0) | |
if mov_mouse[0] !=0: | |
gato.rect.centerx=pos_mouse[0] | |
gato.rect.centery=pos_mouse[1] | |
if click[0] != 0: | |
if reloj.tick() > 250: | |
pygame.mixer.init() | |
pygame.mixer.music.load("mg42_shoot.wav") | |
pygame.mixer.music.play() | |
jax = pos_mouse[0] | |
jay = pos_mouse[1] | |
coor[n]=(jax,jay) | |
# esta parte es para producir el efecto de la mira en movimiento por el disparo | |
gato.rect.centery -=10 | |
xsd=True | |
n=0 | |
# el centro de la mira es quien se encarga de las colisiones ese es el sprite, estas coordenadas centran la mira al centro de la mira | |
mirax = gato.rect.centerx - 24 | |
miray=gato.rect.centery - 25 | |
pantalla.blit(fondo,(0,0)) | |
pantalla.blit(mensaje,(100,20)) | |
pantalla.blit(gato.img,(gato.rect)) | |
pantalla.blit(jugkar.img,(jugkar.rect)) | |
pantalla.blit(salida.img,(salida.rect)) | |
pantalla.blit(minijuego.img,(minijuego.rect)) | |
pantalla.blit(creditos.img,(creditos.rect)) | |
pantalla.blit(mira,(mirax,miray)) | |
# cada disparo crea una lista con las coordenadas del disparo en el diccionario | |
for dispa in coor: | |
disparo = coor[dispa] | |
pygame.draw.circle(pantalla, color, (disparo[0],disparo[1]),4,0) | |
pygame.display.flip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vim: set fileencoding=utf-8 : | |
import pygame | |
from pygame.locals import * | |
import os | |
import sys | |
import fgh | |
class mouse(pygame.sprite.Sprite): | |
def __init__(self): | |
#clase de la mira que interactuara con el menu o texto | |
pygame.sprite.Sprite.__init__(self) | |
self.img = pygame.image.load("centromira.png") | |
# desaparece todo lo blanco y lo hace tranparente | |
self.rect = self.img.get_rect() | |
self.rect.centerx=250 | |
self.rect.centery=270 | |
class atras(pygame.sprite.Sprite): | |
def __init__(self): | |
pygame.sprite.Sprite.__init__(self) | |
self.img=pygame.image.load("atras.png") | |
self.rect=self.img.get_rect() | |
self.rect.centerx=70 | |
self.rect.centery=430 | |
def colision(self,objeto): | |
if self.rect.colliderect(objeto.rect): | |
fgh.main() | |
def main(): | |
pygame.init() | |
pantalla = pygame.display.set_mode((480,457),0) | |
pygame.display.set_caption("future caos") | |
letra = pygame.font.Font("Death.ttf",40) | |
fondo = pygame.image.load("zombies.jpg") | |
mira = pygame.image.load("mira.bmp") | |
mira.set_colorkey((255,255,255)) | |
text = "Daryo" | |
text2 = "Creditos" | |
text3 = "XXXX" | |
gato = mouse() | |
mensaje = letra.render(text, 2, (255, 0, 0)) | |
mensaje2 = letra.render(text2, 2, (255, 0, 0)) | |
mensaje3 = letra.render(text3, 2, (255, 0, 0)) | |
baja = 100 | |
reloj = pygame.time.Clock() | |
coor={} | |
n=0 | |
xsd=False | |
color= (0,0,0) | |
salida=atras() | |
while 1: | |
n+=1 | |
if n == 10 and xsd == True: | |
gato.rect.centery+=10 | |
xsd=False | |
pos_mouse = pygame.mouse.get_pos() | |
mov_mouse = pygame.mouse.get_rel() | |
click = pygame.mouse.get_pressed() | |
if mov_mouse[0] !=0: | |
gato.rect.centerx=pos_mouse[0] | |
gato.rect.centery=pos_mouse[1] | |
if click[0] != 0: | |
if reloj.tick() > 250: | |
pygame.mixer.init() | |
pygame.mixer.music.load("mg42_shoot.wav") | |
pygame.mixer.music.play() | |
jax = pos_mouse[0] | |
jay = pos_mouse[1] | |
coor[n]=(jax,jay) | |
salida.colision(gato) | |
# esta parte es para producir el efecto de la mira en movimiento por el disparo | |
gato.rect.centery -=10 | |
xsd=True | |
n=0 | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
sys.exit(0) | |
if baja <= 500: | |
baja +=0.2 | |
else: | |
baja=100 | |
mirax = gato.rect.centerx - 24 | |
miray=gato.rect.centery - 25 | |
pantalla.blit(fondo,(0,0)) | |
pantalla.blit(mensaje2,(170,10)) | |
if baja <= 350: | |
pantalla.blit(mensaje,(100,baja)) | |
pantalla.blit(mensaje3,(100,baja-50)) | |
pantalla.blit(salida.img,(salida.rect)) | |
pantalla.blit(gato.img,(gato.rect)) | |
pantalla.blit(mira,(mirax,miray)) | |
for dispa in coor: | |
disparo = coor[dispa] | |
pygame.draw.circle(pantalla, color, (disparo[0],disparo[1]),4,0) | |
pygame.display.flip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment