Java程序辅导

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

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

spaceinvaders
Interface SpaceInvader

All Known Implementing Classes:

public interface SpaceInvader

Defines the "SpaceInvader" abstraction. All invaders can move, draw (paint) themselves, report their value, etc.


Method Summary
 boolean(int location)
          Determines whether invader was hit by last shot from gun.
 boolean()
          Returns boolean indicating whether invader is still "alive".
 void()
          Each cycle of the game, the invaders get to move.
 void(java.awt.Graphics g)
          Draw image of invader using operations of java.awt.Graphics object passed as argument.
 int()
          Returns increment to player score obtained when invader of this class is destroyed.
 

Method Detail

move

void move()
Each cycle of the game, the invaders get to move. Different kinds of invader will move in different ways.


paint

void paint(java.awt.Graphics g)
Draw image of invader using operations of java.awt.Graphics object passed as argument.

Parameters:
g - Graphics used for drawing.

live

boolean live()
Returns boolean indicating whether invader is still "alive". Some invaders have finite lifetimes, some can take only a certain amount of damage from gunfire etc; so each invader class may have a different definition of live.

Returns:
true/false value indicating whether the invader is still "live".

isHit

boolean isHit(int location)
Determines whether invader was hit by last shot from gun. (The argument defines the gun's position in game coordinates; invaders "above" the gun may get hit. Invaders have different widths, some invaders may have cloaking devices to protect themselves from gunfire etc etc)

Parameters:
location - Gun's position in game coordinates.
Returns:
true/false indicator of whether hit

value

int value()
Returns increment to player score obtained when invader of this class is destroyed.

Returns:
Integer score value.