#include <psychlops.h>
using namespace Psychlops;	

int code, oldcode;
Psychlops::Rectangle rect(60,60), rect2(60,60);

void psychlops_main() {
	
	Canvas display(Canvas::fullscreen);
	display.clear(Color::gray);
	rect.centering();
	
	Input::refresh();
	
	while(!Input::get(Keyboard::spc)){
		oldcode=code;
		code=-1;
		display.clear(Color::gray);
		
		if(Input::get(Keyboard::c, Keyboard::pushed))code=0; //centering
		if(Input::get(Keyboard::left, Keyboard::pressed))code=1;
		else if(Input::get(Keyboard::right, Keyboard::pressed))code=2;

		switch(code){
			case -1: break;
			case 0: rect.centering(); break;
			case 1: rect.shift(-1,0); break;
			case 2: rect.shift(1,0); break;
		}
			
		rect2.centering().draw(Psychlops::Color(0.75,0.75,0.75)); 
		rect.draw(Psychlops::Color(1.0,1.0,1.0,0.25));
		display.flip();
	}
}