Skip to Main Content
Killer Game Programming in Java
book

Killer Game Programming in Java

by Andrew Davison
May 2005
Intermediate to advanced content levelIntermediate to advanced
998 pages
26h
English
O'Reilly Media, Inc.
Content preview from Killer Game Programming in Java

Initializing the User's Viewpoint

WrapShooter3D calls initUserControls() to configure the viewpoint. The method carries out four main tasks:

  • Sets up the user's gun-in-hand image

  • Positions the user's initial viewpoint

  • Calls AmmoManager to prepare beams and explosions

  • Creates a KeyBehavior object to process keyboard input

The initUserControls() method is:

    private void initUserControls(Vector3d targetVec)
    {
      // add a 'gun in hand' image to the viewpoint
      ViewingPlatform vp = su.getViewingPlatform();
      PlatformGeometry pg = gunHand();
      vp.setPlatformGeometry(pg);
   
      // position starting viewpoint
      TransformGroup steerTG = vp.getViewPlatformTransform();
      Transform3D t3d = new Transform3D();
      steerTG.getTransform( t3d );
      t3d.setTranslation( new Vector3d(0, 1, Z_START) );
      steerTG.setTransform(t3d);
   
      // create ammo (beams and explosions)
      AmmoManager ammoMan = new AmmoManager(steerTG, sceneBG, targetVec);
   
      // set up keyboard controls
      KeyBehavior keyBeh = new KeyBehavior( ammoMan );
           // keyBeh can ask the ammoManager to fire a beam
      keyBeh.setSchedulingBounds(bounds);
      vp.setViewPlatformBehavior(keyBeh);
    }  // end of initUserControls()
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Game Development with LibGDX: From Beginner to Professional

Java Game Development with LibGDX: From Beginner to Professional

Lee Stemkoski

Publisher Resources

ISBN: 0596007302Supplemental ContentErrata Page