Exemplo n.º 1
0
 def __init__(self, inp):
     self.inp = inp
     pygame.init()
     self.DIS = pygame.display.set_mode((width, height), pygame.RESIZABLE,
                                        32)
     self.car = self.initialCars()
     self.man = Man.Man(width, height, "man.png")
     self.backGround()
     time.sleep(1)
     self.t = thread.start_new_thread(self.Run, ())
     #thread.start_new_thread(self.manRun,())
     self.man.manRun()
Exemplo n.º 2
0
    def __init__(self, size):
        """
        Constructeur du plateau de jeu
        Initialisation du plateau

        :param size: taille du plateau
        """
        self.size = size
        self.play_board = [['.' for i in range(size)] for j in range(size)]

        for i in range(0, self.size, 2):
            for j in range(0, self.size, 2):
                self.play_board[i][j] = '_'

        for i in range(1, self.size, 2):
            for j in range(1, self.size, 2):
                self.play_board[i][j] = '_'

        for i in range(0, self.size // 2 - 1, 2):
            for j in range(0, self.size, 2):
                self.play_board[i][j] = Man((i, j), 'B')

        for i in range(1, self.size // 2 - 1, 2):
            for j in range(1, self.size, 2):
                self.play_board[i][j] = Man((i, j), 'B')

        if self.size // 2 % 2:
            x = 0
            y = 1
        else:
            x = 1
            y = 0

        for i in range(self.size // 2 + 1, self.size, 2):
            for j in range(x, self.size, 2):
                self.play_board[i][j] = Man((i, j), 'N')

        for i in range(self.size // 2 + 2, self.size, 2):
            for j in range(y, self.size, 2):
                self.play_board[i][j] = Man((i, j), 'N')
Exemplo n.º 3
0
from Man import *
from Hombre import *

guy_1 = Man("Richard")
guy_2 = Hombre("Ricardo")

guy_1.speak('It\'s a beautiful evening.\n')
guy_2.speak('Es una tard hermosa.\n')

Person.speak(guy_1)
Person.speak(guy_2)
Exemplo n.º 4
0
# Python script for Overriding base methods
# Reference class: @Person.py
# Python script by making features of both (man and Hombre)
# derived classes available
from Man import *
from Hombre import *

# Create instance of each derived class, initializing "name" instance
# variable attribute

guy_1 = Man('Timepass')
guy_2 = Hombre('Timepass2')

# Call the overriding method of each derived class , assigning differernnt values to "msg" argument

guy_1.speak('It\'s a beautiful evening.\n')
guy_2.speak('Es una tarde hermosa.\n')

# Explicitly call the base class method , passing a reference to each derived class -
# but none for the "msg" variable so default values will be used

Person.speak(guy_1)
Person.speak(guy_2)
Exemplo n.º 5
0
import random as rdm
import time
from 5.1 import Man


class Pupil(Man):
    def solve_task(self):
        time.sleep(rdm.randint(3, 6))
        print("{} says: I'm not ready yet.".format(self.name))

        
m = Man('Misha')
print(m.solve_task())
p = Pupil('Ivan')
print(p.solve_task())
Exemplo n.º 6
0
def run():

    pygame.init()
    start = 0
    #heigth
    h = 480
    #width
    w = 1000
    #control if the ball is on the screen
    f = 0
    #direction of the character
    v = 0

    color = (0, 255, 0)
    #load images
    fire = pygame.image.load("pySM/images/fire.bmp")
    img = pygame.image.load("pySM/images/spm.bmp")
    img2 = pygame.image.load("pySM/images/spm2.bmp")
    #load and play music
    pygame.mixer.init(44100, -16, 2, 2048)
    pygame.mixer.music.load("pySM/music/song.mp3")
    pygame.mixer.music.play(0, 0.0)
    
    man = Man(40, 358, 0, [img, img2, fire])
    screen = pygame.display.set_mode((w, h))
    
    running = 1
    
    button = Button(color, (w/2-50, h/2-25), (100, 50)) 
    rectMan = pygame.Rect(man.go-35, man.up-40, 95, 160)
    rectOst = pygame.Rect(500, 430, 50, 50)

    text = pygame.font.SysFont('arial.ttf', 30)
    startText = text.render("START", True, (0,0,0))

    while running:
        event = pygame.event.poll()
        if event.type == pygame.QUIT:
            running = 0
        
        screen.fill((0, 0, 0))  
        if(start == 0):
            button.draw(screen)
            screen.blit(startText, (465, 230))
            if(button.isClicked()):
                start = 1
        elif(start == 1):
            pygame.draw.rect(screen, color, rectMan)
            pygame.draw.rect(screen, color, rectOst)
            
            if(rectOst.colliderect(rectMan)):
                if(color == (0, 255, 0)):
                    color = (255, 0 ,0)
                else:
                    color = (0, 255, 0)
            key = pygame.key.get_pressed()
            if (key[pygame.K_a]):
                v = 1
            if (key[pygame.K_d]):
                v = 0
            
            #if the user press f key, initialize the variables
            #based on the position of the ball
            if(key[pygame.K_f]):
                man.fire(v)

            rectMan = man.move(key, rectMan, rectOst)
            rectMan = man.jump(key, rectMan, rectOst)
            #draw the character 
            man.draw(screen)

        pygame.display.flip()
        pygame.time.wait(5)
Exemplo n.º 7
0
from Man import *
from Woman import *

guy_1 = Man( 'Richard' )
guy_2 = Woman ( 'Anne ' )

guy_1.speak( 'It\'s a beautiful evening, from Richard.\n' )
guy_2.speak('It\'s a beautiful evening, from Anne.\n')

Person.speak( guy_1 )
Person.speak( guy_2 )
Exemplo n.º 8
0
from Man import *
from Woman import *

guy_1 = Man('Richard')
guy_2 = Woman('Anne ')

guy_1.speak('It\'s a beautiful evening, from Richard.\n')
guy_2.speak('It\'s a beautiful evening, from Anne.\n')

Person.speak(guy_1)
Person.speak(guy_2)