Exemple #1
0
	def in_game_screen(self):

		# drunkenness
		self.worm_dir += math.sin(self.ticks * 0.2 ) * 0.004 * self.score

		self.worm_dir += (engine.keystate(K_RIGHT) - engine.keystate(K_LEFT)) * 0.1
		dx = math.sin(self.worm_dir) * self.speed
		dy = math.cos(self.worm_dir) * self.speed
		self.worm_x += dx
		self.worm_y += dy
		self.segments = [(self.worm_x, self.worm_y)] + self.segments[:self.length]

		# collision
		collision = False
		if abs(self.worm_x) > 384 or abs(self.worm_y) > 284:
			collision = True

		for x, y in self.segments[25:]:
			dx = x - self.worm_x
			dy = y - self.worm_y
			if dx * dx + dy * dy < 780:
				collision = True
				break

		if collision:
			print "Ouch!"
			self.bam_sound.play()
			self.state = 2

		dx = self.bottle_x - self.worm_x
		dy = self.bottle_y - self.worm_y
		if dx * dx + dy * dy < 1200:
			self.collect_sound.play()
			self.score += 1
			self.speed += 0.05
			self.length += 20
			self.set_bottle()


		glColor(1, 1, 1)
		self.bottle_sprite.draw(self.bottle_x, self.bottle_y, math.sin(self.ticks * 0.1) * 10, 1)

		glColor(0, 0.7, 0)
		for x, y in self.segments[4:]: self.segment_sprite.draw(x, y)

		self.head_sprite.draw(self.worm_x, self.worm_y, self.worm_dir * -180 / math.pi, 0.6, (self.ticks/15) % 2)

		glColor(1, 1, 1, 0.5)
		font.put(-380, -280, "bottles: %2d" % self.score)
Exemple #2
0
	def render(self):
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)

		glMatrixMode(GL_PROJECTION)
		glLoadIdentity()
		gluPerspective(45, self.ratio, 0.1, 1000)

		glMatrixMode(GL_MODELVIEW)
		glLoadIdentity()

		glRotate(self.ang_x * (180 / math.pi), 1, 0, 0)
		glRotate(self.ang_y * (180 / math.pi), 0, 1, 0)
		glTranslate(-self.pos.x, -self.pos.y, -self.pos.z)

		glColor(1, 1, 1)
		font.put(5, 5, "FPS: %3.2f" % self.fps)
Exemple #3
0
	def render_sub(self):
		glColor(1, 0, 1)
		self.obj.render()

		if self.silhouette:
			glDisable(GL_LIGHTING)
			glLineWidth(5)
			glColor(0, 0, 0)
			self.obj.render_silhouette_raw(get_eye().pos)
			glEnable(GL_LIGHTING)

		glColor(1, 1, 1)
		font.put(5, 100, "surface: %s" % self.surface)
		font.put(5, 110, "volume:  %s" % self.volume)
		font.put(5, 120, "sigma:   %.2f" % self.sigma)
		font.put(5, 130, "alpha:   %.2f" % self.alpha)
Exemple #4
0
	def render_sub(self):


		mat = self.get_projector_mat()

		glPushAttrib(GL_ALL_ATTRIB_BITS)
		glBindTexture(GL_TEXTURE_2D, self.tex)
		glEnable(GL_TEXTURE_2D)
		glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR)
		glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR)
		glTexGenfv(GL_S, GL_OBJECT_PLANE, mat[0])
		glTexGenfv(GL_T, GL_OBJECT_PLANE, mat[1])

		glEnable(GL_TEXTURE_GEN_S)
		glEnable(GL_TEXTURE_GEN_T)

		glColor(0.5, 0.5, 1)
		glCallList(self.orb)

		glPopAttrib(GL_ALL_ATTRIB_BITS)

		glColor(1, 0, 0)
		glPushMatrix()
		glTranslate(*self.eye)
		glCallList(self.dot)
		glPopMatrix()
		glPushMatrix()
		glTranslate(*self.target)
		glCallList(self.dot)
		glPopMatrix()

		glLineWidth(3)
		glDisable(GL_LIGHTING)
		glBegin(GL_LINES)
		glVertex(self.eye)
		glVertex(self.target)
		glEnd()
		glEnable(GL_LIGHTING)

		glColor(1, 1, 1)
		font.put(5, 100, "eye: %s" % self.eye)
		font.put(5, 110, "target: %s" % self.target)
		font.put(5, 120, "up: %s" % self.up)
Exemple #5
0
	def render_sub(self):

		glPushMatrix()
		p = self.p
		if self.inverse: p = -p
		glMultMatrixf([
			1, 0, 0, p.x,
			0, 1, 0, p.y,
			0, 0, 1, p.z,
			0, 0, 0, 1
		])

		glColor(1, 1, 0)
		glCallList(self.cubes[self.bfc])
		glPopMatrix()

		if p.x:
			glColor(1, 0, 0)
			glPushMatrix()
			glTranslate(1/p.x, 0, 0)
			glCallList(self.orb)
			glPopMatrix()

		if p.y:
			glColor(0, 1, 0)
			glPushMatrix()
			glTranslate(0, 1/p.y, 0)
			glCallList(self.orb)
			glPopMatrix()

		if p.z:
			glColor(0, 0, 1)
			glPushMatrix()
			glTranslate(0, 0, 1/p.z)
			glCallList(self.orb)
			glPopMatrix()

		glColor(1, 1, 1)
		font.put(5, 100, str(self.p))
		font.put(5, 110, "bfc: %s" % self.bfc)
		font.put(5, 120, "inverse: %s" % self.bfc)
Exemple #6
0
def center(x, y, text): font.put(x - len(text) * 8 + 8, y, text)


class Sprite: