init: draw_map work
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
tmp.*
 | 
			
		||||
							
								
								
									
										118
									
								
								game.🗿
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										118
									
								
								game.🗿
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,118 @@
 | 
			
		||||
define INPUT = 0xbffe;
 | 
			
		||||
define SCREEN = 0xbfff;
 | 
			
		||||
define SPAWN_X = 1;
 | 
			
		||||
define SPAWN_Y = 1;
 | 
			
		||||
define CASE_SIZE = 42;
 | 
			
		||||
 | 
			
		||||
draw_pixel(x, y, c)
 | 
			
		||||
{
 | 
			
		||||
	[SCREEN + (x & 127) + (y & 127) * 128] = c;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
draw_x(x, y, selected)
 | 
			
		||||
{
 | 
			
		||||
	local current_x = 0;
 | 
			
		||||
	local current_y;
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if (current_x == CASE_SIZE)
 | 
			
		||||
			return;
 | 
			
		||||
		current_y = 0;
 | 
			
		||||
		loop
 | 
			
		||||
		{
 | 
			
		||||
			if (current_y == CASE_SIZE)
 | 
			
		||||
				break;
 | 
			
		||||
			if (current_x == current_y | current_x == CASE_SIZE - current_y)
 | 
			
		||||
				draw_pixel(x + current_x, y + current_y, 0xffff);
 | 
			
		||||
			else
 | 
			
		||||
				draw_pixel(x + current_x, y + current_y, 0x1111 * (selected + 2));
 | 
			
		||||
			current_y++;
 | 
			
		||||
		}
 | 
			
		||||
		current_x++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
draw_o(x, y, selected)
 | 
			
		||||
{
 | 
			
		||||
	local current_x = 0;
 | 
			
		||||
	local current_y;
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if (current_x == CASE_SIZE)
 | 
			
		||||
			return;
 | 
			
		||||
		current_y = 0;
 | 
			
		||||
		loop
 | 
			
		||||
		{
 | 
			
		||||
			if (current_y == CASE_SIZE)
 | 
			
		||||
				break;
 | 
			
		||||
			if (current_x == 2 | current_y == 2 | current_x == CASE_SIZE - 2 | current_y == CASE_SIZE - 2)
 | 
			
		||||
				draw_pixel(x + current_x, y + current_y, 0xffff);
 | 
			
		||||
			else
 | 
			
		||||
				draw_pixel(x + current_x, y + current_y, 0x1111 * (selected + 2));
 | 
			
		||||
			current_y++;
 | 
			
		||||
		}
 | 
			
		||||
		current_x++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
draw_blank(x, y, selected)
 | 
			
		||||
{
 | 
			
		||||
	local current_x = 0;
 | 
			
		||||
	local current_y;
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if (current_x == CASE_SIZE)
 | 
			
		||||
			return;
 | 
			
		||||
		current_y = 0;
 | 
			
		||||
		loop
 | 
			
		||||
		{
 | 
			
		||||
			if (current_y == CASE_SIZE)
 | 
			
		||||
				break;
 | 
			
		||||
			draw_pixel(x + current_x, y + current_y, 0x1111 * (selected + 2));
 | 
			
		||||
			current_y++;
 | 
			
		||||
		}
 | 
			
		||||
		current_x++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
draw_case(x, y, content, selected)
 | 
			
		||||
{
 | 
			
		||||
	if (content == 'x')
 | 
			
		||||
		draw_x(x, y, selected);
 | 
			
		||||
	else if (content == 'o')
 | 
			
		||||
		draw_o(x, y, selected);
 | 
			
		||||
	else
 | 
			
		||||
		draw_blank(x, y, selected);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
draw_map(map, cursor_x, cursor_y)
 | 
			
		||||
{
 | 
			
		||||
	local x = 0;
 | 
			
		||||
	local y;
 | 
			
		||||
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		if (x == 3)
 | 
			
		||||
			return;
 | 
			
		||||
		y = 0;
 | 
			
		||||
		loop
 | 
			
		||||
		{
 | 
			
		||||
			if (y == 3)
 | 
			
		||||
				break;
 | 
			
		||||
			draw_case(x * CASE_SIZE + (x != 0) * (x), y * CASE_SIZE + (y != 0) * (y), [map + x * 3 + y], cursor_x == x & cursor_y == y);
 | 
			
		||||
			y++;
 | 
			
		||||
		}
 | 
			
		||||
		x++;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
{
 | 
			
		||||
	local map = {'b', 'b', 'b','b', 'b', 'b', 'b', 'b', 'b'};
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		slp;
 | 
			
		||||
		draw_map(map, 0, 0);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user