add: move
This commit is contained in:
		
							
								
								
									
										33
									
								
								game.🗿
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								game.🗿
									
									
									
									
									
								
							@ -106,13 +106,44 @@ draw_map(map, cursor_x, cursor_y)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
global input_left;
 | 
			
		||||
global input_right;
 | 
			
		||||
global input_up;
 | 
			
		||||
global input_down;
 | 
			
		||||
 | 
			
		||||
input_update() {
 | 
			
		||||
	local input = [INPUT];
 | 
			
		||||
	input_up = (input & 0x10) != 0;
 | 
			
		||||
	input_down = (input & 0x20) != 0;
 | 
			
		||||
	input_left = (input & 0x40) != 0;
 | 
			
		||||
	input_right = (input & 0x80) != 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cursor_update(cursor_x_ptr, cursor_y_ptr)
 | 
			
		||||
{
 | 
			
		||||
	if (input_up)
 | 
			
		||||
		[cursor_y_ptr] = ([cursor_y_ptr] - 1) % 3; 
 | 
			
		||||
	if (input_down)
 | 
			
		||||
		[cursor_y_ptr] = ([cursor_y_ptr] + 1) % 3; 
 | 
			
		||||
	if (input_left)
 | 
			
		||||
		[cursor_x_ptr] = ([cursor_x_ptr] - 1) % 3; 
 | 
			
		||||
	if (input_right)
 | 
			
		||||
		[cursor_x_ptr] = ([cursor_x_ptr] + 1) % 3; 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main()
 | 
			
		||||
{
 | 
			
		||||
	local cursor_x, cursor_y;
 | 
			
		||||
	local map = {'b', 'b', 'b','b', 'b', 'b', 'b', 'b', 'b'};
 | 
			
		||||
	
 | 
			
		||||
	cursor_x = SPAWN_X;
 | 
			
		||||
	cursor_y = SPAWN_Y;
 | 
			
		||||
	
 | 
			
		||||
	loop
 | 
			
		||||
	{
 | 
			
		||||
		slp;
 | 
			
		||||
		draw_map(map, 0, 0);
 | 
			
		||||
		draw_map(map, cursor_x, cursor_y);
 | 
			
		||||
		input_update();
 | 
			
		||||
		cursor_update(&cursor_x, &cursor_y);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user