Grey Alien BlitzMax Game Framework: Common
Code V1.04
Copyright (c) 2007 by Jake Birkett
Introduction
CommonCode.bmx contains a large library of very useful
functions. It also has some handy Extern declarations and some useful
Types to go with them.
The file is split into 5 sections as follows:
- Externs (win32 and C)
- Consts and Globals
- Types (including a large TDateTime type)
- Functions
- Version History
Function Listing
- ccAddSlash: Adds a forward slash onto a path if it needs it
- ccAnyInput: Tests for any key hit or any mouse button hit
- ccAnyKeyPressed: Tests if any key has been hit
- ccAppFileNonDebug: Returns AppFile but without the .debug on the
end
- ccBezier: Draws a Bezier curve with 2 control points
- ccCalcAnimFrame: Returns the animation frame number based on Counter/Length (very useful)
- ccCalcMSPerFrame: Work out MilliSecs per frame so all game times can be specified as MS
- ccCalcPan: Work out channel pan based on x coord
- ccCentreWindow: Uses Windows API call to centre the current window
- ccCentreWindowHandle: Uses Windows API call to centre the window passed in
- ccCls: Makes a black screen and then flips it to the visible buffer
- ccClsNoFlip: Makes a black screen and does not flip it
- ccClsVSync: Makes a black screen and then flips it to the visible buffer with Vsync
- ccConvertJPGToBMP: Converts a JPG file into a BMP file
- ccCopyRect: Draws a part of an image by using a viewport
- ccCopyStringArray: Copy a string array to another array
- ccCreateFrames: Caches an Image or Anim Image in VRAM
- ccCreateMutex: Windows API call to creates a Mutex and close the program if it already exists
- ccDialogOK: Shows a graphical OK Dialog
- ccDisablePolledInput: Disable PolledInput and switch to framework input
- ccDrawImageArea: Draws part of an image. (faster?)
- ccDrawImage: Draws an image with an optional shadow
- ccDrawImageCentred: Draws an image centred in the screen
- ccDrawImageLight: Draws a light version of an image
- ccDrawImageRect: Draws part of an image. (slow?)
- ccDrawNumbers: Draws numbers from an anim strip (bitmap font)
- ccDrawRect: Draws a rectangle with an optional shadow
- ccDrawRectOutline: Draws an outlined rectangle
- ccDrawText: Draw text with shadow if required
- ccDrawTextAligned: Draw text left, centre or right aligned
- ccDrawTextCentre: Draw text Horizontally centred in the middle of the screen
- ccDrawTextCentreAll: Draw text Horizontally and Vertically centred in the middle of the screen
- ccDrawTextCentred: Draw text horizontally centred based on x coord passed in
- ccDrawTextCentredRoundX: Draw text horizontally centred based on rounded x coord passed in
- ccDrawTextRight: Right justify text to x coord based on Text Width
- ccDrawTextSpacedRounded: DrawText with a specified space between each character
- ccDrawTextSpacedRounded: DrawText with a specified space between each character. X coord is rounded before drawing each character.
- ccEnableMaximize: Uses WindowsAPI call to enable maximize button on window
- ccEnableMinimize: Uses WindowsAPI call to enable minimize button on window
- ccEnablePolledInput: Enable PolledInput and switch off framework input
- ccFadeScreen: Fade screen (and optional sound channel) in or out
- ccFastRand: Faster than BlitzMax Rand()
- ccFastRandSeed: Sets the Seed for ccFastRand()
- ccFileExists: See if a file exists or not
- ccFindScreenRes: Checks to see if a specified screen resolution exists
- ccFirstString: Returns first part of string up to comma
- ccFirstStringToSub: Returns first part of string up to substring
- ccFirstStringToSubChop: Returns first part of string up to substring AND chops the source string
- ccFixLag: Fixes DirectX7 rendering lag in
BlitzMax
- ccFlip: Calls Flip with a parameter decided by a global variable
- ccFlushAll: Flushes Keys and Mouse
- ccGetCursorPos: Windows API call to get the mouse cursor position relative to the desktop top left
- ccGetEnvVar: Uses Windows API call to return an Environment variable
- ccGetMemoryStatus: Returns a TMemoryStatus object for examimation
- ccGetVersionString: Returns the Windows version in a string
- ccGetVideoMemory: Returns Total and Free Video RAM
- ccGetWindowInfo: Uses Windows API call to return useful info such as current window area and client area
- ccGetWindowInfoHandle: Uses Windows API call to return useful info such as any window area and client area
- ccImageRectCollide: See if an image (pixel perfect) collides with a rectangle
- ccIniFirstString: Returns first part of string up to = sign
- ccIniLastString: Return last part of string from = sign
- ccLastStringToSub: Returns last part of string from substring
- ccListIndex: Loops through a list and returns the index of the matching object
- ccListStringIndex: Loops through a string list and returns the index of the matching string
- ccLoadAnimBitmap: Load an Anim bitmap and error if not found
- ccLoadBitmap: Load a bitmap and error if not found
- ccLoadFile: Load a file and show error if not found
- ccLoadSample: Load a sound sample and error if not found
- ccLoadSectionArrayFromFile: Read array of strings from a file until next section is found
- ccLoadSectionStringFromFile: Read string from a section in a file
- ccMidHandle: Midhandle an image or remove a midhandle from an image
- ccMillisecsToMinutes: Converts milliseconds into minutes and seconds
- ccMinimiseWindow: Windows API call to minimise a window
- ccMouseButtons: Returns the total of all
MouseHits
- ccMouseDown: Tests all 3 mouse buttons for MouseDown at
once
- ccMouseDownTotal: Returns the total of all MouseDowns
- ccMouseHit: Tests all 3 mouse buttons for MouseHit at
once
- ccMouseShowHide: Show and Hide the mouse as it enters/leaves the window
- ccPadWithChar: Pad a string (at the end) with the passed in character
- ccPadWithZeros: Pad a string with zeros (on the left) to a set
length
- ccPow2Size: Pass in a size and this will return the nearest higher power of 2 size
- ccPrintGraphicsModes: Outputs all available graphics modes in the Ouput window.
- ccRangeCheck100: Check Value is 0 to 100 and correct it if neccessary
- ccReadIniLine: Reads a line from an ini file and returns the key value
- ccRectsOverLap: Detect if two rectangles overlap
- ccRemoveStringArraySlots: Removes specified string slots from an array
- ccRestoreSolidMode: Sets solid blend, alpha 1 and white colour
- ccRound: Gives proper rounding of Float to Integer without bankers rounding
- ccRunTimeError: Shows a RunTimeError dialog
- ccSaveImage: Save a TImage as a bitmap file
- ccScreenShot: Takes a screenshot and saves it with the date and time as part of the filename
- ccSetIcon: Uses Windows API call to set the window icon
- ccSetPriority: Windows API call to set Process Priority and Thread Priority
- ccSetWallpaper: Uses Windows API call to set the desktop wallpaper
- ccShadowText: Draws text with a definable shadow underneath.
- ccShadowTextSet: Sets the global ShadowText variables
- ccSplitStringIntoLines: Splits a string into an array of strings
- ccTestSectionHeader: Test a section header and error if it doesn't match
- ccVWait: Uses DirectX to wait for a vertical blank
- ccWaitForKeyOrMouse: Waits until any Key is hit or any mouse button is hit
- ccWaitForTime: Wait for a set time or until user aborts
- ccWindowActive: Uses Windows API call to see if the passed in window is active
- ccWindowPosition: Uses Windows API call to return a TRect containing the current window position
- ccWindowPositionHandle: Uses Windows API call to return a TRect containing a window's position
- ccWordWrapArray: Word wrap an array of strings based on the current font
- ccWordWrapArraySpecial: Word wrap an array of strings based on the current font but change width at certain line number
- ccWriteBMP: Write a bitmap (TPixmap) to a TStream
- ccWriteIniLine: updates an ini file with a new value for a key
- ccWriteIniNumber: Writes "string$=value%" to a file
- ccWriteIniString: Writes "string$=value$" to a file