summaryrefslogtreecommitdiff
path: root/noncore/games/zlines/ballpainter.cpp
Unidiff
Diffstat (limited to 'noncore/games/zlines/ballpainter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/zlines/ballpainter.cpp135
1 files changed, 135 insertions, 0 deletions
diff --git a/noncore/games/zlines/ballpainter.cpp b/noncore/games/zlines/ballpainter.cpp
new file mode 100644
index 0000000..c2b34e1
--- a/dev/null
+++ b/noncore/games/zlines/ballpainter.cpp
@@ -0,0 +1,135 @@
1/***************************************************************************
2 ballpainter.cpp - description
3 -------------------
4 begin : Fri May 19 2000
5 copyright : (C) 2000 by Roman Merzlyakov
6 email : roman@sbrf.barrt.ru
7 copyright : (C) 2000 by Roman Razilov
8 email : Roman.Razilov@gmx.de
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#include <qpe/resource.h>
21
22#include <qapplication.h>
23#include "ballpainter.h"
24//#include "shotcounter.h"
25#include <qpainter.h>
26#include "linesboard.h"
27//#include <qcolor.h>
28#include <qjpegio.h>
29
30
31#define PIXSIZE 21
32
33int colorLinesArr[NCOLORS] =
34{0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff00, 0x005080};
35// 0x00bbggrr
36// red , green , blue , yellow , violet , cyan , brown
37
38
39
40BallPainter::BallPainter()
41 : QObject()
42{
43 createPixmap();
44}
45
46BallPainter::~BallPainter()
47{
48}
49
50QPixmap* BallPainter::pixmap( enum Pixmaps pix )
51{
52 QString name;
53 switch(pix) {
54 case Field:
55 name = QString::fromLatin1("zlines/field");
56 break;
57 case Balls:
58 name = QString::fromLatin1("zlines/balls");
59 break;
60 case Fire:
61 name = QString::fromLatin1("zlines/fire");
62 break;
63 }
64
65 return new QPixmap(Resource::loadPixmap(name) );
66}
67
68void BallPainter::createPixmap()
69{
70 // warning( kapp->kde_datadir() +"/klines/data/balls.bmp");
71 backgroundPix = pixmap(Field);
72 QPixmap *balls = pixmap(Balls);
73 QPixmap *fire = pixmap(Fire);
74 if (balls->isNull() ||backgroundPix->isNull() || fire->isNull() )
75 fatal("Cannot open data files.\nHave you correctly installed klines?");
76
77 warning("Pixsize %i", PIXSIZE);
78 for(int c=0; c<NCOLORS; c++)
79 {
80 for(int t=0; t<PIXTIME + FIREBALLS + BOOMBALLS + 1 ; t++)
81 {
82 imgCash[c][t] = new QPixmap(CELLSIZE, CELLSIZE);
83 QPainter p(imgCash[c][t]);
84 p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE);
85 p.drawPixmap(1,1,(*balls),t*PIXSIZE,c*PIXSIZE,PIXSIZE,PIXSIZE);
86 }
87 for(int t=0; t < FIREPIX ; t++)
88 {
89 firePix[t] = new QPixmap(CELLSIZE, CELLSIZE);
90 QPainter p(firePix[t]);
91 p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE);
92 p.drawPixmap(1,1,(*fire),t*PIXSIZE,0,PIXSIZE,PIXSIZE);
93 }
94 }
95 delete balls;
96 delete fire;
97}
98
99
100QPixmap* BallPainter::GetBall(int color, int animstep, int panim)
101{
102 // return backgroundPix;
103
104 if( (color<0) || (color>=NCOLORS) || (animstep<0) || color == NOBALL )
105 {
106 // warning("BallPainter::Background");
107 return backgroundPix;
108 }
109 if ( panim == ANIM_JUMP )
110 {
111 if ( ( animstep < 0 ) || ( animstep >= PIXTIME ) )
112 return backgroundPix;
113 else
114 return imgCash[color][animstep];
115 }
116 else if ( panim == ANIM_BURN )
117 {
118 if ( animstep < FIREBALLS )
119 return imgCash[color][animstep + PIXTIME + BOOMBALLS + 1];
120 else if ( animstep < FIREBALLS + FIREPIX )
121 return firePix[animstep - FIREBALLS];
122 }
123 else if ( panim == ANIM_BORN )
124 {
125 if ( animstep < BOOMBALLS )
126 return imgCash[color][animstep + PIXTIME];
127 else
128 return imgCash[color][NORMALBALL];
129 }
130 // rest is not imlemented yet
131 return imgCash[color][NORMALBALL];
132
133}
134
135