//Position controller
Module pcontrol(
input logic clk,

input logic chara,//left right up down

input logic bullet,//display or not
input logic reset,


output logic x0,y0,flag0,
output logic x1,y1,flag1,
output logic x2,y2,flag2,
output logic x3,y3,flag3,

);
//chara
logic countchara;
logic countbullet;
logic count;
logic t1,t2;



always_ff @(posedge clk or posedge reset)
begin
	if (reset)
		begin 
		t1=0;//defualt??????????
		t2=0;
		count=0;
		flag0=0;//first image
		end	
//counter from 0 to 10
		else begin
		if(count==10)
			count<=0;
		else
		count<=count+1;
		//character
		if (count==7&&chara==0)//right
			x0=x0+1;
		if (count==7&&chara==1)//up
			{t2=0;
			y0=y0+1*t1*t1+3*t1;
			t1=t1+1;}
		if (count==7&&chara==2)//left
			x0=x0-1;
		if (count==7&&chara==3)//down
			{t1=0;
			y0=y0-1*t2*t2-3*t2;
			t2=t2+1;}
		if (count==7&&(flag0<2)&&(bullet==0))
			flag0=flag0+1;
		if (flag0=3&&bullet==0)
			flag0=0;
		if (bullet==1)
			flag0=3;
		end
end


//bullet
always_ff @(posedge clk or posedge reset)
begin
//reset
	if (reset)
		begin 
		countbullet=0;
		justshoot<=0;
		x2<=0;
		y2<=0;
		flag2<=0;
		end	
//counter from 0 to 10
	else begin
		if(countbullet==10)
			begin
			countbullet<=0;
			flag2<=0;//first don't show
			bulletnumber<=0;
			end
		else
			countbullet<=countbullet+1;
		//flag2
		if (justshoot==0)//if not show bullet
			if (bullet==1)//if just shoot
				begin
				if (bulletnumber<2)
					bulletnumber<=bulletnumber+1;
					justshoot<=justshoot+1;
					y2[bulletnumber]<=y0;
					x2[bulletnumber]<=x0;
					flag2[bulletnumber]<=1;
				end
		else if(justshoot!=0)
			else if(countbullet==7&&flag1!=2)
				flag2<=flag2+1;
			else if(countbullet==7&&flag1==2)
				flag2<=1;
			end
		else if (countbullet==7&&justshoot>0)
			begin
			x2<=x2+1;
			end
		
			
		

//





