Ejemplo n.º 1
0
                                                                      -0.5)),
                         height=0.5,
                         name="Extrude",
                         x=4,
                         y=2,
                         z=10)
# Extrude can use three different textures if they are loaded prior to draw()
myextrude.set_shader(shinesh)
myextrude.buf[0].set_draw_details(shinesh, [coffimg, shapebump, shapeshine],
                                  4.0, 0.2)
myextrude.buf[1].set_draw_details(shinesh, [patimg, shapebump, shapeshine],
                                  4.0, 0.2)
myextrude.buf[2].set_draw_details(shinesh, [shapeshine, shapebump, shapeshine],
                                  4.0, 0.2)

mycone = pi3d.Cone(radius=1, height=2, sides=24, name="Cone", x=-4, y=-1, z=10)
mycylinder = pi3d.Cylinder(radius=0.7,
                           height=1.5,
                           sides=24,
                           name="Cyli",
                           x=-2,
                           y=-1,
                           z=10)
# NB Lathe needs to start at the top otherwise normals are calculated in reverse,
# also inside surfaces need to be defined otherwise normals are wrong
mylathe = pi3d.Lathe(path=((0.0, 1.0), (0.6, 1.2), (0.8, 1.4), (1.09, 1.7),
                           (1.1, 1.7), (0.9, 1.4), (0.7, 1.2), (0.08, 1),
                           (0.08, 0.21), (0.1, 0.2), (1.0, 0.05), (1.0, 0.0),
                           (0.001, 0.0), (0.0, 0.0)),
                     sides=24,
                     name="Cup",
Ejemplo n.º 2
0
for p in platforms:
  p.scale(W, H, W)
  p.set_draw_details(shader, [metlimg, flrnorm], 8.0)
  p.positionY(p.y() + mymap.calcHeight(p.x(), p.z())) # adjust for terrain

dr = 0.0                             # rolling speed
dy = 0.0                             # vertical speed (for jumping)
expl = 1.0                           # scale value for exploding
xb, yb, zb = platforms[0].x(), platforms[0].y() + RADIUS + 5.0, platforms[0].z()
                                     # ball location coordinates
xc, yc, zc = xb, yb, zb              # set camera coords equal to ball coords

# end pole
xp, zp = 0.0, 0.0
yp = mymap.calcHeight(xp, zp) + 5
pole = pi3d.Cone(radius=0.5, height=10, x=xp, y=yp, z=zp)
pole.set_draw_details(shader, [metlimg, flrnorm], 12.0)

# keyboard object for getting key presses
mykeys = pi3d.Keyboard()
# mouse for steering
mymouse = pi3d.Mouse(restrict = False)
mymouse.start()

CAMERA = pi3d.Camera()
# main game loop
while DISPLAY.loop_running():
  mx, my = mymouse.position()
  rot = -mx * 0.2
  tilt = my * 0.1 -10.0
  if tilt > 5.0:
sobel_sprite.set_alpha(0.85)
hog_sprite.set_alpha(0.85)
hidden_sprite.set_alpha(0.85)

font = pi3d.Font('fonts/FreeSans.ttf', (150, 150, 150, 255))
str_list = [pi3d.String(font=font, string='1.Border Terrier', x=-1.0, y=1.0, z=3.0),
            pi3d.String(font=font, string='2.Flat Cap', x=-1.0, y=0.5, z=3.0),
            pi3d.String(font=font, string='3.Labrador', x=-1.0, y=0.0, z=3.0),
            pi3d.String(font=font, string='4.Top Hat', x=-1.0, y=-0.5, z=3.0),
            pi3d.String(font=font, string='5.Whippet', x=-1.0, y=-1.0, z=3.0)]
for st in str_list:
  st.set_shader(shader)

arrow_new = arrow_y = -2.0
arrow = pi3d.Cone(radius=0.05, height=0.3, x=0.0, y=arrow_y, z=3.0, rz=90.0)
arrow.set_shader(lgtshd)
arrow.set_material((1.0, 0.9, 0.4))

mykeys = pi3d.Keyboard()
mouse = pi3d.Mouse(restrict=False)
mouse.start()

fr = 0
trained = False
presses = [0] * 5
while DISPLAY.loop_running():
  mx, my = mouse.position()
  mx *= -0.1
  my *= 0.1
  CAM.relocate(mx, my, [-0.5, 0.0, 5.0], [-6.0, -6.0, -6.0])
Ejemplo n.º 4
0
    def __init__(self, sprites):
        # Instantiate an Asteroid Generator
        self.gen = asteroids.AsteroidGenerator(ASTEROIDS, 0.1, None,
                                               shader_explosion,
                                               shader_uv_flat)
        self.bullet_gen = bullets.BulletGenerator()
        self.active_asteroids = {}
        self.asteroid_id = 0
        self.active_bullets = []
        self.hit_asteroids = []
        self.azimuth = 0.0
        self.incl = 0.0
        self.self_hit = -1
        self.sprites = sprites
        self.fixed_sprites = []
        self.lives = INITIAL_LIVES
        self.scores = 0
        self.scores_changed = True
        self.pause = False
        self.free_play = False
        self.fire_button_state = 1
        self.frames = 0
        self.mode = [MODE_READY, READY_TIME]
        self.fire_rumble = 0
        self.quit_app = False
        self.dbg = []
        self.ready_text = pi3d.String(font=FONT_BALLS,
                                      string="READY?"[::-1],
                                      x=-.3,
                                      y=0.8,
                                      z=3.9,
                                      sx=0.018,
                                      sy=0.018)
        self.ready_text.set_shader(shader_uv_flat)
        self.go_text = pi3d.String(font=FONT_BALLS,
                                   string="GO!"[::-1],
                                   x=-.2,
                                   y=0.6,
                                   z=3.9 + 5 * .5,
                                   sx=0.018,
                                   sy=0.018)
        self.go_text.set_shader(shader_uv_flat)

        # Initial sprite location
        s = self.sprites['sight']
        s.position(*SIGHT_POSITION)
        s.scale(*SIGHT_SCALE)
        self.fixed_sprites.append(s)

        s = sprites['radar_panel']
        s.position(*RADAR_PANEL_POSITION)
        s.scale(*RADAR_PANEL_SCALE)
        self.fixed_sprites.append(s)

        self.radar_target = sprites['radar_target']
        self.radar_target.scale(*TARGET_SCALE)

        self.life_full = sprites['life_full']
        self.life_full.scale(*LIFE_BAR_SCALE)

        self.life_empty = sprites['life_empty']
        self.life_empty.scale(*LIFE_BAR_SCALE)

        self.dir_gauge = pi3d.Cone(z=4.0)
        self.dir_gauge.set_shader(shader_uv_flat)