Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
BasicInvader

spaceinvaders
Class BasicInvader

java.lang.Object  spaceinvaders.BasicInvader
All Implemented Interfaces:

public class BasicInvader
extends java.lang.Object
implements

My demonstration basic invader class. Moves slowly downwards to ground 0; jitters from side to side a little.


Constructor Summary
( aGame)
          Constructor - save reference to game object, pick initial position (just off-screen, in game coordinates somewhere high above ground).
 
Method Summary
 boolean(int location)
          If invader directly over laser gun it takes lots of damage, if on edge of laser beam takes less damage.
 boolean()
          Returns live state (invader of this class given an initial strength score that gets reduced if hit by gunfire until no longer "live")
 void()
          Move downwards driting to left for a bit, then drifting back to righ (or vice versa)
 void(java.awt.Graphics g)
          Draw picture of default invader as combinaton of rectangles and lines etc
 int()
          Score obtained for killing invader of this type
 int()
          X-coordinate (game ccords)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicInvader

public BasicInvader( aGame)
Constructor - save reference to game object, pick initial position (just off-screen, in game coordinates somewhere high above ground).

Parameters:
aGame - Reference to Game object
Method Detail

move

public void move()
Move downwards driting to left for a bit, then drifting back to righ (or vice versa)

Specified by:
in interface

paint

public void paint(java.awt.Graphics g)
Draw picture of default invader as combinaton of rectangles and lines etc

Specified by:
in interface
Parameters:
g - Graphics object used for drawing

live

public boolean live()
Returns live state (invader of this class given an initial strength score that gets reduced if hit by gunfire until no longer "live")

Specified by:
in interface
Returns:
true/false status

x

public int x()
X-coordinate (game ccords)

Returns:
x coordinate

isHit

public boolean isHit(int location)
If invader directly over laser gun it takes lots of damage, if on edge of laser beam takes less damage.

Specified by:
in interface
Parameters:
location - Gun (laser) location
Returns:
true/false indicator of whether hit

value

public int value()
Score obtained for killing invader of this type

Specified by:
in interface
Returns:
integer score