Class GameWgt

Contents

Understanding GameEngine Widgets
  GameWgt Data
Derived Classes
Widget Macros
Method Summary
  Useful Access
  Screen Access
  Others

Related Documents

The Itty Bitty GameEngine -- Overview
Your Own Java Game -- Step by step to build a simple "Pong" game
Converting Your Game to JavaScript -- What you need to know to run your game in a web browser
Class GameWgt -- The visual components of a GameEngine game (You are here)
Overriding GameEvent -- The programmatic components of a GameEngine game

Understanding GameEngine Widgets

The class GameWgt is responsible for drawing the game on the screen, which includes some small part of deciding where to do that drawing (but most of those decisions are made in your code in a subclass of GameEvent). GameWgt has eight different widget types defined, of which five are further refined in a subclass of GameWgt. However, all of the methods for these subclass widgets are defined (but possibly politely nonfunctional) in the base class, so it is not necessary for you to be concerned with directly accessing the derived classes or their methods. In fact, all the subclasses of GameWgt are privately embedded inside the code for the GameEngine class JavaGame, where they are rather hard to get to.

Mostly you will not be creating new widgets on the fly in your game, but rather you will define them in GameMaker (see "The Itty Bitty GameEngine"), and the GameEngine will set them up at the start of your game. Thereafter all you need to do is move them around (or change the velocity of the widgets that are defined to be already moving) and decide what to do if they bump into each other, and maybe change their size or color (if your game needs to do that). If you do need to create new widgets, you must be careful to connect them up correctly to the existing widget hierarchy, or they will not be visible or behave properly.

A widget has ten pieces of data that define its basic parameters for drawing: position, size and color, and some additional parameters for arranging its relationship with other widgets (parent and child widgets), plus some information particular to each widget. There are getter and setter methods for accessing these data, which you should try to use when you need to know or change the data during your game's play. The data elements are described next and the accessor methods later, in the Method Summary for this class.

The GameEngine itself uses some specific widgets to facilitate the game play; these are noted where relevant.

Two defined widget types are incomplete. Sprites mostly work, but there aren't any tools for giving them their full functionality. You can change a "Ball" tool diameter, but adding other shapes are not supported yet. The scrollbar is not working at all at this time. We hope to have some of these limitations working before the summer is over.
 

GameWgt Data

 
Name Type ...
RefNum int This the widget's unique reference number
Gtype int The widget's type, currently between 0..7 (see Derived Classes)
Gcolor int The widget's color, either 0x00RRGGBB or else -1 if none
Gtop int The vertical position of the top pixel in this widget, relative to the top-left corner of its parent
Gleft int The horizontal position of the top pixel in this widget, relative to the top-left corner of its parent
Gtall int The widget's height in pixels
Gwide int The widget's width in pixels
Ginfo int The value of this item differs for different widget types. See the Derived Classes for defined specifics.
Parent int The RefNum of the widget which includes this widget's RefNum in its Gdata, or else =0
Gdata int[] An optional array of integers, usually RefNums of child widgets, but for some widget types they are pixels or text (see the specific Derived Classes
Gselim int (Only in GameTxLn and GameScro widgets) another internal data value, a selection point in GameTxLn, and scroll limits in GameScro widgets.

 

Derived Classes

There are eight defined widget types, but types 0 (plain rectangle), 1 (pixel map), and 5 (group) are handled entirely by the base class. This is a complete list of the class names and widget types:
 
Class Name Gtype Function... Ginfo... Gdata...
GameWgt 0 Plain rectangle (none)
GameWgt 1 Pixel map (only used for whole game board at this time) Child The pixels
GameIcon 2 Single color shape up to 32 pixels tall and 64 or more pixels wide Animation The pixels
GameFont 3 Character shapes of a font (drawn as if a single frame of GameIcon) Selection The pixels
GameTxLn 4 A line of text Selection The text
GameWgt 5 Group head over multiple child widgets (ID) The children
GameSprit 6 Group head and velocity over the color layers of an animated sprite Velocity The children
GameScro 7 Group head over scrolled panel and scrollbars (TBD) Scroll limits The children

GameWgt

This is the base class, but among its methods are (non-functional) representative stand-ins for all the externally accessed methods of all the derived classes, so that you can depend on the built-in OOPS  mechanism to access the correct subclass widget instead of worrying about it in your own code.

No separate subclass is needed for types 1 and 5, because all of their methods make sense in the base class (except that the Gdata array is nominally null in the base class, but vigorously used in these other two types.

Drawing the widgets on the screen proceeds hierarchically from the game root pixel-map to the "[List of item lists]" it links to, and then recursively through each subwidget listed in the list's Gdata. This recursion stops for any widget that has no Parent, or that is outside its Parent rectangle, or whose Parent does not list it as a child. The parent's rectangle (if it has any color) is drawn first, then the child widgets on top of that background. Widgets not connected in this hierarchy are not drawn.

Collisions are tested only for sprites (GameSprit) that are listed as children of the first child in the "[List of item lists]" list, which is identified as "[Sprite list]" in the input widget list.
 

GameIcon

Icon widgets are distinguished from the pixel-map widget type in two ways. First, it is only a single color Gcolor, so its pixel map is one bit per pixel, either colored or transparent. Pixels are arranged vertically, a maximum of 32 pixels tall in a single integer, for as many integers in its Gdata array as the sprite is wide.

Then the icons are defined to be animated. The Ginfo value of this widget type is four numbers packed into a single 32-bit ingeter, as follows (reading high to low):

6 bits, The fractional frame rate, a fixed-point number with 4 fraction bits, that is, you should think of the 6-bit number as being divided by 16, so that a (binary) value 011000 (decimal 24) is actually 1.5 animation steps per frame. An internal counter counts the factional animation steps, and each time it crosses into the next integer value (like increasing from 1.99 to 2.00) the next step in the animation occurs. This way the animation can be as slow as once every 16 frames (about 1.6 seconds at the default frame rate of 10fps), or almost four steps per frame. Of course anything faster than one step per frame just skips animation steps. A zero fractional frame rate is not animated.

6 bits, the number of frames -1, so that zero represents one frame, and the maximum (binary) value 111111 (decimal 63) represents 64 frames in the animation loop. Zero (only one frame) is the same as not animated.

6 bits, the step size in Gdata, the number of integers to skip over when advancing the next animation step. Normally this is equal to the actual width of the icon, so that each animation step advances to the next full icon image in the array, but that is not a requirement. For example the rectangular "marching ants" icon consists of diagonal bars four pixels wide, and the animation step is one pixel, which in the case of a 1-pixel slice either vertical or horizontal, the ants appear to have shifted one pixel down or right. Zero step size is the same as not animated.

14 bits, an offset into the Gdata array, where the current pixels for this frame are displayed from. If you use all 64 steps in your animation, you are limited to images 8 pixels wide, or basically you have a maximum number of steps as 16384 divided by your icon width. These are icons (parts of sprites), not whole movies. A zero fractional frame rate or step size is not animated, but you can use different offsets to adjust the appearance of your icon.

The animation mechanism proceeds one calculation every display frame (icons that are off screen do not animate). The fractional frame rate is added to the internal counter for this icon, and if the result is one or more, the step size is subtracted from the current offset, and if that goes negative, it is restarted at the (number of frames -1) times the step size. If that is beyond the end of the array, then nothing is drawn. Checkboxes use this feature (with a fractional frame rate =0) to either show the checkmark or not.

You normally do not need to be concerned with the mechanics of animation, this is taken care of for you -- unless you want to do something tricky 


The first release of GameEngine supports only one icon, a solid circle in four diameters. Real Soon Now we hope to include an icon editor for you to make icons of your own choosing, and a full range of circles from 4-32 pixels in diameter.
 

GameFont

Text lines are displayed one character at a time, where each character is an "icon" in the GameFont table. Fonts are just like icons (GameFont is a subclass of GameIcon), except that they are not animated, and there is some extra code to calculate the character position and width of a particular glyph in the font table, and to (temporarily) set the parent structure of this font widget to wherever this character in the text line is supposed to be displayed.

When you Build your game, only the fonts actually used in your game will be loaded into the widget list. If you plan to change the font on the fly, be sure you have at least one (possibly invisible) GameTxLn that uses each desired font at Build time, or it will not be loaded into your game.

The pixel tables for the seven predefined fonts are included near the front of the JavaGame.java source code. The pixel table for a font has four header numbers, then (for proportional fonts) a character index, or else two more header numbers, followed by the glyph pixels in ASCII order. The first header number is a 4-letter name similar to the ID value that some group widgets use. The second number packs in three bytes (from the bottom up) the font ascent = the number of pixels from the base line to the top of the tallest character, then the descent = the number of pixels below the base line to the bottom of the deepest descender, then the line height in the upper half, which is usually the sum of the ascent+descent. The third number is the letter spacing in pixels, and the fourth is the width of the space character (which is the same for all the characters of the monospace font).

The proportional font glyph index entries are offsets into the pixels following, each the offset of the left edge of that glyph from the front of the table. Thus the character widths are the differences between index offsets of successive glyphs. The index is the offset (from the front of the array) of the leftmost pixels of the space character (which is always zero width), then continuing to the tilde '~' and ending with the table size = the right edge of the tilde. The index is always 96 entries, so the pixels of a proportional font always start at offset 100.

A monospaced font has the same four header numbers, then two more, the second giving the (fixed) character width, followed by the pixels starting at offset +6 (no index needed).
 

GameTxLn

Text lines are stored with the text characters packed four per integer in the Gdata array. They are displayed one character at a time, where each character is an "icon" in the GameFont table. Additional methods that only work for GameTxLn widgets get and set the text, and manage the blinking cursor.
 

GameSprit

A sprite is like a group with an (animated) velocity across the screen. The velocity is a pair of signed fixed-point fractional frame rates, each with eight bits of fraction, so that the sprite can move as slowly as one pixel every 256 frames, or with reasonable precision for diagonal motion. An internal counter is incremented by the fractional rate, and when its integer part changes, the position of the sprite is updated. The velocity value can be thought of as an integer divided by 256, so that an (integer) value of 85 (...001010101 in binary) represents 85/256 = 0.33. Negative velocities are up or left, positive down or right. The maximum positive velocity is 32767 (hexadecimal 7FFF), representing 127.99 pixels per frame, basically three or four flashes of your sprite across the screen, then it's gone.

The Gdata array of a sprite normally consists of layers of icons and rectangles and text items drawn in sequence on top of each other. Each layer has its own color, so a multi-colored sprite can be made up of several layers in their respective colors.

The first release of GameEngine supports only one sprite widget, a moving ball that you can set the velocity and diameter of. Real Soon Now we hope to include a full sprite editor so you can build up sprites from arbitrary icons and other widget types.
 

GameScro

Scrollbars are like a widget group, but with only two or three child widgets, first another group, the panel being scrolled, then the vertical and horizontal scrollbars, each another group of rectangles that the widget code has tied into the scroll position of the panel. This is not fully implemented at this time.
 

Widget Macros

There are numerous places in a GameEngine game where several similar complex objects are made up of individual widgets in a group that stays together. GameEngine uses macros to specify each kind of group, then a single line in the game specification can generate a whole bunch of widgets, and there are eight predefined macros in this initial version (more to be added later) which are described in the documentation for the JavaGame class. [Eventually you will also be able also to define your own macros, but probably not this year.]
 

Method Summary

These 20 methods get widget data:
 
AddPrntsPos GetInfo GetRtVelo GetTextWide
FindElemt GetIxData GetSelim GetType
GetColor GetParent GetSize GetVposn
GetDnVelo GetPosn GetTall GetWide
GetHposn GetRefNum GetTextLn IsVisible
These 26 methods set widget data, or do some kind of output:
 
AddElemt RadioBtn SetInfo SetVposn
CheckIt SetBlinker SetParent SetWgType
DeleElemt SetColor SetPosn SetWide
DrawMe SetDnVelo SetRtVelo SwapData
HideSho SetFlags SetSelim XchElemt
LogMe SetFocus SetSize
PutTextLn SetHposn SetTall
These three methods drive the screen pixel array:
 
SetMyScreen PokePixel RectFill

Useful Access (Getters)

int AddPrntsPos(int here)
 
Parameters
here The widget-relative offset (V<<16)+H in the parent widget 
Returns The packed window-relative offset (V<<16)+H 
Converts a packed position of this widget into an absolute window offset. The parameter here might come from the widget's GetPosn to get its absolute position in the window.


int FindElemt(int whom)
 
Parameters
whom the value to look for in Gdata
Returns the index position of the first such item found, or -1 
Search for a value in this widget's Gdata array. Returns the index position of the first such item found, or -1 if not there. You can use this method to find an element to delete, then pass its returned index to DeleElemt to delete it.


int GetColor()
 
Returns The specified color = Gcolor
Returns the specified color for this widget, = 0x00RRGGBB or -1 if none.


int GetInfo()
 
Returns The information value = Ginfo
Returns the information value for this widget. The meaning of this value is specific to different widget types, as shown in the subclass table.


int GetIxData(int here, int defalt)
 
Parameters
here The index 
defalt The value to return if Gdata[here] does not exist 
Returns The indexed value = Gdata[here], or else defalt if the Gdata does not exist, or here is outside its boundaries
Safely (no exceptions) returns an indexed value from this widget's Gdata, or else a specified default value if it doesn't exist.

Use an index here=-1 and a default value also defalt=-1 to safely get the array size, which will be >0 if the array exists, otherwise =-1.


int GetParent()
 
Returns The Parent
Returns the reference number of this widget's parent widget, or =0 if none is specified.


int GetPosn()
 
Returns The position = (Gtop<<16)+Gleft
Returns the position of this widget in its parent, packed into one integer, vertical into the high half, horizontal in the low half. Use (posn>>16) to extract the vertical component, and SignExtend(posn) extract the horizontal component.


int GetRefNum()
 
Returns The reference number = RefNum
Returns the unique reference number for this widget = its index in AllWgts[].


int GetSelim()
 
Returns The selection or scroll limits = Gselim
Returns the selection of a GameTxLn or scroll limits of a GameScro, otherwise 0. This method is defined in the base class so you don't need to bother with casting the GameWgt as a GameTxLn or GameScro when the override mechanism automatically does that for you.


int GetSize()
 
Returns The size = (Gtall<<16)+Gwide
Returns the size of this widget's containing rectangle, packed into one integer, vertical into the high half, horizontal in the low half. Use (size>>16) to extract the vertical component, and (size&0xFFFF) extract the horizontal component.


String GetTextLn()
 
Returns The text line = Gdata as a String
Returns the text line from a GameTxLn widget, otherwise the empty string "" (if this is called for some other widget type).


int GetTextWide()
 
Returns The width of the whole text line 
Returns the calculated pixel width of a GameTxLn widget's text, otherwise 0 (if this is called for some other widget type).


int GetType()
 
Returns The type = Gtype
Returns the type of this widget with its flags.


boolean IsVisible()
 
Returns true if the widget's rectangle is at least partly on-screen 
Return true if this widget's rectangle is at least partly on-screen. If the widget is not visible for other reasons, IsVisible might return a false positive.


Useful Access (Setters)

int AddElemt(int whom)
 
Parameters
whom the value to look for in Gdata
Returns the index position of the first such item found, or -1 
Insert a new value at the end of (the non-zero values in) this widget's Gdata. Returns the index position where it was inserted, or -1 if it failed. If Gdata is too small, it will be enlarged, but if it is null, AddElemt will fail. If it is already there, AddElemt simply returns its index (same as FindElemt).


boolean CheckIt(boolean tog)
 
Parameters
tog true toggles the checkmark, false leaves it unchanged 
Returns true if the checkmark is showing, false if not 
If this is a component of a checkbox created by the checkbox macro, CheckIt (optionally) toggles the checkmark and returns the new setting. This works for the containing group (which CheckIt searches its subwidgets for the actual checkmark icon) or for the checkmark icon itself, which is recognized by having the same first element as the default checkmark array. The checkmark is hidden by setting the pixel offset past the end of the actual checkmark pixels in its array.


void DeleElemt(int inx)
 
Parameters
inx the index position of the item to delete 
Delete a value in this widget's Gdata array given its index. The remaining items are shifted down to fill the gap, with zero-fill at the end. It is assumed that all the non-zero data is at the front, so a run of zeroes terminates the shifting down.


void DrawMe(int top, int left, int tall, int wide)
 
Parameters
top do not draw above this position 
left do not draw to the left of this position 
tall do not draw below this position +top
wide do not draw to the right of this position +left 
This draws the default widget on the window. Some subclasses override this to alter the appearance, or to draw some completely different representation of the data. The boundaries of a masking rectangle limit the drawing to (usually) the containing widget's dimensions.

The DrawMe method explicitly omits drawing any widget (and its child widgets) if it is outside the specified drawing rectangle, or if its parent hierarchy is incorrect.


void HideSho(boolean sho)
 
Parameters
sho true to show the widget, false to hide it 
Hide or show this widget by moving it off- or on-screen. This is done by adding or removing the 0x4000 bit in its vertical position, so if the widget is not visible for other reasons, calling HideSho(true) probably won't make it visible.


void LogMe(String before)
 
Parameters
before a prefix to add to the front of the line 
This prints a widget's display line in the console log.


int PutTextLn(String aLine)
 
Parameters
aLine The text to set Gdata to 
Set a GameTxLn's text in its Gdata array. This method is defined in the base class so you don't need to bother with casting the GameWgt as a GameTxLn when the override mechanism automatically does that for you.


int RadioBtn(int whom)
 
Parameters
whom the code to be set, 33..126, or else -1 to query 
Returns the current setting code, 33..126 
If this is a component of a radio button created by the radio button macro, RadioBtn either selects a new setting or returns the current setting. It is expected that this will be called for the containing group, and RadioBtn searches its subwidgets to find the one to select, and to deselect the others, by setting each icon widget to either show or hide the selection button. The icon widgets are recognized by having the same second element as the default radio button array.

Radio buttons are distinguished within a group by a single character (preferably a digit or letter) embedded in their information ID. If you call RadioBtn with a negative parameter, it will return the current setting character. If you call RadioBtn with (the ASCII value of) a character greater than space (and not greater than '~', that is 33..126) then it will search for the button with that ID and (if found) set it to selected, and all the others to deselected. If you call RadioBtn with a number 0..31, then it selects whichever button has the character '0'..'9' which is that single digit, or else the letter 'A'..'U' corresponding to the values 10..31 determined by adding 55 to the number given. If that's too confusing, just use the letters.

Internally, the icons show a hollow circle for deselected, and (later in the same Gdata array) a button image for selected, the offset into the array determines which is shown. Each button is a group over a white solid circle icon and the black selection button icon. The button group ID is the 4-character code "Rd_*" where the '*' is replaced by the selector character. The group ID over the set of radio buttons linked together is "RdB*" where again the '*' is replaced by whatever code has been selected, so that asking for the current setting requires no search. The searches and settings are recursive through RadioBtn.


void SetBlinker(boolean pix, int whar)
 
Parameters
pix true if the cursor position is a pixel offset 
whar The new cursor position as a pixel or character offset 
Set the cursor in a GameTxLn's text, either as a pixel offset, or else as calculated from a character offset. This method is defined in the base class so you don't need to bother with casting the GameWgt as a GameTxLn when the override mechanism automatically does that for you.


void SetColor(int color)
 
Parameters
color The color to set Gcolor to, <0 is no color
Set the Gcolor for this widget, = 0x00RRGGBB or -1 if none.


void SetFlags(int info)
 
Parameters
info The flag bits to set Gtype to 
Set the flag bits in this widget's Gtype. The type itself is unchanged. The flag bits are masked to 0x0000FF00. You can read out the current flag bits using GetType(). These are the defined bits:
+256: Collidable ("Bump"), must be set to get Collided events

+512: Type-able ("Key"), must be set to get any keyboard events

+1024: Clickable ("Click"), must be set to get ClickEvt events

+2048: Dragable ("Drag"), must be set to get MouseDn, MouseUp, or any drag events

+4096: Roll-able ("Roll"), must be set to get any rollover events

+8192: Refuse focus on this widget



boolean SetFocus(boolean nuly, int vert, int horz)
 
Parameters
nuly true to give focus, false to take it 
vert the vertical position of a mouse-click giving focus 
horz the horizontal position of the mouse-click 
Returns true if focus accepted, false if can't or losing it 
Give this widget focus, or else take focus away. A widget that is not typeable, clickable, or dragable cannot accept focus. A GameScro widget never accepts focus. A GameTxLn widget uses the coordinates to set the insertion point (blinking cursor) if it can accept keystrokes.


void SetInfo(int info)
 
Parameters
info The information value to set Ginfo to 
Set the information value of this widget's Ginfo, and clear the animation bits in Gtype. The animated widgets GameIcon and GameSprit use the upper half of Gtype to count partial frame rates, but changing Ginfo could invalidate current animation parameters, so clearing those bits forces a restart at its beginning.


void SetParent(int whom)
 
Parameters
whom The RefNum to set Parent to, 0 is none 
Set the Parent for this widget. It should be a valid RefNum of some other widget, or else zero.


void SetPosn(int top, int left)
 
Parameters
top the new top
left the new left edge 
Set the position of the top-left corner of this widget's containing rectangle. If you specify left=0 and top is a packed position (such as returned from GetPosn) but >= 0x10000, then it will use that packed position. If you want to use this shortcut to set a position that might be on the top row of its parent, you can pass it (posn|0x20000000) and the extra high bit will be removed on the way in.


void SetSelim(int whar)
 
Parameters
whar The new selection or scroll limits for Gselim
Set the selection of a of a GameTxLn or scroll limits of a GameScro. This method is defined in the base class so you don't need to bother with casting the GameWgt as a GameTxLn or GameScro when the override mechanism automatically does that for you.


void SetSize(int tall, int wide)
 
Parameters
tall the new height 
wide the new width 
Set the dimensions of this widget's containing rectangle. The specified dimensions must be >0, but if you specify tall=0, it will preserve the previous height and change only the width. If you specify wide=0 and tall is a packed size (such as returned from GetSize) then it will use that packed size. The size of the game window (that is, if RefNum=0 in this widget) are also captured locally for future use.


void SetWgType(int info)
 
Parameters
info The type number to set Gtype to 
Set the of this widget, but only if previously undefined = -1. This can only be called once, when the widget is created, otherwise it has no effect.


int[] SwapData(int[] data)
 
Parameters
data the new array for Gdata
Returns the array previously in Gdata
Exchange this widget's Gdata array for a new array. To capture a reference to the array without changing it, call the method twice:
data = SwapData(null);        // gets data, replaces it with null
if (SwapData(data)==null) {} // puts data back, ignores returned null



void XchElemt(int inx)
 
Parameters
inx the index position of the first of the two items
Exchange two adjacent values in this widget's Gdata array given the index. The remaining items are not affected. Zeroes can only be moved up, not down.


double GetDnVelo()
 
Returns The high 16 bits of the information value Ginfo
If this is a sprite, returns its vertical velocity (positive is down) as a (double) number of pixels per frame.


double GetRtVelo()
 
Returns The low 16 bits of the information value Ginfo
If this is a sprite, returns its horizontal velocity (negative is left) as a (double) number of pixels per frame.


void SetDnVelo(double velo)
 
Parameters
velothe new vertical velocity
If this is a sprite, sets its vertical velocity (positive is down) as a (double) number of pixels per frame. The internal representation is fixed-point, so any velocity smaller than 0.0025 pixels per frame is effectively zero, and larger than 127.99 is clipped to that value.


void SetRtVelo(double velo)
 
Parameters
velothe new horizontal velocity
If this is a sprite, sets its horizontal velocity (negative is left) as a (double) number of pixels per frame. The internal representation is fixed-point, so any velocity smaller than 0.0025 pixels per frame is effectively zero, and larger than 127.99 is clipped to that value.


void SetHposn(int horz)
 
Parameters
horzthe new horizontal position
Sets the horizontal position of this widget = its leftmost pixel column.


void SetVposn(int vert)
 
Parameters
vertthe new vertical position
Sets the vertical position of this widget = its top pixel row.


int GetHposn()
 
Returns The horizontal position = Gleft
Returns the horizontal position of this widget = its leftmost pixel column.


int GetVposn()
 
Returns The vertical position = Gtop
Returns the vertical position of this widget = its top pixel row.


int GetTall()
 
Returns The height = Gtall
Returns the height of this widget.


int GetWide()
 
Returns The width = Gwide
Returns the width of this widget.


void SetTall(int tall)
 
Parameters
tallthe new height, if greater than 0
Sets the height of this widget.


void SetWide(int wide)
 
Parameters
widethe new width, if greater than 0
Sets the width of this widget.


Screen Access

The drawing mechanism used in GameEngine was originally conceived as a separate class, but it is only used here in the GameWgt class and its subclasses, it has been included. Normally you have no need to do any drawing on the screen, the defined widgets do all that for you.

Java has defined a variety of high-level drawing methods, and in most Java programs you should use them. However, because this is a beginning programming course, and because some people -- we hope that includes you -- want to see how the underlying mechanism works, I have exposed all the drawing machinery for your inspection and enlightenment.
 

static int[] GetMyScreen()
 
Returns The current pixel array 
Gets the graphics pixel buffer as an integer array (to save & restore). Not used in GameEngine.


static int GetScreenDims()
 
Returns Packed integer, tall<<16 + wide 
Gets the graphics pixel buffer dimensions packed into a single integer (to save & restore). Not used in GameEngine.


static void PokePixel(int colo, int rx, int cx)
 
Parameters
colo The color to go in that position, = 0x00RRGGBB
rx The pixel row 
cx The pixel column 
Sets the pixel at the specified row and column to the given color.


static void RectFill(int colo, int rx, int cx, int rz, int cz)
 
Parameters
colo The pixel color to fill that rectangle, = 0x00RRGGBB 
rx The pixel row in one corner 
cx The pixel column in the same corner 
rz The pixel row in the other corner (inclusive) 
cz The pixel column there 
Sets a whole rectangle of pixels to a single color, from one corner of the rectangle in pixel coordinates, to the opposite corner. To draw a horizontal line, use the same value for rx=rz; to draw a vertical line, use the same value for cx=cz.


static void SetMyScreen(int[] theAry, int tall, int wide)
 
Parameters
theAry The pixel array, at least tall*wide in length 
tall The number of pixel rows 
wide The number of pixel columns 
Sets the graphics pixel buffer to the client's array, and saves the dimensions for range-testing and index calculation in the drawing methods.


Others

These are internal methods that you normally would not be calling directly. The discussion is included here for completeness.
 
String FixHaff(String before, int whom)
 
Parameters
before a prefix to add to the front 
whom the value with an 8-bit fractional part 
Returns the composite display value 
This is an internal utility for formatting a fixed-point animation value as a string for display purposes.


String FmtFront(String before, boolean dimz, String after)
 
Parameters
before a prefix to add to the front 
dimz true to show also the widget's size 
after a suffix to add to the end 
Returns the composite display value 
This is an internal utility for formatting the front part of a widget's display line in LogMe. The prefix and suffix make building display lines simpler.


String FmtInfo(String before, int tye)
 
Parameters
before a prefix to add to the front 
tye the widget's type 
Returns the composite display value 
This is an internal utility for formatting a widget's information value Ginfo. Some subclasses override this to get different formatting.


int GetAnimBits()
 
Returns The animation bits = Gtype>>16
Returns the animation bits stored in the upper half of Gtype.


String GetIDtxt()
 
Returns The 3- or 4-character ID code 
Return the information value Ginfo of this widget as a String, or else "" if not a valid string.


boolean IsValidIDtxt()
 
Returns true if this has a credible 3- or 4-character ID code 
Test the information value Ginfo of this widget and return true if it is a credible 3- or 4-character ID code, false if not. 3-character ID codes are not used in JavaGame, but if they were, they must begin with a letter. 4-character ID codes must be all ASCII characters in the range '!'..'~'. JavaGame uses only letters.


String toStrMash(String msg, String whom)
 
Parameters
msg a partial result to find the RefNum in
whom a prefix to replace the front of msg, or else alone with RefNum
Returns the composite display value 
This is an internal utility for generating the result that a toString call to a subclass of GameWgt returns. If the parameter msg contains a formatted RefNum, this replaces its prefix; otherwise it returns the stated prefix with the widget's RefNum.


String toString()
 
Returns The reference String for this widget 
Return the class name and RefNum for this widget, plus its ID code if any.



 

Rev. 2020 November 14