コード例 #1
0
    def draw(self, screenpos0, blocksize, bad=False, on=True):
        x0, y0 = screenpos0
        d = int(blocksize * 0.03)
        for x, y in self.blocks:
            px = x0 + blocksize * x + d
            py = y0 + blocksize * y + d
            rect = px, py, blocksize - 2 * d, blocksize - 2 * d
            color = (100, 0, 0) if bad else self.color if on else self.dull
            vista.screen.fill(color, rect)
        for ix0, iy0, ix1, iy1 in self.inputs:
            dx, dy = ix1 - ix0, iy1 - iy0
            rot = {
                (0, 1): 180,
                (1, 0): -90,
                (0, -1): 0,
                (-1, 0): 90,
            }[(dx, dy)]
            pos = int(x0 +
                      (ix1 + 0.5) * blocksize), int(y0 +
                                                    (iy1 + 0.5) * blocksize)
            img.draw("outflow", pos, scale=blocksize / 64, angle=rot)

        px = int(x0 + blocksize * self.center[0])
        py = int(y0 + blocksize * self.center[1])
        img.drawtext(self.name, 14, center=(px, py))
コード例 #2
0
ファイル: dialog.py プロジェクト: cosmologicon/unifac
def draw():
	if not state.state.playing:
		return
	who, _, line = state.state.playing[0].partition(": ")
	imgname = "avatar%s" % who
	ipos = F(50, 480 - 50)
	img.draw(imgname, ipos, scale = avatarscale)
	pos = F(100, 480 - 90)
	img.drawtext(line + "\n ", fontname = fonts[who], fontsize = textsize, topleft = pos, maxwidth = F(480))
	pos = F(100, 480 - 95)
	img.drawtext(names[who] + "\n ", fontname = fonts[who], fontsize = textsize, color = colors[who], midleft = pos)

	rect = pygame.Rect(F(0, 0, 80, 80))
	rect.center = ipos
	pygame.draw.rect(vista.screen, colors[who], rect, F(2))
コード例 #3
0
ファイル: state.py プロジェクト: cosmologicon/unifac
	def drawviewport(self):
		import vista, img
		a = starmap.getoort((self.you.x, self.you.y))
		vista.screen.fill((0, int(80 * a), int(60 * a)))
		vista.drawstars()
		for t in self.things:
			t.draw()
		for s in self.ships:
			s.draw()
		for e in self.effects:
			e.draw()
		for iname in self.interests:
			obj = getattr(self, iname)
			if not vista.isvisible((obj.x, obj.y), obj.radius - 1):
				pos, angle = vista.indpos((obj.x, obj.y))
				img.worlddraw("arrow", pos, angle = angle)
				img.drawtext(settings.inames[iname], F(20), (0, 255, 255), fontname = "teko", center = vista.worldtoscreen(pos))
コード例 #4
0
 def drawviewport(self):
     import vista, img
     a = starmap.getoort((self.you.x, self.you.y))
     vista.screen.fill((0, int(80 * a), int(60 * a)))
     vista.drawstars()
     for t in self.things:
         t.draw()
     for s in self.ships:
         s.draw()
     for e in self.effects:
         e.draw()
     for iname in self.interests:
         obj = getattr(self, iname)
         if not vista.isvisible((obj.x, obj.y), obj.radius - 1):
             pos, angle = vista.indpos((obj.x, obj.y))
             img.worlddraw("arrow", pos, angle=angle)
             img.drawtext(settings.inames[iname],
                          F(20), (0, 255, 255),
                          fontname="teko",
                          center=vista.worldtoscreen(pos))
コード例 #5
0
def draw():
    if mapmode:
        state.state.drawmainmap()
    else:
        state.state.drawviewport()
    vista.screen.fill((20, 25, 30), settings.prect)
    state.state.drawnavmap()
    if state.state.alerts:
        img.drawtext("\n".join(state.state.alerts),
                     color=(255, 0, 0),
                     fontsize=settings.alertfontsize,
                     topleft=(0, 0))
    for b in buttons:
        b.draw()
    img.drawtext("Connected modules:",
                 fontsize=F(24),
                 fontname="prosto",
                 topleft=F(490, 10))
    texts = [
        "SpaceBucks: %s" % state.state.bank,
        "Hull: %s/%s" % (state.state.you.hp, state.state.you.maxhp),
    ]
    colors = [
        (200, 200, 200),
        (100, 200, 100),
    ]
    for j, (text, color, pos) in enumerate(zip(texts, colors,
                                               settings.statpos)):
        img.drawtext(text,
                     fontsize=settings.statfontsize,
                     fontname="prosto",
                     center=pos)
    if shroud:
        vista.screen.blit(shroud, (0, 0))
    dialog.draw()
コード例 #6
0
 def drawmainmap(self):
     import vista, img
     vista.drawmainoort()
     scale = settings.grect.width / (2 * starmap.rx)
     for t in self.things:
         if t.surveyed:
             px, py = vista.worldtomainmap((t.x, t.y))
             r = int(scale * t.radius)
             pygame.draw.circle(vista.screen, (200, 200, 200), (px, py), r)
     for iname in self.interests:
         obj = getattr(self, iname)
         if isinstance(obj, things.Sun):
             pass
         px, py = vista.worldtomainmap((obj.x, obj.y))
         #			pygame.draw.circle(vista.screen, (200, 200, 200), (px, py), F(10), 1)
         img.drawtext(settings.inames[iname],
                      F(12),
                      fontname="teko",
                      center=(px, py))
     px, py = vista.worldtomainmap((self.you.x, self.you.y))
     img.drawtext("YOU",
                  F(12),
                  fontname="teko",
                  color=(255, 200, 0),
                  center=(px, py))
     img.drawtext("Surveyed planets and stars",
                  F(24),
                  fontname="viga",
                  center=F(240, 20))
コード例 #7
0
def draw():
	vista.screen.fill((255, 255, 255))
	img.drawtext(settings.gamename, F(60), center = F(854/2, 120), fontname = "prosto")
	img.drawtext("by Christoper Night\n ", F(20), center = F(854/2, 220), fontname = "prosto")
	img.drawtext("music by Mary Bichner\n ", F(20), center = F(854/2, 270), fontname = "prosto")
	for b in buttons:
		b.draw()
コード例 #8
0
ファイル: menuscene.py プロジェクト: cosmologicon/unifac
def draw():
	vista.screen.fill((255, 255, 255))
	img.drawtext(settings.gamename, F(80), center = F(854/2, 120), fontname = "prosto")
	img.drawtext("by Christoper Night\n ", F(30), center = F(854/2, 220), fontname = "prosto")
	img.drawtext("music by Mary Bichner\n ", F(30), center = F(854/2, 270), fontname = "prosto")
	for b in buttons:
		b.draw()
コード例 #9
0
ファイル: gamescene.py プロジェクト: cosmologicon/unifac
def draw():
	if mapmode:
		state.state.drawmainmap()
	else:
		state.state.drawviewport()
	vista.screen.fill((20, 25, 30), settings.prect)
	state.state.drawnavmap()
	if state.state.alerts:
		img.drawtext("\n".join(state.state.alerts), color = (255, 0, 0), fontsize = settings.alertfontsize, topleft = (0, 0))
	for b in buttons:
		b.draw()
	img.drawtext("Connected modules:", fontsize = F(24), fontname = "prosto", topleft = F(490, 10))
	texts = [
		"Hull: %s/%s" % (state.state.you.hp, state.state.you.maxhp),
		"SpaceBucks: %s" % state.state.bank,
	]
	colors = [
		(200, 200, 200),
		(100, 200, 100),
	]
	for j, (text, color, pos) in enumerate(zip(texts, colors, settings.statpos)):
		img.drawtext(text, fontsize = settings.statfontsize, fontname = "prosto", center = pos)
	if shroud:
		vista.screen.blit(shroud, (0, 0))
	dialog.draw()
コード例 #10
0
ファイル: parts.py プロジェクト: cosmologicon/unifac
	def draw(self, screenpos0, blocksize, bad = False, on = True):
		x0, y0 = screenpos0
		d = int(blocksize * 0.03)
		for x, y in self.blocks:
			px = x0 + blocksize * x + d
			py = y0 + blocksize * y + d
			rect = px, py, blocksize - 2 * d, blocksize - 2 * d
			color = (100, 0, 0) if bad else self.color if on else self.dull
			vista.screen.fill(color, rect)
		for ix0, iy0, ix1, iy1 in self.inputs:
			dx, dy = ix1 - ix0, iy1 - iy0
			rot = {
				(0, 1): 180,
				(1, 0): -90,
				(0, -1): 0,
				(-1, 0): 90,
			}[(dx, dy)]
			pos = int(x0 + (ix1 + 0.5) * blocksize), int(y0 + (iy1 + 0.5) * blocksize)
			img.draw("outflow", pos, scale = blocksize / 64, angle = rot)

		px = int(x0 + blocksize * self.center[0])
		py = int(y0 + blocksize * self.center[1])
		img.drawtext(self.name, 14, center = (px, py))
コード例 #11
0
def draw():
    if not state.state.playing:
        return
    who, _, line = state.state.playing[0].partition(": ")
    imgname = "avatar%s" % who
    ipos = F(50, 480 - 50)
    img.draw(imgname, ipos, scale=avatarscale)
    pos = F(100, 480 - 90)
    img.drawtext(line + "\n ",
                 fontname=fonts[who],
                 fontsize=textsize,
                 topleft=pos,
                 maxwidth=F(480))
    pos = F(100, 480 - 95)
    img.drawtext(names[who] + "\n ",
                 fontname=fonts[who],
                 fontsize=textsize,
                 color=colors[who],
                 midleft=pos)

    rect = pygame.Rect(F(0, 0, 80, 80))
    rect.center = ipos
    pygame.draw.rect(vista.screen, colors[who], rect, F(2))
コード例 #12
0
ファイル: state.py プロジェクト: cosmologicon/unifac
	def drawmainmap(self):
		import vista, img
		vista.drawmainoort()
		scale = settings.grect.width / (2 * starmap.rx)
		for t in self.things:
			if t.surveyed:
				px, py = vista.worldtomainmap((t.x, t.y))
				r = int(scale * t.radius)
				pygame.draw.circle(vista.screen, (200, 200, 200), (px, py), r)
		for iname in self.interests:
			obj = getattr(self, iname)
			if isinstance(obj, things.Sun):
				pass
			px, py = vista.worldtomainmap((obj.x, obj.y))
#			pygame.draw.circle(vista.screen, (200, 200, 200), (px, py), F(10), 1)
			img.drawtext(settings.inames[iname], F(12), fontname = "teko", center = (px, py))
		px, py = vista.worldtomainmap((self.you.x, self.you.y))
		img.drawtext("YOU", F(12), fontname = "teko", color = (255, 200, 0), center = (px, py))
		img.drawtext("Surveyed planets and stars", F(24), fontname = "viga", center = F(240, 20))
コード例 #13
0
ファイル: buildscene.py プロジェクト: cosmologicon/unifac
def draw():
	vista.screen.fill((50, 50, 50))
	for x in range(settings.shipw):
		for y in range(settings.shiph):
			vista.screen.fill((100, 50, 0), (bx0 + bscale*x, by0 + bscale*y, bscale-3, bscale-3))
	for x0, y0, x1, y1 in state.state.supplies.values():
		dx, dy = x1 - x0, y1 - y0
		rot = {
			(1, 0): -90,
			(-1, 0): 90,
		}[(dx, dy)]
		pos = int(bx0 + (x0 + 0.5) * bscale), int(by0 + (y0 + 0.5) * bscale)
		img.draw("inflow", pos, scale = bscale / 64, angle = rot)

	for part in state.state.parts:
		on = isinstance(part, parts.Conduit) or part.name in state.state.hookup
		part.draw((bx0, by0), bscale, on = on)
	for (x0, y0, scale), control in zip(cps, controls):
		on = isinstance(control, parts.Conduit) or control.name in state.state.unlocked
		control.draw((x0, y0), scale, on = on)
		if control is cursor:
			control.drawoutline((x0, y0), scale)
	for b in buttons:
		b.draw()
	titlesize = F(34)
	subtitlesize = F(18)
	titlefont = "audiowide"
	img.drawtext("OUTFIT CAPSULE", fontsize = F(42), fontname = titlefont, color = (100, 200, 0), bottomleft = F(20, 460))
	img.drawtext("MODULES", fontsize = titlesize, fontname = titlefont, color = (200, 100, 100), midbottom = F(130, 45))
	img.drawtext("SHIP LAYOUT", fontsize = titlesize, fontname = titlefont, color = (160, 160, 160), midbottom = F(854/2, 45))
	img.drawtext("Click to remove", fontsize = subtitlesize, fontname = titlefont, color = (160, 160, 160), midtop = F(854/2, 45))
	img.drawtext("CONDUITS", fontsize = titlesize, fontname = titlefont, color = (100, 200, 100), midbottom = F(854-130, 45))
	img.drawtext("Re-click to rotate", fontsize = subtitlesize, fontname = titlefont, color = (100, 200, 100), midtop = F(854-130, 45))
	img.drawtext("Spacebucks: $%d\n " % state.state.bank, fontsize = F(24), fontname = "viga", color = (100, 0, 200), bottomright = F(840, 384))
	if isinstance(point, parts.Part) and not isinstance(point, parts.Conduit):
		info = settings.moduleinfo[point.name]
		img.drawtext(info, fontsize = F(32), fontname = "teko", midtop = F(854/2, 100), maxwidth = F(340))
		if point.name not in state.state.unlocked:
			info = "Cost to unlock: $%d" % settings.modulecosts[point.name]
			img.drawtext(info, fontsize = F(64), fontname = "teko", midtop = F(854/2, 340))
			
	if cursor is not None and mpos is not None:
		p = (mpos[0] - bx0) / bscale, (mpos[1] - by0) / bscale
		icon = cursor.nearest(p)
		bad = not state.state.canaddpart(icon)
		icon.draw((bx0, by0), bscale, bad = bad)
	dialog.draw()