Whew... this was very tedious work... but anyway... finally... here is the
RETRO GAME FANTASY COMPUTER FRAMEWORK API
After loading a Tiled map that contains an Objects layer objects will automatically be processed and stored in one of 6 global object arrays:
objects in the Tiled map that have their type set to
interactive are stored in the
fciobjects array.
objects in the Tiled map that have their type set to
collectible are stored in the
fccobjects array.
objects in the Tiled map that have their type set to
enemy are stored in the
fceobjects array.
objects in the Tiled map that have their type set to
zone are stored in the
fczobjects array.
objects in the Tiled map that have their type set to
trigger are stored in the
fctobjects array.
all other objects in the Tiled map are stored in the
fcgobjects array and the
.category field will be set to whatever the type is set to in the Tiled map for that object.
// to lower the maximum # of sprites and particles which may benefit performance in HTML5 builds
// MUST BE CALLED BEFORE CALLING fcinit
fcsetspritelimits(maxparticles as integer, max8 as integer, max16 as integer, max32 as integer)
// to initialize the RETRO GAME FANTASY COMPUTER SYSTEM
fcinit(screenmode as integer, paletteid as integer, fullscreen as integer, fps as integer, vsync as integer)
// to update and render everything... you do not need to call sync() in your main loop you only need to call this
fcdraw()
// change the current screen mode... you might use fcMODE256 for the Title Screen and fcMODE160 for the gameplay for example.
fcsetscreenmode(mode as integer)
// get the current width of the fantasy computer system screen
fcscreenwidth()
// get the current height of the fantasy computer system screen
fcscreenheight()
// STAT FUNCTIONS RETURNING ACTIVE PARTICLE AND SPRITE COUNTS
fcactiveparticlecount()
fcactivesprite8count()
fcactivesprite16count()
fcactivesprite32count()
// MISC FUNCTIONS THAT ARE VERY HELPFUL FOR GAME DEV
// returns -1, 0 or 1 identifying the sign of the value passed in
fcsgn(value as float)
// basically performs a lerp but with no setup or anything needed
fcmovevalueto(curvalue as float, targetvalue as float, amounttochange as float)
// returns the minimum of two values
fcmin(value1 as float, value2 as float)
// returns the maximum of two values
fcmax(value1 as float, value2 as float)
// loads a spritesheet image and, if exists, loads the accompanying image flags file
fcloadspritesheet(size as integer, paletteid as integer, name as string, transparentcolorindex as integer)
// saves a spritesheet to the media folder as a binary file
fcsavespritesheetbinary(size as integer, name as string)
// loads a spriteheet from a binary file
fcloadspritesheetbinary(size as integer, paletteid as integer, name as string, transparentcolorindex as integer, key as binary)
// load tilesheet image and, if exists, loads the accompanying image flags file
fcloadtilesheet(paletteid as integer, name as string, transparentcolorindex as integer)
// save tilesheet as binary file
fcsavetilesheetbinary(name as string)
_fcsavetilesheetbinary(name)
endfunction
// loads a tilesheet from a binary file
fcloadtilesheetbinary(paletteid as integer, name as string, transparentcolorindex as integer, key as binary)
// set the current system palette (impacts textgrids and particles)... there are 10 palettes... 0 to 9
fcsetpalette(paletteID as integer)
// SET PARTICLE COLORS (PALETTE INDEXED) AND SPRITE IMAGES TO THE APPROPRIATE SPRITE SHEETS
// set particle color
fcsetpcolor(id as integer, colorindex as integer)
// set the image of a sprite
fcsets8image(id as integer, image as integer)
fcsets16image(id as integer, image as integer)
fcsets32image(id as integer, image as integer)
// GET PARTICLE COLOR INDEX AND SPRITE IMAGE IDS
// gets the color of a particle
fcgetpcolor(id as integer)
// get the current image of a sprite
fcgets8image(id as integer)
fcgets16image(id as integer)
fcgets32image(id as integer)
// SET PARTICLE AND SPRITE FRAMES
// set the frame of a particle
fcsetpframe(id as integer, frame as float)
// set the frame of a sprite
fcsets8frame(id as integer, frame as float)
fcsets16frame(id as integer, frame as float)
fcsets32frame(id as integer, frame as float)
// GET PARTICLE AND SPRITE FRAMES
// get the frame of a particle
fcgetpframe(id as integer)
fcgets8frame(id as integer)
fcgets16frame(id as integer)
fcgets32frame(id as integer)
// ADD AN AMOUNT TO THE PARTICLE AND SPRITE FRAMES
// add an amount to a particle's frame and returns the resulting frame value
fcaddpframe(id as integer, amount as float)
// add an amount to a sprite's frame and returns the resulting frame value
fcadds8frame(id as integer, amount as float)
fcadds16frame(id as integer, amount as float)
fcadds32frame(id as integer, amount as float)
// ADD AN AMOUNT TO THE PARTICLE AND SPRITE FRAMES
// IF THE FRAME VALUE BECOMES LESS THAN MIN... MAX IS ADDED TO THE FRAME VALUE
// IF THE FRAME VALUE BECOMES EQUAL TO, OR GREATER THAN, MAX... MAX IS SUBTRACTED FROM THE FRAME VALUE
// WrapAdd to a particle's frame and returns the resulting frame value
fcwrapaddpframe(id as integer, amount as float, min as float, max as float)
// WrapAdd to a Sprite's frame and returns the resulting frame value
fcwrapadds8frame(id as integer, amount as float, min as float, max as float)
fcwrapadds16frame(id as integer, amount as float, min as float, max as float)
fcwrapadds32frame(id as integer, amount as float, min as float, max as float)
// ENABLE OR DISABLE PARTICLES AND SPRITES
// turn a particle on valid ids range from 0..135
fcsetpon(id as integer)
// set the state of a particle on/off
fcsetpstate(id as integer, onoff as integer)
// turn a particle off
fcsetpoff(id as integer)
// turn a sprite on valid ids... sprite8: 0..79 sprite16: 0..31 sprite32: 0..7
fcsets8on(id as integer)
fcsets16on(id as integer)
fcsets32on(id as integer)
// set the state of a sprite on/off
fcsets8state(id as integer, onoff as integer)
fcsets16state(id as integer, onoff as integer)
fcsets32state(id as integer, onoff as integer)
// turn a sprite off
fcsets8off(id as integer)
fcsets16off(id as integer)
fcsets32off(id as integer)
// TURN ALL PARTICLES OR ALL SPRITES OF A CERTAIN SIZE OFF
// turn off all particles
fcsetpalloff()
// turn off all sprites
fcsets8alloff()
fcsets16alloff()
fcsets32alloff()
// GET "ON" STATUS OF PARTICLES AND SPRITES
// returns true (1) if the specified particle is turned on
fcgetpon(id as integer)
// returns true (1) if the specified sprite is turned on
fcgets8on(id as integer)
fcgets16on(id as integer)
fcgets32on(id as integer)
// GET THE FIRST PARTICLE OR SPRITE THAT IS NOT CURRENTLY "ON" (I.E. USE THIS TO GET A SPRITE NOT CURRENTLY BEING USED)
// get a particle
fcgetap()
// get a sprite
fcgetas8()
fcgetas16()
fcgetas32()
// get a particle within a specific range (i.e if you wanted to only get particles with ids ranging from 11 to 20 this function will do that)
fcgetapin(startindex as integer, endindex as integer)
// get a sprite within a specific range
fcgetas8in(startindex as integer, endindex as integer)
fcgetas16in(startindex as integer, endindex as integer)
fcgetas32in(startindex as integer, endindex as integer)
// SHOW OR HIDE PARTICLES AND SPRITES
// hide a particle
fchidep(id as integer)
// hide (false / 0) or show (true / 1) a particle
fchideshowp(id as integer, hideshow)
// show a particle
fcshowp(id as integer)
// hide a sprite
fchides8(id as integer)
fchides16(id as integer)
fchides32(id as integer)
// hide (false / 0) or show (true / 1) a sprite
fchideshows8(id as integer, hideshow)
fchideshows16(id as integer, hideshow)
fchideshows32(id as integer, hideshow)
// show a sprite
fcshows8(id as integer)
fcshows16(id as integer)
fcshows32(id as integer)
// SET PARTICLES AND SPRITES TO BE DOUBLE WIDTH AND HEIGHT
// set a particle to be double width and height
fcsetpdoublesize(id as integer)
// set a sprite to be double width and height
fcsets8doublesize(id as integer)
fcsets16doublesize(id as integer)
fcsets32doublesize(id as integer)
// SET PARTICLES AND SPRITES TO BE NORMAL WIDTH AND HEIGHT
// set a particle to be normal width and height
fcsetpnormalsize(id as integer)
// set a sprite to be normal width and height
fcsets8normalsize(id as integer)
fcsets16normalsize(id as integer)
fcsets32normalsize(id as integer)
// SET WIDTH AND HEIGHT SCALE OF PARTICLES AND SPRITES (WIDTH & HEIGHT CAN EACH BE 1 FOR NORMAL SIZE OR 2 FOR DOUBLE)
// set the size of a particle (1=1, 2=2)
fcsetpsize(id as integer, width as integer, height as integer)
// set the size of a sprite sprite8 1=8, 2=16 sprite16 1=16, 2=32 sprite32 1=32, 2=64
fcsets8size(id as integer, width as integer, height as integer)
fcsets16size(id as integer, width as integer, height as integer)
fcsets32size(id as integer, width as integer, height as integer)
// SET POSITION OF PARTICLES AND SPRITES
// set the position of a particle
fcsetppos(id as integer, x as float, y as float)
// set the x-position of a particle
fcsetpxp(id as integer, x as float)
// set the y-position of a particle
fcsetpyp(id as integer, y as float)
// set the position of a sprite
fcsets8pos(id as integer, x as float, y as float)
fcsets16pos(id as integer, x as float, y as float)
fcsets32pos(id as integer, x as float, y as float)
// set the x-position of a sprite8
fcsets8xp(id as integer, x as float)
fcsets16xp(id as integer, x as float)
fcsets32xp(id as integer, x as float)
// set the y-position of a sprite8
fcsets8yp(id as integer, y as float)
fcsets16yp(id as integer, y as float)
fcsets32yp(id as integer, y as float)
// SET POSITION OF PARTICLES AND SPRITES WITHIN A MAP LAYER... use when you have scrolling maps
// sets the position of a particle within the space of the specified mapview's layer
fcsetpposinmaplayer(viewid as integer, layer as integer, particleid as integer, x as float, y as float)
// sets the x-position of a particle within the space of the specified mapview's layer
fcsetpxpinmaplayer(viewid as integer, layer as integer, particleid as integer, x as float)
// sets the y-position of a particle within the space of the specified mapview's layer
fcsetpypinmaplayer(viewid as integer, layer as integer, particleid as integer, y as float)
// sets the position of a sprite within the space of the specified mapview's layer
fcsets8posinmaplayer(viewid as integer, layer as integer, spriteid as integer, x as float, y as float)
fcsets16posinmaplayer(viewid as integer, layer as integer, spriteid as integer, x as float, y as float)
fcsets32posinmaplayer(viewid as integer, layer as integer, spriteid as integer, x as float, y as float)
// sets the x-position of a sprite within the space of the specified mapview's layer
fcsets8xpinmaplayer(viewid as integer, layer as integer, spriteid as integer, x as float)
fcsets16xpinmaplayer(viewid as integer, layer as integer, spriteid as integer, x as float)
fcsets32xpinmaplayer(viewid as integer, layer as integer, spriteid as integer, x as float)
// sets the y-position of a sprite within the space of the specified mapview's layer
fcsets8ypinmaplayer(viewid as integer, layer as integer, spriteid as integer, y as float)
fcsets16ypinmaplayer(viewid as integer, layer as integer, spriteid as integer, y as float)
fcsets32ypinmaplayer(viewid as integer, layer as integer, spriteid as integer, y as float)
// ADJUST POSITION OF PARTICLES AND SPRITES BY A SPECIFIED AMOUNT
// adjust the position of a particle by a specified amount in x and a specified amount in y
fcmovep(id as integer, x as float, y as float)
// adjust the x-position of a particle by a specified amount
fcmovepx(id as integer, x as float)
// adjust the y-position of a particle by a specified amount
fcmovepy(id as integer, y as float)
// adjust the position of a sprite by a specified amount in x and a specified amount in y
fcmoves8(id as integer, x as float, y as float)
fcmoves16(id as integer, x as float, y as float)
fcmoves32(id as integer, x as float, y as float)
// adjust the x-position of a sprite by a specified amount
fcmoves8x(id as integer, x as float)
fcmoves16x(id as integer, x as float)
fcmoves32x(id as integer, x as float)
// adjust the y-position of a sprite by a specified amount
fcmoves8y(id as integer, y as float)
fcmoves16y(id as integer, y as float)
fcmoves32y(id as integer, y as float)
// GET POSITION OF PARTICLES AND SPRITES
// get the current screen x-position of a particle
fcgetpxp(id as integer)
// get the current screen y-position of a particle
fcgetpyp(id as integer)
// get the current screen x-position of a sprite
fcgets8xp(id as integer)
fcgets16xp(id as integer)
fcgets32xp(id as integer)
// get the current screen y-position of a sprite
fcgets8yp(id as integer)
fcgets16yp(id as integer)
fcgets32yp(id as integer)
// FLIP SPRITES HORIZONTALLY AND VERTICALLY
fcflips8(id as integer, hflip as integer, vflip as integer)
fcflips16(id as integer, hflip as integer, vflip as integer)
fcflips32(id as integer, hflip as integer, vflip as integer)
// GET A SPRITE'S HORIZONTAL FLIP STATUS
// returns true(1) if the specified sprite is currently flipped horizontally
fcgets8hflip(id as integer)
fcgets16hflip(id as integer)
fcgets32hflip(id as integer)
// GET A SPRITE'S VERTICAL FLIP STATUS
// returns true(1) if the specified sprite is currently flipped vertically
fcgets8vflip(id as integer)
fcgets16vflip(id as integer)
fcgets32vflip(id as integer)
// SET DEPTH OF PARTICLES AND SPRITES
// set the depth of a particle
fcsetpdepth(id as integer, depth as integer)
// set the depth of a sprite
fcsets8depth(id as integer, depth as integer)
fcsets16depth(id as integer, depth as integer)
fcsets32depth(id as integer, depth as integer)
// GET DEPTH OF PARTICLES AND SPRITES
// get the depth of a particle
fcgetpdepth(id as integer)
// get the depth of a sprite
fcgets8depth(id as integer)
fcgets16depth(id as integer)
fcgets32depth(id as integer)
// SET ALPHA OF PARTICLES AND SPRITES VALID VALUES RANGE FROM 0=FULLY TRANSPARENT TO 7=FULLY OPAQUE
// set the alpha of a particle
fcsetpalpha(id as integer, alpha as integer)
// set the alpha of a sprite
fcsets8alpha(id as integer, alpha as integer)
fcsets16alpha(id as integer, alpha as integer)
fcsets32alpha(id as integer, alpha as integer)
// SET HANDLE OF SPRITES
fcsets8handle(id as integer, xoffset as float, yoffset as float)
fcsets16handle(id as integer, xoffset as float, yoffset as float)
fcsets32handle(id as integer, xoffset as float, yoffset as float)
// SET SPRITE-TO-SPRITE HIT BOX ON SPRITES ie a sprite collider
fcsets8hitbox(id as integer, x1 as integer,y1 as integer, x2 as integer,y2 as integer)
fcsets16hitbox(id as integer, x1 as integer,y1 as integer, x2 as integer,y2 as integer)
fcsets32hitbox(id as integer, x1 as integer,y1 as integer, x2 as integer,y2 as integer)
// SET SPRITE-TO-TILE HIT BOX ON SPRITES ie a tile collider
fcsets8tilehitbox(id as integer, x1 as integer,y1 as integer, x2 as integer,y2 as integer)
fcsets16tilehitbox(id as integer, x1 as integer,y1 as integer, x2 as integer,y2 as integer)
fcsets32tilehitbox(id as integer, x1 as integer,y1 as integer, x2 as integer,y2 as integer)
// CHECK COLLISIONS BETWEEN SPRITES AND SPRITES
// check for collision between a sprite8 and another sprite8
fcs8cols8(id1 as integer, id2 as integer)
// check for collision between a sprite8 and a sprite16
fcs8cols16(id1 as integer, id2 as integer)
// check for collision between a sprite8 and a sprite32
fcs8cols32(id1 as integer, id2 as integer)
// check for collision between a sprite16 and another sprite16
fcs16cols16(id1 as integer, id2 as integer)
// check for collision between a sprite16 and a sprite32
fcs16cols32(id1 as integer, id2 as integer)
// check for collision between a sprite32 and another sprite32
fcs32cols32(id1 as integer, id2 as integer)
// DISPLAY TEXT
// display text in the 8x8 character size grid
fctext8(shaded as integer, x as integer, y as integer, colorindex as integer, text as string)
// display text in the 16x16 character size grid
fctext16(shaded as integer, x as integer, y as integer, colorindex as integer, text as string)
// display text in the 32x32 character size grid
fctext32(shaded as integer, x as integer, y as integer, colorindex as integer, text as string)
// SET THE DEPTH OF THE TEXT GRIDS
fcsett8depth(depth as integer)
fcsett16depth(depth as integer)
fcsett32depth(depth as integer)
// CLEAR X & Y OFFSETS FOR TEXT GRIDS
fccleart8offsets()
fccleart16offsets()
fccleart32offsets()
// SET THE X-OFFSET OF A ROW OF TEXT IN A TEXT GRID
fcsett8rowxoffset(row as integer, xoffset as float)
fcsett16rowxoffset(row as integer, xoffset as float)
fcsett32rowxoffset(row as integer, xoffset as float)
// SET THE Y-OFFSET OF A COLUMN OF TEXT IN A TEXT GRID
fcsett8colyoffset(col as integer, yoffset as float)
fcsett16colyoffset(col as integer, yoffset as float)
fcsett32colyoffset(col as integer, yoffset as float)
// SET THE COLOR OF AN ENTIRE ROW OF TEXT IN A TEXT GRID
fcsett8rowcolor(row as integer, colorindex as integer)
fcsett16rowcolor(row as integer, colorindex as integer)
fcsett32rowcolor(row as integer, colorindex as integer)
// SET THE COLOR OF AN ENTIRE COLUMN OF TEXT IN A TEXT GRID
fcsett8colcolor(col as integer, colorindex as integer)
fcsett16colcolor(col as integer, colorindex as integer)
fcsett32colcolor(col as integer, colorindex as integer)
// SET THE COLOR OF AN INDIVIDUAL TEXT CELL IN A TEXT GRID
fcsett8color(col as integer, row as integer, colorindex as integer)
fcsett16color(col as integer, row as integer, colorindex as integer)
fcsett32color(col as integer, row as integer, colorindex as integer)
// RESET AN ENTIRE TEXT GRID CLEARING ALL TEXT AND REMOVING ANY POSITIONING OFFSETS THAT WERE SET
fcresett8()
fcresett16()
fcresett32()
// DIVIDER OVERLAY USED TO SECTION SCREEN AS NEEDED
// reset the divider overlay
fcresetdiv()
// color a section of the divider overlay
fccolordiv(x as integer, y as integer, w as integer, h as integer, colorindex1 as integer, colorindex2 as integer)
// enable (turn on) the divider overlay
fcenablediv()
// disable (turn off) the divider overlay
fcdisablediv()
// TERRAIN LINES
// enable terrain lines
fcenableterrainlines(startyp as integer, endyp as integer, linecount as integer, scale as integer, colorindex1 as integer, colorindex2 as integer)
// disable terrain lines
fcdisableterrainlines()
// update terrain lines
fcupdateterrainlines(speed as float)
// update terrain line colors
fcupdateterraincolors(colorindex1 as integer, colorindex2 as integer)
// GRADIENT BACKDROPS
// enable gradient backdrops
fcenablegradient(gradientbackdropid as integer)
// disable gradient backdrops
fcdisablegradient(gradientbackdropid as integer)
// set the style of a gradient backdrop
fcsetgradientstyle(gradientbackdropid as integer, style as integer)
// set gradient backdrop starting y-position
fcsetgradientyp(gradientbackdropid as integer, startingypos as integer)
// set gradient backdrop height
fcsetgradientheight(gradientbackdropid as integer, height as integer)
// TILED MAP AND RETRO GAME FANTASY COMPUTER MAP & TILESHEET SUPPORT
// load a Tiled map and the tilesheet (tileset) to use with it
fcloadtiledmap(tilesize as integer, paletteid as integer, mapfilename as string, tilesetfilename as string, transparentcolorindex as integer)
// save the RETRO GAME FANTASY COMPUTER FRAMEWORK tilemap data as a binary file
fcsavemapbinary(filename as string)
// load a RETRO GAME FANTASY COMPUTER FRAMEWORK binary tilemap file
fcloadmapbinary(filename as string)
// MAPVIEWS
// initialize a MapView
fcinitmapview(viewid as integer, layers as integer, screenx as integer, screeny as integer, tileswide as integer, tileshigh as integer)
// hide a map layer in a mapview
fchidemaplayer(viewid as integer, layer as integer)
// hide an entire mapview
fchidemapview(viewid as integer)
// set a mapview layer to support transparency
fcsetmaplayertransparent(viewid as integer, layer as integer)
// set a mapview layer to be opaque
fcsetmaplayeropaque(viewid as integer, layer as integer)
// set the depth of a layer in a MapView
fcsetmapviewlayerdepth(viewid as integer, layer as integer, depth as integer)
// set depth of an entire MapView... note the layers in the mapview will have depth assigned incrementally as required from the depth value passed in
fcsetmapviewdepth(viewid as integer, depth as integer)
// draw a layer of a mapview
fcDrawMapViewLayer(viewid as integer, layer as integer, mappixelx as float, mappixely as float)
// draw an entire map view (all layers)
fcDrawMapView(viewid as integer, mappixelx as float, mappixely as float)
// get the id of the tile at the specified x and y coordinates in the specified layer
// NOTE: MapView does not need to be passed in because MapViews are only logical constructs that allow a view into the tilemap data
fcmapgettile(maplayer as integer, tx as integer, ty as integer)
// set the id of the tile at the specified x and y coordinates in the specified layer
fcmapsettile(maplayer as integer, tx as integer, ty as integer, tileid as integer)
// CHECK COLLISIONS BETWEEN SPRITES AND TILEMAP returns a fctilecollisiontype
fcs8coltile(spriteid as integer, spritexv as float, spriteyv as float, mapview as integer, maplayer as integer, splitchecks as integer, flags as integer)
fcs16coltile(spriteid as integer, spritexv as float, spriteyv as float, mapview as integer, maplayer as integer, splitchecks as integer, flags as integer)
fcs32coltile(spriteid as integer, spritexv as float, spriteyv as float, mapview as integer, maplayer as integer, splitchecks as integer, flags as integer)
// get the sprite-to-tile collision info for the last collision check... returns a fctilecollisiontype
fcgettilecollinfo()
// get image flags full value for a given sprite image representing ALL FLAGS that have been set
fcgets8imageflags(imageid as integer)
fcgets16imageflags(imageid as integer)
fcgets32imageflags(imageid as integer)
// get image flags full value for a sprite
fcgets8flags(sprite as integer)
fcgets16flags(sprite as integer)
fcgets32flags(sprite as integer)
// get a specific flag for a sprite
fcgets8flag(sprite as integer, flag as integer)
fcgets16flag(sprite as integer, flag as integer)
fcgets32flag(sprite as integer, flag as integer)
// check multiple flags for a sprite
fcgets8multiflags(sprite as integer, flagsmask as integer)
fcgets16multiflags(sprite as integer, flagsmask as integer)
fcgets32multiflags(sprite as integer, flagsmask as integer)
// get flags full value for a given tile
fcgettflags(tileid as integer)
// get a specific flag for a given tile
fcgettflag(tileid as integer, flag as integer)
// check multiple flags for a given tile
fcgettmultiflags(tileid as integer, flagsmask as integer)