Package: com.multiversesocial.hyperview
Class: com.multiversesocial.hyperview.Gob
Source: src/com/multiversesocial/hyperview/Gob.java
A Gob is a sprite: an image drawn at x,y (exact position fx,fy, doubles, since V3.2), size width,height, depth z. It can follow a Spline (attach / detach), takes part in collisions (COLLIDE_AT_END Spline or the GOB_COLLISION_OUTLINE flag), orbits a parent and carries the flag words gobFlags, gobFlags2, gobEventFlags.
setAngle(radians) / setAngleDegrees / rotateBy. The angle is in radians, positive = clockwise on the screen, about the centre of the drawn rectangle. Angle 0 is exactly the old drawImage path. Otherwise the Gob is drawn with a Graphics2D transform, ROTATE_BILINEAR (default, smooth alpha edges when the art has a transparent margin) or ROTATE_NEAREST (setRotateInterpolation). The collision outline turns with it and still scales with z (GobGeometry).setPhysics(mass,restitution,response) makes a Gob physical (mass > 0 and response RESPONSE_BOUNCE or RESPONSE_STOP). vx,vy are in pixels per physics step (one per display frame, or per real time with CollisionManager.realTimeStep). BOUNCE: impulse with restitution (momentum is conserved between moving Gobs; 1 = elastic, 0 = they go on together). STOP: “ball in sand”, the Gob halts where it touches and is immovable for the partner. No mass and no response = the old V3.22 flag-only behaviour, nothing changes.setHitPoints(n); each impact costs 0.5 * reduced mass * closing speed^2 * damageScale * damageFactor; at 0 the Gob explodes (onExplode(from) may handle it, e.g. the Asteroids break-up into 5 to 12 pieces; otherwise a CollisionAnimGob plays and the Gob is removed).isPhysicsOwned()): the Spline stays attached but is not stepped. resumeSpline() gives control back (the Gob jumps to the Spline's current point); setVelocity() takes over at once; setPhysicsMotion(false) lets the application move the Gob while the pass still resolves contacts.containsPoint(x,y) (bounding rectangle of the turned sprite, polygon, alpha mask for outline-flag Gobs), setPickable, setPickAlpha, hooks onPick / onSelect / onDeselect, isSelected(). See HyperView.pickGob().A Spline is added to a Gob with attachSpline(s) (setSpline is the same; addSpline is the old name and the two Spline constructors use it). It sets GOB_SPLINE_ENA, puts the Gob on the first point of the path, resets the Spline and, for SP_ZBUFFER_ENA, does gobZInit() and sets ZBUFFER_ENA. getSpline() returns it (null when none); detachSpline() clears GOB_SPLINE_ENA and lets go: the Gob stays exactly where it is (position, size, z-buffer state), the Spline is returned, not cleaned up, and can be attached again (it restarts). A Spline belongs to one Gob: attaching it to a second Gob throws IllegalStateException; attaching another Spline to a Gob replaces (releases) the first; attachSpline(null) detaches.
Movement comes from the Spline. HyperView.run() calls Spline.step(gob) once per display frame; the Spline advances its distance by speed pixels along the curve and the Gob’s exact position is written with setFloatPosition(fx,fy). fx,fy,fz are doubles (getFloatX, getFloatY, getFloatZ); the integer x,y,z used for drawing, bounds and collisions are those rounded (floor(v+0.5)) and x2,y2 follow. A speed of 0.35 px/frame therefore moves x only every third frame while fx changes every frame. move(int,int) sets both. When STOP_AT_END is reached the Spline releases the Gob (spline becomes null) on the end point.
A Gob takes part in the collision pass that HyperView.collisionPass() runs once per display frame (CollisionManager.collide()) if takesPartInCollisions(): its Spline has COLLIDE_AT_END (collidesAtEnd()) or it has the flag GOB_COLLISION_OUTLINE (gobFlags2, 0x800; isImageOutlineEnabled()). The two are independent:
The outline used is, in this order: 1. a polygon set by hand with setOutline() (it wins; with the flag set the image is then not traced); 2. the traced image outline (alpha >= outlineAlphaMin 128, outer contour only, holes ignored, Douglas-Peucker outlineEpsilon 1.0, at most outlineMaxPoints 48 points; if the largest piece is too thin, its bounding box; several pieces: the largest); 3. the bounding box x,y .. x+width-1,y+height-1 (a fully transparent image keeps it; AnimGobs are not traced). The outline is in image pixels, moves with the Gob and is scaled by width/widthBase when the Gob is z-buffered; it is never rotated.
On contact both Gobs get GOB_COLLIDED (cleared in the first frame without contact), collisionX/Y; a new contact also bumps collisionCount, sets collidedWith and adds a CollisionAnimGob. Nothing is stopped or removed. Members: collidesAtEnd, takesPartInCollisions, setImageOutlineEnabled, isImageOutlineEnabled, computeImageOutline, hasImageOutline, invalidateImageOutline, getImageOutlineRawPoints, setOutline, clearOutline, hasOutline, getOutline, getWorldOutline, isCollided, getCollisionCount, getCollidedWith, clearCollision.
public class Gob extends Linkable implements HyperConstants, TextConstants
| Declaration | Value / initializer | Description | Source |
|---|---|---|---|
volatile double angle | rotation, RADIANS, positive = clockwise on the screen; 0 = the unrotated fast path | ||
Graphics asynchGraphics1 | No comment in source; used in cleanUp(). | ||
Graphics asynchGraphics2 | No comment in source; used in cleanUp(). | ||
Image asynchImage1 | For double buffered external input. | ||
Image asynchImage2 | For double buffered external input. | ||
Gob[] attachedGob | No comment in source; assigned in Gob(), addGob(); used in moveNext(). | ||
int attachedIndex | No comment in source; assigned in Gob(), cleanUp(). | ||
Image backGround | No comment in source; used in cleanUp(). | ||
volatile MemoryImageSource bgMemoryImageSource | No comment in source; assigned in Gob(). | ||
int bGPen | No comment in source; assigned in Gob(). | ||
int bottomMax | No comment in source; assigned in Gob(). | ||
int boundX1 | Bounding box of the world outline, inclusive (boundX1, boundY1, boundX2, boundY2): the cheap reject test of the collision pass. | ||
int boundX2 | Right edge of the bounding box (see boundX1). | ||
int boundY1 | Top of the bounding box (see boundX1). | ||
int boundY2 | Bottom of the bounding box (see boundX1). | ||
volatile int clickX | If onClick() enabled where it was clicked on | ||
volatile int clickY | If onClick() enabled where it was clicked on | ||
Gob collidedWith | The other Gob of the most recent new contact (stays after the two separate). Read with getCollidedWith(). | ||
int collisionClassMask | No comment in source; assigned in initScanline(). | ||
int collisionCount | Number of separate contacts this Gob has had (not frames: a long touch counts once). Read with getCollisionCount(). | ||
int collisionTick | Incremented once per collision pass this Gob takes part in. | ||
int collisionX | Contact point of the latest contact in screen pixels, updated while the Gobs touch (collisionX, collisionY). | ||
int collisionY | y of the contact point (see collisionX). | ||
Gob[] contactGob | CollisionManager bookkeeping: Gobs touched in recent frames, to tell a new contact from a continuing one. | ||
int contactN | Entries in use in contactGob / contactTick. | ||
int[] contactTick | For each contactGob entry: the other Gob’s collisionTick when last seen. | ||
int curAttached | No comment in source; assigned in Gob(), cleanUp(). | ||
int currentZIndex | No comment in source; assigned in Gob(). | ||
volatile HyperView curView | No comment in source; assigned in Gob(), move(); used in printGobAttr(), addSpline(), inView(), onDisplay(), onClick() …. | ||
float damageFactor | = 1.0f | multiplies the impact energy that becomes damage | |
public static int defaultRotateInterpolation | = ROTATE_BILINEAR | Interpolation new Gobs start with. | |
int depth | Granularity of z | ||
Gob destGob | No comment in source; assigned in cleanUp(); used in center(), toString(). | ||
Graphics destGraphics | No comment in source; assigned in Gob(), cleanUp(). | ||
int dispatchHoldCount | No comment in source; assigned in Gob(). | ||
int drawMode | No comment in source; assigned in Gob(). | ||
int dX | No comment in source; assigned in Gob(); used in printGobAttr(). | ||
int dY | Delta for movment | ||
int dZ | No comment in source; assigned in Gob(); used in printGobAttr(). | ||
boolean exploded | hit points ran out; the Gob is exploding / removed | ||
volatile MemoryImageSource fgMemoryImageSource | No comment in source; assigned in Gob(). | ||
int fGPen | No comment in source; assigned in Gob(). | ||
double fx | V2.43 V3.2 floating point position (a Spline writes these; x,y,z are them rounded) | ||
double fy | exact position, top left, in pixels; x = round(fx) while a Spline drives the Gob | ||
double fz | No comment in source. | ||
int gobEventFlags | No comment in source; assigned in Gob(). | ||
volatile int gobFlags2 | No comment in source; assigned in Gob(), remove(), remGob(); used in isMemoryImageSource(), toString(). | ||
volatile int gobFlags | No comment in source; assigned in Gob(), remove(), addSpline(), zENA(), zOff() …; used in center(), toString(). | ||
int gobGadIndex | No comment in source; assigned in Gob(). | ||
int gobHx | No comment in source; assigned in Gob(). | ||
int gobHy | Home position | ||
int gobHz | No comment in source; assigned in Gob(). | ||
String gobName | No comment in source; assigned in Gob(), cleanUp(); used in onRelease(), toString(). | ||
int gobNumber | index in goblist # | ||
double gobOrbitDc | right ascension / orbit angle (radians) | ||
int gobOrbitRadiusY | elliptical Y radius (typically 78% of radius) | ||
int gobOrbitRadius | No comment in source; assigned in Gob(). | ||
double gobOrbitRa | centidegrees per ~16ms tick | ||
int gobOrbitSpeed | elliptical Y radius (typically 78% of radius) | ||
Image gobPic | Current Reference. | ||
int gobTypeFlags | No comment in source; assigned in Gob(). | ||
Graphics graphics | No comment in source; assigned in Gob(); used in getGraphics(), cleanUp(). | ||
int gravity | No comment in source; assigned in Gob(). | ||
boolean halted | RESPONSE_STOP has stopped it: v = 0, immovable until setVelocity() | ||
int heightBase | Actual height of iamge | ||
int height | No comment in source; assigned in Gob(), gobZInit(); used in printGobAttr(), addSpline(), center(), isInView(), initScanline() …. | ||
float hitPoints | current hit points (only used when maxHitPoints > 0) | ||
double hSin | Sin of height relative to z | ||
double hyp | Hypotenues of Sin | ||
boolean imageOutlineDone | V3.2: outlineX/Y were traced from the image (GOB_COLLISION_OUTLINE), not set by hand | ||
int imageOutlineRaw | V3.2: the image outline was tried (success, nothing opaque, or not possible): do not retry | ||
int impactCount | impacts that were resolved by the physics response | ||
String infoString | No comment in source; assigned in Gob(), cleanUp(). | ||
boolean integrate | = true | true: the collision pass moves the Gob by vx,vy; false: the application moves it | |
double kvx | velocity measured from the position change per pass (Spline driven or kinematic Gob) | ||
double kvy | velocity measured from the position change per pass (Spline driven or kinematic Gob) | ||
float lastImpactEnergy | 0.5 * reduced mass * speed^2 of that impact | ||
Gob lastImpactFrom | the Gob that caused it | ||
float lastImpactSpeed | closing speed of the last impact that hurt / bounced this Gob (pixels per step) | ||
boolean lastPValid | No comment in source. | ||
double lastPX | position at the previous collision pass (velocity of a Spline / application driven Gob) | ||
double lastPY | position at the previous collision pass (velocity of a Spline / application driven Gob) | ||
volatile int lClickX | No comment in source; assigned in Gob(). | ||
volatile int lClickY | No comment in source; assigned in Gob(). | ||
int leftMin | No comment in source; assigned in Gob(). | ||
float mass | > 0 makes the Gob physical (with a response other than RESPONSE_NONE) | ||
int maxAttached | Change to suit your needs. | ||
float maxHitPoints | 0 = indestructible (the default) | ||
static volatile int memoryCounter | = 0 | No comment in source; not referenced by name in this type’s methods. | |
volatile int moveNum | No comment in source; assigned in Gob(). | ||
int[] mX2 | No comment in source; assigned in Gob(), cleanUp(). | ||
int[] mX | Multiple background update list/ MouseHandler event stack. | ||
int[] mY2 | No comment in source; assigned in Gob(), cleanUp(). | ||
int[] mY | No comment in source; assigned in Gob(), cleanUp(). | ||
int oldX | No comment in source; assigned in Gob(). | ||
int oldY | For BackGround Restore | ||
int oldZ | No comment in source; assigned in Gob(). | ||
double orbitFcx | declination / tilt (radians) | ||
double orbitFcy | float center X (subpixel) | ||
Gob orbitGob | No comment in source; assigned in cleanUp(). | ||
int orbitStamp | float center Y (subpixel) | ||
public static int outlineAlphaMin | = OutlineTracer.DEFAULT_ALPHA | V3.2: image outlines computed in this JVM (proof of the flag gate) | |
public static volatile int outlineComputeCount | = 0 | V3.2: boundary pixels traced before simplification (information) | |
public static double outlineEpsilon | = OutlineTracer.DEFAULT_EPSILON | alpha >= this is opaque | |
boolean outlineFromImage | Collision outline + flags (COLLIDE_AT_END, see CollisionManager) | ||
public static int outlineMaxPoints | = OutlineTracer.DEFAULT_MAX_POINTS | Douglas-Peucker tolerance, pixels | |
int outlineN | Number of vertices set with setOutline(); 0 = no outline set, the default (bounding box) is used. | ||
public static volatile int outlineRebuildCount | = 0 | Number of times the collision pass (re)built a traced outline in this JVM (a test reads it). | |
boolean outlineSrcSet | V3.22: the image the current outline was traced from (identity: a new image rebuilds it) | ||
Image outlineSrc | V3.2: image outlines computed in this JVM (proof of the flag gate) | ||
int[] outlineX | Outline vertices in image pixels (0,0 = top left pixel of the widthBase x heightBase image); copied by setOutline(). | ||
int[] outlineY | y values of the outline vertices (see outlineX). | ||
boolean physicsOwned | physics drives the position; a Spline attached to the Gob is paused (not stepped) | ||
boolean pickable | = true | HyperView.pickGob may return it | |
boolean pickAlpha | = true | with GOB_COLLISION_OUTLINE: click through transparent pixels, not only outside the contour | |
int pickMaskH | No comment in source. | ||
int pickMaskKey | = -1 | No comment in source. | |
Image pickMaskSrc | No comment in source. | ||
int pickMaskW | No comment in source. | ||
boolean[] pickMask | opaque pixels of the sprite (clip), built on the first alpha pick | ||
public static final int RESPONSE_BOUNCE | = 1 | Contact response: bounce (impulse with the restitution; momentum is conserved between two moving Gobs). | |
public static final int RESPONSE_NONE | = 0 | Contact response: none. The Gob only gets the V3.22 flags / counters (the old behaviour). | |
public static final int RESPONSE_STOP | = 2 | Contact response: stop ("ball in sand"): the Gob halts where it touches and stays there. | |
int response | RESPONSE_NONE (default), RESPONSE_BOUNCE, RESPONSE_STOP | ||
float restitution | = 1.0f | 1 = elastic, 0 = inelastic (no rebound) | |
int rightMax | No comment in source; assigned in Gob(). | ||
public static final int ROTATE_BILINEAR | = 1 | Rotation interpolation: bilinear (smooth edges, alpha blended). The default. | |
public static final int ROTATE_NEAREST | = 0 | Rotation interpolation: nearest neighbour pixel (sharp, fast). | |
int rotateInterpolation | = defaultRotateInterpolation | No comment in source. | |
Scanline[] scanLine | No comment in source; assigned in initScanline(); used in printScanLines(). | ||
Graphics selectGraphics | No comment in source; assigned in Gob(); used in cleanUp(). | ||
Image selectImage | No comment in source; assigned in Gob(); used in cleanUp(). | ||
volatile long selectTime | No comment in source; name appears in 2 other source file(s): HyperMouse, HyperView. | ||
float spin | radians per physics step added to angle by the collision pass (physics Gobs) | ||
boolean splineMeasured | the velocity was measured from a Spline driven position at the previous pass | ||
Spline spline | No comment in source; assigned in Gob(), addSpline(); used in cleanUp(). | ||
int tint | No comment in source; assigned in Gob(). | ||
int topMin | No comment in source; assigned in Gob(). | ||
int totalAttached | Total number of Gobs attached | ||
int traceRaw | V3.2: boundary pixels traced before simplification (information) | ||
float vx | velocity, pixels per physics step (= per display frame by default) | ||
float vy | vertical velocity, pixels per physics step (see vx) | ||
int widthBase | Actual width of image | ||
int width | No comment in source; assigned in Gob(), gobZInit(); used in printGobAttr(), addSpline(), center(), isInView(), initScanline() …. | ||
int worldN | Number of valid vertices in worldX / worldY. | ||
int[] worldX | The outline at the Gob’s current position and size (screen pixels), rebuilt by CollisionManager.updateOutline() every display frame; reused, not reallocated per frame. | ||
int[] worldY | y values of worldX. | ||
double wSin | Sin of width relative to z | ||
int x2 | No comment in source; assigned in Gob(), center(). | ||
int x | No comment in source; assigned in Gob(), center(); used in printGobAttr(), inView(), onDisplay(), isInView(), toString(). | ||
int y2 | No comment in source; assigned in Gob(), center(). | ||
int y | Current Position | ||
int z | No comment in source; assigned in Gob(), gobZInit(), initScanline(), printScanLines(); used in printGobAttr(), toString(). |
| Signature | Description | Source |
|---|---|---|
Gob() | 1 statement(s); calls super(). | |
Gob(Gob tGob, String tName, int tFlags) | Target Gob, Name, etc | |
Gob(Gob tGob, String tName, int tX, int tY, int tFlags) | 4 statement(s); calls this(). | |
Gob(Gob tGob, String tName, int tX, int tY, int pX, int pY, Spline tSpline, int tFlags) | 10 statement(s); calls this(), gobZInit(). | |
Gob(Gob tGob, String tName, int tWidth, int tHeight, int pX, int pY, int tFlags) | 2 statement(s); calls this(), move(). | |
Gob(HyperView tView, MemoryImageSource tMemoryImageSource, int tWidth, int tHeight, int tFlags) | 1 statement(s); calls this(). | |
Gob(HyperView tView, String tName, MemoryImageSource tFGMemoryImageSource, MemoryImageSource tBGMemoryImageSource, int tWidth, int tHeight, int tFlags) | 78 statement(s); calls super(), curView.createImage(), gobPic.getGraphics(), tView.createImage(), tName.endsWith() …; creates URL. | |
Gob(HyperView tView, String tName, int tFlags) | 1 statement(s); calls this(). | |
Gob(HyperView tView, String tName, int sx, int sy, Spline tSpline, int tFlags) | 11 statement(s); calls this(), gobZInit(). | |
Gob(HyperView tView, String tName, int tWidth, int tHeight, int tFlags) | 1 statement(s); calls this(). | |
Gob(HyperView tView, String tName, int tX, int tY, int pX, int pY) | 1 statement(s); calls this(). | |
Gob(HyperView tView, String tName, int sx, int sy, int pX, int pY, int tFlags) | 2 statement(s); calls this(), move(). | |
Gob(HyperView tView, int[] tData, int tWidth, int tHeight, int tFlags) | 1 statement(s); calls this(); creates MemoryImageSource. | |
Gob(ViewMain tViewMain, String tName, int sx, int sy, int pX, int pY, int tFlags) | 2 statement(s); calls this(), move(). | |
Gob(ViewMain tViewMain, int sx, int sy, int pX, int pY, int tFlags) | 2 statement(s); calls this(), move(). |
| Signature | Description | Source |
|---|---|---|
public void addGob(Gob tGob) | 4 statement(s). | |
public int addOrbitGob(Gob child, int radius, int speed, double ra, double dc) | Orbit child around this Gob. ra/dc in radians; speed = centidegrees per ~16ms tick. | |
public void addSpline(Spline tSpline) | 6 statement(s); calls gobZInit(). | |
public Spline attachSpline(Spline s) | Make this Gob follow s: GOB_SPLINE_ENA is set, the Gob moves to the first point of the path (float position fx,fy,fz and x,y,z), and if the Spline has SP_ZBUFFER_ENA the Gob is z-buffered (width/height scale with z). A Spline already attached to this Gob is released first. A Spline can only be followed by one Gob (it keeps the distance travelled): another Gob's Spline gives IllegalStateException; detach it there first. s == null is detachSpline(). Returns s. | |
public void center() | 3 statement(s). | |
public void cleanUp() | 15 statement(s); calls gobPic.flush(), graphics.dispose(), selectImage.flush(), selectGraphics.dispose(), asynchImage1.flush() …. | |
public void clearCollision() | Forgets the contacts: count 0, no collidedWith, GOB_COLLIDED off. | |
private void clearImageOutlineQuiet() | No comment in source. | |
public void clearOutline() | Back to the default outline: the bounding box x,y .. x+width-1,y+height-1. | |
public boolean collidesAtEnd() | True if this Gob takes part in the collision pass: GOB_SPLINE_ENA is set and its Spline has COLLIDE_AT_END. | |
public void collisionOff() | 1 statement(s). | |
public void collisionOn() | 1 statement(s). | |
public boolean computeImageOutline() | Trace the outline polygon from the image NOW and wait for the image if it is still loading (up to 5 s). Does nothing and returns false unless the GOB_COLLISION_OUTLINE flag is set, or when a hand set outline exists (it wins). Returns true if the Gob now has an outline traced from the image; false if the image has no opaque pixel, could not be read, or this is an AnimGob (the image is a strip of clips; the Gob keeps the bounding box). | |
public boolean containsPoint(int px, int py) | Is the screen pixel px,py on this Gob? Rotation, z scale, outline polygon and (flagged Gobs) alpha are respected. | |
public void damage(double amount, Gob from) | Take damage (hit points are reduced, an explosion follows at the next collision pass, or call explode()). Only if destructible. | |
public Spline detachSpline() | Let go of the Spline: GOB_SPLINE_ENA is cleared and the Gob stays exactly where it is (position, size and ZBUFFER_ENA are not touched). Returns the Spline (still usable: attach it to a Gob again, it restarts at its first point) or null if there was none. The Spline is not cleaned up. | |
public void disable() | 1 statement(s). | |
private boolean doImageOutline(boolean wait) | No comment in source. | |
public int drawHeight() | See drawWidth(). | |
boolean drawRotated(Graphics gr, Image src, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, ImageObserver obs, boolean clipSrc) | Draw src (the part sx,sy,sw,sh of it; sw <= 0: the whole image) scaled into the rectangle dx,dy,dw,dh turned by this Gob's angle about the rectangle's centre. clipSrc: restrict the drawing to the source part (an AnimGob strip, so the neighbouring clips do not bleed in). Returns what Graphics.drawImage returns (false = the image is not completely loaded yet). The Graphics2D's transform, clip and interpolation hint are restored. | |
public int drawWidth() | The size this Gob is DRAWN at for its current z, by the z-buffer rule of gobZInit() / HyperView.run(): width = widthBase * wSin / z + 1, height = heightBase * hSin / z + 1 (z < 0: the base size; z uses the exact fz of a Spline with SP_ZBUFFER_ENA). A Gob without ZBUFFER_ENA is drawn at width x height. | |
public void enable() | 1 statement(s). | |
boolean ensureCollisionOutline() | CollisionManager: make sure this colliding Gob has its polygon. While the image is still loading, a Gob with GOB_COLLISION_OUTLINE waits (returns false: not tested with a wrong shape); any other colliding Gob is tested with the 4 corner box polygon and traced on a later pass. Returns true when the Gob can be tested. | |
boolean ensureImageOutline() | The same, called by the collision pass (display thread): never waits. If the image is not completely loaded yet it returns false and the pass asks again next frame. Returns true when finished (done or given up). | |
public void explode() | Explode now: onExplode(), then (unless it handled it) the CollisionAnimGob and removal. | |
public double getAngleDegrees() | No comment in source. | |
public double getAngle() | The rotation in radians. | |
public Gob getCollidedWith() | The Gob of the latest new contact, or null. | |
public int getCollisionCount() | Number of separate contacts so far. | |
public double getDamageFactor() | No comment in source. | |
public double getFloatX() | Exact x of the top left corner (equals x until a Spline moves the Gob in sub pixel steps). | |
public double getFloatY() | Exact y of the top left corner. | |
public double getFloatZ() | Exact z. | |
public Graphics getGraphics() | Returns graphics. | |
public double getHitPoints() | No comment in source. | |
public Image getImageFromJar(String fileName) | 4 statement(s); calls HyperView.resolveResourceURLStatic(), curView.getAppletContext().getImage(), curView.getAppletContext(), curView.hyperViewOut(). | |
public int getImageOutlineRawPoints() | Boundary pixels the last image trace of this Gob found before simplification (0 if none). | |
public int getImpactCount() | No comment in source. | |
public double getLastImpactEnergy() | The impact energy / speed of the last physical impact (see CollisionManager). | |
public Gob getLastImpactFrom() | No comment in source. | |
public double getLastImpactSpeed() | No comment in source. | |
public double getMass() | No comment in source. | |
public double getMaxHitPoints() | No comment in source. | |
public static int getOutlineComputeCount() | How many image outlines were computed in this JVM (all Gobs). Gobs without the flag never add to it. | |
public Polygon getOutline() | The outline in image pixels (a copy). Default: a new Polygon of the box 0,0 .. widthBase-1,heightBase-1. | |
int[] getPixels() | 6 statement(s); calls pixelGrabber.grabPixels(), pixelGrabber.getStatus(); creates PixelGrabber. | |
public int getResponse() | No comment in source. | |
public double getRestitution() | No comment in source. | |
public int getRotateInterpolation() | No comment in source. | |
public double getSpin() | No comment in source. | |
public Spline getSpline() | The Spline this Gob follows, or null. | |
public double getVelocityX() | No comment in source. | |
public double getVelocityY() | No comment in source. | |
public Polygon getWorldOutline() | The outline at the Gob’s position and size in screen pixels as of the last collision pass (a copy; empty Polygon before the first pass). | |
public void gobZInit() | 14 statement(s); calls Math.sqrt(). | |
public boolean hasImageOutline() | True if the current outline was traced from the image (false: hand set, or the bounding box). | |
public boolean hasOutline() | True if setOutline() gave this Gob its own outline (outlineN >= 3). | |
public void initScanline(int tInt) | This routine converts the Image into a Double linked list of Scanlines This works, but I am going to change it to use a 1 bitplane bitmask. | |
public void invalidateImageOutline() | Forget the traced outline and trace again the next time it is needed (a new image, a changed alpha threshold). | |
public boolean inView() | 2 statement(s). | |
public boolean isCollided() | True while this Gob overlaps another COLLIDE_AT_END Gob: tests GOB_COLLIDED, which the pass sets and clears every frame. | |
public boolean isDynamic() | True if the Gob is physical: mass > 0 and a response other than RESPONSE_NONE. | |
public boolean isExploded() | True once the hit points ran out (the Gob exploded and is removed). | |
public boolean isHalted() | RESPONSE_STOP has stopped the Gob. | |
public boolean isImageOutlineEnabled() | True if this Gob has the GOB_COLLISION_OUTLINE flag (collision outline from the image). | |
boolean isInView() | 2 statement(s). | |
boolean isMemoryImageSource() | Returns ((gobFlags2 & GOB_MEMORYIMAGESOURCE) != 0). | |
public boolean isPhysicsOwned() | The Spline is attached but paused because the physics moves the Gob. | |
public boolean isPickable() | No comment in source. | |
public boolean isSelected() | Is this the selected Gob of its view? | |
private void moveInt(int tX, int tY) | No comment in source. | |
public void moveNext() | Advance along attached-gob chain if present. | |
public void move(Gadget tGadget, int tX, int tY) | 7 statement(s). | |
public void move(int tX, int tY) | 8 statement(s); calls HyperView.getCurView(). | |
public void onClick() | 1 statement(s); calls curView.statusText(). | |
public void onDeselect() | Called when it stopped being the selected Gob. Default: nothing. | |
public boolean onDisplay() | 3 statement(s). | |
public boolean onExplode(Gob from) | Called when the hit points are used up, before the default explosion. Return true to handle it yourself (the Asteroids demo breaks the rock into pieces): the default CollisionAnimGob is then NOT added and the Gob is NOT removed (you do it). Return false (the default) for the explosion animation at the Gob and its removal. from = the Gob that hit it last or null. | |
public void onPick(int px, int py) | Called by HyperView.pickAndSelect when this Gob was picked by a click at the view pixel x,y. Default: nothing. | |
public void onRelease() | 1 statement(s); calls curView.statusText(). | |
public void onSelect() | Called when the Gob became the selected Gob of its view (click, or HyperView.selectGob). Default: nothing. | |
boolean opaqueAt(double ub, double vb) | opaque pixel at ub,vb (pixel index coordinates of the widthBase x heightBase picture)? true if it can not be told. | |
Image outlineImage() | The image the outline is traced from (the sprite which is drawn). AnimGob: its strip. | |
private boolean[] pickMaskFor() | the opaque mask of the sprite part: null while the image is not loaded or cannot be read | |
public void printGobAttr(HyperView curView) | 19 statement(s); calls curView.text(). | |
public void printScanLines() | 6 statement(s); calls initScanline(). | |
void releaseSpline() | STOP_AT_END reached (called by Spline.step): the Spline lets go, the Gob stays on the end point. | |
public void remGob() | Detach this gob from its view display list. | |
public void remove() | 2 statement(s). | |
public void resumeSpline() | Hand control back to the Spline (it continues from its own distance; the Gob jumps to that point). | |
public void rotateBy(double radians) | Turn by radians more (positive = clockwise). | |
static int roundPos(double v) | No comment in source. | |
public void setAngleDegrees(double degrees) | Same in degrees. | |
public void setAngle(double radians) | Set the rotation in radians (positive = clockwise on screen). Normalised to (-PI, PI]; a full turn is exactly 0. | |
public void setDamageFactor(double f) | Scale of the damage this Gob takes from an impact (1 = the impact energy; 0 = takes none). | |
public void setFloatPosition(double nx, double ny) | Set the exact position (top left); x,y are the rounded values and x2,y2 follow. Does not clip to the view. | |
public void setFloatZ(double nz) | Set the exact z; z is the rounded value, at least 1. | |
public void setHitPoints(double max) | Hit points: max > 0 makes the Gob destructible (hp = max). 0 or less = indestructible (the default). | |
public void setImageOutlineEnabled(boolean on) | Switch the GOB_COLLISION_OUTLINE flag. on: the Gob takes part in the collision pass and its outline is traced from its image (alpha >= outlineAlphaMin) the first time the pass sees it with a loaded image, or when computeImageOutline() is called. An outline set with setOutline() is kept (it wins). off: the flag is cleared and an outline traced from the image is dropped (back to the bounding box); a hand set one stays. | |
public void setMass(double tMass) | No comment in source. | |
public void setOutline(Polygon p) | Sets the collision outline. Vertices are pixels of the Gob’s own image (0,0 = top left pixel; widthBase-1,heightBase-1 = bottom right pixel); they are copied. The pass translates the outline with the Gob (x,y) and scales it by width/widthBase when z-buffered. No rotation (the Gob has none). null or fewer than 3 vertices restores the default (bounding box). | |
public void setOutline(int[] xs, int[] ys, int n) | Same with arrays; the first n vertices of xs[] / ys[] are copied. | |
public void setPhysicsMotion(boolean passMovesIt) | true: the collision pass moves the Gob by its velocity (default); false: the application moves it. | |
public Gob setPhysics(double tMass, double tRestitution, int tResponse) | Make the Gob physical: mass (> 0), restitution (0 = inelastic .. 1 = elastic) and response (RESPONSE_BOUNCE, RESPONSE_STOP; RESPONSE_NONE turns physics off again). Returns this. mass <= 0 gives RESPONSE_NONE. | |
public void setPickable(boolean on) | HyperView.pickGob() may return this Gob (default true). | |
public void setPickAlpha(boolean on) | With GOB_COLLISION_OUTLINE: a pixel with alpha below outlineAlphaMin is not hit (default true). false: contour polygon only. | |
public void setResponse(int tResponse) | No comment in source. | |
public void setRestitution(double r) | No comment in source. | |
public void setRotateInterpolation(int mode) | ROTATE_NEAREST or ROTATE_BILINEAR for this Gob's rotated drawing. | |
public void setSpin(double radiansPerStep) | Spin: radians added to the angle per physics step by the collision pass (only Gobs the pass integrates). | |
public void setSpline(Spline s) | Same as attachSpline(s). | |
public void setVelocity(double tvx, double tvy) | Set the velocity in pixels per physics step (one display frame unless CollisionManager.realTimeStep). A halted Gob moves again. On a Gob with a Spline the physics takes over (see above). | |
int[] spriteRect() | The part of the image the Gob shows {x,y,w,h}, or null for the whole image. AnimGob: the current clip. | |
public boolean takesPartInCollisions() | Does the CollisionManager test this Gob? Yes if it follows a Spline with COLLIDE_AT_END (the spline end mode) OR it has the GOB_COLLISION_OUTLINE flag (the Gob flag). The two are independent: COLLIDE_AT_END alone uses a hand set outline or the bounding box; GOB_COLLISION_OUTLINE alone (no Spline needed, a stationary Gob will do) additionally traces the outline from the image. | |
public String toString() | 5 statement(s); calls Binary.toString(). | |
int traceRect(Image im, int gx, int gy, int gw, int gh, int[][] out) | Trace the opaque outline of the rectangle gx,gy,gw,gh of image im (gw < 0: the whole image). Returns 0 = not loaded yet (ask again next frame), 1 = polygon in out[0] (x) / out[1] (y), in this Gob's base pixels (0,0 = top left pixel of the widthBase x heightBase picture), 2 = nothing opaque / unreadable. | |
public void zENA() | 1 statement(s). | |
private double zForSize() | No comment in source. | |
public void zOff() | 1 statement(s). | |
static { … } | Implicit default constructor generated by the compiler (not written in the source). |
Fields: attachment, index, linkFlags, name, next, parentList, prev
Methods: inList(), setName(String)
instantiation — MegaMooV.java, line 87
87 new Gob(curView,"ea2.gif",46,47,sp2,0);
subclass — AnimGob.java, line 6
6 public class AnimGob extends Gob implements AnimationConstants, HyperConstants
7 {
declaration — Abort.java, line 8
8 Gob destroyGob;