Author Topic: Program Processing System  (Read 1964 times)

MrTAToad

  • Guest
Program Processing System
« on: 2012-Jul-25 »
The Program Processing System is a module driven routine for running a program with one control loop, and with the system dealing with all loading (and reloading) of graphics, sound and music, as well as coping with resolution change, multiple languages.

It has :

  • Sprite system
  • 3D system (but not implemented)
  • Music (not implemented yet)
  • Samples
  • Language/language selection
  • Loading from a resource file
  • Progress bar
  • Batch processing system (for items that dont need much control)
  • Standard text processing
  • Proportional font processing (using my own system)
  • Module routine (registering/moving backwards, forwards and jumping to a specific module)

A module would consist of two parts : The TYPE and standard functions which call specific On functions (it's slightly inefficient (but not noticable, but needs to be done so that PROTOTYPE can be used).

Code: (glbasic) [Select]
//! Called only once when the program starts.  For user types, all graphics should be loaded before this function is called
//\param None
//\return TRUE if initilisation finished correctly, FALSE if there was an error
FUNCTION OnProgramStart%:
self.OnProgramEnd()

RETURN TRUE
ENDFUNCTION

//! Called only once when the program ends
//\param None
//\return TRUE
FUNCTION OnProgramEnd%:
RETURN TRUE
ENDFUNCTION

//! Called when there is a screen resolution change.  All graphics will have been reloaded before this call
//\param screenWidth% - Width of screen resolution
//\param screenHeight% - Height of screen resolution
//\return TRUE if the resolution change succeeded, FALSE otherwise
FUNCTION OnResolutionChange%:screenWidth%,screenHeight%
RETURN TRUE
ENDFUNCTION

//! Called when there is a need to change languages
//\param TLanguageLoader - Language processing system
//\return > 0 if the user selected a language, 0 if the user cancelled language select or < 0 if there was an error
FUNCTION OnLanguageChange%:languageLoader AS TLanguageLoader
RETURN TRUE
ENDFUNCTION

//! Called whenever a given module starts, usually by the module processing system starting this module
//\param TSetup_Base - Base routines
//\return TRUE if setup was successful, FALSE otherwise
FUNCTION OnRoutineStart%:_setup AS TSetup_Base
RETURN TRUE
ENDFUNCTION

//\! Called whenever the module processing system is about to move onto another module.  Used to remove any unwanted data
//\param TSetup_Base - Base routines
//\return TRUE
FUNCTION OnRoutineEnd%:_setup AS TSetup_Base
RETURN TRUE
ENDFUNCTION

//! Call when either screen resolution changes or language does
//\param None
//\return TRUE
FUNCTION OnChange%:
RETURN TRUE
ENDFUNCTION

//! Called on each game loop, this displays all user created graphics (not those in the animator processor system)
//\param TSetup_Base - Base routine
//\return TRUE
FUNCTION OnDisplay2D%:_setup AS TSetup
RETURN TRUE
ENDFUNCTION

FUNCTION OnDisplay3D:_setup AS TSetup_Base
RETURN TRUE
ENDFUNCTION

//! Process all user created graphics and anything else user created.  Called once in each game loop
//\param TSetup_Base - Base routines
//\param tResult - Result of operation.
//\param speed - Current movement speed for this loop
//\param TRUE - Operation completed sucessfully, FALSE - Use contents of tResult to determine next action
FUNCTION Process%:_setup AS TSetup_Base,result AS tResult,speed
result.result$=STATE_MODULECONTINUE%
resut.moduleName$=""
RETURN TRUE
ENDFUNCTION

and the function list would consist of something like :

Code: (glbasic) [Select]
FUNCTION title_OnProgramStart%:_setup AS TSetup_Base
RETURN title.OnProgramStart(_setup)
ENDFUNCTION

FUNCTION title_OnProgramEnd%:_setup AS TSetup_Base
RETURN title.OnProgramEnd(_setup)
ENDFUNCTION

FUNCTION title_OnResolutionChange%:screenWidth%,screenHeight%
RETURN title.OnResolutionChange(screenWidth%,screenHeight%)
ENDFUNCTION

FUNCTION title_OnLanguageChange%:languageLoader AS TLanguageLoader
RETURN title.OnLanguageChange(languageLoader)
ENDFUNCTION

FUNCTION title_OnChange%:
RETURN title.OnChange()
ENDFUNCTION

FUNCTION title_OnRoutineStart%:_setup AS TSetup_Base
RETURN title.OnRoutineStart(_setup)
ENDFUNCTION

FUNCTION title_OnRoutineEnd%:_setup AS TSetup_Base
RETURN title.OnRoutineEnd(_setup)
ENDFUNCTION

FUNCTION title_OnDisplay2D%:_setup AS TSetup_Base
RETURN title.OnDisplay2D(_setup)
ENDFUNCTION

FUNCTION title_OnDisplay3D%:_setup AS TSetup_Base
RETURN title.OnDisplay3D(_setup)
ENDFUNCTION

FUNCTION title_OnProcess%:_setup AS TSetup_Base,result AS tResult,speed
RETURN title.OnProcess(_setup,result,speed)
ENDFUNCTION

At the moment its got the start of the options screen, which will be updated...

[attachment deleted by admin]

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2653
    • View Profile
Re: Program Processing System
« Reply #1 on: 2012-Jul-25 »
Only had a chance for a quick wee look but it already looks very comprehensive and well written, very handy! :good:
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

MrTAToad

  • Guest
Re: Program Processing System
« Reply #2 on: 2012-Jul-26 »
It should be quite useful for everyone!

MrTAToad

  • Guest
Re: Program Processing System
« Reply #3 on: 2012-Aug-20 »
I've been working on this recently, and have the basics of an options menu in.

Just need to put pointers into their own class.

All in all, it coud be rather profitable :)
« Last Edit: 2012-Aug-21 by MrTAToad »

MrTAToad

  • Guest
Re: Program Processing System
« Reply #4 on: 2012-Aug-21 »
This is my BallZ II game running using TSetup.  Note that it's running in debug mode, so it can slow down slightly in the main game.

Also note that it isn't complete : I need to add the hiscores and game over modules...  Oh, and the collection text is inaccurate :)

It's joystick only (I found that allowing mouse controls causes logical problems, especially if other users use joysticks)...

[attachment deleted by admin]