class Missile(object):
    def __init__(self, w=1.0, h=1.0):
        self.isActive = False
        self.x = 0.0
        self.y = 0.0
        self.z = 0.0
        self.dx = 0.0
        self.dy = 0.0
        self.dz = 0.0
        self.w = w
        self.h = h
        self.countDown = 0
        self.picture = Plane(w, h)

    #initialise the launch of the missile
    def fire(self, x, y, z, dx, dy, dz, cnt=10):
        self.isActive = True
        self.x = x
        self.y = y
        self.z = z
        self.dx = dx
        self.dy = dy
        self.dz = dz
        self.countDown = cnt
        self.picture.position(x, y, z)
        self.picture.rotateToY(atan(dx / dz))

    #move and draw
    def move(self, tex):
        if self.countDown > 0:
            self.picture.translate(self.dx, self.dy, self.dz)
            self.picture.rotateIncY(32)
            self.picture.draw(tex)
            self.countDown -= 1
Пример #2
0
class Missile(object):
  def __init__(self, w=1.0, h=1.0):
    self.isActive = False
    self.x = 0.0
    self.y = 0.0
    self.z = 0.0
    self.dx = 0.0
    self.dy = 0.0
    self.dz = 0.0
    self.w = w
    self.h = h
    self.countDown = 0
    self.picture = Plane(w, h)

  #initialise the launch of the missile
  def fire(self, x, y, z, dx, dy, dz, cnt=10):
    self.isActive = True
    self.x = x
    self.y = y
    self.z = z
    self.dx = dx
    self.dy = dy
    self.dz = dz
    self.countDown = cnt
    self.picture.position(x, y, z)
    self.picture.rotateToY(atan(dx/dz))

  #move and draw
  def move(self, tex):
    if self.countDown > 0:
      self.picture.translate(self.dx, self.dy, self.dz)
      self.picture.rotateIncY(32)
      self.picture.draw(tex)
      self.countDown -= 1
Пример #3
0
num = (2, 2)
asphere = Sphere(sides=32)
for i in range(num[0]):
  for j in range(num[1]):
    myshape.add(asphere, -num[0]*0.9 + 1.8*i, -num[1]*0.9 +1.8*j, 0.0)

myshape.position(0.0, 0.0, 5)
myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 1.0, 0.1)
myshape.set_material((1.0, 0.5, 0.2, 0.5))

mywater = Plane(w=130.0, h=130.0)
mywater.set_draw_details(matsh, [waterbump[0], shapeshine], 12.0, 0.6)
mywater.set_material((0.0, 0.05, 0.1))
mywater.set_fog((0.4, 0.6, 0.8, 0.0),150)
mywater.rotateToX(90.001)
mywater.position(0.0, -2.0, 0.0)

arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa")   #load ttf font and set the font colour to 'raspberry'
mystring = String(font=arialFont, string="Now the Raspberry Pi really does rock")
mystring.translate(0.0, 0.0, 1)
mystring.set_shader(flatsh)

tick = 0
av_fps = 0
i_n=0
spf = 0.1 # seconds per frame, i.e. water image change
next_time = time.time() + spf
dx = 0.02
offset = 0.0 # uv offset
do = -0.001 # uv increment
Пример #4
0
    dy = (my - omy) * 0.02
    omy = my
    if ((ym >= (0) and dy < 0) or (ym <= mapheight and dy > 0)): ym += dy
    if not (dy == 0.0 and dx == 0.0):
        camera.reset()
        camera.position((xm, 2 + ym, -maphalf - 2.5))

    #monster movement
    drx = sx - rx
    if abs(drx) > max_speed: drx = drx / abs(drx) * max_speed
    dry = sy - ry
    if abs(dry) > max_speed: dry = dry / abs(dry) * max_speed
    rx += drx
    ry += dry

    monster.position(rx, ry, maphalf)

    dsy -= gravity
    sx += dsx
    sy += dsy
    sz += dsz
    # now uses the clashTest method from elevationMap

    clash = mymap.clashTest(sx, sy, sz, radius)
    # bouncing physics
    if clash[0]:
        # returns the components of normal vector if clash
        nx, ny, nz = clash[1], clash[2], clash[3]
        # move it away a bit to stop it getting trapped inside if it has tunelled
        jDist = clash[4] + 0.2
        sx, sy, sz = sx + jDist * nx, sy + jDist * ny, sz + jDist * nz
Пример #5
0
asphere = Sphere(sides=32)
for i in range(num[0]):
    for j in range(num[1]):
        myshape.add(asphere, -num[0] * 0.9 + 1.8 * i, -num[1] * 0.9 + 1.8 * j,
                    0.0)

myshape.position(0.0, 0.0, 5)
myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 1.0, 0.1)
myshape.set_material((1.0, 0.5, 0.2, 0.5))

mywater = Plane(w=130.0, h=130.0)
mywater.set_draw_details(matsh, [waterbump[0], shapeshine], 12.0, 0.6)
mywater.set_material((0.0, 0.05, 0.1))
mywater.set_fog((0.4, 0.6, 0.8, 0.0), 150)
mywater.rotateToX(90.001)
mywater.position(0.0, -2.0, 0.0)

arialFont = Ttffont(
    "fonts/FreeMonoBoldOblique.ttf",
    "#dd00aa")  #load ttf font and set the font colour to 'raspberry'
mystring = String(font=arialFont,
                  string="Now the Raspberry Pi really does rock")
mystring.translate(0.0, 0.0, 1)
mystring.set_shader(flatsh)

tick = 0
av_fps = 0
i_n = 0
spf = 0.1  # seconds per frame, i.e. water image change
next_time = time.time() + spf
dx = 0.02
Пример #6
0
  camera.identity()
  camera.translate(xm,-2+ym-mapheight,-maphalf-2.5)

  myecube.draw(ectex,xm,ym,zm)
  mymap.draw(groundimg)

  #monster movement
  drx = sx - rx
  if abs(drx) > max_speed: drx = drx/abs(drx) * max_speed
  dry = sy - ry
  if abs(dry) > max_speed: dry = dry/abs(dry) * max_speed
  rx += drx
  ry += dry

  monster.position(rx, ry, -maphalf)

  dsy -= gravity
  sx += dsx
  sy += dsy
  sz += dsz
  # now uses the clashTest method from elevationMap
  clash = mymap.clashTest(sx, sy, sz, radius)
  # bouncing physics
  if clash[0]:
    # returns the components of normal vector if clash
    nx, ny, nz =  clash[1], clash[2], clash[3]
    # move it away a bit to stop it getting trapped inside if it has tunelled
    jDist = clash[4] + 0.1
    sx, sy, sz = sx - jDist*nx, sy - jDist*ny, sz - jDist*nz