Paint Pixels

Posted By: Rasch

Paint Pixels - 10/10/09 19:36

Hi there iīm currently not know how to continue my project cause i want to let the user draw a black pixel on the screen as long as he holds mouse left. But how can i realize that? I used draw_line draw_box and bmap_create but nothing works.

I donīt load a level its a pure 2d game with one picture in the background.

Greets

sry this for lite_c posted in wrong section.
Posted By: DJBMASTER

Re: Paint Pixels - 10/10/09 19:43

ermm i was going to suggest using 'draw_point3d' but then i realised you were only after a 2D solution.

Ermm I guess you could dynamically create a BMAP* that is 1x1 and fill it with a colour using 'bmap_fill'. Then you can display the BMAP* in a PANEL*.

You can use 'while(mouse_left==1)' to make sure it is only created when the mouse button is held. You can use either 'mouse_pos.x/y or mouse_cursor.x/y' to get the current position of the mouse.
Posted By: Rasch

Re: Paint Pixels - 10/10/09 19:44

Alright i will try this solution now

thanks
Posted By: DJBMASTER

Re: Paint Pixels - 10/10/09 19:57

Here is my quick go...
Code:
#include <acknex.h>
#include <default.c>

BMAP* pixel_bmap = "#1x1x16"; 
var temp_mouse_posx = 0;
var temp_mouse_posy = 0;

void main()
{	
	mouse_mode = 4;
	vec_set(screen_color,vector(255,255,255));
	wait(1);
	bmap_fill(pixel_bmap,vector(0,0,0),100);
	
	while(1)
	{
		mouse_pos.x = mouse_cursor.x;
		mouse_pos.y = mouse_cursor.y;
		if(mouse_left==1)
		{
			
			if(temp_mouse_posx != mouse_pos.x && temp_mouse_posy != mouse_pos.y)
			{
				
				PANEL* temp_panel = pan_create("bmap = pixel_bmap;",1);
				temp_panel.pos_x = mouse_pos.x;
				temp_panel.pos_y = mouse_pos.y;
				set(temp_panel,SHOW);
				temp_mouse_posx = mouse_pos.x;
				temp_mouse_posx = mouse_pos.y;
			}	
		}
		wait(1);
	}
}


Posted By: Rasch

Re: Paint Pixels - 10/10/09 20:10

Great that works but the problem is if i move to fast it creates single points is therer a way to convert this to a full line?
Posted By: DJBMASTER

Re: Paint Pixels - 10/10/09 20:48

um yeh, that is annoying, maybe 'mouse_sync' will help as it uses more computing power to syncronize the engine cursor with the windows one.

That's all I can think of at the moment.
Posted By: MMike

Re: Paint Pixels - 10/11/09 03:19

treyd the set_pixel Api?
© 2023 lite-C Forums