#include "sprites.h"


void Raphael_Idle(Co co){
    Let x = SCol(co,raphael);
    Let y = SRow(co,raphael);
    Let state = Clock(co)%4;
    if(SAt(co,x,y+1)==' ' &&
       SAt(co,x-1,y)==' ' &&
       SAt(co,x+1,y)==' '){
        //SPlot(co,sai,Pixel,x,y-1,TR);
        //SPlot(co,saiB,Pixel,x,y,TR);
        SPlot(co,raphael,Ninja, x, y+1, RG);
    }
    else if (SAt(co,x,y+1) == ' '){
        if (state == 0){
            //SPlot(co,sai,' ',x,y-1,T);
            //SPlot(co,saiB,'!',x,y,T);
            SPlot(co,raphael,Ninja, x, y+1, RG);
        }
        else {
            //SPlot(co,sai,'x',x+1,y,Red);
            //SPlot(co,saiB,'+',x-1,y,Red);
            SPlot(co,raphael,Ninja, x, y, RG);
        }
    }
    else{
        switch(state){
            case 0:
                //SPlot(co,sai,'x',x+1,y,Red);
                //SPlot(co,saiB,'*',x-1,y,Red);
            break;
            case 1:
                //SPlot(co,sai,'+',x+1,y,Red);
                //SPlot(co,saiB,'x',x-1,y,Red); 
            break;
            case 2:
                //SPlot(co,sai,'*',x+1,y,Red);
                //SPlot(co,saiB,'x',x-1,y,Red); 
            break;
            case 3:
                //SPlot(co,sai,'x',x+1,y,Red);
                //SPlot(co,saiB,'+',x-1,y,Red); 
            break;
        };
        SPlot(co,raphael,Ninja, x, y, RG);
    }
}

void Raphael_ChargeLeft(Co co){
    Let x = SCol(co,raphael);
    Let y = SRow(co,raphael);
    Let brothers[] = {raphael, 0};
    //no obstacle on the left
    if(SAt(co,x-1,y) == ' '){
        //Snake(co,brothers,x-1,y);
    }
    //no obstacle upside
    else if(SAt(co,x,y-1) == ' '){
        //Snake(co,brothers,x,y-1);
    }
}

void Raphael_ChargeRight(Co co){
    Let x = SCol(co,raphael);
    Let y = SRow(co,raphael);
    Let brothers[] = {raphael, 0};
    //SPlot(co,saiB,Pixel,x,y,TR);
    if (SAt(co,x+1,y) == ' '){
        //Snake(co,brothers,x+1,y);
    }
    else if(SAt(co,x,y-1) == ' '){
        //Snake(co,brothers,x,y-1);
    }
}

void Raphael(Co co){
    if (SCol(co,raphael) == 0)
    if (SRow(co,raphael) == 0)
    return;

    if (leonardo != raphael)
    Next(co,Raphael_Idle);
    else if (Pressed(co,'a')) 
    Next(co,Raphael_ChargeLeft);
    else if (Pressed(co,'d'))
    Next(co,Raphael_ChargeRight);
    else
    {
        //he following
        //SStamp(co,sai,' ',T);
        //SStamp(co,saiB,' ',TR);
        SStamp(co,raphael,Ninja, RG);
    }
}


