Beispiel #1
0
    def __init__(self, title, width, height):
        self.Title = title
        self.Height = height
        self.Width = width
        self.Screen = pygame.display.set_mode((self.Width, self.Height))

        #This is to initialize the framerate (fps)
        self.Clock = pygame.time.Clock()

        #This color is a refrence to the color object, in there all different colors are defined
        self.Color = clr.Color()
        self.DefaultFont = pygame.font.SysFont(None, 30)

        #Initialize text messages
        self.StartText = Text.Text(
            self.Color.Black, self.DefaultFont,
            "Make the player move on the screen, up, down, left and right!")
        self.NextLine = Text.Text(
            self.Color.Black, self.DefaultFont,
            "Why do the same thing over and over again when it allready exists!!!"
        )

        #Create all game characters here
        self.Player1 = c.Component(c.Position(400, 100), "enemy.png")
        self.Apple = c.Component(c.Position(0, 0), "apple.png")

        self.AppleCounter = 0
        self.Score = Text.Text(self.Color.Black, self.DefaultFont,
                               "Apple Counter: " + str(self.AppleCounter))
Beispiel #2
0
    def main(self):
        while True:
            if self.mainScreen:
                self.reset(0, 3, True)
                self.screen.blit(self.background, (0, 0))
                self.titleText.draw(self.screen)
                self.titleText2.draw(self.screen)
                self.enemy1Text.draw(self.screen)
                self.enemy2Text.draw(self.screen)
                self.enemy3Text.draw(self.screen)
                self.enemy4Text.draw(self.screen)
                self.create_main_menu()

            elif self.startGame:
                if len(self.enemies) == 0:
                    currentTime = time.get_ticks()
                    if currentTime - self.gameTimer < 3000:
                        self.screen.blit(self.background, (0, 0))
                        self.scoreText2 = Text(FONT, 20, str(self.score),
                                               GREEN, 85, 5)
                        self.scoreText.draw(self.screen)
                        self.scoreText2.draw(self.screen)
                        self.nextRoundText.draw(self.screen)
                        self.livesText.draw(self.screen)
                        self.livesGroup.update(self.keys)
                        self.check_input()
                    if currentTime - self.gameTimer > 3000:
                        # Move enemies closer to bottom
                        self.enemyPositionStart += 35
                        self.reset(self.score, self.lives)
                        self.gameTimer += 3000
                else:
                    currentTime = time.get_ticks()
                    self.play_main_music(currentTime)
                    self.screen.blit(self.background, (0, 0))
                    self.allBlockers.update(self.screen)
                    self.scoreText2 = Text(FONT, 20, str(self.score), GREEN,
                                           85, 5)
                    self.scoreText.draw(self.screen)
                    self.scoreText2.draw(self.screen)
                    self.livesText.draw(self.screen)
                    self.check_input()
                    self.allSprites.update(self.keys, currentTime,
                                           self.enemies)
                    self.explosionsGroup.update(self.keys, currentTime)
                    self.check_collisions()
                    self.create_new_ship(self.makeNewShip, currentTime)
                    self.update_enemy_speed()
                    if len(self.enemies) > 0:
                        self.make_enemies_shoot()
                        self.boss += 1

            elif self.gameOver:
                currentTime = time.get_ticks()
                # Reset enemy starting position
                self.enemyPositionStart = self.enemyPositionDefault
                self.create_game_over(currentTime)
                self.boss = 0
            display.update()
            self.clock.tick(60)
Beispiel #3
0
    def __init__(self, title, width, height):
        self.Title = title
        self.Height = height
        self.Width = width
        self.Screen = pygame.display.set_mode((self.Width, self.Height))

        #This is to initialize the framerate (fps)
        self.Clock = pygame.time.Clock()

        #This color is a refrence to the color object, in there all different colors are defined
        self.Color = clr.Color()
        self.DefaultFont = pygame.font.SysFont(None, 30)

        #Initialize text messages
        self.StartText = Text.Text(self.Color.Black, self.DefaultFont,
                                   "Welcom to my pygame template!!!")

        #Initialize the soundprovider
        self.BackgroundMusic = sp.SoundProvider(
            "9th_Symphony_Finale_by_Beethoven.mp3")
        #Set the background music to play
        self.BackgroundMusic.Play(5)

        #Create all game characters here
        self.Player1 = c.Component(c.Position(400, 100), "enemy.png")

        #Create a button
        self.ExitButton = button.Button(
            300, 250, 50, 200, self.Color.Red,
            Text.Text(self.Color.Black, self.DefaultFont, "Exit"),
            lambda: sys.exit())
        self.StartButton = button.Button(
            600, 250, 50, 200, self.Color.Green,
            Text.Text(self.Color.Black, self.DefaultFont, "Start"))
Beispiel #4
0
    def __init__(self, title, width, height):
        self.Title = title
        self.Height = height
        self.Width = width
        self.Screen = pygame.display.set_mode((self.Width, self.Height))

        #This is to initialize the framerate (fps)
        self.Clock = pygame.time.Clock()

        #This color is a refrence to the color object, in there all different colors are defined
        self.Color = clr.Color()
        self.DefaultFont = pygame.font.SysFont(None,30)

        #Initialize text messages
        self.InfoText = Text.Text(self.Color.Red, self.DefaultFont, "COUNT TO 10 | Click the button to increment the counter and finish the game!!!")

        
        #Create a button
        self.CountButton = button.Button(100,250, 50,200, self.Color.Yellow, Text.Text(self.Color.Black, self.DefaultFont, "Click me!"))
       
        #Initialize the counter to 0
        self.Counter = 0

        #Store the counter in a text object
        self.CounterText = Text.Text(self.Color.Black, self.DefaultFont, str(self.Counter))
def predict(with_embedding, input_prefix=''):
    if with_embedding:
        model_emb = models.load_model('data/out/lstm_model_emb')

        token2ind, ind2token = text_train.token2ind, text_train.ind2token

        text_prefix = Text(input_prefix, token2ind, ind2token)

        pred_emb = ModelPredict(model_emb,
                                text_prefix,
                                token2ind,
                                ind2token,
                                max_len,
                                embedding=True)

        with open("./lstm_with_embedding_output.txt", 'w') as f:
            for idx in range(100):
                print(str(idx + 1) + "/100")
                f.write(pred.generate_sequence(40, temperature=0.7))
                f.write('\n')
    else:
        model = models.load_model('lstm_model')

        token2ind, ind2token = text_train.token2ind, text_train.ind2token

        text_prefix = Text(input_prefix, token2ind, ind2token)

        pred = ModelPredict(model, text_prefix, token2ind, ind2token, max_len)

        with open("./lstm_output.txt", 'w') as f:
            for idx in range(100):
                print(str(idx + 1) + "/100")
                f.write(pred.generate_sequence(40, temperature=0.7))
                f.write('\n')
Beispiel #6
0
    def run(self):

        with open(self.parameters['ready_text'], "r") as myfile:
            text2show = myfile.read().replace('\n,', '\n')
        try:
            text2show = text2show.replace('NBLOCKS',
                                          str(self.parameters['nblocks']))
        except:
            pass
        try:
            text2show = text2show.replace(
                'NTRIALS',
                str(len(self.trial_settings) / self.parameters['nblocks']))
        except:
            pass
        text_screen = Text(self.parameters, self.screen, text2show)
        text_screen.show()

        expdata = list()
        sumacc_mem = list()
        sumacc_tim = list()
        blocki = 0
        for k, settings in enumerate(self.trial_settings):

            trial = Trial(settings, self.parameters, self.screen)
            trialdata = trial.run()
            expdata.append(trialdata)

            if 'mem' in settings:
                sumacc_mem.append(trialdata[2][0])
            elif 'timing' in settings:
                sumacc_tim.append(trialdata[2][0])

            if fmod(k + 1,
                    len(self.trial_settings) / self.parameters['nblocks']
                    ) == 0:  # feedback after mini/practice block
                blocki = blocki + 1
                dbstop()
                avgacc_mem = round(
                    float(np.mean(np.asarray(sumacc_mem))) * 100.0)
                avgacc_tim = float(np.mean(np.asarray(sumacc_tim)))
                if avgacc_tim < 0.25:
                    timefb = 'underestimated'
                elif avgacc_tim > 0.25:
                    timefb = 'overestimated'
                else:
                    timefb = 'correctly estimated'

                text2show = ('This was block ' + str(blocki) + ' of ' +
                             str(self.parameters['nblocks']) +
                             '\n\nYour memory/search accuracy was ' +
                             str(avgacc_mem) + '\n\nOn average you ' + timefb +
                             ' the delays' + '\n\nPress a button to continue')
                text_screen = Text(self.parameters, self.screen, text2show)
                text_screen.show()

        self._finished = True
        self.output = expdata
Beispiel #7
0
 def __init__(self, window_width, window_height, dark_color, light_color):
     self.light_color = light_color
     self.dark_color = dark_color
     self.title = Text.Text("Laws of Reflection", (window_width // 2, window_height // 2 - 170), light_color, 60)
     self.author_text = Text.Text("A game by Michael Rainsford Ryan", (window_width // 2, window_height // 2 - 100),
                                  light_color, 20)
     self.continue_text = Text.Text("press space to play", (window_width // 2, window_height // 2 + 100),
                                    dark_color, 30)
     self.twitter_text = Text.Text("Twitter: @MichaelRainRyan", (window_width // 2, window_height // 2 + 260),
                                   dark_color, 18)
Beispiel #8
0
 def create_text(self):
     self.titleText = Text(FONT, 50, 'Space Invaders', WHITE, 164, 155)
     self.titleText2 = Text(FONT, 25, 'Press any key to continue', WHITE,
                            201, 225)
     self.gameOverText = Text(FONT, 50, 'Game Over', WHITE, 250, 270)
     self.nextRoundText = Text(FONT, 50, 'Next Round', WHITE, 240, 270)
     self.enemy1Text = Text(FONT, 25, '   =   10 pts', GREEN, 368, 270)
     self.enemy2Text = Text(FONT, 25, '   =  20 pts', BLUE, 368, 320)
     self.enemy3Text = Text(FONT, 25, '   =  30 pts', PURPLE, 368, 370)
     self.enemy4Text = Text(FONT, 25, '   =  ?????', RED, 368, 420)
     self.scoreText = Text(FONT, 20, 'Score', WHITE, 5, 5)
     self.livesText = Text(FONT, 20, 'Lives ', WHITE, 640, 5)
    def __init__(self, window_width, window_height, text_color):
        self.thanks_text = Text.Text(
            "Thanks for Playing!",
            (window_width // 2, window_height // 2 - 50), text_color, 40)
        self.follow_text1 = Text.Text(
            "If you liked this game, consider following",
            (window_width // 2, window_height // 2 + 20), text_color, 20)

        self.follow_text2 = Text.Text(
            "me on Twitter @MichaelRainRyan :)",
            (window_width // 2, window_height // 2 + 60), text_color, 20)

        self.exit_text = Text.Text(
            "press Esc to exit to menu",
            (window_width // 2, window_height // 2 + 250), text_color, 25)
Beispiel #10
0
 def draw(self):
     pygame.draw.rect(self.surface, self.bgColor, self.rect, self.width)
     self.onHover()
     txt = Text(
         self.surface, self.text, "Consolas", 30, (255, 255, 255), "center",
         (self.rect[0] + self.rect[2] / 2, self.rect[1] + self.rect[3] / 2))
     txt.draw()
Beispiel #11
0
    def __init__(this, screen, events, levelManager):
        ### Universal Componenets
        this.screen = screen
        this.events = events
        this.levelManager = levelManager

        # Level Properties
        this.stageText = Text(screen, "",
                              screen.get_width() / 2, 20, (225, 75, 50), 45,
                              "Fonts/Roboto.ttf", True, False, False, False, 0,
                              0, 0)
        this.colorList = [(225, 50, 50), (50, 225, 50), (50, 50, 225)]
        this.textColor = 0
        this.textState = 1

        # State-Specific Properties
        this.state = 0
        ## Bonus Round
        this.bonusFrame = 0
        this.frameTime = 0
        this.textStage = 0

        # Objects
        this.player = Player(screen, events, levelManager)
        this.bonusEnemies = 0

        this.time = 0

        this.SetState(0)
Beispiel #12
0
 def test_analysis_is_correct(self):
     text1 = Text("The Ass of my aSs is not my arse")
     result1 = text1.generate_analysis()
     self.assertEqual(result1['ass']['position'], [1, 4])
     self.assertEqual(result1['ass']['count'], 2)
     self.assertEqual(result1['arse']['position'], [8])
     self.assertEqual(result1['arse']['count'], 1)
Beispiel #13
0
    def __init__(self, title, width, height):
        #The basic parameters wich make up the game
        self.Title = title
        self.Height = height
        self.Width = width
        self.Screen = pygame.display.set_mode((self.Width, self.Height))

        #This is to initialize the framerate (fps)
        self.Clock = pygame.time.Clock()

        #This color is a refrence to the color object, in there all different colors are defined
        self.Color = clr.Color()
        self.DefaultFont = pygame.font.SysFont(None, 30)

        self.InfoText = Text.Text(
            self.Color.Black, self.DefaultFont,
            "Score 3 points to go to the next level, press space to fly!")

        #Create all game characters here
        self.Player1 = c.Component(c.Position(400, 250), "enemy.png")

        #Empty list of enemies, this will be filled during the game
        #This is a special kind of list called an array, each element in the array has an unique Index
        #indeces start from 0, by calling Enemies[3] you call enemy in position number 3
        #!!!!BECAREFULL WITH THE BOUNDS: When the index does not exist you will get an error, always check if the IndexError
        #exists before calling it.
        self.Enemies = []
Beispiel #14
0
    def layout(self):
        self.setbbox(QRectF(0.0, 0.0, self.loWidth(), self.loHeight()))
        n = self.no() + 1 + self._score.pageFormat()._pageOffset
        if self.score().styleB(StyleIdx.ST_showPageNumber) and (
                self.no() > 0
                or self.score().styleB(StyleIdx.ST_showPageNumberOne)):
            if n & 1:
                subtype = TEXT.TEXT_PAGE_NUMBER_ODD
            else:
                subtype = TEXT.TEXT_PAGE_NUMBER_EVEN
            if n & 1:
                style = TEXT.TEXT_STYLE_PAGE_NUMBER_ODD
            else:
                style = TEXT.TEXT_STYLE_PAGE_NUMBER_EVEN
            if self._pageNo == 0:
                self._pageNo = Text(self.score())
                self._pageNo.setParent(self)
            if subtype != self._pageNo.subtype():
                self._pageNo.setSubtype(subtype)
                self._pageNo.setTextStyle(style)
            s = QString("%1").arg(n)
            if self._pageNo.getText() != s:
                self._pageNo.setText(s)
                self._pageNo.layout()
        else:
            self._pageNo = 0

        if self._score.rights:
            if self._copyright == 0:
                self._copyright = TextC(self._score.rights)
                self._copyright.setParent(self)
                self._copyright.setTextStyle(TEXT.TEXT_STYLE_COPYRIGHT)
                self._copyright.layout()
        else:
            self._copyright = 0
Beispiel #15
0
    def __init__(this, screen, events, levelManager, command, commandParameter, txt, x, y, sizeX, sizeY, btnCol, hvrCol, psdCol, txtCol, fadeIn, speed):
        ### Universal Componenets
        this.screen = screen # used to display button
        this.events = events # gets events
        this.levelManager = levelManager

        ### Commands
        this.command = command # button pressed action
        this.commandParameter = commandParameter # extra button press parameter

        ### Button Properties
        this.x = x # x pos
        this.desiredX = x # used with transitions
        this.y = y # y pos
        this.size = (sizeX, sizeY) # size
        this.txt = txt # text

        ### Colors
        this.btnCol = btnCol # button
        this.hvrCol = hvrCol # hover
        this.psdCol = psdCol # pressed
        this.txtCol = txtCol # text

        ### Transitions
        this.fadeIn = fadeIn # whether or not to use a transition
        this.speed = speed # transition speed
        if (this.fadeIn):
            this.x = screen.get_width()

        ### Button State
        this.hover = False
        this.pressed = False
        
        this.text = Text(screen, this.txt, this.x, this.y - this.size[1]/2 + 7, this.txtCol, 30, "Fonts/Roboto.ttf",True, False, False, False, 0, 0, speed)
Beispiel #16
0
    def __init__(this, screen, events, time):
        ### Universal Componenets
        this.screen = screen
        this.events = events

        this.time = time
        this.state = 0
        this.textInput = Text(screen, "",
                              screen.get_width() / 2, 250, (255, 255, 255), 18,
                              "Fonts/Roboto.ttf", True, False, False, False, 0,
                              0, 0)
        this.leaderboards = []
        for i in range(0, 5):
            this.leaderboards.append(
                Text(screen, "",
                     screen.get_width() / 2 - 100, 250 + (25 * i),
                     (255, 255, 255), 18, "Fonts/Roboto.ttf", False, False,
                     False, False, 0, 0, 0))
Beispiel #17
0
    def __init__(self,canvas,x,y,diameter,width,startDegrees,rangeDegrees,minValue,maxValue,minWrnValue,maxWrnValue,minColor,normalColor,maxColor,fontSize,textSize,textColor,text,backgroundColor,updateFunction,updateParam):
	self.updateFunction = updateFunction
	self.updateParam = updateParam
        self.canvas = canvas
        self.minValue=minValue
        self.maxValue=maxValue
        self.rangeDegrees = rangeDegrees
        self.startDegrees = startDegrees
        self.minWrnValue = minWrnValue
        self.maxWrnValue = maxWrnValue
        self.minColor = minColor
        self.normalColor = normalColor
        self.maxColor = maxColor
        self.idBackground = self.canvas.create_arc(x-(diameter/2),y-(diameter/2),x+(diameter/2),y+(diameter/2),style="arc", start=self.startDegrees, extent=-self.rangeDegrees,fill="",outline=backgroundColor,width=width)
        self.idCircle = self.canvas.create_arc(x-(diameter/2),y-(diameter/2),x+(diameter/2),y+(diameter/2),style="arc", start=self.startDegrees, extent=-self.rangeDegrees,fill="",outline=normalColor,width=width)
        
        self.idValue = Text(canvas,x,y,"Helvetica",fontSize,"bold",textColor,"","","80")
        self.idText = Text(canvas,x,y+(diameter/4.5),"Helvetica",textSize,"bold",textColor,"","",text) 
Beispiel #18
0
	def __init__(self, number, name=str("Dude")):
		#Constants
		self.score = 0
		self.name = str("          ")
		self.name = name[0:9]
		
		#Variables
		self.pinFallen = []
		self.emptyTurns = 0 #Count the number of turns without points
		
		self.textName = Text()
		self.textScore = Text()
		nameScreen = overlayer1.objects["playerNameText"]
		scoreScreen = overlayer1.objects["playerScoreText"]
		camera = overlayer1.objects["Camera"]
		self.textName.consRel(self.name, "Russian.ttf", nameScreen, camera, -Vector((0, number*0.1*6, 0)), 10)
		self.textScore.consRel(str(self.score), "Russian.ttf", scoreScreen, camera, -Vector((0, number*0.1*6, 0)), 1, Vector((0.1, 0.1)))
		
		print("  Player "+name+" has been successfully created")
Beispiel #19
0
    def run(self):

        with open(self.parameters['ready_text'], "r") as myfile:
            text2show = myfile.read().replace('\n,', '\n')
        try:
            text2show = text2show.replace('NBLOCKS',
                                          str(self.parameters['nblocks']))
        except:
            pass
        try:
            text2show = text2show.replace(
                'NTRIALS', str(len(self.trials) / self.parameters['nblocks']))
        except:
            pass
        text_screen = Text(self.parameters, self.screen, text2show)
        text_screen.show()

        expdata = list()
        sumacc = 0
        blocki = 0
        # for k, settings in enumerate(self.trial_settings):
        for k, trial in enumerate(self.trials):

            # trial = Trial(settings, self.parameters, self.screen)
            trialdata = trial.run()
            expdata.append(trialdata)
            sumacc = sumacc + trialdata[2][0]
            if fmod(k + 1,
                    len(self.trial_settings) / self.parameters['nblocks']
                    ) == 0:  # feedback after mini/practice block
                blocki = blocki + 1
                avgacc = round(float(sumacc) / float(len(expdata)) * 100.0)
                text2show = 'This was block ' + str(blocki) + ' of ' + str(
                    self.parameters['nblocks']
                ) + '\n\nYour accuracy was ' + str(
                    avgacc) + '\n\nPress a button to continue'
                text_screen = Text(self.parameters, self.screen, text2show)
                text_screen.show()

        self._finished = True
        self.output = expdata
Beispiel #20
0
	def __init__(self, file_path):
		super(Scene, self).__init__()

		pygame.mixer.init(44100, -16, 4, 2048)
		self.all_object_list = pygame.sprite.LayeredUpdates()
		self.blocks = dict() # Prototype
		self.main_block = BlockSprite()
		self.background = Object()
		self.current_button = None
		self.button_list = []
		self.block_list = []
		self.sound_list = dict()
		self.current_stage = 0
		self.board = None
		self.stage_text = Text('Monotype Corsiva', 38, bold = True, color = (200, 50, 0))
		self.solution_text = Text('Consolas', 20, bold = True, color = (50, 140, 0))
		self.time_text = Text('Consolas', 20, bold = True, color = (50, 140, 0))
		self.mem_text = Text('Consolas', 20, bold = True, color = (50, 140, 0))
		self.step_text = Text('Consolas', 20, bold = True, color = (50, 140, 0))

		self.is_mouse_pressed = False
		self.is_drag = False
		self.orig_mouse_pos = None
		self.orig_block_pos = None
		self.current_block_margin = [0, 0]
		self.current_block = None

		self.game_mode = Game_mode.NORMAL
		self.is_solve = False
		self.is_moving = False
		self.speed = 5
		self.velocity = None
		self.goal = None

		# Load scene's resources
		self.read_scene(file_path)
Beispiel #21
0
    def __init__(this, screen, events, levelManager):
        ### Universal Components
        this.screen = screen
        this.events = events
        this.levelManager = levelManager

        this.title = Text(screen, "Retalion",
                          screen.get_width() / 2, 20, (225, 240, 230), 30,
                          "Fonts/Roboto.ttf", True, True, True, True,
                          this.screen.get_width() / 8, -100, 12)
        this.button = Button(screen, events, this.levelManager,
                             Command.LevelChange, 1, "Play",
                             screen.get_width() / 2, 300, 200, 50,
                             (100, 250, 100), (150, 255, 150), (75, 225, 75),
                             (0, 0, 0), True, 11)
Beispiel #22
0
 def text_(self):
     if s.is_empty():
         self.open()
     else:
         self.make_duplicate()
         path = s.peek()
         content = self.textEdit.toPlainText()
         fontScale = int(self.text_fontScale.value())
         color = (text_b, text_g, text_r)
         x = int(self.text_x.toPlainText())
         y = int(self.text_y.toPlainText())
         thickness = int(self.text_thickess.value())
         txt = Text()
         txt.addText(path, content, fontScale, x, y, color, thickness)
         self.show_()
Beispiel #23
0
    def __init__(self, run, x, y, w, h, align):
        self.run = run
        self.color = Constants.BLUE
        self.image = pygame.Surface((w, h))
        self.image.convert()
        self.image.fill(self.color)
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y
        self.align = align
        self.text_list = []

        # Assigns coordinates of textbox based on alignment
        for line in range(0, 8):
            if self.align == "left":
                text = Text(Constants.font_sz, "", "left", x + Constants.mar_1,
                            y + Constants.mar_1 + Constants.font_sz * line,
                            Constants.WHITE)
            else:
                text = Text(
                    Constants.font_sz, "", "center", self.rect.centerx,
                    self.rect.y + Constants.mar_1 + Constants.font_sz * line,
                    Constants.WHITE)
            self.text_list += [text]
def setup():
    globs.camera = Camera(vec3(0, 0, 1), vec3(0, 0, 0), vec3(0, 1, 0),
                          3.14 / 4, 0.1, 1000)

    globs.pewSound = Mix_LoadWAV(os.path.join("assets", "pew.ogg").encode())

    glEnable(GL_MULTISAMPLE)
    glEnable(GL_DEPTH_TEST)
    glDepthFunc(GL_LEQUAL)
    glClearColor(0, 0, 0, 0)
    globs.starProg = Program("starvs.txt", "starfs.txt")
    globs.mainProg = Program("vs.txt", "fs.txt")
    globs.shipProg = Program("shipvs.txt", "shipfs.txt")

    globs.boss = Mesh(os.path.join("assets", "toothyjaws.obj.mesh"))
    globs.boss.pos = vec3(3.5, 0, 0)

    globs.starVao = makeStars()

    glEnable(GL_PROGRAM_POINT_SIZE)
    globs.player = Ship()
    globs.enemyShips.append(EnemyShip())
    globs.enemySins.append(EnemySin())

    #drawBackground()

    glEnable(GL_BLEND)
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
    Program.setUniform("screenSize", globs.screenSize)
    Program.updateUniforms()
    globs.charge = Text("Roboto-Black.ttf", 26)
    globs.chargeCount = 0

    global lightPositions
    #change x*4 to suit num lights
    lightPositions = array.array("f", [0] * 1 * 4)
    lightColors = array.array("f", [0] * 1 * 4)
    idx = 0
    lightPositions[idx] = 0  #x
    lightPositions[idx + 1] = 1  #y
    lightPositions[idx + 2] = 1  #z
    lightPositions[idx + 3] = 0  #w, 0-directional or 1-positional
    lightColors[idx] = 1.5
    lightColors[idx + 1] = 0
    lightColors[idx + 2] = 0
    Program.setUniform("lightPositions[0]", lightPositions)
    Program.setUniform("lightColors[0]", lightColors)
Beispiel #25
0
    def __init__(self, xpos, ypos, row, ship, mystery, score, game):
        sprite.Sprite.__init__(self)
        self.isMystery = mystery
        self.game = game
        self.isShip = ship
        if mystery:
            self.text = Text(FONT, 20, str(score), WHITE, xpos + 20, ypos + 6)
        elif ship:
            self.image = IMAGES[SHIP]
            self.rect = self.image.get_rect(topleft=(xpos, ypos))
        else:
            self.row = row
            self.load_image()
            self.image = transform.scale(self.image, (40, 35))
            self.rect = self.image.get_rect(topleft=(xpos, ypos))
            self.game.screen.blit(self.image, self.rect)

        self.timer = time.get_ticks()
Beispiel #26
0
    def __init__(self, master=None, filePath=None, helpURL=None, **kargs):
        Tkinter.Frame.__init__(self, master, **kargs)

        self.master = master
        self.filePath = filePath

        self.inputWdg = Text.Text(master=self,
                                  width=60,
                                  height=10,
                                  helpURL=helpURL)
        self.inputWdg.grid(row=0, column=0, sticky=Tkinter.NSEW)
        self.inputWdg.bind("<Key-Escape>", self.run)

        self.scroll = Tkinter.Scrollbar(self, command=self.inputWdg.yview)
        self.inputWdg.configure(yscrollcommand=self.scroll.set)
        self.scroll.grid(row=0, column=1, sticky=Tkinter.NS)

        if self.filePath:
            fd = RO.OS.openUniv(self.filePath)
            try:
                self.inputWdg.delete(1.0, Tkinter.END)
                for line in fd.readlines():
                    self.inputWdg.insert(Tkinter.END, line)
            finally:
                fd.close()

        self.cmdbar = Tkinter.Frame(self, borderwidth=2, relief=Tkinter.SUNKEN)
        self.open = Tkinter.Button(self.cmdbar,
                                   text='Open...',
                                   command=self.open)
        self.open.pack(side=Tkinter.LEFT, expand=0, padx=3, pady=3)
        self.save = Tkinter.Button(self.cmdbar,
                                   text='Save...',
                                   command=self.save)
        self.save.pack(side=Tkinter.LEFT, expand=0, padx=3, pady=3)
        self.clr = Tkinter.Button(self.cmdbar, text='Clear', command=self.clr)
        self.clr.pack(side=Tkinter.LEFT, expand=0, padx=3, pady=3)
        self.run = Tkinter.Button(self.cmdbar, text='Run', command=self.run)
        self.run.pack(side=Tkinter.RIGHT, expand=0, padx=3, pady=3)
        self.cmdbar.grid(row=1, column=0, columnspan=2, sticky=Tkinter.EW)

        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self.inputWdg.focus_set()
Beispiel #27
0
    def __init__(self, screen, width, height):
        super().__init__(screen, width, height)

        self.__back_img = pygame.image.load('./source/image/background.jpg')
        self.__back_img = pygame.transform.scale(self.__back_img,
                                                 (SCREEN_WIDTH, SCREEN_HEIGHT))

        self.__title = Text(screen, None, TITLE_HEIGHT, 'Five Chess',
                            BLACK_COLOR, TITLE_X, TITLE_Y)

        self.__start_button = StartButton(self.get_screen(), 'Start',
                                          TITLE_X - BUTTON_WIDTH // 2,
                                          TITLE_Y + TITLE_HEIGHT, True)
        self.__model_button = UseAIButton(self.get_screen(), 'PVE',
                                          TITLE_X - BUTTON_WIDTH // 2,
                                          TITLE_Y + TITLE_HEIGHT + 60)
        self.__exit_button = ExitButton(self.get_screen(), 'Exit',
                                        TITLE_X - BUTTON_WIDTH // 2,
                                        TITLE_Y + TITLE_HEIGHT + 120)
Beispiel #28
0
 def draw(self):
     r = self.borderRadius
     rect = tuple(int(i) for i in self.rect)
     if r > min(rect[2], rect[3]) // 2: r = min(rect[2], rect[3]) // 2
     pygame.draw.rect(self.surface, self.bgColor,
                      (rect[0], rect[1] + r, rect[2], rect[3] - 2 * r))
     pygame.draw.rect(self.surface, self.bgColor,
                      (rect[0] + r, rect[1], rect[2] - 2 * r, rect[3]))
     pygame.draw.circle(self.surface, self.bgColor,
                        (rect[0] + r, rect[1] + r), r)
     pygame.draw.circle(self.surface, self.bgColor,
                        (rect[0] + rect[2] - r, rect[1] + r), r)
     pygame.draw.circle(self.surface, self.bgColor,
                        (rect[0] + rect[2] - r, rect[1] + rect[3] - r), r)
     pygame.draw.circle(self.surface, self.bgColor,
                        (rect[0] + r, rect[1] + rect[3] - r), r)
     self.onHover()
     txt = Text(
         self.surface, self.text, "Consolas", 30, (255, 255, 255), "center",
         (self.rect[0] + self.rect[2] / 2, self.rect[1] + self.rect[3] / 2))
     txt.draw()
Beispiel #29
0
 def __init__(self, canvas, x, y, diameter, maxG, outlineWidth,
              outlineColor, lineWidth, lineColor, textColor):
     self.x = x
     self.y = y
     self.diameter = diameter
     self.maxG = maxG
     self.canvas = canvas
     self.idGauge = self.canvas.create_oval(x - (diameter / 2),
                                            y - (diameter / 2),
                                            x + (diameter / 2),
                                            y + (diameter / 2),
                                            outline=outlineColor,
                                            width=outlineWidth)
     self.idLine = self.canvas.create_line(x,
                                           y,
                                           x,
                                           y + (diameter / 2),
                                           fill=lineColor,
                                           width=lineWidth)
     self.text = Text(canvas, x + (diameter / 2.6), y + (diameter / 2.1),
                      "Helvetica", int(diameter * 0.09), "bold", textColor,
                      "", "", "1.0 G")
Beispiel #30
0
    def __init__(this, screen, events, levelManager):
        ### Universal Components
        this.screen = screen
        this.events = events
        this.levelManager = levelManager

        # Player Properties
        this.speed = 6.8
        this.rotSpeed = 6.89
        this.x = 300
        this.y = 400
        this.rot = 0
        this.size = (50, 50)
        this.color = (235, 235, 235)
        this.player = pygame.image.load("Images/Player.png").convert_alpha()
        this.playerRect = this.player.get_rect()
        this.hp = 3
        this.hpText = Text(screen, ("Health: " + str(this.hp)), 5, 5,
                           (255, 255, 255), 18, "Fonts/Roboto.ttf", False,
                           False, False, False, 0, 0, 0)

        # State-Specific Properties
        this.state = 0