Esempio n. 1
0
def think(dt, mpos, mdown, mup, *args):
	global pointed, tmessage, fade, fading
	mx, my = mpos
	for jlevel, (r, x, y) in level.layout.items():
		if jlevel not in progress.unlocked:
			continue
		x, y = F((x, y))
		if (x - mx) ** 2 + (y - my) ** 2 < F(r) ** 2:
			pointed = jlevel
			break
	else:
		pointed = None
	if pointed == "credits" and mdown:
		from . import creditscene
		scene.push(creditscene)
	elif pointed is not None and mdown:
		progress.setchosen(pointed)
		fading = False
	if fading:
		fade = math.clamp(fade + 1.5 * dt, 0, 1)
	else:
		fade = math.clamp(fade - 1.5 * dt, 0, 1)
		if fade == 0:
			scene.pop()
			scene.push(playscene)
			scene.push(cutscene.Start())
	if tmessage:
		if tmessage == 5:
			sound.playsfx("3up")
		tmessage = max(0, tmessage - dt)
Esempio n. 2
0
def drawwaves():
	from . import view
	drawn = set()
	for wave in wavespecs + donewaves:
		t, angle, etype, n = wave
		t = tlevel - t
		if t < -10:
			continue
		elif t < 0:
			text = "Wave\nincoming\nin:\n%d sec" % int(-t)
			alpha = math.clamp(t + 10, 0, 1)
		elif t < 10:
			text = "Wave\nincoming"
			alpha = math.clamp(10 - t, 0, 1)
		else:
			continue
		if angle in drawn:
			continue
		drawn.add(angle)
		fontsize = view.screenlength(20)
		x, y = outstep(angle, 20)
		x += 0.2 * (cell.x - x)
		y += 0.2 * (cell.y - y)
		ptext.draw(text, midtop = view.screenpos((x, y)), angle = -360 * angle,
			fontsize = fontsize, fontname = "Stint", lineheight = 0.85,
			color = "#FF4F4F", shadow = (0.5, 1), alpha = 0.4 * alpha)
Esempio n. 3
0
	def think(self, dt, mpos, mdown, *args):
		self.t += dt
		if self.fading:
			self.fade = math.clamp(self.fade + dt / self.tfade, 0, 1)
		else:
			self.fade = math.clamp(self.fade - dt / self.tfade, 0, 1)
		if self.fade <= self.fadeend and not self.fading:
			scene.pop()
		if mdown:
			self.fading = False
Esempio n. 4
0
def draw():
	window.screen.fill((0, 0, 0))
	background.draw(hradius = 6)

	a1 = math.clamp((t - 3.5) / 2, 0, 1)
	a2 = math.clamp((t - 10) / 2, 0, 1)
	ptext.draw(settings.gamename, fontsize = F(70), center = F(427, 140),
		owidth = 2, color = "#44FF77", gcolor = "#AAFFCC", alpha = a1, fontname = "Audiowide")
	ptext.draw("Thank you for playing", fontsize = F(26), midtop = F(427, 180),
		owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide")

	background.drawwash()
Esempio n. 5
0
def draw():
	window.screen.fill((0, 0, 0))
	background.draw()

	a1 = math.clamp((t - 4) / 2, 0, 1)
	a2 = math.clamp((t - 5.5) / 2, 0, 1)
	a3 = math.clamp((t - 6.5) / 2, 0, 1)
	a4 = math.clamp((t - 8) / 2, 0, 1)
	ptext.draw(settings.gamename, fontsize = F(70), center = F(427, 140),
		owidth = 2, color = "#44FF77", gcolor = "#AAFFCC", alpha = a1, fontname = "Audiowide")
#	ptext.draw("by Christopher Night", fontsize = F(26), midtop = F(427, 180),
#		owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide")

	background.drawwash()
Esempio n. 6
0
	def think(self, dt, mpos, mdown, *args):
		self.t += dt
		if self.fading:
			self.fade = math.clamp(self.fade + dt / self.tfade, 0, 1)
		else:
			self.fade = math.clamp(self.fade - dt / self.tfade, 0, 1)
		if self.fade <= self.fadeend and not self.fading:
			from . import menuscene
			menuscene.setmessage("Thank you for playing!")
			scene.pop()
			scene.push(menuscene)
		dialog.think(dt)
		if self.t > 1 and dialog.tquiet > 1:
			self.fading = False
Esempio n. 7
0
	def draw(self):
		parent = get(self.parentid)
		if not parent:
			return
		p = px, py = window.screenpos(parent.X, parent.y)
		color = tuple(int(a * (0.8 + 0.2 * math.sin(8 * self.t))) for a in (128, 255, 128))
		pygame.draw.circle(window.screen, color, p, F(5), 0)
		pygame.draw.circle(window.screen, color, p, F(10), F(1))
		pygame.draw.circle(window.screen, color, p, F(15), F(1))
		dx = F(90 * math.clamp(self.t * 0.6 - 0.2, 0, 1))
		pygame.draw.line(window.screen, color, p, (px + dx, py), F(1))
		ptext.draw("TELEPORT TO\nTHIS SHIP", fontsize = F(12), color = (128, 255, 128),
			owidth = 1, fontname = "Exo", midleft = (px + F(20), py),
			alpha = math.clamp(self.t - 1, 0, 1))
Esempio n. 8
0
	def draw(self):
		ds = [-0.02 * j for j in range(8, -1, -1)]
		ss = [2, 2, 2, 3.2, 3.2, 3.2, 4, 4, 4]
		for d, s in zip(ds, ss):
			f = math.clamp((self.flife + d) * 1.1, 0, 1)
			if not 0 < f < 1:
				continue
			fp = math.clamp(f * 1.3 - 0.3, 0, 1)
			f = (3 - 2 * f) * f ** 2
			fp = (3 - 2 * fp) * fp ** 2
			X = self.X + fp * (self.X1 - self.X)
			y = self.y + fp * (self.y1 - self.y)
			r = 10 * f * (1 - f)
			a = 25 * self.t + 45 * d + j * math.tau / 6
			image.worlddraw("slash-" + self.color, X + r/y * math.sin(a), y + r * math.cos(a), s, rotate = False)
Esempio n. 9
0
def drawtitle():
    a1 = math.clamp((t - 4) / 2, 0, 1)
    a2 = math.clamp((t - 5.5) / 2, 0, 1)
    a3 = math.clamp((t - 6.5) / 2, 0, 1)
    a4 = math.clamp((t - 8) / 2, 0, 1)
    ptext.draw(settings.gamename,
               fontsize=F(70),
               center=F(427, 140),
               owidth=2,
               color="#44FF77",
               gcolor="#AAFFCC",
               alpha=a1,
               fontname="Audiowide")
    ptext.draw("by Christopher Night",
               fontsize=F(26),
               midtop=F(427, 180),
               owidth=2,
               color="#7777FF",
               gcolor="#AAAAFF",
               alpha=a2,
               fontname="Audiowide")
    ptext.draw("MUSIC\nPRODUCTION\nTESTING\nARTWORK\nVOICE",
               fontsize=F(24),
               topright=F(427 - 10, 240),
               lineheight=1.24,
               owidth=2,
               color="#7777FF",
               gcolor="#AAAAFF",
               alpha=a2,
               fontname="Audiowide")
    ptext.draw(
        "Mary Bichner\nCharles McPillan\nLeo Stein\nMolly Zenobia\nRandy Parcel",
        fontsize=F(24),
        topleft=F(427 + 10, 240),
        lineheight=1.24,
        owidth=2,
        color="#7777FF",
        gcolor="#AAAAFF",
        alpha=a2,
        fontname="Audiowide")
    ptext.draw("Press space to begin",
               fontsize=F(24),
               midtop=F(427, 440),
               owidth=2,
               color="#777777",
               gcolor="#AAAAAA",
               alpha=a3,
               fontname="Audiowide")
Esempio n. 10
0
	def pdrawG(self):
		if self.pGlast == self.pG():
			return self.ptileG()
		f = math.clamp(self.movet / self.tmove, 0, 1)
		xG, yG, zG = math.mix(self.ptileGlast, self.ptileG(), f)
		zG += 0.8 * f * (1 - f)
		return xG, yG, zG
Esempio n. 11
0
def getbounce(objs, dt):
    ds = [[0, 0] for _ in objs]
    for i, j in getcollisions(objs):
        x0, y0, r0, m0 = objs[i]
        x1, y1, r1, m1 = objs[j]
        if (x0 - x1)**2 + (y0 - y1)**2 < (r0 + r1)**2:
            dx = x1 - x0
            dy = y1 - y0
            if dx == 0 and dy == 0:
                a = random.angle()
                dx = 1.0 * math.sin(a)
                dy = 1.0 * math.cos(a)
            d = math.sqrt(dx**2 + dy**2)
            f = math.clamp(20 * (r0 + r1 - d), 50, 200)
            dx *= dt / d * f
            dy *= dt / d * f
            da = math.sqrt(dx**2 + dy**2)
            if d + da > 1.001 * (r0 + r1):
                db = 1.001 * (r0 + r1) - d
                dx *= db / da
                dy *= db / da
            f0, f1 = (1, 0) if m1 > 100 * m0 else (
                0, 1) if m0 > 100 * m1 else (m1 / (m0 + m1), m0 / (m1 + m0))
            #			f0, f1 = (m1 / (m0 + m1), m0 / (m1 + m0))
            ds[i][0] -= dx * f0
            ds[i][1] -= dy * f0
            ds[j][0] += dx * f1
            ds[j][1] += dy * f1
    return ds
Esempio n. 12
0
def draw():
    if self.dscene is None:
        background.draw()
    else:
        self.dscene.draw()
    alpha = int(math.clamp(self.a * 255, 0, 255))
    pview.fill((255, 255, 255, alpha))
Esempio n. 13
0
def draw():
	if playing:
		filename, who, line = playing
		t = pygame.time.get_ticks() * 0.001
		h, angle, fstretch = 390, 0, 1
		if "bounce" in who:
			freq = float(who[7:])
			h = 400 - 20 * abs(math.sin(freq * math.tau * t))
		if "rock" in who:
			freq = float(who[5:])
			angle = 10 * math.sin(freq * math.tau * t)
		if "sink" in who:
			h += 20 * math.sqrt(tplaying)
		if "Z" in who:
			imgname = "zume"
			center = F(100, h)
			align = "right"
			fontname = "SansitaOne"
			color = 100, 255, 255
		else:
			imgname = "simon"
			center = F(854 - 100, h)
			align = "left"
			fontname = "PatrickHand"
			color = 255, 100, 255
		alpha = math.clamp(4 * tplaying, 0, 1)
		ptext.draw(line, midbottom = F(854 / 2, 470), width = F(500),
			color = color, shadow = (1, 1),
			fontsize = F(36), fontname = fontname, lineheight = 0.8)
		img.draw(imgname, center, radius = F(80), fstretch = fstretch, angle = angle, tocache = False)

	if currenttip:
		ptext.draw(currenttip, center = F(854 / 2, 160), width = F(500),
			color = (255, 255, 100), shadow = (1, 1), fontname = "PermanentMarker",
			fontsize = F(28))
Esempio n. 14
0
def falling(screenpos, scale, vy):
    vy = math.clamp(vy, -30, 30)
    x, y = screenpos
    dystretch = vy / 70
    drawfoot((x - 0.8 * scale, y + (-0.2 + dystretch) * scale), scale)
    drawfoot((x + 0.8 * scale, y + (0.2 + dystretch) * scale), scale)

    # back fist
    drawfoot((x + (1.5 * math.cos(dystretch)) * scale, y +
              (-2.5 + 3 * dystretch) * scale), scale)

    # dress
    x0, y0 = x - 0.3 * scale, y - 1 * scale
    path = [(-1.4, 0), (-0.2, -0.5), (2, -0.5), (1.5, 1), (1, 3), (0, 3.2),
            (-1, 1.5)]
    ps = [(i(x0 + scale * dx * (1 - 0.6 * dystretch)),
           i(y0 - scale * (dy / (1 - 0.3 * dystretch) - 1.3 * dystretch)))
          for dx, dy in path]
    pygame.draw.polygon(pview.screen, (0, 0, 0), ps, i(0.6 * scale))
    pygame.draw.polygon(pview.screen, (100, 100, 250), ps, 0)

    # front fist
    drawfoot((x - (1.5 * math.cos(dystretch)) * scale, y +
              (-2.5 + 3 * dystretch) * scale), scale)

    # Tilt head to look up during upward motion and down during downward motion.
    x0, y0 = x + 0.5 * scale, y - 5 * scale
    drawnoggin((x0, y0), scale, angle=0.2 + 0.5 * dystretch)

    if settings.DEBUG:
        pygame.draw.circle(pview.screen, (255, 0, 255), screenpos,
                           i(0.3 * scale))
Esempio n. 15
0
def getbounce(objs, dt):
	ds = [[0, 0] for _ in objs]
	for i, j in getcollisions(objs):
		x0, y0, r0, m0 = objs[i]
		x1, y1, r1, m1 = objs[j]
		if (x0 - x1) ** 2 + (y0 - y1) ** 2 < (r0 + r1) ** 2:
			dx = x1 - x0
			dy = y1 - y0
			if dx == 0 and dy == 0:
				a = random.angle()
				dx = 1.0 * math.sin(a)
				dy = 1.0 * math.cos(a)
			d = math.sqrt(dx ** 2 + dy ** 2)
			f = math.clamp(20 * (r0 + r1 - d), 50, 200)
			dx *= dt / d * f
			dy *= dt / d * f
			da = math.sqrt(dx ** 2 + dy ** 2)
			if d + da > 1.001 * (r0 + r1):
				db = 1.001 * (r0 + r1) - d
				dx *= db / da
				dy *= db / da
			f0, f1 = (1, 0) if m1 > 100 * m0 else (0, 1) if m0 > 100 * m1 else (m1 / (m0 + m1), m0 / (m1 + m0))
#			f0, f1 = (m1 / (m0 + m1), m0 / (m1 + m0))
			ds[i][0] -= dx * f0
			ds[i][1] -= dy * f0
			ds[j][0] += dx * f1
			ds[j][1] += dy * f1
	return ds
Esempio n. 16
0
def think(dt, mpos, mdown, *args):
    global t, fading, fade
    t += dt
    if mdown or t > 17.5:
        fading = False
    fade = math.clamp(fade + 2 * dt * (1 if fading else -1), 0, 1)
    if not fading and fade == 0:
        scene.pop()
Esempio n. 17
0
def think(dt, mpos, mdown, *args):
	global t, fading, fade
	t += dt
	if mdown or t > 17.5:
		fading = False
	fade = math.clamp(fade + 2 * dt * (1 if fading else -1), 0, 1)
	if not fading and fade == 0:
		scene.pop()
Esempio n. 18
0
def drawtitle():
	a1 = math.clamp((t - 4) / 2, 0, 1)
	a2 = math.clamp((t - 5.5) / 2, 0, 1)
	a3 = math.clamp((t - 6.5) / 2, 0, 1)
	a4 = math.clamp((t - 8) / 2, 0, 1)
	ptext.draw(settings.gamename, fontsize = F(70), center = F(427, 140),
		owidth = 2, color = "#44FF77", gcolor = "#AAFFCC", alpha = a1, fontname = "Audiowide")
	ptext.draw("by Christopher Night", fontsize = F(26), midtop = F(427, 180),
		owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide")
	ptext.draw("MUSIC\nPRODUCTION\nTESTING\nARTWORK\nVOICE",
		fontsize = F(24), topright = F(427 - 10, 240), lineheight = 1.24,
		owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide")
	ptext.draw("Mary Bichner\nCharles McPillan\nLeo Stein\nMolly Zenobia\nRandy Parcel",
		fontsize = F(24), topleft = F(427 + 10, 240), lineheight = 1.24,
		owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide")
	ptext.draw("Press space to begin",
		fontsize = F(24), midtop = F(427, 440),
		owidth = 2, color = "#777777", gcolor = "#AAAAAA", alpha = a3, fontname = "Audiowide")
Esempio n. 19
0
	def think(self, dt):
		from . import recipe
		self.targetcolor = recipe.getcolor(self)
		if self.disabled:
			tr, tg, tb = self.targetcolor
			self.targetcolor = tr // 3, tg // 3, tb // 3
		if self.targetcolor is not None and self.color != self.targetcolor:
			d = int(max(100 * dt, 1))
			self.color = tuple(math.clamp(y, x - d, x + d) for x, y in zip(self.color, self.targetcolor))
Esempio n. 20
0
def drawscene():
    window.screen.fill((20, 0, 0))
    R, X0, y0 = window.camera.R, window.camera.X0, window.camera.y0
    window.camera.R = window.sy / 54 * math.clamp(3 * (tplay - 4), 0.3, 2)
    window.camera.y0 = random.uniform(-1, 1)
    window.camera.X0 = tplay * 0.1
    background.draw(factor=8)
    window.camera.R, window.camera.X0, window.camera.y0 = R, X0, y0
    background.drawwash()
Esempio n. 21
0
	def think(self, dt, *args):
		self.t += dt
		if self.fading:
			self.fade = math.clamp(self.fade + dt / self.tfade, 0, 1)
			self.tview += dt
			if self.tview >= self.lifetime:
				self.fading = False
		else:
			self.fade = math.clamp(self.fade - dt / self.tfade, 0, 1)
		if self.fade <= self.fadeend and not self.fading:
			state.removesave()
			if self.tomenu:
				from . import menuscene
				scene.pop()
				scene.pop()
				scene.push(menuscene)
			else:
				scene.pop()
Esempio n. 22
0
def drawscene():
	window.screen.fill((20, 0, 0))
	R, X0, y0 = window.camera.R, window.camera.X0, window.camera.y0
	window.camera.R = window.sy / 54 * math.clamp(3 * (tplay - 4), 0.3, 2)
	window.camera.y0 = random.uniform(-1, 1)
	window.camera.X0 = tplay * 0.1
	background.draw(factor = 8)
	window.camera.R, window.camera.X0, window.camera.y0 = R, X0, y0
	background.drawwash()
Esempio n. 23
0
	def draw(self):
		target = get(self.targetid)
		if not target:
			return
		for d, s in [(-0.1, 3), (-0.05, 6), (0, 8), (0.05, 6), (0.1, 3)]:
			f = math.clamp(self.flife + d, 0, 1)
			X = self.X + f * (target.X - self.X)
			y = self.y + f * (target.y - self.y)
			pygame.draw.circle(window.screen, (255, 128, 255), window.screenpos(X, y), F(s), 0)
Esempio n. 24
0
def getscene():
    nscene = len(skycolors)
    scenelength = 40
    dlength = 4
    score = currentscore()
    jscene = int(score / scenelength) % nscene
    lastscene = (jscene - 1) % nscene if score > scenelength else 0
    f = math.clamp(score % scenelength / dlength, 0, 1)
    return lastscene, jscene, f
Esempio n. 25
0
def draw():
    startprofile("draw")
    pview.fill((100, 100, 255))
    #	objs = list(state.boards.values()) + list(state.blocks) + list(state.effects) + list(state.hazards)
    objs = list(state.hills) + list(state.effects) + list(state.hazards)
    objs.sort(key=lambda obj: (obj.z, -obj.y))
    for obj in objs:
        obj.draw()
    state.you.draw()
    if self.t < 1:
        a = math.clamp(int(255 * (1 - math.smoothfade(self.t, 0, 1))), 0, 255)
        pview.fill((255, 255, 255, a))
    if self.tlose > 0:
        a = math.clamp(int(255 * math.smoothfade(self.tlose, 0, 0.5)), 0, 255)
        pview.fill((255, 255, 255, a))
    stopprofile("draw")
    if self.printprofile:
        print(" ".join("%s=%d" % item
                       for item in sorted(self.profile.items())))
Esempio n. 26
0
 def draw(self):
     ds = [-0.02 * j for j in range(8, -1, -1)]
     ss = [2, 2, 2, 3.2, 3.2, 3.2, 4, 4, 4]
     for j, (d, s) in enumerate(zip(ds, ss)):
         f = math.clamp((self.flife + d) * 1.1, 0, 1)
         if not 0 < f < 1:
             continue
         fp = math.clamp(f * 1.3 - 0.3, 0, 1)
         f = (3 - 2 * f) * f**2
         fp = (3 - 2 * fp) * fp**2
         X = self.X + fp * (self.X1 - self.X)
         y = self.y + fp * (self.y1 - self.y)
         r = 10 * f * (1 - f)
         a = 25 * self.t + 45 * d + j * math.tau / 6
         image.worlddraw("slash-" + self.color,
                         X + r / y * math.sin(a),
                         y + r * math.cos(a),
                         s,
                         rotate=False)
Esempio n. 27
0
	def rangle(self):
		if self.draining:
			return math.clamp(40 * self.tdrain + 100 * self.drainsink, 0, 70)
		vz = (self.v + self.vwater).z
		if self.landed:
			p = 1 * self.pos
			dp = p + self.v + self.vwater
			p.z = 0
			dp.z = 0
			vz += self.section.dzwater(dp) - self.section.dzwater(p)
		return math.degrees(math.atan(vz / 20))
Esempio n. 28
0
 def dof(j0, j1, jc=None):
     x0, y0 = ps[j0]
     x1, y1 = ps[j1]
     f = 1
     if jc is not None:
         xc, yc = ps[jc]
         a = math.clamp(
             math.dot(math.norm((xc - x0, yc - y0)),
                      math.norm((x1 - xc, y1 - yc))), -0.999, 0.999)
         f = 1 / math.cos(math.acos(a) / 2)
     return math.norm((x1 - x0, y1 - y0), w * f)
Esempio n. 29
0
def draw():
    window.screen.fill((0, 0, 0))
    background.draw()

    a1 = math.clamp((t - 4) / 2, 0, 1)
    a2 = math.clamp((t - 5.5) / 2, 0, 1)
    a3 = math.clamp((t - 6.5) / 2, 0, 1)
    a4 = math.clamp((t - 8) / 2, 0, 1)
    ptext.draw(settings.gamename,
               fontsize=F(70),
               center=F(427, 140),
               owidth=2,
               color="#44FF77",
               gcolor="#AAFFCC",
               alpha=a1,
               fontname="Audiowide")
    #	ptext.draw("by Christopher Night", fontsize = F(26), midtop = F(427, 180),
    #		owidth = 2, color = "#7777FF", gcolor = "#AAAAFF", alpha = a2, fontname = "Audiowide")

    background.drawwash()
Esempio n. 30
0
 def think(self, dt):
     from . import recipe
     self.targetcolor = recipe.getcolor(self)
     if self.disabled:
         tr, tg, tb = self.targetcolor
         self.targetcolor = tr // 3, tg // 3, tb // 3
     if self.targetcolor is not None and self.color != self.targetcolor:
         d = int(max(100 * dt, 1))
         self.color = tuple(
             math.clamp(y, x - d, x + d)
             for x, y in zip(self.color, self.targetcolor))
Esempio n. 31
0
 def draw(self):
     parent = get(self.parentid)
     if not parent:
         return
     p = px, py = window.screenpos(parent.X, parent.y)
     color = tuple(
         int(a * (0.8 + 0.2 * math.sin(8 * self.t)))
         for a in (128, 255, 128))
     pygame.draw.circle(window.screen, color, p, F(5), 0)
     pygame.draw.circle(window.screen, color, p, F(10), F(1))
     pygame.draw.circle(window.screen, color, p, F(15), F(1))
     dx = F(90 * math.clamp(self.t * 0.6 - 0.2, 0, 1))
     pygame.draw.line(window.screen, color, p, (px + dx, py), F(1))
     ptext.draw("TELEPORT TO\nTHIS SHIP",
                fontsize=F(12),
                color=(128, 255, 128),
                owidth=1,
                fontname="Exo",
                midleft=(px + F(20), py),
                alpha=math.clamp(self.t - 1, 0, 1))
Esempio n. 32
0
def draw():
    s0, s1, fs = getscene()
    skycolor = colormix(skycolors[s0], skycolors[s1], fs)

    pview.fill(skycolor)
    objs = list(state.hills) + list(state.effects) + list(state.hazards)
    objs.sort(key=lambda obj: (obj.z, -obj.y))
    for obj in objs:
        obj.draw()
    state.you.draw()
    if self.t < 1:
        a = math.clamp(int(255 * (1 - math.smoothfade(self.t, 0, 1))), 0, 255)
        pview.fill((255, 255, 255, a))
    if self.tlose > 0:
        a = math.clamp(int(255 * math.smoothfade(self.tlose, 0, 0.5)), 0, 255)
        pview.fill((255, 255, 255, a))
    ptext.draw("Distance: %d m" % currentscore(),
               topright=T(1000, 24),
               fontsize=T(30),
               color="black",
               fontname="Acme")
Esempio n. 33
0
 def draw(self):
     target = get(self.targetid)
     if not target:
         return
     ds = [-0.02 * j for j in range(8, -1, -1)]
     ss = [2, 2, 2, 3.2, 3.2, 3.2, 4, 4, 4]
     for d, s in zip(ds, ss):
         f = math.clamp((self.flife + d) * 1.1, 0, 1)
         if not 0 < f < 1:
             continue
         fp = math.clamp(f * 1.3 - 0.3, 0, 1)
         f = (3 - 2 * f) * f**2
         fp = (3 - 2 * fp) * fp**2
         X = self.X + fp * (target.X - self.X)
         y = self.y + fp * (target.y - self.y)
         r = 10 * f * (1 - f)
         a = 25 * self.t + 45 * d + j * math.tau / 6
         image.worlddraw("slash-white",
                         X + r / y * math.sin(a),
                         y + r * math.cos(a),
                         s,
                         rotate=False)
Esempio n. 34
0
def draw():
    if playing:
        filename, who, line = playing
        t = pygame.time.get_ticks() * 0.001
        h, angle, fstretch = 390, 0, 1
        if "bounce" in who:
            freq = float(who[7:])
            h = 400 - 20 * abs(math.sin(freq * math.tau * t))
        if "rock" in who:
            freq = float(who[5:])
            angle = 10 * math.sin(freq * math.tau * t)
        if "sink" in who:
            h += 20 * math.sqrt(tplaying)
        if "Z" in who:
            imgname = "zume"
            center = F(100, h)
            align = "right"
            fontname = "SansitaOne"
            color = 100, 255, 255
        else:
            imgname = "simon"
            center = F(854 - 100, h)
            align = "left"
            fontname = "PatrickHand"
            color = 255, 100, 255
        alpha = math.clamp(4 * tplaying, 0, 1)
        ptext.draw(line,
                   midbottom=F(854 / 2, 470),
                   width=F(500),
                   color=color,
                   shadow=(1, 1),
                   fontsize=F(36),
                   fontname=fontname,
                   lineheight=0.8)
        img.draw(imgname,
                 center,
                 radius=F(80),
                 fstretch=fstretch,
                 angle=angle,
                 tocache=False)

    if currenttip:
        ptext.draw(currenttip,
                   center=F(854 / 2, 160),
                   width=F(500),
                   color=(255, 255, 100),
                   shadow=(1, 1),
                   fontname="PermanentMarker",
                   fontsize=F(28))
Esempio n. 35
0
    def slerp(self, other, t):
        angle = self.dot(other)
        quat1 = self

        if angle < 0.0:
            quat1 = self.scale(-1.0)
            angle = -angle

        if 1.0 - angle > 0.001:
            return self.lerp(other, t)

        angle = math.clamp(angle, -1.0, 1.0)
        theta = math.acos(angle) * t
        co_quat = (other - self.scale(angle))

        return self.scale(math.cos(theta)) + co_quat.scale(math.sin(theta))
Esempio n. 36
0
	def draw(self):
		target = get(self.targetid)
		if not target:
			return
		ds = [-0.02 * j for j in range(8, -1, -1)]
		ss = [2, 2, 2, 3.2, 3.2, 3.2, 4, 4, 4]
		for d, s in zip(ds, ss):
			f = math.clamp((self.flife + d) * 1.2 - 0.1, 0, 1)
			if not 0 < f < 1:
				continue
			f = (3 - 2 * f) * f ** 2
			X = self.X + f * (target.X - self.X)
			y = self.y + f * (target.y - self.y)
			r = 10 * f * (1 - f)
			a = -25 * self.t + 45 * d + j * math.tau / 6
			image.worlddraw("slash-white", X + r/y * math.sin(a), y + r * math.cos(a), s, rotate = False)
Esempio n. 37
0
def think(dt, kdowns, kpressed):
    global youftarget, boards, blocks, hills, effects
    kright = (1 if settings.ispressed(kpressed, "right") else
              0) - (1 if settings.ispressed(kpressed, "left") else 0)
    if kright:
        dftarget = 2 * dt * kright
        youftarget = math.clamp(youftarget + dftarget, -1, 1)
    else:
        youftarget = math.softapproach(youftarget, 0, 4 * dt)
    view.X0 += settings.speed * dt
    you.think(dt)
    for hazard in hazards:
        hazard.think(dt)
    removegone()
    for hazard in hazards:
        if hazard.hitsyou():
            you.gethit()
Esempio n. 38
0
def draw():
    background.draw()
    for jspot, rFspotspec in enumerate(self.rFspotspecs):
        if jspot == self.jload:
            continue
        Fspot = rFspot(*rFspotspec)
        omega = 100 * (math.phi * jspot % 1 - 0.5)
        theta = omega * pygame.time.get_ticks() * 0.001
        self.designs[jspot % len(self.designs)].draw(Fspot, theta)
    if self.jload is None:
        for jbutton, button in enumerate(self.buttons):
            button.draw(lit=(jbutton == self.jbutton))
    if self.jload is not None:
        alpha = math.clamp(200 * self.a, 0, 200)
        pview.fill((0, 0, 60, alpha))
        self.designs[self.jload % len(self.designs)].draw(self.Fload)
        spec = self.specs[self.jload % len(self.designs)]
        if spec["designname"]:
            ptext.draw(spec["designname"],
                       midbottom=T(940, 300),
                       width=T(380),
                       color="#aabbff",
                       shade=1,
                       fontsize=T(80),
                       fontname="ChelaOne",
                       shadow=(1, 1),
                       alpha=self.a)
        if spec["makername"]:
            ptext.draw("by",
                       center=T(940, 360),
                       color="#ffffaa",
                       shade=1,
                       fontsize=T(54),
                       fontname="ChelaOne",
                       shadow=(1, 1),
                       alpha=self.a)
            ptext.draw(spec["makername"],
                       midtop=T(940, 420),
                       width=T(380),
                       color="#aabbff",
                       shade=1,
                       fontsize=T(80),
                       fontname="ChelaOne",
                       shadow=(1, 1),
                       alpha=self.a)
Esempio n. 39
0
def think(dt):
	from . import dialog, state, scene, menuscene, playscene
	channel = pygame.mixer.Channel(0)
	if music and not channel.get_queue():
		channel.queue(music)
	if channel.get_busy():
		volume = 0.8
		if dialog.tquiet < 0.5:
			volume = 0.3 + dialog.tquiet
		if scene.top() is playscene:
			if state.twin or state.tlose:
				f = math.clamp(1 - 0.5 * max(state.twin, state.tlose), 0, 1)
				volume *= f
		elif scene.top() is menuscene:
			volume *= menuscene.fade
		channel.set_volume(volume)
	for sname, sfactor in sfxsuppression.items():
		sfxsuppression[sname] *= math.exp(-2 * dt)
Esempio n. 40
0
 def makesurf(self):
     self.w = pview.w
     scale = 20 * view.scale(self.z)
     w0, h0 = int(pview.w / scale) + 5, int(pview.h / scale) + 5
     surf = pygame.Surface((w0, h0)).convert_alpha()
     surf.fill((200, 200, 255, 0))
     arr = pygame.surfarray.pixels_alpha(surf)
     y0 = h0 / 2 + 5 * pview.f
     for y in range(h0):
         a0 = 100 + 600 * (y - y0) / h0
         for x in range(w0):
             arr[x, y] = math.clamp(a0 + random.randint(-20, 20), 0, 200)
     del arr
     surf = pygame.transform.smoothscale(surf,
                                         (int(w0 * scale), int(h0 * scale)))
     self.surf = pygame.Surface(pview.size).convert_alpha()
     self.surf.fill((0, 0, 0, 0))
     self.surf.blit(surf, surf.get_rect(center=self.surf.get_rect().center))
Esempio n. 41
0
def think(dt):
    from . import dialog, state, scene, menuscene, playscene
    channel = pygame.mixer.Channel(0)
    if music and not channel.get_queue():
        channel.queue(music)
    if channel.get_busy():
        volume = 0.8
        if dialog.tquiet < 0.5:
            volume = 0.3 + dialog.tquiet
        if scene.top() is playscene:
            if state.twin or state.tlose:
                f = math.clamp(1 - 0.5 * max(state.twin, state.tlose), 0, 1)
                volume *= f
        elif scene.top() is menuscene:
            volume *= menuscene.fade
        channel.set_volume(volume)
    for sname, sfactor in sfxsuppression.items():
        sfxsuppression[sname] *= math.exp(-2 * dt)
Esempio n. 42
0
def draw():
	t = pygame.time.get_ticks() * 0.001
	vZ = math.sqrt(view.Z)
	nmote = min(int(math.ceil(len(motes) / vZ ** 2)), len(motes))
	nmote = math.clamp(int(nmote * settings.background), 0, nmote)
	for x, y, vx, vy, z, r in motes[:nmote]:
		x += vx * t - view.x0
		y += vy * t - view.y0
		x *= z
		y *= z
		px, py = F([
			854 / 2 + vZ * (z * (x + vx * t + 2 * view.x0)),
			480 / 2 - vZ * (z * (y + vy * t + 2 * view.y0)),
		])
		r = F(vZ * r)
		px = (px + 2 * r) % (view.sx + 4 * r) - 2 * r
		py = (py + 2 * r) % (view.sy + 4 * r) - 2 * r
		img = blob.mote(r, 0.01)
		view.screen.blit(img, (px, py), None, pygame.BLEND_SUB)
Esempio n. 43
0
def draw():
    t = pygame.time.get_ticks() * 0.001
    vZ = math.sqrt(view.Z)
    nmote = min(int(math.ceil(len(motes) / vZ**2)), len(motes))
    nmote = math.clamp(int(nmote * settings.background), 0, nmote)
    for x, y, vx, vy, z, r in motes[:nmote]:
        x += vx * t - view.x0
        y += vy * t - view.y0
        x *= z
        y *= z
        px, py = F([
            854 / 2 + vZ * (z * (x + vx * t + 2 * view.x0)),
            480 / 2 - vZ * (z * (y + vy * t + 2 * view.y0)),
        ])
        r = F(vZ * r)
        px = (px + 2 * r) % (view.sx + 4 * r) - 2 * r
        py = (py + 2 * r) % (view.sy + 4 * r) - 2 * r
        img = blob.mote(r, 0.01)
        view.screen.blit(img, (px, py), None, pygame.BLEND_SUB)
Esempio n. 44
0
def think(dt):
	global epictarget
	if musicmode == "game":
		if epictarget == 0 and epicness > 0.75:
			epictarget = 1
		elif epictarget == 1 and epicness < 0.25:
			epictarget = 0
		elif epictarget == 1 and epicness > 1.75:
			epictarget = 2
		elif epictarget == 2 and epicness < 1.25:
			epictarget = 1
	musicvolume = settings.musicvolume[0] if lineplaying() else settings.musicvolume[1]

	dvmax = dt / settings.musiccrossfadetime
	for j in (0, 1, 2):
		goalvolume = musicvolume if j == epictarget else 0
		if channel_volumes[j] != goalvolume:
			dv = math.clamp(goalvolume - channel_volumes[j], -dvmax, dvmax)
			channel_volumes[j] += dv
			channels[j].set_volume(channel_volumes[j])
Esempio n. 45
0
	def setstate(self, lifetime = 1, preserved = False, **kw):
		self.lifetime = lifetime
		self.flife = math.clamp(self.t / self.lifetime, 0, 1)
		self.preserved = preserved
Esempio n. 46
0
	def think(self, dt):
		if not self.alive:
			return
		self.flife = math.clamp(self.t / self.lifetime, 0, 1)
		if self.t > self.lifetime and not self.preserved:
			self.die()
Esempio n. 47
0
def zoom(dz):
	global z, Z
	z = math.clamp(z + 0.25 * dz, -1, 3)
	Z = math.exp(0.5 * round(z))
	constrain()
Esempio n. 48
0
	def think(self, dt):
		if self.t > self.lifetime:
			self.alive = False
		self.flife = math.clamp(self.t / self.lifetime, 0, 1)
Esempio n. 49
0
	def draw(self):
		for d, s in [(-0.1, 3), (-0.05, 6), (0, 8), (0.05, 6), (0.1, 3)]:
			f = math.clamp(self.flife + d, 0, 1)
			X = self.X + f * (self.X1 - self.X)
			y = self.y + f * (self.y1 - self.y)
			pygame.draw.circle(window.screen, (255, 128, 255), window.screenpos(X, y), F(s), 0)
Esempio n. 50
0
def think(dt, events, kpressed):
	global todraw
	kx = kpressed["right"] - kpressed["left"]
	ky = kpressed["up"] - kpressed["down"]

	dt0 = dt
	if kpressed["go"] and control:
		dt *= 0.3

	hud.think(dt0)
	quest.think(dt)
	dialog.think(dt0)
	background.think(dt)
	sound.epicness = 2 - (state.you.y - 100) / 160
	sound.think(dt)

	oldX, oldy = state.you.X, state.you.y

	if 1e10 * random.random() < dt:
		state.ships.append(thing.Skiff(
			X = random.uniform(0, math.tau),
			y = state.R,
			vx = random.uniform(-6, 6)
		))
		state.ships.append(thing.Beacon(
			X = random.uniform(0, math.tau),
			y = state.R,
			vx = random.uniform(-6, 6)
		))
	nbubble = int(dt * 30) + (random.random() < dt * 30 % 1)
	for _ in range(nbubble):
		X = random.gauss(state.you.X, 30 / state.you.y)
		y = random.gauss(state.you.y, 30)
		if y < state.R - 10:
			state.effects.append(thing.Bubble(X = X, y = y))

	if sum(isinstance(effect, thing.BubbleChain) for effect in state.effects) < 10:
		for c in state.convergences:
			N = math.clamp((100 / window.distance(state.you, c)) ** 2, 0.05, 1)
			nbubble = int(dt * N) + (random.random() < dt * N % 1)
			for _ in range(nbubble):
				X = random.gauss(state.you.X, 30 / state.you.y)
				y = random.gauss(state.you.y, 30)
				if state.Rcore < y < state.R - 20:
					state.effects.append(thing.BubbleChain(X = X, y = y, X0 = c.X, y0 = c.y))


	for event in events:
		if event.type == KEYDOWN and event.key == "go":
			control.clear()
			control["cursor"] = state.you
			control["queue"] = {}
			control["qtarget"] = [state.you.X, state.you.y]
			control["t0"] = 0.001 * pygame.time.get_ticks()
		if event.type == KEYDOWN and event.key == "abort":
			if not state.you.significant:
				state.you.die()
			regenerate()
		if event.type == KEYUP:
			if not state.quickteleport and "queue" in control and event.key in ("up", "left", "right", "down"):
				control["queue"][event.key] = 0
		if event.type == KEYUP and event.key == "go" and "cursor" in control:
			if control["cursor"] is not state.you:
				state.effects.append(
					thing.Teleport(X = state.you.X, y = state.you.y, targetid = control["cursor"].thingid)
				)
				sound.play("teleport")
				state.you = control["cursor"]
			elif 0.001 * pygame.time.get_ticks() - control["t0"] < settings.tactivate:
				state.you.deploy()
			control.clear()
		
	if kpressed["go"] and control:
		if any(kpressed[x] for x in ("left", "right", "up", "down")):
			control["t0"] = -1000
		if state.quickteleport:
			control["qtarget"][0] += kx * dt0 * settings.vqteleport / control["qtarget"][1]
			control["qtarget"][1] += ky * dt0 * settings.vqteleport
			dx = math.Xmod(control["qtarget"][0] - state.you.X) * state.you.y
			dy = control["qtarget"][1] - state.you.y
			f = math.sqrt(dx ** 2 + dy ** 2) / settings.rqteleport
			if f > 1:
				dx /= f
				dy /= f
				control["qtarget"] = [state.you.X + dx / state.you.y, state.you.y + dy]
			retarget()
		else:
			q = control["queue"]
			for key in q:
				q[key] += dt0
				if q[key] >= settings.jumpcombotime:
					dx = ("right" in q) - ("left" in q)
					dy = ("up" in q) - ("down" in q)
					jump(dx, dy)
					q.clear()
					break
	else:
		dvx = kx * dt * 20
		dvy = ky * dt * 20
		state.you.vx += dvx
		state.you.vy = min(state.you.vy + dvy, 0)

	todraw = []
	scollide = []
	hcollide = []

	state.you.think(0)  # Clear out any controls that should be overridden

	for convergence in state.convergences:
		if window.camera.near(convergence):
			convergence.think(dt)
			todraw.append(convergence)


	repopulating = (dt + state.you.t % 1) // 1
	if repopulating:
		nships = []
		for ship in state.ships:
			if not window.camera.on(ship) and ship is not state.you and not ship.significant:
				continue
			ship.think(dt)
			if ship.alive:
				nships.append(ship)
				todraw.append(ship)
			else:
				ship.die()
		state.ships = nships
		repopulateslice()
	else:
		nships = []
		for ship in state.ships:
			if not window.camera.near(ship):
				nships.append(ship)
				continue
			ship.think(dt)
			if ship.alive:
				nships.append(ship)
				if window.camera.on(ship):
					todraw.append(ship)
			else:
				ship.die()
		state.ships = nships
	if not state.you.alive:
		regenerate()
	nobjs = []
	for obj in state.objs:
		if not window.camera.on(obj):
			nobjs.append(obj)
			continue
		obj.think(dt)
		if obj.alive:
			nobjs.append(obj)
			todraw.append(obj)
		else:
			obj.die()
	state.obj = nobjs
	for hazard in state.hazards:
		if not window.camera.near(hazard):
			continue
		hazard.think(dt)
		todraw.append(hazard)
		if window.camera.on(hazard):
			hcollide.append(hazard)
	state.obj = nobjs
#	for filament in state.filaments:
#		filament.think(dt)

	neffects = []
	for effect in state.effects:
		effect.think(dt)
		if effect.alive:
			todraw.append(effect)
			neffects.append(effect)
		else:
			effect.die()
	state.effects = neffects

	scollide = [state.you]
	for s in scollide:
		if not s.vulnerable():
			continue
		for h in hcollide:
			if window.distance(h, s) < h.hazardsize:
				s.takedamage(h.dhp)

	if window.dbycoord((oldX, oldy), (state.you.X, state.you.y)) > settings.rqteleport + 10:
		clearfull()
		populatefull()

	if state.quickteleport and "qtarget" in control:
		X, y = control["qtarget"]
		dX = math.Xmod(X - state.you.X)
		dy = y - state.you.y
		window.camera.X0 = state.you.X + dX * 0.5
		window.camera.y0 = state.you.y + dy * 0.5
		window.camera.setlimits()
	else:
		window.camera.follow(state.you)
		window.camera.think(dt)
Esempio n. 51
0
	def think(self, dt):
		self.vy = math.clamp(self.vy, -self.vymax, self.vymax)
Esempio n. 52
0
	def think(self, dt):
		self.vx = math.clamp(self.vx, -self.vxmax, self.vxmax)
Esempio n. 53
0
	def think(self, dt):
		if self is not state.you:
			self.driftax += dt * random.uniform(-0.3, 0.3)
			self.driftax = math.clamp(self.driftax, -0.5, 0.5)
			self.vx += dt * self.driftax