void init(MainStruct *mains, PlayerStruct players[], char nrplayers, GameStruct *game, ItemStruct zombie[MAX_ZOMBIES], ItemStruct shots[][2])
{
	ClearVram();
	srand(game->frames);

	//Set everything to 0
	memset(mains, 0, sizeof(MainStruct));
	memset(players, 0, sizeof(PlayerStruct)*nrplayers);
	memset(game, 0, sizeof(GameStruct));
	memset(zombie, 0, sizeof(ItemStruct)*MAX_ZOMBIES);
	memset(shots, 0, sizeof(ItemStruct)*4);
	memset(sprites, 0, sizeof(struct SpriteStruct)*32);

	//init graphics as well
	initgraphics(mains);
	setoverlay(nrplayers);

	for(int p = 0; p < nrplayers; p++)
	{
		//Main char sprites and guns
		players[p].sprite.nrsprite = 1 + 4 * p;
		players[p].sprite.animcount = 0;
		players[p].sprite.nranim = 1 + 22 * p;

		sprites[players[p].sprite.nrsprite].tileIndex=1 + 22 * p;
		sprites[players[p].sprite.nrsprite+1].tileIndex=11 + 22 * p;
		sprites[players[p].sprite.nrsprite].x = sprites[players[p].sprite.nrsprite+1].x = players[p].x;
		sprites[players[p].sprite.nrsprite].y = players[p].y;
		sprites[players[p].sprite.nrsprite+1].y = players[p].y + TILE_HEIGHT;

		//Init the shots as well.
		for(int i = 0; i < 2; i++)
		{
			shots[p][i].sprite.nrsprite = players[p].sprite.nrsprite + 2 + i;	
			shots[p][i].sprite.nranim = 64;
			shots[p][i].x = shots[p][i].y = DISABLED_SPRITE;
			shots[p][i].kill = NOT_ZOMBIE;
			sprites[shots[p][i].sprite.nrsprite].tileIndex = 64;
		}

		//init player variables
		players[p].x = 72 + 10 * p; //entry point yeah!
		players[p].y = 166;
		players[p].life = 3;
		players[p].gundelay = 35;
	}

	//init various game variables
	game->zombies = 1;
	initzombie(&(zombie[0]), mains, 9);

	return;
}
Esempio n. 2
0
void main()
{
	initvars();
	initgraphics();
	showlogo();
	
	do
	{
		while(!mainoptions());
		playgame();
	}while(1); //Infinite loop
}
Esempio n. 3
0
int ca3Dbase::run(int argc, char **argv)
{
	ca3Dglobal::CurrentCA = this;

	initglut(argc, argv);
	initspace(size, wrap);
	initgraphics();
	initcamera();

	glutMainLoop(); //call the main loop
	return 0;
}
Esempio n. 4
0
void initvmd() {
  // Assume that VMD should not initialize or use MPI
  // It is conceivable we would want to be able to load the VMD
  // Python module into a MPI-based Python run, and enable the 
  // MPI features of VMD, but we'll have to determine the best way
  // to detect this and it will need to be tested since we may have
  // to handle this case differently than the normal MPI case where
  // VMD explicitly does MPI initialization and shutdown itself. 
  int mpienabled = 0;

  // If there's already a VMDapp in get_vmdapp, then we must be running
  // inside a standalone VMD instead of being loaded as a python extension.
  // Don't throw an error - just load the methods for interoperability
  // in case vmd.so is in the PYTHONPATH of the standalone application.
  if (get_vmdapp() != NULL) {
    (void)Py_InitModule((char *)"vmd", VMDAppMethods);
    return;
  }

  int argc=1;
  char *argv[1];
  argv[0] = Py_GetProgramFullPath();
  if (!VMDinitialize(&argc, (char ***) &argv, mpienabled)) {
    return;
  }

  // XXX this is a hack, and it would be better to tie this into 
  //     VMDApp more directly at some later point, but the regular
  //     VMD startup code is similarly lame, so we'll use it for now.
  const char *disp = getenv("VMDDISPLAYDEVICE");
  if (!disp) disp="text";

  int loc[2] = { 50, 50 };
  int size[2] = { 400, 400 };
  VMDgetDisplayFrame(loc, size);

  VMDApp *app = new VMDApp(1, argv, mpienabled);
  app->VMDinit(1, argv, disp, loc, size);

  // read application defaults
  VMDreadInit(app);

  // read user-defined startup files
  VMDreadStartup(app);

  set_vmdapp(app);

  // set my local static
  the_app = app;

  PyObject *vmdmodule = Py_InitModule((char *)"vmd", VMDAppMethods);

  initanimate();
  initatomsel();
  initaxes();
  initcolor();
  initdisplay();
  initgraphics();
  initimd();
  initlabel();
  initmaterial();
  initmolecule();
  initmolrep();
  initmouse();
  initrender();
  inittrans();
  initvmdmenu();

#ifdef VMDNUMPY
  initvmdnumpy();
#endif

  if (PyErr_Occurred()) return;

  static const char *modules[] = {
    "animate", "atomsel", "axes", "color", "display", "graphics",
    "imd", "label", "material", "molecule", "molrep", "mouse", 
    "render", "trans", "vmdmenu", "vmdnumpy"
  };
  for (unsigned i=0; i<sizeof(modules)/sizeof(const char *); i++) {
    const char *m = modules[i];
#if (PY_MAJOR_VERSION == 2) && (PY_MINOR_VERSION < 5)
#define CAST_HACK (char *)
#else 
#define CAST_HACK
#endif
    PyModule_AddObject(vmdmodule, CAST_HACK m, PyImport_ImportModule( CAST_HACK m));
  }
  event_tstate = PyThreadState_Get();
#if defined(VMD_SHARED)
  PyOS_InputHook = vmd_input_hook;
#endif
}
Esempio n. 5
0
int main(int argc, string argv[])
{
    glutInit(&argc, argv);
    initparam(argv, defv);
    instr = stropen(getparam("in"), "r");
    refscale = getdparam("refscale");
    if (! strnull(getparam("colordata"))) {	/* color data wanted?	    */
        if (getbparam("dopcolor"))
	    error("%s: colordata precludes dopcolor\n", getargv0());
	if (! scanopt(PhiTag "," SmoothTag "," RhoTag "," EntFuncTag ","
		      UinternTag "," UdotIntTag "," UdotRadTag ","
		      UdotVisTag "," TauTag "," BirthTag "," DeathTag ","
		      AuxTag, getparam("colordata")))
	    error("%s: %s unknown\n", getargv0(), getparam("colordata"));
	bodytags[1] = getparam("colordata");	/* replace key w/ field...  */
	butbind[2] = COLORMAP;
    } else if (getbparam("dopcolor")) {
        dopcolor = TRUE;
	bodytags[1] = VelTag;			/* replace key w/ velocity  */
	butbind[2] = COLORMAP;
    }
    if (! strnull(getparam("vectordata"))) {
        if (! scanopt(VelTag "," AccTag "," AuxVecTag,
		      getparam("vectordata")))
	    error("%s: %s unknown\n", getargv0(), getparam("vectordata"));
	if (! (streq(getparam("vectordata"), VelTag) && dopcolor))
	    bodytags[2] = getparam("vectordata");
	butbind[2] = VSCALE;
    }
    maxfast = getiparam("maxfast");
    if (sscanf(getparam("defcolors"), "%x,%x", &pcolor, &bcolor) != 2)
	error("%s: can't scan defcolor parameter\n", getargv0());
    if (sscanf(getparam("viewsize"), "%ix%i", &wscreen, &hscreen) != 2)
	error("%s: can't scan viewsize parameter\n", getargv0());
    layout_body(bodytags, Precision, NDIM);
    if (! strnull(getparam("colordata"))) {
        scalaroff =
	  streq(bodytags[1], PhiTag)     ? PhiField.offset :
	  streq(bodytags[1], SmoothTag)  ? SmoothField.offset :
	  streq(bodytags[1], RhoTag)     ? RhoField.offset :
	  streq(bodytags[1], EntFuncTag) ? EntFuncField.offset :
	  streq(bodytags[1], UinternTag) ? UinternField.offset :
	  streq(bodytags[1], UdotIntTag) ? UdotIntField.offset :
	  streq(bodytags[1], UdotRadTag) ? UdotRadField.offset :
	  streq(bodytags[1], UdotVisTag) ? UdotVisField.offset :
	  streq(bodytags[1], TauTag)     ? TauField.offset :
	  streq(bodytags[1], BirthTag)   ? BirthField.offset :
	  streq(bodytags[1], DeathTag)   ? DeathField.offset :
	  streq(bodytags[1], AuxTag)     ? AuxField.offset : -1;
	assert(scalaroff != -1);
    }
    if (! strnull(getparam("vectordata"))) {
        vectoroff =
	  streq(getparam("vectordata"), VelTag)    ? VelField.offset :
	  streq(getparam("vectordata"), AccTag)    ? AccField.offset :
	  streq(getparam("vectordata"), AuxVecTag) ? AuxVecField.offset : -1;
	assert(vectoroff != -1);
    }
    if (! getdata())
        error("%s: no data in input file\n", getargv0());
    initgraphics(argv[0]);
    glutMainLoop();
    return (0);
}