Exemple #1
0
void Game::Initialize()
{
	//Setup game window
	CL_DisplayWindowDescription desc;
	desc.set_title("SUPER MEGA AWESOME GAME                 by R&D Intercative");
	desc.set_size(CL_Size(RESOLUTION_X, RESOLUTION_Y), true);
	desc.set_allow_resize(false);
	m_window = CL_DisplayWindow(desc);

	//Setup input device and graphic context
	m_gc = m_window.get_gc();

	//Initialize resource manager and quit slot
	m_resources = CL_ResourceManager("resources.xml");
	m_quitSlot = m_window.sig_window_close().connect(this, &Game::OnQuit);
	m_keyDownSlot = m_window.get_ic().get_keyboard().sig_key_down().connect(this, &Game::OnKeyDown);

	XmlParser parser("settings/PlayerClasses.xml");
	s32 playerTypeCount = parser.ReadIntAttr("/PlayerClasses", "count");

	for (s32 i = 0; i < playerTypeCount; i++) {
		s8 node[64] = "/PlayerClasses/Class";
		s8 temp[5];
		itoa(i + 1, temp, 10);
		strcat(node, temp);
		s8 playerClass[32];
		parser.ReadText(node, playerClass, sizeof(playerClass));
		m_playerTypes.insert(std::pair<PlayerType, string>((PlayerType)i, string(playerClass)));
	}
}
int Application::main(const std::vector<CL_String> &args)
{
	try
	{		
		// Create a window
		CL_DisplayWindowDescription desc;
		desc.set_title("PacMan");
		desc.set_allow_resize(true);
		desc.set_size(CL_Size(800, 600), true);
		CL_DisplayWindow window(desc);

		CL_GraphicContext gc = window.get_gc();

		// Create world
		World world(window);

		world.run();
	}
	catch(CL_Exception &exception)
	{
		// Create a console window for text-output if not available
		CL_ConsoleWindow console("Console", 80, 160);
		CL_Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());
		console.display_close_message();

		return -1;
	}

	return 0;
}
Exemple #3
0
Graphics::Graphics(Profile &profile)
: mMinAspect(0.0f), mMaxAspect(0.0f), mVSync(true), mFPSTime(0), mNumFrames(0), mFPS(0.0f), mBlendMode(BLEND_ALPHA)
{
	// setup the graphics settings
	CL_DisplayWindowDescription desc;
	desc.set_title("Balance");
	desc.set_size(CL_Size(profile.getInt("width", 1024), profile.getInt("height", 768)), true);
	desc.set_swap_interval(mVSync ? 1 : 0);
	if (profile.getBool("fullscreen", true))
	{
		desc.set_decorations(false);
		desc.set_fullscreen(true);
	}
	else
	{
		desc.set_allow_resize(true);
	}
	mWindow = CL_DisplayWindow(desc);

	// make window visible while debugging under SciTE
	mWindow.show();

	// connect window signals
	mSlots.connect(Application::getSingleton().getSigUpdate(), this, &Graphics::onUpdate);
	mSlots.connect(mWindow.get_ic().get_mouse().sig_key_down(), this, &Graphics::onMouseDown);
	mSlots.connect(mWindow.get_ic().get_mouse().sig_key_dblclk(), this, &Graphics::onMouseDown);
	mSlots.connect(mWindow.get_ic().get_mouse().sig_key_up(), this, &Graphics::onMouseUp);
	mSlots.connect(mWindow.sig_resize(), this, &Graphics::onResize);
	mSlots.connect(mWindow.sig_window_close(), this, &Graphics::onClose);

	// initialize the graphics settings
	mWindow.get_gc().set_map_mode(cl_user_projection);
	setScreenSize(1024.0f, 768.0f);
	setBlendMode(mBlendMode);

	// save the current settings
	profile.setBool("fullscreen", desc.is_fullscreen());
	profile.setInt("width", desc.get_size().width);
	profile.setInt("height", desc.get_size().height);
}
Exemple #4
0
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
	quit = false;

	// Set the window
	CL_DisplayWindowDescription desc;
	desc.set_title("ClanLib App Example");
	desc.set_size(CL_Size(1200, 500), true);
	desc.set_allow_resize(true);

	CL_DisplayWindow window(desc);

	// Connect the Window close event
	CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);

	// Connect a keyboard handler to on_key_up()
	CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);

	// Get the graphic context
	CL_GraphicContext gc = window.get_gc();

	// Load a sprite from a png-file
	tux = CL_PixelBuffer("Resources/tux.png");

	tux_original = CL_Image(gc, tux, tux.get_size());
	current_format = cl_rgba8;

	//current_format = cl_rgba8;
	//current_format = cl_rgb8;
	//current_format = cl_bgra8;
	//current_format = cl_bgr8;
	//current_format = cl_r8;
	//current_format = cl_r8_snorm;
	//current_format = cl_r16;
	//current_format = cl_r16_snorm;
	//current_format = cl_rg8;
	//current_format = cl_rg8_snorm;
	//current_format = cl_rg16;
	//current_format = cl_rg16_snorm;
	//current_format = cl_r3_g3_b2;
	//current_format = cl_rgb4;
	//current_format = cl_rgb5;
	//current_format = cl_rgb8_snorm;
	//current_format = cl_rgb10;
	//current_format = cl_rgb12;		// XX
	//current_format = cl_rgb16;
	//current_format = cl_rgb16_snorm;
	//current_format = cl_rgba2;		// XX
	//current_format = cl_rgba4;
	//current_format = cl_rgb5_a1;
	//current_format = cl_rgba8_snorm;
	//current_format = cl_rgb10_a2;
	//current_format = cl_rgba12;		// X
	//current_format = cl_rgba16;
	//current_format = cl_rgba16_snorm;
	//current_format = cl_srgb8;
	//current_format = cl_srgb8_alpha8;
	//current_format = cl_r16f;
	//current_format = cl_rg16f;
	//current_format = cl_rgb16f;
	//current_format = cl_rgba16f;
	//current_format = cl_r32f;
	current_format = cl_rg32f;
	//current_format = cl_rgb32f;
	//current_format = cl_rgba32f;
	//current_format = cl_r11f_g11f_b10f;	// X
	//current_format = cl_rgb9_e5;	// X
	//current_format = cl_r8i;
	//current_format = cl_r8ui;
	//current_format = cl_r16i;
	//current_format = cl_r16ui;
	//current_format = cl_r32i;
	//current_format = cl_r32ui;
	//current_format = cl_rg8i;
	//current_format = cl_rg8ui;
	//current_format = cl_rg16i;
	//current_format = cl_rg16ui;
	//current_format = cl_rg32i;
	//current_format = cl_rg32ui;
	//current_format = cl_rgb8i;
	//current_format = cl_rgb8ui;
	//current_format = cl_rgb16i;
	//current_format = cl_rgb16ui;
	//current_format = cl_rgb32i;
	//current_format = cl_rgb32ui;
	//current_format = cl_rgba8i;
	//current_format = cl_rgba8ui;
	//current_format = cl_rgba16i;
	//current_format = cl_rgba16ui;
	//current_format = cl_rgba32i;
	//current_format = cl_rgba32ui;
	//current_format = cl_depth_component16;
	//current_format = cl_depth_component24;
	//current_format = cl_depth_component32;
	//current_format = cl_depth_component32f;
	//current_format = cl_depth24_stencil8;
	//current_format = cl_depth32f_stencil8;
	//current_format = cl_compressed_red;
	//current_format = cl_compressed_rg;
	//current_format = cl_compressed_rgb;
	//current_format = cl_compressed_rgba;
	//current_format = cl_compressed_srgb;
	//current_format = cl_compressed_srgb_alpha;
	//current_format = cl_compressed_red_rgtc1;
	//current_format = cl_compressed_signed_red_rgtc1;
	//current_format = cl_compressed_rg_rgtc2;
	//current_format = cl_compressed_signed_rg_rgtc2;
	//current_format = cl_compressed_rgb_s3tc_dxt1;
	//current_format = cl_compressed_rgba_s3tc_dxt1;
	//current_format = cl_compressed_rgba_s3tc_dxt3;
	//current_format = cl_compressed_rgba_s3tc_dxt5;
	//current_format = cl_compressed_srgb_s3tc_dxt1;
	//current_format = cl_compressed_srgb_alpha_s3tc_dxt1;
	//current_format = cl_compressed_srgb_alpha_s3tc_dxt3;
	//current_format = cl_compressed_srgb_alpha_s3tc_dxt5;


	display_gc = &gc;
	update_images();

	CL_Font font(gc, "tahoma", 24);

	// Run until someone presses escape
	while (!quit)
	{

		gc.clear(CL_Colorf(0.0f,0.0f,0.2f));

		tux_original.draw(gc, 0, 0);
		tux_convert.draw(gc, 400, 0);
		tux_unconvert.draw(gc, 800, 0);

		font.draw_text(gc, 10, 400, "cl_rgba8");

		if (gl_supported)
		{
			font.draw_text(gc, 410, 400, "converted");
		}
		else
		{
			font.draw_text(gc, 410, 400, "NOT SUPPORTED BY clanGL");
		}

		font.draw_text(gc, 810, 400, "converted back to cl_rgba8");

		window.flip(1);

		// This call processes user input and other events
		CL_KeepAlive::process(0);
	}

	return 0;
}
Exemple #5
0
// The start of the Application
int App::start(const std::vector<CL_String> &args)
{
	quit = false;

	// Set the window
	CL_DisplayWindowDescription desc;
	desc.set_title("ClanLib Worker GC Example");
	desc.set_size(CL_Size(640, 480), true);
	desc.set_allow_resize(true);

	CL_DisplayWindow window(desc);
	CL_OpenGL::set_active(NULL);	//  wglCreateContextAttribsARB will fail if the shared context is current in a different thread.
	WorkerGC worker_gc;
	CL_System::sleep(200);	// Fixme

	// Connect the Window close event
	CL_Slot slot_quit = window.sig_window_close().connect(this, &App::on_window_close);

	// Connect a keyboard handler to on_key_up()
	CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &App::on_input_up);

	// Get the graphic context
	CL_GraphicContext gc = window.get_gc();

	worker_gc.Start("../../../Examples/Game/DiceWar/Resources/lobby_background1.png");

	CL_Sprite spr_logo;

	float sin_count = 0.0f;
	float ypos = 0.0f;
	float ydir = 0.3f;

	unsigned int last_time = CL_System::get_time();

	// Run until someone presses escape
	while (!quit)
	{
		unsigned int current_time = CL_System::get_time();
		float time_delta_ms = static_cast<float> (current_time - last_time);
		last_time = current_time;

		if (!spr_logo.is_null())
		{
			gc.clear(CL_Colorf(0.0f,0.0f,0.2f));
			spr_logo.draw(gc, 
				(float) gc.get_width()-spr_logo.get_width(),
				(float) gc.get_height()-spr_logo.get_height());
		}
		else
		{
			gc.clear(CL_Colorf(0.5f,0.0f,0.0f));
		}

		// Move the lines
		ypos += ydir * time_delta_ms;
		if (ydir > 0.0f)
		{
			if ((ypos+200.0f) >= gc.get_height())
			{
				ypos = (float) (gc.get_height() - 200);
				ydir *= -1.0f;
			}
		}
		else
		{
			if (ypos <= 0.0f)
			{
				ypos = 0.0f;
				ydir *= -1.0f;
			}
		}
			
		CL_Draw::fill(gc, 0, ypos-1.0f, (float) gc.get_width(), ypos-8.0f,CL_Colorf(1.0f, 1.0f, 1.0f));
		CL_Draw::fill(gc, 0, ypos+198.0f, (float) gc.get_width(), ypos+190.0f, CL_Colorf(1.0f, 1.0f, 1.0f));


		// Flip the display, showing on the screen what we have drawed
		// since last call to flip()
		window.flip(1);

		if (worker_gc.IsReady())
		{
				spr_logo = worker_gc.Get();
		}

		// This call processes user input and other events
		CL_KeepAlive::process(0);



	}

	return 0;
}
Exemple #6
0
int ExampleText::start(const std::vector<CL_String> &args)
{ 
	// Create a console window for text-output if not available
	CL_ConsoleWindow console("Console");
	
	quit = false;

	// Set a videomode
	CL_DisplayWindowDescription desc;
	desc.set_allow_resize(false);
	desc.set_title("ClanLib CL_SpanLayout Example");
	desc.set_size(CL_Size(800, 600), true);
	CL_DisplayWindow window(desc);

	// Connect the Window close event
	CL_Slot slot_quit = window.sig_window_close().connect(this, &ExampleText::on_window_close);

	// Connect a keyboard handler to on_key_up()
	CL_Slot slot_keyboard_up = window.get_ic().get_keyboard().sig_key_up().connect(this, &ExampleText::on_keyboard_up);

	CL_GraphicContext gc = window.get_gc();

	CL_TextureGroup texture_group(gc, CL_Size(512, 512));

	CL_FontDescription font_desc;
	font_desc.set_typeface_name("Tahoma");
	font_desc.set_anti_alias(true);
	font_desc.set_height(32);
	CL_Font_System font_normal(gc, font_desc);

	font_desc.set_weight(800);
	font_desc.set_height(40);
	CL_Font_System font_bold(gc, font_desc);

	// Share the font texture
	font_normal.set_texture_group(texture_group);
	font_bold.set_texture_group(texture_group);

	CL_Texture texture_text(gc, text_window_size, text_window_size);
	texture_text.set_wrap_mode(cl_wrap_repeat, cl_wrap_repeat, cl_wrap_repeat);
	texture_text.set_min_filter(cl_filter_linear);
	texture_text.set_mag_filter(cl_filter_linear);

	// Create the framebuffer, and attach the texture text into its color buffer
	CL_FrameBuffer fb_text;
	fb_text = CL_FrameBuffer(gc);
	fb_text.attach_color_buffer(0, texture_text);

	float angle = 0.0f;

	std::vector<CL_SpanLayout> layout;

	// Count number of lines
	int num_lines = 0;
	for (const char **text_ptr = TextToShow; *text_ptr; text_ptr++)
	{
		num_lines++;
	}

	// Extend layout vector
	layout.resize(num_lines);

	int ypos = 60;
	for (int line_count=0; line_count < num_lines; line_count++, ypos += 8)
	{
		layout[line_count] = CL_SpanLayout();

		layout[line_count].set_position(CL_Point(20, ypos));

		layout[line_count].set_align(cl_justify);

		const char *text_ptr = TextToShow[line_count];
		if (text_ptr[0] == '-')
		{
			layout[line_count].add_text(text_ptr, font_normal, CL_Colorf::red);
		}
		else if (strstr(text_ptr, "Clan"))
		{
			layout[line_count].add_text(text_ptr, font_bold, CL_Colorf::yellow);
		}
		else
		{
			layout[line_count].add_text(text_ptr, font_normal, CL_Colorf::yellow);
		}

		layout[line_count].layout(gc, texture_text.get_width() - 60);

		ypos += layout[line_count].get_size().height;

	}

	// Run until someone presses escape
	while (!quit)
	{
		int start_time = CL_System::get_time();

		gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));

		// Draw a nice blue gradient in the background
		CL_Draw::gradient_fill(gc, window.get_viewport(), CL_Gradient(CL_Colorf::lightblue, CL_Colorf::lightblue, CL_Colorf::darkblue, CL_Colorf::darkblue));

		// Draw the text into the frame buffer
		update_text(gc, fb_text, font_normal, layout);

		angle += 0.5f;
		if (angle >= 360.0f)
			angle -= 360.0f;

		// Draw the text
		draw_text(gc, texture_text, CL_Angle(angle, cl_degrees));

		last_fps = 1000.0f / (CL_System::get_time()-start_time);
		// Flip the display, showing on the screen what we have drawn
		window.flip(1);

		// This call updates input and performs other "housekeeping" call this each frame
		CL_KeepAlive::process();
	}

	return 0;
}
Exemple #7
0
// The start of the Application
int Basic::start(const std::vector<CL_String> &args)
{
	quit = false;

	// Set the window
	CL_DisplayWindowDescription desc;
	desc.set_title("ClanLib OpenCL Basic Example");
	desc.set_size(CL_Size(640, 480), true);
	desc.set_allow_resize(true);

	CL_DisplayWindow window(desc);

	// Connect the Window close event
	CL_Slot slot_quit = window.sig_window_close().connect(this, &Basic::on_window_close);

	// Connect a keyboard handler to on_key_up()
	CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &Basic::on_input_up);

	// Get the graphic context
	CL_GraphicContext gc = window.get_gc();

	cl_int error;
	cl_platform_id platform;
	cl_uint platforms;
	
	error = clGetPlatformIDs(1, &platform, &platforms);
	if (error != CL_SUCCESS)
		throw CL_Exception("clGetPlatformIDs failed");

	cl_device_id device;
	cl_uint devices;
	error = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 1, &device, &devices);
	if (error != CL_SUCCESS)
		throw CL_Exception("clGetDeviceIDs failed");
	
	cl_context_properties properties[]={CL_CONTEXT_PLATFORM, (cl_context_properties)platform, 0};
	cl_context context;
	context = clCreateContext(properties, 1, &device, NULL, NULL, &error);
	if (error != CL_SUCCESS)
		throw CL_Exception("clCreateContext failed");

	cl_command_queue cq;
	cq = clCreateCommandQueue(context, device, 0, &error);
	if (error != CL_SUCCESS)
		throw CL_Exception("clCreateCommandQueue failed");

	static const char source_code[] = 
		""
		"__kernel void simple_test(__global float *vals)"
		"{"
		"	const uint i = get_global_id(0);"
		""
		"vals[i] = 1.23;"
		"}"
		"";


	const char *src[] = {source_code};

	cl_program prog;
	prog = clCreateProgramWithSource(context, 1, src, NULL, &error);
	if (error != CL_SUCCESS)
		throw CL_Exception("clCreateProgramWithSource failed");

	error = clBuildProgram(prog, 0, NULL, "", NULL, NULL);
	if (error != CL_SUCCESS)
		throw CL_Exception("clBuildProgram failed");

	cl_kernel k_simple_test;
	k_simple_test = clCreateKernel(prog, "simple_test", &error);
	if (error != CL_SUCCESS)
		throw CL_Exception("clCreateKernel failed");

	static const int buffer_length = 64;
	cl_mem ref_buffer;
	ref_buffer = clCreateBuffer(context, CL_MEM_READ_WRITE, sizeof(float) *  buffer_length, NULL, &error);
	if (error != CL_SUCCESS)
		throw CL_Exception("clCreateBuffer failed");

	error = clSetKernelArg(k_simple_test, 0, sizeof(ref_buffer), &ref_buffer);
	if (error != CL_SUCCESS)
		throw CL_Exception("clSetKernelArg failed");

	const size_t worksize = buffer_length;
	error = clEnqueueNDRangeKernel(cq, k_simple_test, 1, NULL, &worksize, NULL, 0, NULL, NULL);
	if (error != CL_SUCCESS)
		throw CL_Exception("clEnqueueNDRangeKernel failed");

	error = clFinish(cq);
	if (error != CL_SUCCESS)
		throw CL_Exception("clFinish failed");

	float ram_buffer[buffer_length];
	error=clEnqueueReadBuffer(cq, ref_buffer, CL_TRUE, 0, sizeof(float) * buffer_length, ram_buffer, 0, NULL, NULL);
	if (error != CL_SUCCESS)
		throw CL_Exception("clEnqueueReadBuffer failed");

	error=clFinish(cq);
	if (error != CL_SUCCESS)
		throw CL_Exception("clFinish failed");

	// Clean up
	clReleaseKernel(k_simple_test);
	clReleaseProgram(prog);
	clReleaseCommandQueue(cq);
	clReleaseContext(context);
	clReleaseMemObject(ref_buffer);

	// Test output
	for (int cnt=0;cnt < buffer_length; cnt++)
	{
		if (ram_buffer[cnt] != 1.23f)
			throw CL_Exception("It did not work!");
	}

	CL_Font font(gc, "tahoma", 24);

	// Run until someone presses escape
	while (!quit)
	{
		gc.clear(CL_Colorf(0.0f,0.0f,0.2f));
		font.draw_text(gc, 32, 32, "Success");
		window.flip(1);
		CL_KeepAlive::process(0);
	}

	return 0;
}
Exemple #8
0
// The start of the Application
int Tetris::start(const std::vector<CL_String> &args)
{
    quit = false;
    finish = false;

//    leftborderlist = new LeftBordeList();
 //   rightbordelist = new RightBordeList();

    // Set the window
    CL_DisplayWindowDescription desc;
    desc.set_title("Tetris");
    desc.set_size(CL_Size(320, 640), true);
    desc.set_allow_resize(true);

    CL_DisplayWindow window(desc);

    // Connect the Window close event
    CL_Slot slot_quit = window.sig_window_close().connect(this, &Tetris::on_window_close);

    // Connect a keyboard handler to on_key_up()
    CL_Slot slot_input_up = (window.get_ic().get_keyboard()).sig_key_up().connect(this, &Tetris::on_input_up);

    // Get the graphic context
    CL_GraphicContext gc = window.get_gc();

    // Load a sprite from a png-file
    //CL_Sprite spr_logo(gc, "Resources/logo.png");

    float sin_count = 0.0f;
    float ypos = 0.0f;
    float ydir = 0.3f;

    unsigned int last_time = CL_System::get_time();

    CL_Font font(gc, "Utopia", 40);
    linesRemoved = 0;

    // Run until someone presses escape
    while (!quit)
    {
        unsigned int current_time = CL_System::get_time();
        float time_delta_ms = static_cast<float> (current_time - last_time);
        last_time = current_time;
        float shift = time_delta_ms/20;
        shift = 1.0f;

        //std::cout << "shift = " << shift << std::endl;

        // Clear the display in a dark blue nuance
        // The four arguments are red, green, blue and alpha
        gc.clear(CL_Colorf(25.0f,25.0f,25.0f));
        std::string s;
        std::stringstream out;
        out << linesRemoved;
        s = out.str();
        font.draw_text(gc, 250,40, s.c_str(), CL_Colorf::blue);

        int l = bottomborderlist.getLineNumberToDelete();

        while (l != -1)
        {
            l = bottomborderlist.getLineNumberToDelete();
            if (l!= -1)
            {
                if (!bottomborderlist.isFullHeight())
                {
                    linesRemoved++;
                }

            }
            bottomborderlist.removeLine(l);


        }



        if (!figlist.checkCollisionDown(bottomborderlist))
        {
            figlist.moveDown(shift);


        }
        else
        {
            FigureList newfl = figlist;
            newfl.setStablePosition();

            if (!finish)
            {
                bottomborderlist.addList(newfl.getFigureList());
                if (figlist.checkCollisionDown(bottomborderlist))
                {
                   figlist.reset();


                }
                else
                {
                    figlist.reset();
                    figlist.clearFigureList();

                }

            }


            if (figlist.checkCollisionDown(bottomborderlist))
            {

                finish  = true;

            }



        }

        leftborderlist.draw(gc);
         rightborderlist.draw(gc);
         bottomborderlist.draw(gc);

        if (finish == false  && !figlist.checkCollisionDown(bottomborderlist))
        {
            figlist.draw(gc);
        }
        else
        {
             if (linesRemoved < 5)
                    {
                        font.draw_text(gc, 10,40, "You Lost", CL_Colorf::black);
                    }
                    else
                    {
                        font.draw_text(gc, 10,40, "You Won", CL_Colorf::black);
                    }

        }












        // Flip the display, showing on the screen what we have drawed
        // since last call to flip()
        window.flip(1);

        // This call processes user input and other events
        CL_KeepAlive::process(0);
    }
    return 0;
}
Exemple #9
0
void Game::run()
{	

	//_________________________________________________________________
	//										V I D E O   S E T T I N G S
	screen_x_res = 640;
	screen_y_res = 480;

	CL_DisplayWindowDescription desc;
	desc.set_title("Roadgeddon");
	desc.set_size(CL_Size(screen_x_res, screen_y_res), true);
	desc.set_allow_resize(false);

	CL_DisplayWindow window(desc);
	
	CL_Slot slot_quit				= window.sig_window_close()							.connect(this,&Game::on_quit);
	CL_Slot slot_keyboard_key_down	= (window.get_ic().get_keyboard()).sig_key_down()	.connect(this,&Game::on_key_down);
	CL_Slot slot_keyboard_key_up	= (window.get_ic().get_keyboard()).sig_key_up()		.connect(this,&Game::on_key_up);
	CL_Slot slot_mouse_moved		= (window.get_ic().get_mouse()).sig_pointer_move()	.connect(this,&Game::on_pointer_move);
	CL_Slot slot_mouse_down			= (window.get_ic().get_mouse()).sig_key_down()		.connect(this,&Game::on_pointer_down);
	CL_Slot slot_mouse_up			= (window.get_ic().get_mouse()).sig_key_up()		.connect(this,&Game::on_pointer_up);
	
	gc = window.get_gc();

	CL_ResourceManager resources("resources.xml");
	resources_=&resources;

	int time_elapsed_ms = 0;
	int lastTime = 0;
	int currentTime = 0;
	currentTime = CL_System::get_time();
	lastTime = CL_System::get_time();

	//________________________________________________________________
	//											           S O U N D S

	total_channels=3;
	current_channel=1;
	CL_SoundBuffer music("Music1",&resources);
	music.set_volume(0.3f);

	sound_session1.play();
	sound_session2.play();
	sound_session3.play();

	total_samples = 6;
	samples.resize(total_samples);
	samples[0] = CL_SoundBuffer("Explosion1",&resources);
	samples[1] = CL_SoundBuffer("Explosion2",&resources);
	samples[2] = CL_SoundBuffer("Hurt1",&resources);
	samples[3] = CL_SoundBuffer("Hurt2",&resources);
	samples[4] = CL_SoundBuffer("Powerup1",&resources);
	samples[5] = CL_SoundBuffer("Shoot1",&resources);
	
	for(int i = 0; i<total_samples; i++)
	{
		samples[i].set_volume(0.3f);
	}
	
	CL_SoundBuffer_Session music_session = music.prepare();
	music_session_ = &music_session;

	music_session.set_looping(true);
	music_session.play();
	is_music_muted = false;

	//________________________________________________________________
	//											     G A M E   P R E P
	
	Map map(*this);
	Player player(*this);

	mapP = &map;
	playerP = &player;

	time_elapsed_since_last_enemy=0;
	
	//________________________________________________________________
	//														 O T H E R 
	srand(CL_System::get_time());

	while (!quit)
	{
		currentTime = CL_System::get_time();
		time_elapsed_ms = currentTime - lastTime; 
		lastTime = currentTime;
	
		update_game(time_elapsed_ms);
		update_signal.invoke(time_elapsed_ms);

		map.drawBackground();
		draw_signal.invoke();

		// Flip the display, showing on the screen what we have drawed since last call to flip()
		window.flip(1);

		// This call processes user input and other events
		CL_KeepAlive::process(0);

		// Sleep for a little while to avoid using too much of the CPU.
		CL_System::sleep(5);

		if(objects_for_deletion.size()>0)
		{
			std::list<Gameobject *>::iterator it;
			for(it=objects_for_deletion.begin(); it!= objects_for_deletion.end(); ++it)
			{
				delete (*it);
			}

			objects_for_deletion.clear();
		}
	}
}