예제 #1
0
파일: circle.py 프로젝트: m4reQ/Oss-2.0
    def __init__(self, pos, time=0):
        self.pos = pos

        self.destroyed = False
        self.alpha = 200

        if time != -1:
            self.startTime = GetMax(time - AR, 0)
            self.endTime = GetMax(time + AR, 0)
            self.hitTime = GetMax(time - (AR / 2),
                                  0)  #a quarter after circle show time
        else:
            self.startTime = -1
            self.endTime = float('inf')
            self.hitTime = float('inf')

        self.textureCount = Circle.textureCount
        self.backgroundCount = Circle.backgroundCount

        self.bgName = 'circlebg_' + str(self.backgroundCount)
        self.fontName = 'circlefont_' + str(self.textureCount)

        self.fontTexture = mainResManager.GetTexture(self.fontName)
        self.bgTexture = mainResManager.GetTexture(self.bgName)

        self.circleSurf = pygame.Surface(
            (Circle.radius * 2 + 4, Circle.radius * 2 + 4),
            pygame.HWSURFACE | pygame.SRCALPHA).convert()
        self.circleSurf.fill((255, 0, 255))
        self.circleSurf.set_colorkey((255, 0, 255))
        self.circleSurf.blit(self.bgTexture.Get(), (0, 0))
        pygame.draw.circle(self.circleSurf, (255, 255, 255, 255),
                           (int(Circle.radius), int(Circle.radius)),
                           Circle.radius, int(3 * scale))
        pygame.draw.circle(self.circleSurf, (128, 128, 128, 255),
                           (int(Circle.radius), int(Circle.radius)),
                           (Circle.radius + int(1 * scale)), int(2 * scale))
        self.circleSurf.blit(self.fontTexture.Get(), (0, 0))

        if Circle.textureCount < 9:
            Circle.textureCount += 1
        else:
            Circle.textureCount = 0

        if Circle.count % 4 == 0 and Circle.count != 0:
            if Circle.backgroundCount < 4:
                Circle.backgroundCount += 1
            else:
                Circle.backgroundCount = 0

        self.shouldDraw = True

        Circle.count += 1
예제 #2
0
	def Render(self):
		while self.isRunning:
			renderStart = timer()

			playgroundStart = timer()
			self.win.blit(mainResManager.GetTexture(self.backgroundName).Get(), (0, 0))
			self.renderStats.blitCount += 1

			for circle in self.map.objectsLeft:
				circle.Draw(self.win, self.time_ms, self)
			
			self.renderStats.playgroundDrawTime = timer() - playgroundStart
			
			if self.drawInterface:
				self.DrawGui()

			self.DrawCursor()

			pygame.display.flip()

			if prefs.useFpsCap:
				waitStart = timer()
				self.clock.tick(prefs.targetFps)
				self.renderStats.waitTime = timer() - waitStart

			self.renderStats.renderTime = timer() - renderStart
			self.time += self.renderStats.renderTime
			self.time_ms += self.renderStats.renderTime * 1000
예제 #3
0
    def __init__(self, win):
        self.win = win
        self.width = win.get_width()
        self.height = win.get_height()
        self.game = None
        self.time = 0
        self.frameTime = 0
        self.cursorPos = (0, 0)
        self.isRunning = True
        self.messages = []

        self.startButton = Button((25, self.height - 80, 170, 32),
                                  (156, 45, 119), self.Start,
                                  "Start new game!")
        self.exitButton = Button((25, self.height - 40, 170, 32),
                                 (156, 45, 119), self.Close, "Exit")
        self.editorButton = Button((25, self.height - 120, 170, 32),
                                   (156, 45, 119), self.OpenEditor,
                                   "Maps editor")
        self.settingsButton = Button(
            (25, 25, 48, 48), (0, 0, 0),
            self.OpenSettings,
            backgroundImg=mainResManager.GetTexture("setsIcn").Get())

        self.startButton.activeColor = Color.Gray
        self.exitButton.activeColor = Color.Gray
        self.editorButton.activeColor = Color.Gray

        self.startButton.colorOnHover = True
        self.exitButton.colorOnHover = True
        self.editorButton.colorOnHover = True

        self.AddMessage("Welcome to Oss!")
        pygame.display.set_caption("Oss! - Menu")
예제 #4
0
    def Render(self):
        #clear
        self.win.fill((110, 33, 84))

        #render playfield
        playField = pygame.Rect(self.playfield["minX"], self.playfield["minY"],
                                self.playfield["width"],
                                self.playfield["height"])
        pygame.draw.rect(self.win, (0, 0, 0), playField, 1)

        #render points
        pygame.draw.circle(self.win, Color.Red, self.lastRegs[0], 3)
        pygame.draw.circle(self.win, Color.Green, self.lastRegs[1], 3)

        #render mode
        if Editor.regMode == RegisterMode.Time:
            mode = "Time"
        elif Editor.regMode == RegisterMode.Position:
            mode = "Position"
        else:
            mode = "Invalid"

        rModeText = mainResManager.GetFont("comicsansms_18").render(
            "Register mode: {}".format(mode), True, Color.White)
        self.win.blit(rModeText, (3, 3))

        #render time
        rTimeText = mainResManager.GetFont("comicsansms_24").render(
            "Time: {}ms".format(int(self.time * 1000)), True, Color.White)
        self.win.blit(rTimeText, (3, rModeText.get_height() + 3))

        #render cursor
        self.win.blit(
            mainResManager.GetTexture('cursor').Get(),
            (self.cursorPos[0] - mainResManager.GetTexture('cursor').Width / 2,
             self.cursorPos[1] -
             mainResManager.GetTexture('cursor').Height / 2))
예제 #5
0
파일: circle.py 프로젝트: m4reQ/Oss-2.0
    def Draw(self, surf, time, game):
        if not self.shouldDraw:
            return

        if time >= self.startTime and time <= self.endTime:
            self.circleSurf.set_alpha(self.alpha)

            surf.blit(
                self.circleSurf,
                (self.pos[0] - Circle.radius, self.pos[1] - Circle.radius))
            game.renderStats.blitCount += 1

            if time >= self.hitTime and time <= self.endTime:
                if not self.destroyed:
                    surf.blit(
                        mainResManager.GetTexture("hitlayout").Get(),
                        (self.pos[0] - Circle.radius,
                         self.pos[1] - Circle.radius))
예제 #6
0
	def DrawCursor(self):
		tex = mainResManager.GetTexture('cursor')
		self.win.blit(tex.Get(), (self.cursorPos[0] - tex.Width / 2, self.cursorPos[1] - tex.Height / 2))
		self.renderStats.blitCount += 1
예제 #7
0
 def DrawBackground(self):
     self.win.blit(
         mainResManager.GetTexture("menu_background").Get(), (0, 0))
예제 #8
0
 def DrawCursor(self):
     drawPos = (self.cursorPos[0] -
                mainResManager.GetTexture('cursor').Width / 2,
                self.cursorPos[1] -
                mainResManager.GetTexture('cursor').Height / 2)
     self.win.blit(mainResManager.GetTexture("cursor").Get(), drawPos)