Not sure if this is any use to you but I wrote it to help me with debugging purposes and its useful for printing to a debuglog.txt file, it also appends the document (which automatically adds the new stuff under the old stuff)
Constants.agc
/****************************** Constants for DEBUGGING USE ******************************/
rem IMPORTANT - WHEN DEBUG IS SET TO 1 RELEASE MODE MUST BE SET TO 0 AND VICE VERSA
#constant DEBUG_MODE 1 // 0 to set inactive, 1 to set active
#constant RELEASE_MODE 0 // 0 to set inactive, 1 to set active
rem Do we want to append the file ?
#constant APPEND 1 // Set append to true for when writing to the file
rem Create 2 variables to fetch and store the current date and time values
#constant CURRENTDATE GetCurrentDate() // Write the current date to the debug log
#constant CURRENTTIME GetCurrentTime() // Write the current time to the debug log
#constant DAYOFTHEWEEK GetDayOfWeek() // Write the current day of the week
Globals.agc
/****************************** Global Variables ******************************/
rem Global Variable for use with debugging, sets the name of the text file to create
global gDebugLog as string = "DebugLog.txt"
rem Create a variable to store a string in memory for each day of the week
global gDayOfTheWeek as string = ""
Debuglog.agc
/****************************** DEBUGGING USE ******************************/
rem Include the necessary header files
#include "globals.agc"
#include "constants.agc"
rem This functon is for testing purposes it will be used to output stuff to a test file, like a debugging log
function WriteToDebugLog( fileID as integer, fileName as string, textToOutput as string )
rem Check to see if we are in DEBUG_MODE
if( DEBUG_MODE = 1 )
rem If we are then we overwrite the IDE and specify our debug log to write to the project folder
SetRawWritePath( "C:\Users\Gunne\Documents\repos\AGK2\AGK-Projects\LearnWithMe" )
endif
rem Check to see if we are in RELEASE_MODE
if( RELEASE_MODE = 1 )
rem If we are let the IDE handle the debug log and write it to the safe default folder directory
SetFolder( "/media" )
endif
rem Now we want to open and create the file to write too
OpenToWrite( fileID, fileName, APPEND )
rem Now we write the specified values to the file
WriteLine( fileID, textToOutput )
rem Finally, we close the file after we have finished writing to it
CloseFile( fileID )
endfunction
rem This function prints the date, day of the week and time to the screen
function PrintTimeDateDay()
rem print time data to screen
Print("Date: " + CURRENTDATE)
select DAYOFTHEWEEK
case 0 : gDayOfTheWeek = "Sunday" : endcase
case 1 : gDayOfTheWeek = "Monday" : endcase
case 2 : gDayOfTheWeek = "Tuesday" : endcase
case 3 : gDayOfTheWeek = "Wednesday" : endcase
case 4 : gDayOfTheWeek = "Thursday" : endcase
case 5 : gDayOfTheWeek = "Friday" : endcase
case 6 : gDayOfTheWeek = "Saturday" : endcase
endselect
Print( "Day : " + gDayOfTheWeek )
Print( "Time: " + CURRENTTIME )
endfunction
/****************************** DEBUGGING USE ******************************/
main.agc usage
/****************************** MAIN GAME LOOP ******************************/
// Project: Learn With Me
// Created: 2015-12-15
// Include the necessary header files
#include "setup.agc"
#include "globals.agc"
#include "constants.agc"
#include "debughelper.agc"
#include "splashscreen.agc"
#include "mainmenu.agc"
rem Function Prototypes
// Main Loop, will continue to run until the user quits/exits the program
do
/****************************** DEBUGGING USE ******************************/
rem Call on our function to write to the debug log
rem If the game state is in the loading state and we are in debug mode
if ( gGameState = GAMESTATE_LOADING and DEBUG_MODE = 1 )
rem Write the specified text to the debug log
WriteToDebugLog( 1, gDebugLog, "********************* DEBUG MODE ***************************" )
endif
rem Ifthe game state is in the loading state and we are in release mode
if ( gGameState = GAMESTATE_LOADING and RELEASE_MODE = 1 )
rem Write the specified text tot he debug log
WriteToDebugLog( 1, gDebugLog, "********************* RELEASE MODE *************************" )
endif
rem If game state is in the loading state
if ( gGameState = GAMESTATE_LOADING )
rem Write the current data and time to the file
WriteToDebugLog( 1, gDebugLog, "Kids- Learn With Me App Prototype" )
WriteToDebugLog( 1, gDebugLog, "Programmer: David Gunner (Jnr)" )
WriteToDebugLog( 1, gDebugLog, "Website: http://gunnerjnr.uk" )
WriteToDebugLog( 1, gDebugLog, "DATE: " + CURRENTDATE )
WriteToDebugLog( 1, gDebugLog, "TIME: " + CURRENTTIME )
WriteToDebugLog( 1, gDebugLog, "************************************************************" )
WriteToDebugLog( 1, gDebugLog, "NOW ENTERING MAIN GAME LOOP" )
WriteToDebugLog( 1, gDebugLog, "CHECKING GAME STATES..." )
endif
/***************************************************************************/
/** GAME LOGIC HERE **/
/****************************** CHECK GAME STATES ******************************/
rem Here we continually check the current game states and call on the neccasary methods
select gGameState
rem This is to handle all things that will happen in our loading state
case GAMESTATE_LOADING:
rem Print some text to the screen
Print( "The current state is GAMESTATE_LOADING" )
rem Write to our debug log file
//WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_LOADING" )
rem Call on our function to set up our screen resolutions
ScreenSetup()
rem Call on our function to display our splash screen while the game assets are loading
ShowSplashscreen()
rem Call the function to load the menu background image
MenuBackground()
MenuButtons()
rem Set our game state to GAMESTATE_MAIN_MENU
gGameState = GAMESTATE_MAIN_MENU
endcase
rem This state handles all things for the main menu screen
case GAMESTATE_MAIN_MENU:
rem Print some text to the screen
Print( "The current state is GAMESTATE_MAIN_MENU" )
rem
CheckMenuButtons()
rem Write to our debug log file
//WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_MAIN_MENU" )
rem Set the game state to the appropriate state depending on the chosen action by the user
rem e.g - If the users presses the play/start button we set the game state to the relevant state
//gGameState = GAMESTATE_START_GAME
endcase
rem This state will take the user to the level section screen if the users wishes to start the game
case GAMESTATE_START_GAME:
rem Print some text to the screen
Print( "The current state is GAMESTATE_START_GAME" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_START_GAME" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = GAMESTATE_OPTIONS
endcase
rem The state will take the user to the options screen
case GAMESTATE_OPTIONS:
rem Print some text to the screen
Print( "The current state is GAMESTATE_OPTIONS" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_OPTIONS" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = GAMESTATE_CREDITS
endcase
rem This state will take the user to the credits screen
case GAMESTATE_CREDITS:
rem Print some text to the screen
Print( "The current state is GAMESTATE_CREDITS" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_CREDITS" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = GAMESTATE_EXIT
endcase
rem This state will handle the cleaning up of memory, objects, sprites etc.. and then exit the game
case GAMESTATE_EXIT:
rem Print some text to the screen
Print( "The current state is GAMESTATE_EXIT" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_EXIT" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = GAMESTATE_LEVEL_SELECTION
endcase
rem This state will present the user with the level select screen, from here dependant on which level they choose
rem will determine what the next state will be - e.g if they choose level one the state will become gGameState = GAMESTATE_LEVEL_ONE
rem this can be seen for real in the next case statement below
case GAMESTATE_LEVEL_SELECTION:
rem Print some text to the screen
Print( "The current state is GAMESTATE_LEVEL_SELECTION" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_LEVEL_SELECTION" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = GAMESTATE_LEVEL_ONE
endcase
rem This state will handle which level to take the user off too dependant on the level chosen
rem NOTE this may not be the best way to achieve this perhaps an array or something might be better
rem to chose the level number, instead of the need for 200 case statements ( one for each level )
case GAMESTATE_LEVEL_ONE:
rem Print some text to the screen
Print( "The current state is GAMESTATE_LEVEL_ONE" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "The current state is GAMESTATE_LEVEL_ONE" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = 8
endcase
rem This will probably be removed at some point it was mainly for debugging and testing purposes
case GAMESTATE_NO_STATE:
rem Print some text to the screen
Print( "NO STATE" )
endcase
rem this is the default case, it too will also most likely be removed unless I find a use for it
case default:
rem Print some text to the screen
Print( "DEFAULT CASE" )
rem Write to our debug log file
WriteToDebugLog( 1, gDebugLog, "DEFAULT CASE" )
WriteToDebugLog( 1, gDebugLog, "EXITING MAIN GAME LOOP..." )
WriteToDebugLog( 1, gDebugLog, "We have now reached the end of our loop, the Current gGameState = GAMESTATE_NO_STATE" )
WriteToDebugLog( 1, gDebugLog, "************************************************************" )
rem Set the game state to the appropriate state depending on the chosen action by the user
//gGameState = GAMESTATE_NO_STATE
endcase
endselect
rem Print the text 'FPS' before the actual FPS count
PrintC( "FPS: ")
rem Print the current Frames Per Second to the screen display
Print( ScreenFPS() )
rem Update/Synchronise the game
Sync()
loop
/****************************** TODO ******************************/
Image of it in action
Anyway its possibly not what you wanted to know but might prove handy for anybody in the future
Cheers
GunnerJnr