#include "playground.h"

#include <kdebug.h>

Playground::Playground(QCanvas *canvas, QWidget *parent, const char *name)
: QCanvasView(canvas, parent, name)
{
	setFocus();

	setHScrollBarMode(QScrollView::AlwaysOff);
	setVScrollBarMode(QScrollView::AlwaysOff);

	viewport()->setPaletteBackgroundColor(QColor(0, 0, 0));

	show();
}

Playground::~Playground()
{
}

void Playground::keyPressEvent(QKeyEvent *e)
{
	//kdDebug() << "playground: key pressed" << endl;
	switch(e->key())
	{
		case Qt::Key_Down:
			emit key(KeyDown);
			break;
		case Qt::Key_Up:
			emit key(KeyUp);
			break;
		case Qt::Key_Left:
			emit key(KeyLeft);
			break;
		case Qt::Key_Right:
			emit key(KeyRight);
			break;
		case Qt::Key_Space:
			emit key(KeyFire);
			break;
		case Qt::Key_Minus:
			emit key(KeyZoomOut);
			break;
		case Qt::Key_Plus:
			emit key(KeyZoomIn);
			break;
		case Qt::Key_Tab:
			emit key(KeyWeapon);
			break;
		case Qt::Key_Return:
			emit key(KeyTimebomb);
			break;
		case Qt::Key_F:
			emit key(KeyFullscreen);
			break;
		case Qt::Key_P:
			emit key(KeyPause);
			break;
	}
}

