コード例 #1
0
void reset() {
	resetFollow();
	while (g_pHead != 0) {
		destroy(popTail());
	}
	pushTail(initSun(createNewElement())); //init sun
}
コード例 #2
0
void myInit()
{
	initMaths();
	camInit(g_Camera);
	camInputInit(g_Input);
	camInputExplore(g_Input, true);

	glClearColor(0.01f, 0.01f, 0.01f, 0.0f); //sets the colour values to use when clearing the colours, essentially sets the canvas colour
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHT0); //sets the colour of the light (0 == white)
	glEnable(GL_LIGHTING); //allows GL to make lighting calculations
	glEnableClientState(GL_VERTEX_ARRAY);

	pushTail(initSun(createNewElement())); //init sun

	loadTextures();
}
コード例 #3
0
ファイル: TestParticle.cpp プロジェクト: jinjianxin/cocos2d-x
bool TestParticle::init()
{
	if(! CCLayer::init())
		return false;
	size = CCDirector::sharedDirector()->getWinSize();

	initSmoke();	
	initFirework();
	initFire();
	initSun();
	initGalaxy();
	initFlower();
	initFlower();
	initBigFlower();
	initRotFlower();
	initMeteor();
	initSpiral();
	initExplosion();
	initSnow();

	return true;
}
コード例 #4
0
void rightClickMenu(int iCommand) {


	switch (iCommand) { //change to constants

	case PAUSE:
		g_bPlaying = false;
		break;
	case PLAY:
		g_bPlaying = true;
		break;
	case RESET:
		reset();
		break;
	case LONG_TRAILS: {
		resetTrails();
		g_iHistoryVariableLength = iHistoryMax;
		break; }
	case SHORT_TRAILS: {
		resetTrails();
		g_iHistoryVariableLength = g_iHistoryVariableLength / 3;

		if (g_iHistoryVariableLength < 300) {
			g_iHistoryVariableLength = 300; //with alpha, any shorter and they are basically off
		}

		break; }
	case TRAILS_OFF:
		g_bTrailsOn = false;
		break;
	case TRAILS_ON:
		g_bTrailsOn = true;
		break;
	case INCREASE_FPS:
		g_fFPSMultiplier += 0.2f;
		break;
	case DECREASE_FPS: {
		g_fFPSMultiplier -= 0.2f;

		if (g_fFPSMultiplier < 0.2f) { //stops it from having 0 fps, which currently would cause a crash
			g_fFPSMultiplier = 0.2f;
		}
		break; }
	case SAVE:
		saveFile();
		break;
	case LOAD:
		loadFile();
		break;
	case INCREASE_POPCAP:
		g_iMaintainPlanetNumber = g_iMaintainPlanetNumber * 2;
		break;
	case DECREASE_POPCAP:
		g_iMaintainPlanetNumber = g_iMaintainPlanetNumber / 2;
		break;
	case TEXTURES_ON:
		g_bTexturesOn = true;
		break;
	case TEXTURES_OFF:
		g_bTexturesOn = false;
		break;
	case PARTICLES_ON:
		g_bParticlesOn = true;
		break;
	case PARTICLES_OFF:
		g_bParticlesOn = false;
		break;
	case INCREASE_VELOCITY: 
		g_fVelocityMultiplier *= 2.0f;
		break;
	case DECREASE_VELOCITY:
		g_fVelocityMultiplier /= 2.0f;
		break; 
	case REVERSE_VELOCITY:
		g_fVelocityMultiplier *= -1.0f;
		break;
	case INCREASE_SIZE: {
		if (g_pFollowing) {
			g_pFollowing->fMass *= 2.0f;
			g_pFollowing->fSize *= 2.0f;
			g_pFollowing->iSlices += 5;
			g_pFollowing->iSegments += 5;
		}
		break; }
	case DECREASE_SIZE: {
		if (g_pFollowing) {
			g_pFollowing->fMass /= 2.0f;
			g_pFollowing->fSize /= 2.0f;
			g_pFollowing->iSlices = 20;
			g_pFollowing->iSegments = 20;
		}
		break; }
	case REMOVE_VELOCITY: {
		if (g_pFollowing) {
			vecInitDVec(g_pFollowing->afVelocity);
			vecInitDVec(g_pFollowing->afAcceleration);
		}
		break; }
	case CHANGE_COLOUR: {
		if (g_pFollowing) {
			g_pFollowing->afDiffuse[0] = randFloat(0.3f, 0.8f);
			g_pFollowing->afDiffuse[1] = randFloat(0.3f, 0.8f);
			g_pFollowing->afDiffuse[2] = randFloat(0.3f, 0.8f);
			g_pFollowing->afAmbient[0] = g_pFollowing->afDiffuse[0] / 2.0f;
			g_pFollowing->afAmbient[1] = g_pFollowing->afDiffuse[1] / 2.0f;
			g_pFollowing->afAmbient[2] = g_pFollowing->afDiffuse[2] / 2.0f;
		}
		break; }
	case STOP_FOLLOWING: 
		resetFollow();
		break;
	case SPHERE:
		pushTail(seedPlanetValues(createNewElement()));
		break;
	case CUBE:
		pushTail(seedCubeValues(createNewElement()));
		break;
	case CONE:
		pushTail(seedConeValues(createNewElement()));
		break;
	case TEAPOT:
		pushTail(seedTeapotValues(createNewElement()));
		break;
	case VERY_LARGE_SPHERE: {
		jrPlanet* pPlanet = seedPlanetValues(createNewElement()); 
		pPlanet->fSize = randFloat(50.0f, 100.0f);
		pPlanet->fMass = pPlanet->fSize * 20;
		pPlanet->iSegments = 30;
		pPlanet->iSlices = 30;
		pushTail(pPlanet);
		break; }
	case COMET: {
		jrPlanet* pPlanet = seedPlanetValues(createNewElement()); 
		pPlanet->fSize = pPlanet->fSize / 2;
		pPlanet->fMass = pPlanet->fSize * 20;
		pPlanet->m_bParticles = true;
		pushTail(pPlanet);
		break; }
	case SUN: {
		jrPlanet* pSun = initSun(createNewElement());
		pSun->afPosition[0] = randFloat(-3000.0f, 3000.0f);
		pSun->afPosition[1] = randFloat(-3000.0f, 3000.0f);
		pSun->afPosition[2] = randFloat(-3000.0f, 3000.0f);
		pushTail(pSun);
		break; }
	case EARTH: {
		jrPlanet* pPlanet = seedPlanetValues(createNewElement());
		pPlanet->fMass *= 1.5f;
		pPlanet->fSize *= 1.5f;

		pPlanet->iSegments = 20;
		pPlanet->iSlices = 20;

		pPlanet->afDiffuse[0] = 0.2f;
		pPlanet->afDiffuse[1] = 0.4f;
		pPlanet->afDiffuse[2] = 0.8f;

		pPlanet->afAmbient[0] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[1] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[2] = pPlanet->afDiffuse[0] / 2.0f;

		pPlanet->iType = EARTH;
		pushTail(pPlanet);
		break; }
	case MOON: {
		jrPlanet* pPlanet = seedPlanetValues(createNewElement());
		pPlanet->fMass *= 1.5f;
		pPlanet->fSize *= 1.5f;

		pPlanet->iSegments = 20;
		pPlanet->iSlices = 20;

		pPlanet->afDiffuse[0] = 0.8f;
		pPlanet->afDiffuse[1] = 0.8f;
		pPlanet->afDiffuse[2] = 0.8f;

		pPlanet->afAmbient[0] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[1] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[2] = pPlanet->afDiffuse[0] / 2.0f;

		pPlanet->iType = MOON;
		pushTail(pPlanet);
		break; }
	case MARS: {
		jrPlanet* pPlanet = seedPlanetValues(createNewElement());
		pPlanet->fMass *= 1.5f;
		pPlanet->fSize *= 1.5f;

		pPlanet->iSegments = 20;
		pPlanet->iSlices = 20;

		pPlanet->afDiffuse[0] = 0.8f;
		pPlanet->afDiffuse[1] = 0.3f;
		pPlanet->afDiffuse[2] = 0.3f;

		pPlanet->afAmbient[0] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[1] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[2] = pPlanet->afDiffuse[0] / 2.0f;

		pPlanet->iType = MARS;
		pushTail(pPlanet);
		break; }
	case DEATH_STAR: {
		jrPlanet* pPlanet = seedPlanetValues(createNewElement());
		pPlanet->fMass *= 1.5f;
		pPlanet->fSize *= 1.5f;

		pPlanet->iSegments = 20;
		pPlanet->iSlices = 20;

		pPlanet->afDiffuse[0] = 0.2f;
		pPlanet->afDiffuse[1] = 0.2f;
		pPlanet->afDiffuse[2] = 0.2f;

		pPlanet->afAmbient[0] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[1] = pPlanet->afDiffuse[0] / 2.0f;
		pPlanet->afAmbient[2] = pPlanet->afDiffuse[0] / 2.0f;

		pPlanet->iType = DEATH_STAR;
		pushTail(pPlanet);
		break; }
	}
}
コード例 #5
0
ファイル: shipViewer.c プロジェクト: Natsirtt/URSProject
int main(int argc, char *argv[]) {
  SDL_Surface *screen;
  if (argc > 1) {
    screen = gu_init_SDL("URS Ship Viewer", atoi(argv[1]));
  } else {
    screen = gu_init_SDL("URS Ship Viewer", 0);
  }
  gu_init_GL();
  gu_init_display(display);

  skuInitKeyBinder(&kb);
  skuBindKeyHandler(&kb, SDLK_BACKSPACE, reinitCam);
  skuBindKeyHandler(&kb, SDLK_UP, rotateUp);
  skuBindKeyHandler(&kb, SDLK_DOWN, rotateDown);
  skuBindKeyHandler(&kb, SDLK_LEFT, rotateLeft);
  skuBindKeyHandler(&kb, SDLK_RIGHT, rotateRight);
  skuBindKeyHandler(&kb, SDLK_z, zoom);
  skuBindKeyHandler(&kb, SDLK_s, dezoom);
  skuBindKeyHandler(&kb, SDLK_q, left);
  skuBindKeyHandler(&kb, SDLK_d, right);

  camInit(&camera);

  gu_initLights();

  GLfloat whiteLight[4] = {1, 1, 1, 1};
  GLfloat blackLight[4] = {0, 0, 0, 1};
  glLightfv(GL_LIGHT0, GL_AMBIENT, blackLight);
  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);

  glMatrixMode(GL_PROJECTION);
  gluPerspective(50, (float) screen->w / screen->h, 1, 10000);
  glMatrixMode(GL_MODELVIEW);
  reinitCam();

  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  initShip(&ship, 0, 0, 0);
  initSun(&sun, 0, 30, 30, 3, 0, 0, 0, 0);
  GLuint texDesc;
  gu_initTextures(&texDesc, 1, 1, "space.png");
  initSpace(&space, 0, 0, 0, 10, 0, 0, texDesc, 10);

  continuer = 1;
  SDL_Event event;

  Uint32 startTime;
  Uint32 ellapsedTime = 0;
  int frameNb = 0;

  //Boucle principale
  while (continuer) {
    
    //Les FPS
    startTime = SDL_GetTicks();
    if (ellapsedTime >= 1000) {
      printf("\r~%d fps", frameNb);
      fflush(stdout);
      ellapsedTime = 0;
      frameNb = 0;
    }

    //Les events
    while (SDL_PollEvent(&event)) {
      eventCatcher(&event);
    }
    skuHandle(&kb);
    gu_display();
    frameNb++;

    ellapsedTime += SDL_GetTicks() - startTime;
  }
  //C'est finit, libération des ressources
  printf("\n");
  gu_SDLQuit(1);
  exit(EXIT_SUCCESS);
}