Example #1
0
DemoCMotion::DemoCMotion(clan::DisplayWindow &window) : window(window), fontColor(255.0f, 255.0f, 255.0f), blendingMode(L_ADDITIVE_BLENDING)
{
	window.set_title("LinearParticle Example - CMotion ");
	sc.connect(window.sig_window_close(), clan::bind_member(this, &DemoCMotion::on_window_close));
	canvas = clan::Canvas(window);

	sc.connect(window.get_keyboard().sig_key_up(), [&](const clan::InputEvent &input){on_key_up(input, canvas); });

	// initialize LinearParticle
	L_ParticleSystem::init();

	// create surface to be used for particle and set the alignment
	surface = clan::Sprite(canvas,"Resources/sketch.png");
	surface.set_alignment(clan::origin_center);
	font = clan::Font("Arial", 16);

	motion_ctrl.set_speed_limit(0.65f);
	motion_ctrl.set_point_acceleration( 320, 240, 0.001f );

	particle = clan::make_unique<L_Particle>(&surface, 3000);
	particle->rotating4();
	particle->set_motion_controller(&motion_ctrl);


	L_Vector shooting_vector;
	shooting_vector.set2( 0.4, L_DEGREE_TO_RADIAN(-90) );
	effect = clan::make_unique<L_ShootingEffect>(460, 360, shooting_vector, 16, 6);
	effect->add(particle.get());
	effect->set_width_interval(20);
	effect->set_angle_interval(L_DEGREE_TO_RADIAN(40));
	effect->set_life_distortion(600);
	effect->set_size_distortion(0.4f);
	effect->set_speed_distortion(0.06f);
	effect->initialize();

	bg_color = clan::Colorf(0.0f,0.0f,0.0f);

	set_style(canvas);

	last_time = clan::System::get_time();

}
Example #2
0
	bool update()
	{
		if (window.get_keyboard().get_keycode(keycode_escape))
			quit = true;

		canvas.clear(Colorf(0.5f,0.5f,0.5f));

		small_font.draw_text(canvas, 10, 40, "Image From Texture (10,60)");
		image_texture.draw(canvas, 10, 60);

		small_font.draw_text(canvas, 150, 40, "Image From Load (150,60)");
		image_loaded.draw(canvas, 150, 60);

		small_font.draw_text(canvas, 300, 40, "Image From Resources (300,60)");
		image_resources.draw(canvas, 300, 60);

		small_font.draw_text(canvas, 450, 40, "Image Copied (450,60)");
		image_copy.draw(canvas, 450, 60);

		small_font.draw_text(canvas, 10, 190, "Image - Top Right (10,200)");
		image_top_right.draw(canvas, 10, 200);

		small_font.draw_text(canvas, 150, 190, "Image - Top Right (150,200)");
		image_texture.draw(canvas, Rect(32, 0, Size(32, 32)), Rect(150, 200, Size(32, 32)));

		small_font.draw_text(canvas, 300, 190, "Image - Bottom Right (300,200)");
		image_bottom_right.draw(canvas, 300, 200);

		small_font.draw_text(canvas, 450, 190, "Image - Bottom Right (450,200)");
		image_texture.draw(canvas, Rect(32, 32, Size(32, 32)), Rect(450, 200, Size(32, 32)));

		small_font.draw_text(canvas, 10, 290, "700 Images (10,300)");
		for(int i=0;i<700;i++)
			image_texture.draw(canvas, 10, 300);

		small_font.draw_text(canvas, 150, 290, "br image (150,400) Size(128,256)");
		image_bottom_right.draw(canvas, Rect(150, 300, Size(128, 256)));

		small_font.draw_text(canvas, 300, 290, "Image - black");
		image_black.draw(canvas, 300, 300);

		small_font.draw_text(canvas, 300, 490, "Image - Scale (1.5, 2.5)");
		image_texture.set_scale(1.5f, 2.5f);
		image_texture.draw(canvas, 300, 500);
		image_texture.set_scale(1.0f, 1.0f);

		small_font.draw_text(canvas, 450, 460, "Image - Alignment (4 images with 8 pixel offset)");
		small_font.draw_text(canvas, 450, 475, "(top left, top right, bottom left, bottom right)");
		small_font.draw_text(canvas, 450, 490, "(Circle denotes the draw origin)");
		const int offset = 96;

		image_texture.set_alignment(origin_top_left, 8, 8);
		image_texture.draw(canvas, 450+offset, 500+offset);
		image_texture.set_alignment(origin_top_right, -8, 8);
		image_texture.draw(canvas, 450+offset, 500+offset);

		image_texture.set_alignment(origin_bottom_left, 8, -8);
		image_texture.draw(canvas, 450+offset, 500+offset);
		image_texture.set_alignment(origin_bottom_right, -8, -8);
		image_texture.draw(canvas, 450+offset, 500+offset);

		canvas.fill_circle(450+offset, 500+offset, 4, Colorf(1.0f, 1.0f, 1.0f, 0.9f));

		small_font.draw_text(canvas, 700, 460, "Image - Center Alignment (4 images with 8 pixel offset)");
		small_font.draw_text(canvas, 700, 475, "(top center, right center, bottom center, left center)");
		small_font.draw_text(canvas, 700, 490, "(Circle denotes the draw origin)");
				
		image_texture.set_alignment(origin_top_center, 0, 8);
		image_texture.draw(canvas, 700+offset, 500+offset);
		image_texture.set_alignment(origin_bottom_center, 0, -8);
		image_texture.draw(canvas, 700+offset, 500+offset);

		image_texture.set_alignment(origin_center_left, 8, 0);
		image_texture.draw(canvas, 700+offset, 500+offset);
		image_texture.set_alignment(origin_center_right, -8, 0);
		image_texture.draw(canvas, 700+offset, 500+offset);

		canvas.fill_circle(700+offset, 500+offset, 4, Colorf(1.0f, 1.0f, 1.0f, 0.9f));

		small_font.draw_text(canvas, 700, 160, "Image - Center Align (4 images with 64 pixel offset)");
		small_font.draw_text(canvas, 700, 175, "Also Includes a centered image (Without offset)");
		small_font.draw_text(canvas, 700, 190, "(Circle denotes the draw origin)");

		const int center_image_offset = 64;

		image_texture.set_alignment(origin_center, 0, 0);
		image_texture.draw(canvas, 700+offset, 200+offset);

		image_texture.set_alignment(origin_center, 0, center_image_offset);
		image_texture.draw(canvas, 700+offset, 200+offset);
		image_texture.set_alignment(origin_center, 0, -center_image_offset);
		image_texture.draw(canvas, 700+offset, 200+offset);

		image_texture.set_alignment(origin_center, center_image_offset, 0);
		image_texture.draw(canvas, 700+offset, 200+offset);
		image_texture.set_alignment(origin_center, -center_image_offset, 0);
		image_texture.draw(canvas, 700+offset, 200+offset);

		canvas.fill_circle(700+offset, 200+offset, 4, Colorf(1.0f, 1.0f, 1.0f, 0.9f));

		// Restore alignment
		image_texture.set_alignment(origin_top_left, 0, 0);

		dump_fps();

		window.flip(1);

		return !quit;
	}