Esempio n. 1
0
void Player::ConnectSlots(CL_Signal_v0& drawSignal, CL_Signal_v1<int>& updateSignal, CL_DisplayWindow window)
{
	//TODO: pass CL_InputDevice instead of CL_DisplayWindow to prevent unnecessary method invokations
	AnimateObject::ConnectSlots(drawSignal, updateSignal);
	m_keyDownSlot = window.get_ic().get_keyboard().sig_key_down().connect(this, &Player::OnKeyDown);
	m_keyUpSlot = window.get_ic().get_keyboard().sig_key_up().connect(this, &Player::OnKeyUp);
}
Esempio n. 2
0
Game::Game(CL_DisplayWindow& window) : window(window), quit(false), end(false)
{
	// Input-Eventhandler anlegen
	slotQuit = window.sig_window_close().connect(this, &Game::onWindowClose);
	slotKeyDown = window.get_ic().get_keyboard().sig_key_down().connect(this, &Game::onKeyDown);
	slotMouseDown = window.get_ic().get_mouse().sig_key_down().connect(this, &Game::onMouseDown);

	// Board und AI erstellen
	board = new Board(*this, CL_Size(BOARD_WIDTH, BOARD_HEIGHT));
	ai = new AI(*this);

	// Board und AI den Spielkomponenten hinzufügen
	components.push_back(board);
	components.push_back(ai);
}
Esempio n. 3
0
Game::Game(CL_DisplayWindow& window) : window(window), quit(false), pause(false)
{
    // Eventhandler anlegen
    slotQuit = window.sig_window_close().connect(this, &Game::onWindowClose);
    slotKeyDown = window.get_ic().get_keyboard().sig_key_down().connect(this, &Game::onKeyDown);

    components.push_back(new CellularAutomat(*this, 32, 184, 0.8f));
}
Esempio n. 4
0
int DemoSimple::run(CL_DisplayWindow &window)
{
	quit = false;

	// Set the window
	window.set_title("LinearParticle Example - Simple ");

	// Connect the Window close event
	CL_Slot slot_quit = window.sig_window_close().connect(this, &DemoSimple::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, &DemoSimple::on_input_up);

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

	// initialize LinearParticle
	L_ParticleSystem::init();

	// create surface to be used for particle and set the alignment
	CL_Sprite surface(gc,"Resources/light16p.png");
	surface.set_alignment(origin_center);

	// create a sample of particle with life of 5000
	L_Particle particle(&surface,5000);

	// create dropping effect with period of 16
	L_DroppingEffect dropper(0,0,16);

	// add the particle to dropper effect
	dropper.add(&particle);

	// initialize particle effect
	dropper.initialize();

	float x_pos = 320;
	float y_pos = 240;
	float x_vel = 3.0f;
	float y_vel = 3.0f;

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

	FramerateCounter frameratecounter;

	// Run until someone presses escape
	while (!quit)
	{
		gc.clear();

		x_pos += x_vel;
		y_pos += y_vel;

		if( x_pos > 640 || x_pos < 0 )
			x_vel = -x_vel;

		if( y_pos > 480 || y_pos < 0 )
			y_vel = -y_vel;

		dropper.set_position(x_pos, y_pos);
			dropper.trigger();

		/* pass frame time to L_ParticleEffect::run(int) for time based system,
			a constant number would be a reference time unit for frame based system. */
		dropper.run(16);

		// draw dropping effect
		L_DrawParticle(gc,dropper);

		frameratecounter.show_fps(gc, font);
		window.flip(0);	// Set to "1" to lock to screen refresh rate
		frameratecounter.frame_shown();

		CL_KeepAlive::process(0);
	}

	// deinitialize LinearParticle
	L_ParticleSystem::deinit();

	return 0;
}
void GameObject_Pacman::AttachKeyboard(CL_DisplayWindow &window)
{
	slots.connect(window.get_ic().get_keyboard().sig_key_down(), this, &GameObject_Pacman::on_key_down);
}