Entradas

Mostrando entradas de diciembre, 2019

JUEGO BLACK JACK CON PYGAME

Imagen
Main import casino import pygame import sys import os import math import time import tkinter as tk from tkinter import messagebox pygame.init() cardBack = pygame.image.load(os.path.join('png', 'cardBack.png')) screen = pygame.display.set_mode((1400, 800)) pygame.display.set_caption('Black Jack') clock = pygame.time.Clock() myfont = pygame.font.SysFont('monospace', 70) smallFont = pygame.font.SysFont('monospace', 30) bg = pygame.image.load(os.path.join('back', 'background.jpg')) screen.fill((0,128,0)) clock = pygame.time.Clock() deck = casino.cards() cardList = deck.getCards() d = casino.dealer(cardList) p = casino.player(cardList) pygame.display.flip() onTable = [] topCards = [] cardImg = [None] # Load 52 Images two_clubs = pygame.image.load(os.path.join('png', '2_of_clubs.png')) two_diamonds = pygame.image.load(os.path.join('png', '2_of_diamonds.png')) two_hearts = pygame.image.load(os.p...

Programa imagenes con sonido

Imagen
from Tkinter import * from PIL import Image,ImageTk # la usamos para desplegar las imagenes import os #para poder usar las las ruta de archivos o carpetas import pygame # para reproducir los archivos de sonido mp3 import time import random dir = os.path.dirname(__file__) fotos = dir + '/imagenes2/' sonidos= dir + '/sonidos/' def play(): print "" def stop(): print"" root=Tk() root.geometry('500x500') label = Label(root) label.pack() label2 = Label(root, text="", font=("Arial", 12, "bold")) label2.pack() btn1=Button(root,text="Iniciar",command=play).pack(fill=X) btn2=Button(root,text="Terminar", command=stop).pack(fill=X) arreglo=[1,2,3,4,5,6,7,8] eleccion_aleatoria= str(arreglo.index(random.choice(arreglo))+1) print eleccion_aleatoria figura = fotos + eleccion_aleatoria + '.png' print figura #tomar el nombre del archivo del sonido sonido = sonidos + eleccion_aleator...

mi figura 3d

Imagen
import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * verticies = ( (0.5, 1, -0.5),#0A (0.5, -1, -0.5),#1B (-0.5, -1, -0.5),#2C (-0.5, 1, -0.5),#3D (0, -0.5, 0.5),#4E (0, 0.5, 0.5),#5F ) edges = ( (0,1), (0,3), (0,5), (2,1), (2,3), (2,4), (4, 5), (4, 1), (4, 2), (5, 4), (5, 0), (5, 3) ) def Cube(): glBegin(GL_LINES) for edge in edges: for vertex in edge: glVertex3fv(verticies[vertex]) glEnd() def main(): pygame.init() display = (800,600) pygame.display.set_mode(display, DOUBLEBUF|OPENGL) gluPerspective(45, (display[0]/display[1]), 0.1, 50.0) glTranslatef(0.0,0.0, -5) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() glRotatef(1, 3, 1, 1) glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) ...

Estrella 3d Alfredo

Imagen
import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * verticies = ( (-2,0,0.75), (-0.75,0,-0.25), (-1.25,0,-2), (0,0,-1), (1.25,0,-2), (0.75,0,-0.25), (2,0,0.75), (0.5,0,0.75), (0,0,2.5), (-0.5,0,0.75), (0,-0.5,0), (0,0.5,0), ) edges = ( (0, 1), (0,9), (0,10), (0,11), (1,10), (1,11), (2,1), (2,3), (2,10), (2,11), (3,10), (3,11), (4, 3), (4,5), (4,10), (4,11), (5,10), (5,11), (6, 5), (6,7), (6,10), (6,11), (7,10), (7,11), (8, 7), (8,9), (8,10), (8,11), (9,10), (9,11) ) def Cube(): glBegin(GL_LINES) for edge in edges: for vertex in edge: glVertex3fv(verticies[vertex]) glEnd() def main(): pygame.init() display = (1500,1000) pygame.display.set_mode(display, DOUBLEBUF|OPENGL) gluPerspective(45, (display[0]/display[1...

Cubo 3d

Imagen
import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * verticies = ( (1, -1, -1), (1, 1, -1), (-1, 1, -1), (-1, -1, -1), (1, -1, 1), (1, 1, 1), (-1, -1, 1), (-1, 1, 1) ) edges = ( (0,1), (0,3), (0,4), (2,1), (2,3), (2,7), (6,3), (6,4), (6,7), (5,1), (5,4), (5,7) ) def Cube(): glBegin(GL_LINES) for edge in edges: for vertex in edge: glVertex3fv(verticies[vertex]) glEnd() def main(): pygame.init() display = (800,600) pygame.display.set_mode(display, DOUBLEBUF|OPENGL) gluPerspective(45, (display[0]/display[1]), 0.1, 50.0) glTranslatef(0.0,0.0, -5) while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() glRotatef(1, 3, 1, 1) glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) Cube() ...

Thread video

Imagen
import thread import time x=0 def contador(): global x while True: print "Hilo secundario vivo" time.sleep(2) if x==1: break print "Se a acabado la ejecucion del hilo" def main(): global x print "Hilo main iniciado" thread.start_new(contador, ()) x=input("Presione cualquier tecla para terminar") print "Hilo main terminado" main()

Ejemplo Hilos

import threading import time def hola_mundo(nombre): print('hola mundo' + nombre) time.sleep(5) if __name__ =='__main__': hilos= threading.Thread(target=hola_mundo('Angelo')) hilos.start() hilos.join() print ('hola mundo desde el hilo principal')