summaryrefslogtreecommitdiffstats
path: root/q15/src/gameboard.h
blob: 8150acb624c9b7ae2e0834d0bf4a6a278a467118 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * $Id: gameboard.h,v 0.1 2005/08/14 12:10:05 denis Exp $
 *
 * Author: Denis Kozadaev (denis@tambov.ru)
 * Description:
 *
 * See also: style(9)
 *
 * Hacked by:
 */

#ifndef	__GAME_BOARD_H__
#define	__GAME_BOARD_H__

#include <stdlib.h>

#include <tqwidget.h>
#include <tqlabel.h>
#include <tqpixmap.h>
#include <tqtimer.h>


class BoardItem:public TQLabel
{
public:

	BoardItem(int, TQWidget *parent = NULL, const char *name = NULL);
	~BoardItem();

	int	item()const{return (num);}

private:
	int	num;

protected:
	void	paintEvent(TQPaintEvent *);
};

//------------------------------------------------------------------------------

class GameBoard:public TQWidget
{
	Q_OBJECT
public:

	GameBoard(TQWidget *parent = NULL, const char *name = NULL);
	~GameBoard();

	void	newGame();
	void	loadImage();

private:
	int		n, nt, xt, yt, dx, dy;
	BoardItem	*map[16];
	TQTimer		*tmr;
	TQPixmap	origin;

	void	initMap();
	void	startMoving(int, int);
	void	checkEndGame();
	void	newTask();

	int	index(int, int);
	int	mayMove(int);
	int	step(int, int);
	int	sign(int);

protected:
	void	resizeEvent(TQResizeEvent *);
	void	mousePressEvent(TQMouseEvent *);

private slots:
	void	moveItem();
};

#endif	/* __GAME_BOARD_H__ */