Esempio n. 1
0
render::render(char* song, bool play) {
	this->play = play;
	running = setupSDL();

	if (play) {
		BASS_Init(-1, 44100, 0, NULL, NULL);
		HSTREAM stream;
		stream = BASS_StreamCreateFile(false, song, 0, 0, BASS_SAMPLE_FLOAT | BASS_STREAM_PRESCAN);
		sound_chan = stream;
		BASS_ChannelPlay(sound_chan, false);
	}


	srand(time(NULL));
	for (int i = 0; i < BALL_SIZE; i++) {
		balls[i].setX(rand()%BOX_SIZE*2);
		balls[i].setY(rand()%BOX_SIZE*2);
		balls[i].setZ(rand()%BOX_SIZE*2);
	}

	rotx = 0;
	roty = 0;
	rotz = 0;
	box_x = 0;
	box_y = 0;
	box_z = 0;
	posx = 0;
	posy = 0;
	posz = 100;
	max = BALL_SIZE;
}
Esempio n. 2
0
	// main program
int main(int argc, char* argv[])
{

SDL_Event event;
// logo
SDL_Texture* boat;
SDL_Rect bsrc;
SDL_Rect bdest;

int x =0;
int y =0;
Mix_Music *gMusic = NULL;
setupSDL();
// loads giant logo
 boat = loadImage("boat.png");
 bsrc.w = 600; bsrc.h = 400; 
 bsrc.x = 0;   bsrc.y =0;
 bdest.w =550;   bdest.h=350;
 bdest.x = 500;  bdest.y = 300;


 
 
 

while(1)
{
 	SDL_RenderClear(renderer);
 SDL_RenderCopy(renderer, boat, &bsrc, &bdest);
  
	   //gMusic = Mix_LoadMUS( "boathorn.wav" );
 SDL_RenderPresent(renderer);
// when the start is pushed
// another frame is loaded
// probably using mouse event and pixels
 if (SDL_PollEvent(&event) > 0)
                       {
                       switch(event.type)
                         {
						    Mix_FreeMusic( gMusic );
                         case SDL_QUIT: 
                           exit(0);
                         }
                       }
					   
SDL_Delay(50);




}
}
Esempio n. 3
0
int GameApp::initLibraries()
{	
	if( setupSDL() < 0 ){		// Initialize SDL.
		std::cerr << "Failed to initialize SDL." << std::endl; 
		exit(1);
	}    
    
    setupRenderingContext();	// OpenGL.
    setupMatrices();			// OpenGL.    
    setupSound();				// FMOD sound.
    
    std::srand ((unsigned int)time(NULL));	// Seed random numbers.

	return 0;
}