Hacktendo API

Hacktendo has a complex API that we are going to work on flushing out better as we go along, talking with other players as they attempt to make games will probably also be very helpful. Also keep in mind we do report compiler errors and some other bugs to the actual Java console output, if you're in on the fairly early beta, you should make sure you open up your Java Console and keep an eye out for Hacktendo related errors.

Depricated: Using setViewportX() and setViewportY() seems to work better.

setXSpeed(int speed)
Sets the scroll speed of the game window in the x direction, used for smooth scrolling transitions.

Depricated: Using setViewportX() and setViewportY() seems to work better.

setYSpeed(int speed):
Sets the scroll speed of the game window in the y direction, used for smooth scrolling transitions.

You can setup and check timestamps to use an actual timing mechanism for sprite movement, etc

deleteTimeStamp("key"):
Deletes a time stamp.

checkTimeStamp("key"):
Returns the time in milliseconds that has passed since the creation of the time stamp associated with the key.

createTimeStamp("key"):
Creates a timer and associates it with the key.

Functions that don't provide the ID assume that the script associated with the sprite running the given script is the target. Most sprite getters and setters have these two types of methods.

getX(int id) or getX()
Returns x position of sprite associated with ID.

getY(int id) or getY()
Returns y position of sprite associated with ID.

getZ(int id) or getZ()
Returns z position of sprite associated with ID. [0,1,2] 0 being the farthest back layer. This determines drawing order.

getFrame(int id) or getFrame()
Returns the current cell of the sprite being rendered [0-7]. Each sprite has eight animation cells, get and set frame can be used to create animation effects.

getImage(int id) or getImage()
Returns the current 8 cell image associated with the sprite. It is possible to change the sprites image and script, allowing you to create fairly complex sprites.

getScript(int id) or getScript()
Returns the current script ID associated with the sprite.

setX(int id,int x) or setX(int x)
Sets the current x position of a sprite, in world coordinates.

setY(int id,int y) or setX(int y)
Sets the current y position of a sprite.

setZ(int id,int z) or setX(int z)
Sets the current z position of a sprite. [0,1,2]

setFrame(int id,int frame) or setFrame(int frame)
Sets the current animation frame of the sprite [0-7]

setImage(int id,int image) or setImage(int image)
Set the current 8 frame image associated with the sprite.

setScript(int id,int scriptID) or setScript(int scriptID)
Sets the script currently associated with a given sprite.

setWidth(int id,int width) or setWidth(int width)
Sets the width of the sprite, used by the collision handling system.

setHeight(int id,int height) or setHeight(int height)
Sets the height of the sprite, used by the collision handling system.

setCollisionType(int id,int type) or setCollisionType(int type);
Sets the type used by the collision system. 0: Pixel Based 1: Rectangular.

setGlobal("key",[int,string,float,boolean])
Sets a global variable that can be accessed from any script via the key.

getGlobal("key")
Returns the global variable associated with the key.

setLocal("key",[int,string,float,boolean])
Sets a local variable that can be accessed from any script via the key.

getLocal("key")
Returns the local variable associated with the key. Each sprite can keep track of their own variables.

boolean isGlobalSet(String key)
Returns whether the global variable represented by key has been set or not.

boolean isLocalSet(String key) or isLocalSet(int spriteID,String key)
Returns whether the local variable represented by key has been set or not.

Keyboard events come in the form of lists that you should iterate through using a loop, this way if more than one key is pressed at a time, things are cool.

getKeyUpCount()
Returns the number of keys that a player has stopped pressing down since the last time the key handler was accessed.

getKeyDownCount()
Returns the number of keys that a player has pressed down since the last time the key handler was accessed.

int getNextKeyUp()
Returns the integer value of a key recently depressed by a player... this removes it from the queue (e.g, you should do key handling in one location).

int getNextKeyDown()
Returns the integer value of a key currently being pressed by a player... this removes it from the queue (e.g, you should do key handling in one location).

You can send messages between sprites much like a key event message. Iterate through a sprite's messages to get all of them.

messageSprite(int spriteID,String flag,Object message)
Messages a sprite referenced by id with a flag and value.

int getMessageCount()
returns the number of messages received.

int getCollidedCount()
returns the number of collsions since last frame.

String getFlag()
Returns the flag for the current message.

Object getMessage()
Returns the current message.

nextMessage()
Moves message queue to next message.

int createSprite(int imageID,int scriptID,int x,int y,int z)
Returns the sprites ID.

destroySprite() or destroySprite(int spriteID)
Destroys the sprite.

int getID()
returns the sprites id.

changeMap(int mapID,int scriptID)
Changes the map to the map in your resource handler indicated by mapID, and loads the script alluded to by scriptID.

setMusic(int musicID)
Changes the background music.

playSound(int soundID)
Plays the sound.

Collision also works based on an array. If something has hit one of your sprites it will be given the ID of the sprite that had collided with it, move through the list in a while loop to see everything it collided with.

nextCollided()
Moves to collision queue to the next collision.

int collidedWith()
Returns the sprite or tile ID of the object collided with.

int collidedType()
Returns the type collided with. 0 for a sprite, 1 for a tile.

save(String key,Object value)
creates a key-value pair to be saved in a save game file on players virtual HD.

load(String key)
Loads a value from a save game file on players virtual HD based off a key.

int getMapID()
Returns the current map id.

triggerWatch(String note)
Triggers a watch on makers computer based on the note of the watch. It triggers based on the note that you set on your watch.

boolean isPassable(int x,int y)
returns whether the tile at position (x,y) on map is passable or not.

setViewportX(int x)
Sets the map X value for display to screen.

int getViewportX()
Returns the current map X value for display to screen.

setViewportY(int y)
Sets the map Y value for display to screen.

int getViewportY()
Returns the current map Y value for display to screen.

Drawing primitives uses screen coordinates not world coordinates

drawRectangle(int x,int y,int width,int height,int red,int green,int blue,int alpha)
Draws a rectangle on the screen based on screen (x,y). Color values range from 0-255.

fillRectangle(int x,int y,int width,int height,int red,int green,int blue,int alpha)
Draws a filled rectangle on the screen based on screen (x,y). Color values range from 0-255.

drawText(String text,String font,int fontSize,int x,int y,int red,int green,int blue,int alpha)
Draws text on the screen based on screen (x,y). Color values range from 0-255.

drawLine(int x1,int y1,int x2,int y2,int red,int green,int blue,int alpha)
Draws a line on the screen based on screen (x,y). Color values range from 0-255.

drawOval(int x,int y,int width,int height,int red,int green,int blue,int alpha)
Draws an oval on the screen based on screen (x,y). Color values range from 0-255.

fillOval(int x,int y,int width,int height,int red,int green,int blue,int alpha)
Draws a filled oval on the screen based on screen (x,y). Color values range from 0-255.

drawArc(int x,int y,int width,int height,int red,int green,int blue,int alpha)
Draws an arc on the screen based on screen (x,y). Color values range from 0-255.

fillArc(int x,int y,int width,int height,int red,int green,int blue,int alpha)
Draws a filled arc on the screen based on screen (x,y). Color values range from 0-255.

debug(String message)
Sends a message to the Java terminal.

float sqrt(float value)
Returns the square root of value.

float abs(float value)
Returns the absolute value of value.

float tan(float angle)
Returns the tangent of the angle.

float cos(float angle)
Returns the cosine of the angle.

float sin(float angle)
Returns the sine of the angle.

float atan(float value)
Returns the arctangent of the value.

float acos(float value)
Returns the arc cosine of the value.

float asin(float value)
Returns the arc sine of the value.

float rand()
Returns a random value between 0-1.

float floor(float value)
Returns the integer value of value rounded down.

float pow(float value,float exponent)
Returns the value of value to the power of exponent.

int intValue(float value)
Returns the integer value of value.