Author: ArcRiley
Date: 2007-07-09 01:06:55 -0400 (Mon, 09 Jul 2007)
New Revision: 442
Modified:
games/blockdropper/blocks.py
Log:
upgraded for PySoy
Modified: games/blockdropper/blocks.py
===================================================================
--- games/blockdropper/blocks.py 2007-07-09 03:35:33 UTC (rev 441)
+++ games/blockdropper/blocks.py 2007-07-09 05:06:55 UTC (rev 442)
@@ -1,18 +1,15 @@
# This should only have to be run once.
-import soya
+import soy
import os, os.path, sys
-soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))
-class BlockWorld(soya.World) :
+class BlockMesh(soy.meshes.Mesh) :
def __init__(self, diffuse, specular) :
- soya.World.__init__(self)
- material = soya.Material()
+ material = soy.materials.Material()
material.shininess = 15.0
- material.separate_specular = True
material.diffuse = diffuse
material.specular = specular
- Vert = VertexGroup()
+ Vert = VertexGroup(self)
# Create Faces
# 2 Halves
@@ -22,15 +19,15 @@
# 4 Quarters in each side
for c in (1.0, -1.0) :
for d in (1.0, -1.0) :
- points = (Vert(self, b, (.500*a, .000*c, .000*d)), # 0
- Vert(self, b, (.500*a, .000*c, .450*d)), # 1
- Vert(self, b, (.500*a, .450*c, .450*d)), # 2
- Vert(self, b, (.500*a, .450*c, .000*d)), # 3
- Vert(self, b, (.485*a, .485*c, .000*d)), # 4
- Vert(self, b, (.485*a, .485*c, .450*d)), # 5
- Vert(self, b, (.475*a, .475*c, .475*d)), # 6
- Vert(self, b, (.485*a, .450*c, .485*d)), # 7
- Vert(self, b, (.485*a, .000*c, .485*d))) # 8
+ points = (Vert(b, (.500*a, .000*c, .000*d)), # 0
+ Vert(b, (.500*a, .000*c, .450*d)), # 1
+ Vert(b, (.500*a, .450*c, .450*d)), # 2
+ Vert(b, (.500*a, .450*c, .000*d)), # 3
+ Vert(b, (.485*a, .485*c, .000*d)), # 4
+ Vert(b, (.485*a, .485*c, .450*d)), # 5
+ Vert(b, (.475*a, .475*c, .475*d)), # 6
+ Vert(b, (.485*a, .450*c, .485*d)), # 7
+ Vert(b, (.485*a, .000*c, .485*d))) # 8
faces = ([points[0], points[1], points[2]],
[points[0], points[2], points[3]],
[points[2], points[4], points[3]],
@@ -42,32 +39,35 @@
for face in faces :
if a*c*d==1 :
face.reverse()
- f = soya.Face(self, face, material)
- f.smooth_lit = True
+ f = soy.atoms.Face(self, verts=face, material=material)
+
class VertexGroup :
- def __init__(self) :
+ def __init__(self, mesh) :
self.verts = {}
+ self.mesh = mesh
- def __call__(self, parent, shift, coord) :
+ def __call__(self, shift, coord) :
if shift == 1 : coord = (coord[1], coord[2], coord[0])
elif shift == 2 : coord = (coord[2], coord[0], coord[1])
if not self.verts.has_key(coord) :
- self.verts[coord] = soya.Vertex(parent, coord[0], coord[1], coord[2])
+ self.verts[coord] = soy.atoms.Vertex(self.mesh, position=coord)
return self.verts[coord]
colors = {
- 'aqua' : ((.2, .9, .9, 1.0), (.4, 1.0, 1.0, 1.0)),
- 'teal' : ((.2, .4, 1.0, 1.0), (.4, .6, 1.0, 1.0)),
- 'rose' : ((1.0, .2, .4, 1.0), (1.0, .4, .6, 1.0)),
- 'jade' : ((.2, 1.0, .3, 1.0), (1.0, .4, .6, 1.0)),
- 'gold' : ((1.0, .8, .1, 1.0), (1.0, .9, .2, 1.0)),
- 'grey' : ((.7, .7, .7, 1.0), (1.0,1.0,1.0, 1.0)),
- 'plum' : ((.9, .2, .9, 1.0), (1.0, .4, 1.0, 1.0)),
- 'pink' : ((.9, .6, .6, 1.0), (1.0, .8, .8, 1.0)),
+ 'aqua' : ((0.2, 0.9, 0.9), (0.4, 1.0, 1.0)),
+ 'teal' : ((0.2, 0.4, 1.0), (0.4, 0.6, 1.0)),
+ 'rose' : ((1.0, 0.2, 0.4), (1.0, 0.4, 0.6)),
+ 'jade' : ((0.2, 1.0, 0.3), (1.0, 0.4, 0.6)),
+ 'gold' : ((1.0, 0.8, 0.1), (1.0, 0.9, 0.2)),
+ 'grey' : ((0.7, 0.7, 0.7), (1.0, 1.0, 1.0)),
+ 'plum' : ((0.9, 0.2, 0.9), (1.0, 0.4, 1.0)),
+ 'pink' : ((0.9, 0.6, 0.6), (1.0, 0.8, 0.8)),
}
blocks = {}
for color in colors :
- blocks[color] = BlockWorld(colors[color][0], colors[color][1]).shapify()
+ diffuse = soy.colors.Color(floats=colors[color][0])
+ specular = soy.colors.Color(floats=colors[color][1])
+ blocks[color] = BlockMesh(diffuse, specular)
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn