Package: com.multiversesocial.hyperview
Class: com.multiversesocial.hyperview.Gob
Source: src/com/multiversesocial/hyperview/Gob.java

Gob

HyperView V3.2 — class
version V3.2 class

Summary

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.

V3.23: rotation, physics and picking

Source file: Gob.java

Hierarchy

Extends: Linkable

Implements: HyperConstants, TextConstants

Referenced HyperView classes

Media files used

Following a Spline (V3.2): attach / detach, floating point position

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.

Collision outline & flags (COLLIDE_AT_END, GOB_COLLISION_OUTLINE)

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.

Declaration & members

public class Gob extends Linkable implements HyperConstants, TextConstants

Declared in src/com/multiversesocial/hyperview/Gob.java, lines 1–2248. 153 field(s), 15 constructor(s), 119 method(s). Every member has an anchor you can link to (e.g. Gob.html#<id>).

Fields (153)

DeclarationValue / initializerDescriptionSource
volatile double anglerotation, RADIANS, positive = clockwise on the screen; 0 = the unrotated fast pathline 175
Graphics asynchGraphics1No comment in source; used in cleanUp().line 45
Graphics asynchGraphics2No comment in source; used in cleanUp().line 48
Image asynchImage1For double buffered external input.line 44
Image asynchImage2For double buffered external input.line 47
Gob[] attachedGobNo comment in source; assigned in Gob(), addGob(); used in moveNext().line 57
int attachedIndexNo comment in source; assigned in Gob(), cleanUp().line 54
Image backGroundNo comment in source; used in cleanUp().line 50
volatile MemoryImageSource bgMemoryImageSourceNo comment in source; assigned in Gob().line 64
int bGPenNo comment in source; assigned in Gob().line 67
int bottomMaxNo comment in source; assigned in Gob().line 86
int boundX1Bounding box of the world outline, inclusive (boundX1, boundY1, boundX2, boundY2): the cheap reject test of the collision pass.line 151
int boundX2Right edge of the bounding box (see boundX1).line 151
int boundY1Top of the bounding box (see boundX1).line 151
int boundY2Bottom of the bounding box (see boundX1).line 151
volatile int clickXIf onClick() enabled where it was clicked online 130
volatile int clickYIf onClick() enabled where it was clicked online 130
Gob collidedWithThe other Gob of the most recent new contact (stays after the two separate). Read with getCollidedWith().line 153
int collisionClassMaskNo comment in source; assigned in initScanline().line 133
int collisionCountNumber of separate contacts this Gob has had (not frames: a long touch counts once). Read with getCollisionCount().line 152
int collisionTickIncremented once per collision pass this Gob takes part in.line 158
int collisionXContact point of the latest contact in screen pixels, updated while the Gobs touch (collisionX, collisionY).line 154
int collisionYy of the contact point (see collisionX).line 154
Gob[] contactGobCollisionManager bookkeeping: Gobs touched in recent frames, to tell a new contact from a continuing one.line 155
int contactNEntries in use in contactGob / contactTick.line 157
int[] contactTickFor each contactGob entry: the other Gob’s collisionTick when last seen.line 156
int curAttachedNo comment in source; assigned in Gob(), cleanUp().line 55
int currentZIndexNo comment in source; assigned in Gob().line 71
volatile HyperView curViewNo comment in source; assigned in Gob(), move(); used in printGobAttr(), addSpline(), inView(), onDisplay(), onClick() ….line 36
float damageFactor= 1.0fmultiplies the impact energy that becomes damageline 194
public static int defaultRotateInterpolation= ROTATE_BILINEARInterpolation new Gobs start with.line 173
int depthGranularity of zline 82
Gob destGobNo comment in source; assigned in cleanUp(); used in center(), toString().line 60
Graphics destGraphicsNo comment in source; assigned in Gob(), cleanUp().line 61
int dispatchHoldCountNo comment in source; assigned in Gob().line 128
int drawModeNo comment in source; assigned in Gob().line 68
int dXNo comment in source; assigned in Gob(); used in printGobAttr().line 112
int dYDelta for movmentline 113
int dZNo comment in source; assigned in Gob(); used in printGobAttr().line 114
boolean explodedhit points ran out; the Gob is exploding / removedline 202
volatile MemoryImageSource fgMemoryImageSourceNo comment in source; assigned in Gob().line 63
int fGPenNo comment in source; assigned in Gob().line 66
double fxV2.43 V3.2 floating point position (a Spline writes these; x,y,z are them rounded)line 74
double fyexact position, top left, in pixels; x = round(fx) while a Spline drives the Gobline 75
double fzNo comment in source.line 76
int gobEventFlagsNo comment in source; assigned in Gob().line 126
volatile int gobFlags2No comment in source; assigned in Gob(), remove(), remGob(); used in isMemoryImageSource(), toString().line 125
volatile int gobFlagsNo comment in source; assigned in Gob(), remove(), addSpline(), zENA(), zOff() …; used in center(), toString().line 124
int gobGadIndexNo comment in source; assigned in Gob().line 129
int gobHxNo comment in source; assigned in Gob().line 107
int gobHyHome positionline 108
int gobHzNo comment in source; assigned in Gob().line 109
String gobNameNo comment in source; assigned in Gob(), cleanUp(); used in onRelease(), toString().line 69
int gobNumberindex in goblist #line 85
double gobOrbitDcright ascension / orbit angle (radians)line 120
int gobOrbitRadiusYelliptical Y radius (typically 78% of radius)line 117
int gobOrbitRadiusNo comment in source; assigned in Gob().line 116
double gobOrbitRacentidegrees per ~16ms tickline 119
int gobOrbitSpeedelliptical Y radius (typically 78% of radius)line 118
Image gobPicCurrent Reference.line 39
int gobTypeFlagsNo comment in source; assigned in Gob().line 127
Graphics graphicsNo comment in source; assigned in Gob(); used in getGraphics(), cleanUp().line 40
int gravityNo comment in source; assigned in Gob().line 111
boolean haltedRESPONSE_STOP has stopped it: v = 0, immovable until setVelocity()line 200
int heightBaseActual height of iamgeline 84
int heightNo comment in source; assigned in Gob(), gobZInit(); used in printGobAttr(), addSpline(), center(), isInView(), initScanline() ….line 81
float hitPointscurrent hit points (only used when maxHitPoints > 0)line 190
double hSinSin of height relative to zline 78
double hypHypotenues of Sinline 79
boolean imageOutlineDoneV3.2: outlineX/Y were traced from the image (GOB_COLLISION_OUTLINE), not set by handline 136
int imageOutlineRawV3.2: the image outline was tried (success, nothing opaque, or not possible): do not retryline 137
int impactCountimpacts that were resolved by the physics responseline 217
String infoStringNo comment in source; assigned in Gob(), cleanUp().line 70
boolean integrate= truetrue: the collision pass moves the Gob by vx,vy; false: the application moves itline 196
double kvxvelocity measured from the position change per pass (Spline driven or kinematic Gob)line 209
double kvyvelocity measured from the position change per pass (Spline driven or kinematic Gob)line 209
float lastImpactEnergy0.5 * reduced mass * speed^2 of that impactline 213
Gob lastImpactFromthe Gob that caused itline 215
float lastImpactSpeedclosing speed of the last impact that hurt / bounced this Gob (pixels per step)line 211
boolean lastPValidNo comment in source.line 205
double lastPXposition at the previous collision pass (velocity of a Spline / application driven Gob)line 204
double lastPYposition at the previous collision pass (velocity of a Spline / application driven Gob)line 204
volatile int lClickXNo comment in source; assigned in Gob().line 131
volatile int lClickYNo comment in source; assigned in Gob().line 131
int leftMinNo comment in source; assigned in Gob().line 88
float mass> 0 makes the Gob physical (with a response other than RESPONSE_NONE)line 180
int maxAttachedChange to suit your needs.line 53
float maxHitPoints0 = indestructible (the default)line 192
static volatile int memoryCounter= 0No comment in source; not referenced by name in this type’s methods.line 37
volatile int moveNumNo comment in source; assigned in Gob().line 102
int[] mX2No comment in source; assigned in Gob(), cleanUp().line 99
int[] mXMultiple background update list/ MouseHandler event stack.line 98
int[] mY2No comment in source; assigned in Gob(), cleanUp().line 101
int[] mYNo comment in source; assigned in Gob(), cleanUp().line 100
int oldXNo comment in source; assigned in Gob().line 90
int oldYFor BackGround Restoreline 91
int oldZNo comment in source; assigned in Gob().line 92
double orbitFcxdeclination / tilt (radians)line 121
double orbitFcyfloat center X (subpixel)line 122
Gob orbitGobNo comment in source; assigned in cleanUp().line 115
int orbitStampfloat center Y (subpixel)line 123
public static int outlineAlphaMin= OutlineTracer.DEFAULT_ALPHAV3.2: image outlines computed in this JVM (proof of the flag gate)line 142
public static volatile int outlineComputeCount= 0V3.2: boundary pixels traced before simplification (information)line 139
public static double outlineEpsilon= OutlineTracer.DEFAULT_EPSILONalpha >= this is opaqueline 143
boolean outlineFromImageCollision outline + flags (COLLIDE_AT_END, see CollisionManager)line 135
public static int outlineMaxPoints= OutlineTracer.DEFAULT_MAX_POINTSDouglas-Peucker tolerance, pixelsline 144
int outlineNNumber of vertices set with setOutline(); 0 = no outline set, the default (bounding box) is used.line 145
public static volatile int outlineRebuildCount= 0Number of times the collision pass (re)built a traced outline in this JVM (a test reads it).line 1557
boolean outlineSrcSetV3.22: the image the current outline was traced from (identity: a new image rebuilds it)line 141
Image outlineSrcV3.2: image outlines computed in this JVM (proof of the flag gate)line 140
int[] outlineXOutline vertices in image pixels (0,0 = top left pixel of the widthBase x heightBase image); copied by setOutline().line 146
int[] outlineYy values of the outline vertices (see outlineX).line 147
boolean physicsOwnedphysics drives the position; a Spline attached to the Gob is paused (not stepped)line 198
boolean pickable= trueHyperView.pickGob may return itline 219
boolean pickAlpha= truewith GOB_COLLISION_OUTLINE: click through transparent pixels, not only outside the contourline 221
int pickMaskHNo comment in source.line 224
int pickMaskKey= -1No comment in source.line 226
Image pickMaskSrcNo comment in source.line 225
int pickMaskWNo comment in source.line 224
boolean[] pickMaskopaque pixels of the sprite (clip), built on the first alpha pickline 223
public static final int RESPONSE_BOUNCE= 1 (constant)Contact response: bounce (impulse with the restitution; momentum is conserved between two moving Gobs).line 169
public static final int RESPONSE_NONE= 0 (constant)Contact response: none. The Gob only gets the V3.22 flags / counters (the old behaviour).line 167
public static final int RESPONSE_STOP= 2 (constant)Contact response: stop ("ball in sand"): the Gob halts where it touches and stays there.line 171
int responseRESPONSE_NONE (default), RESPONSE_BOUNCE, RESPONSE_STOPline 188
float restitution= 1.0f1 = elastic, 0 = inelastic (no rebound)line 186
int rightMaxNo comment in source; assigned in Gob().line 89
public static final int ROTATE_BILINEAR= 1 (constant)Rotation interpolation: bilinear (smooth edges, alpha blended). The default.line 165
public static final int ROTATE_NEAREST= 0 (constant)Rotation interpolation: nearest neighbour pixel (sharp, fast).line 163
int rotateInterpolation= defaultRotateInterpolationNo comment in source.line 176
Scanline[] scanLineNo comment in source; assigned in initScanline(); used in printScanLines().line 58
Graphics selectGraphicsNo comment in source; assigned in Gob(); used in cleanUp().line 42
Image selectImageNo comment in source; assigned in Gob(); used in cleanUp().line 41
volatile long selectTimeNo comment in source; name appears in 2 other source file(s): HyperMouse, HyperView.line 159
float spinradians per physics step added to angle by the collision pass (physics Gobs)line 178
boolean splineMeasuredthe velocity was measured from a Spline driven position at the previous passline 207
Spline splineNo comment in source; assigned in Gob(), addSpline(); used in cleanUp().line 72
int tintNo comment in source; assigned in Gob().line 132
int topMinNo comment in source; assigned in Gob().line 87
int totalAttachedTotal number of Gobs attachedline 52
int traceRawV3.2: boundary pixels traced before simplification (information)line 138
float vxvelocity, pixels per physics step (= per display frame by default)line 182
float vyvertical velocity, pixels per physics step (see vx)line 184
int widthBaseActual width of imageline 83
int widthNo comment in source; assigned in Gob(), gobZInit(); used in printGobAttr(), addSpline(), center(), isInView(), initScanline() ….line 80
int worldNNumber of valid vertices in worldX / worldY.line 150
int[] worldXThe outline at the Gob’s current position and size (screen pixels), rebuilt by CollisionManager.updateOutline() every display frame; reused, not reallocated per frame.line 148
int[] worldYy values of worldX.line 149
double wSinSin of width relative to zline 77
int x2No comment in source; assigned in Gob(), center().line 104
int xNo comment in source; assigned in Gob(), center(); used in printGobAttr(), inView(), onDisplay(), isInView(), toString().line 94
int y2No comment in source; assigned in Gob(), center().line 105
int yCurrent Positionline 95
int zNo comment in source; assigned in Gob(), gobZInit(), initScanline(), printScanLines(); used in printGobAttr(), toString().line 96

Constructors (15)

SignatureDescriptionSource
Gob()1 statement(s); calls super().line 252
Gob(Gob tGob, String tName, int tFlags)Target Gob, Name, etcline 263
Gob(Gob tGob, String tName, int tX, int tY, int tFlags)4 statement(s); calls this().line 288
Gob(Gob tGob, String tName, int tX, int tY, int pX, int pY, Spline tSpline, int tFlags)10 statement(s); calls this(), gobZInit().line 268
Gob(Gob tGob, String tName, int tWidth, int tHeight, int pX, int pY, int tFlags)2 statement(s); calls this(), move().line 281
Gob(HyperView tView, MemoryImageSource tMemoryImageSource, int tWidth, int tHeight, int tFlags)1 statement(s); calls this().line 339
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.line 366
Gob(HyperView tView, String tName, int tFlags)1 statement(s); calls this().line 258
Gob(HyperView tView, String tName, int sx, int sy, Spline tSpline, int tFlags)11 statement(s); calls this(), gobZInit().line 554
Gob(HyperView tView, String tName, int tWidth, int tHeight, int tFlags)1 statement(s); calls this().line 360
Gob(HyperView tView, String tName, int tX, int tY, int pX, int pY)1 statement(s); calls this().line 275
Gob(HyperView tView, String tName, int sx, int sy, int pX, int pY, int tFlags)2 statement(s); calls this(), move().line 328
Gob(HyperView tView, int[] tData, int tWidth, int tHeight, int tFlags)1 statement(s); calls this(); creates MemoryImageSource.line 334
Gob(ViewMain tViewMain, String tName, int sx, int sy, int pX, int pY, int tFlags)2 statement(s); calls this(), move().line 322
Gob(ViewMain tViewMain, int sx, int sy, int pX, int pY, int tFlags)2 statement(s); calls this(), move().line 316

Methods (119)

SignatureDescriptionSource
public void addGob(Gob tGob)4 statement(s).line 864
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.line 724
public void addSpline(Spline tSpline)6 statement(s); calls gobZInit().line 569
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.line 590
public void center()3 statement(s).line 1018
public void cleanUp()15 statement(s); calls gobPic.flush(), graphics.dispose(), selectImage.flush(), selectGraphics.dispose(), asynchImage1.flush() ….line 1069
public void clearCollision()Forgets the contacts: count 0, no collidedWith, GOB_COLLIDED off.line 1797
private void clearImageOutlineQuiet()No comment in source.line 1700
public void clearOutline()Back to the default outline: the bounding box x,y .. x+width-1,y+height-1.line 1743
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.line 1342
public void collisionOff()1 statement(s).line 1331
public void collisionOn()1 statement(s).line 1326
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).line 1432
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.line 2121
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.line 2071
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.line 658
public void disable()1 statement(s).line 891
private boolean doImageOutline(boolean wait)No comment in source.line 1450
public int drawHeight()See drawWidth().line 1684
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.line 1871
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.line 1673
public void enable()1 statement(s).line 787
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.line 1564
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).line 1442
public void explode()Explode now: onExplode(), then (unless it handled it) the CollisionAnimGob and removal.line 2081
public double getAngleDegrees()No comment in source.line 1832
public double getAngle()The rotation in radians.line 1821
public Gob getCollidedWith()The Gob of the latest new contact, or null.line 1791
public int getCollisionCount()Number of separate contacts so far.line 1785
public double getDamageFactor()No comment in source.line 2059
public double getFloatX()Exact x of the top left corner (equals x until a Spline moves the Gob in sub pixel steps).line 700
public double getFloatY()Exact y of the top left corner.line 706
public double getFloatZ()Exact z.line 712
public Graphics getGraphics()Returns graphics.line 836
public double getHitPoints()No comment in source.line 2043
public Image getImageFromJar(String fileName)4 statement(s); calls HyperView.resolveResourceURLStatic(), curView.getAppletContext().getImage(), curView.getAppletContext(), curView.hyperViewOut().line 1043
public int getImageOutlineRawPoints()Boundary pixels the last image trace of this Gob found before simplification (0 if none).line 1414
public int getImpactCount()No comment in source.line 2108
public double getLastImpactEnergy()The impact energy / speed of the last physical impact (see CollisionManager).line 2098
public Gob getLastImpactFrom()No comment in source.line 2113
public double getLastImpactSpeed()No comment in source.line 2103
public double getMass()No comment in source.line 1961
public double getMaxHitPoints()No comment in source.line 2048
public static int getOutlineComputeCount()How many image outlines were computed in this JVM (all Gobs). Gobs without the flag never add to it.line 1420
public Polygon getOutline()The outline in image pixels (a copy). Default: a new Polygon of the box 0,0 .. widthBase-1,heightBase-1.line 1761
int[] getPixels()6 statement(s); calls pixelGrabber.grabPixels(), pixelGrabber.getStatus(); creates PixelGrabber.line 1291
public int getResponse()No comment in source.line 1981
public double getRestitution()No comment in source.line 1971
public int getRotateInterpolation()No comment in source.line 1849
public double getSpin()No comment in source.line 1860
public Spline getSpline()The Spline this Gob follows, or null.line 648
public double getVelocityX()No comment in source.line 1999
public double getVelocityY()No comment in source.line 2004
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).line 1771
public void gobZInit()14 statement(s); calls Math.sqrt().line 792
public boolean hasImageOutline()True if the current outline was traced from the image (false: hand set, or the bounding box).line 1393
public boolean hasOutline()True if setOutline() gave this Gob its own outline (outlineN >= 3).line 1755
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.line 1145
public void invalidateImageOutline()Forget the traced outline and trace again the next time it is needed (a new image, a changed alpha threshold).line 1399
public boolean inView()2 statement(s).line 765
public boolean isCollided()True while this Gob overlaps another COLLIDE_AT_END Gob: tests GOB_COLLIDED, which the pass sets and clears every frame.line 1779
public boolean isDynamic()True if the Gob is physical: mass > 0 and a response other than RESPONSE_NONE.line 1932
public boolean isExploded()True once the hit points ran out (the Gob exploded and is removed).line 2065
public boolean isHalted()RESPONSE_STOP has stopped the Gob.line 2030
public boolean isImageOutlineEnabled()True if this Gob has the GOB_COLLISION_OUTLINE flag (collision outline from the image).line 1349
boolean isInView()2 statement(s).line 1062
boolean isMemoryImageSource()Returns ((gobFlags2 & GOB_MEMORYIMAGESOURCE) != 0).line 717
public boolean isPhysicsOwned()The Spline is attached but paused because the physics moves the Gob.line 2024
public boolean isPickable()No comment in source.line 2132
public boolean isSelected()Is this the selected Gob of its view?line 2159
private void moveInt(int tX, int tY)No comment in source.line 913
public void moveNext()Advance along attached-gob chain if present.line 1313
public void move(Gadget tGadget, int tX, int tY)7 statement(s).line 969
public void move(int tX, int tY)8 statement(s); calls HyperView.getCurView().line 906
public void onClick()1 statement(s); calls curView.statusText().line 841
public void onDeselect()Called when it stopped being the selected Gob. Default: nothing.line 2154
public boolean onDisplay()3 statement(s).line 776
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.line 2092
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.line 2144
public void onRelease()1 statement(s); calls curView.statusText().line 846
public void onSelect()Called when the Gob became the selected Gob of its view (click, or HyperView.selectGob). Default: nothing.line 2149
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.line 2208
Image outlineImage()The image the outline is traced from (the sprite which is drawn). AnimGob: its strip.line 1551
private boolean[] pickMaskFor()the opaque mask of the sprite part: null while the image is not loaded or cannot be readline 2171
public void printGobAttr(HyperView curView)19 statement(s); calls curView.text().line 228
public void printScanLines()6 statement(s); calls initScanline().line 1259
void releaseSpline()STOP_AT_END reached (called by Spline.step): the Spline lets go, the Gob stays on the end point.line 669
public void remGob()Detach this gob from its view display list.line 854
public void remove()2 statement(s).line 562
public void resumeSpline()Hand control back to the Spline (it continues from its own distance; the Gob jumps to that point).line 2016
public void rotateBy(double radians)Turn by radians more (positive = clockwise).line 1838
static int roundPos(double v)No comment in source.line 674
public void setAngleDegrees(double degrees)Same in degrees.line 1827
public void setAngle(double radians)Set the rotation in radians (positive = clockwise on screen). Normalised to (-PI, PI]; a full turn is exactly 0.line 1815
public void setDamageFactor(double f)Scale of the damage this Gob takes from an impact (1 = the impact energy; 0 = takes none).line 2054
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.line 680
public void setFloatZ(double nz)Set the exact z; z is the rounded value, at least 1.line 691
public void setHitPoints(double max)Hit points: max > 0 makes the Gob destructible (hp = max). 0 or less = indestructible (the default).line 2036
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.line 1371
public void setMass(double tMass)No comment in source.line 1954
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).line 1718
public void setOutline(int[] xs, int[] ys, int n)Same with arrays; the first n vertices of xs[] / ys[] are copied.line 1727
public void setPhysicsMotion(boolean passMovesIt)true: the collision pass moves the Gob by its velocity (default); false: the application moves it.line 2010
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.line 1941
public void setPickable(boolean on)HyperView.pickGob() may return this Gob (default true).line 2127
public void setPickAlpha(boolean on)With GOB_COLLISION_OUTLINE: a pixel with alpha below outlineAlphaMin is not hit (default true). false: contour polygon only.line 2138
public void setResponse(int tResponse)No comment in source.line 1976
public void setRestitution(double r)No comment in source.line 1966
public void setRotateInterpolation(int mode)ROTATE_NEAREST or ROTATE_BILINEAR for this Gob's rotated drawing.line 1844
public void setSpin(double radiansPerStep)Spin: radians added to the angle per physics step by the collision pass (only Gobs the pass integrates).line 1855
public void setSpline(Spline s)Same as attachSpline(s).line 642
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).line 1990
int[] spriteRect()The part of the image the Gob shows {x,y,w,h}, or null for the whole image. AnimGob: the current clip.line 2165
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.line 1360
public String toString()5 statement(s); calls Binary.toString().
Overrides Object.toString()
line 2224
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.line 1610
public void zENA()1 statement(s).line 753
private double zForSize()No comment in source.line 1694
public void zOff()1 statement(s).line 758
static { … }Implicit default constructor generated by the compiler (not written in the source).implicit

Inherited members

Non-private members inherited from HyperView superclasses and not overridden or hidden here.

From Linkable (7 fields, 2 methods)

Fields: attachment, index, linkFlags, name, next, parentList, prev

Methods: inList(), setName(String)

Examples

Real usage taken from elsewhere in the HyperView 3.2 source (file and line shown; source path src/com/multiversesocial/hyperview/).

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;
Hits--