VgaGames 3 - VgaGames3-object man-pages

[.. upper level ..]

ofunc_new()

Create the common VgaGames3-object structure.
SYNTAX
struct vg3_ofunc * ofunc_new(void)

RETURN VALUE
Returns a pointer to the common VgaGames3-object structure.

DESCRIPTION
This not a VgaGames3 function. It has to be created in addition to the game source files with the shipped helper program vg3-objfunc-create-cfile. This program recursively scans c- and c++-files from the current directory for following functions: - void getofc_*(struct vg3_ofunc_objfunc *) This function has to fill out the passed parameter struct vg3_ofunc_objfunc * for a VgaGames3-object, which must define the appropriate functions (f_new, f_free, ...) - void getoofc_*(struct vg3_ofunc_objobjfunc *) This function has to fill out the passed parameter struct vg3_ofunc_objobjfunc * for two VgaGames3-objects for an interaction of both, which must define the appropriate functions (e.g. f_collision) - void getofmgmt_*(struct vg3_ofunc_ofmgmt *) This function has to fill out the passed parameter struct vg3_ofunc_ofmgmt * for object-managing functions where * means an arbitrary remaining name. (Not all of these functions need to be defined.) Then it writes to stdout the created function, which must be included to the game source files.

EXAMPLE

Function for a sunnyboy object:
  void getofc_sboy(struct vg3_ofunc_objfunc *ofc) {
    snprintf(ofc->oid, sizeof(ofc->oid), "SUNNYBOY");
    ofc->f_new = f_new;
    ofc->f_free = f_free;
    ofc->f_run = f_run;
    ofc->f_draw = f_draw;
    /* we don't need f_data */
  }

  /* now define f_new(), f_free(), f_run() and f_draw() */

Function for an interaction of two sunnyboy objects:
  void getoofc_sboy_sboy(struct vg3_ofunc_objobjfunc *oofc) {
    /* if there are two different objects, the order of object-IDs doesn't matter */
    snprintf(oofc->oid1, sizeof(oofc->oid1), "SUNNYBOY");
    snprintf(oofc->oid2, sizeof(oofc->oid2), "SUNNYBOY");
    oofc->f_collision = f_collision;
    /* we don't need f_quit */
  }

  /* now define f_collision() */

Function for an object-management for the sunnyboy object:
  void getofmgmt_sboy(struct vg3_ofunc_ofmgmt *ofm) {
    snprintf(ofm->oid, sizeof(ofm->oid), "SUNNYBOY");
    ofm->f_activate = f_activate;
    ofm->f_deactivate = f_deactivate;
    ofm->f_run = f_run;
    ofm->f_data = f_data;
  }
  /* now define f_activate(), f_deactivate(), f_run() and f_data() */

SEE ALSO
VG3_ofunc_free()