Commit aec7052e authored by Stephan Kulow's avatar Stephan Kulow
Browse files

some random fixes my wife complained about - including creating

higher resolution graphics

svn path=/trunk/KDE/kdegames/klines/; revision=638808
parent 14aa605e
......@@ -79,7 +79,7 @@ KLinesAnimator::KLinesAnimator( KLinesScene* scene )
bool KLinesAnimator::isAnimating() const
{
return (m_bornTimeLine.state() == QTimeLine::Running
return (m_bornTimeLine.state() == QTimeLine::Running
|| m_moveTimeLine.state() == QTimeLine::Running
|| m_removeTimeLine.state() == QTimeLine::Running);
}
......@@ -106,13 +106,15 @@ void KLinesAnimator::animateMove( const FieldPos& from, const FieldPos& to )
void KLinesAnimator::animateRemove( const QList<BallItem*>& list )
{
m_moveTimeLine.stop();
m_removeTimeLine.stop();
if(list.isEmpty())
{
emit removeFinished();
return;
}
m_removeTimeLine.stop();
m_removedBalls = list;
m_removeTimeLine.start();
}
......@@ -178,7 +180,7 @@ void KLinesAnimator::findPath( const FieldPos& from, const FieldPos& to )
// Implementation of A* pathfinding algorithm
// Thanks to Patrick Lester for excellent tutorial on gamedev.net.
// See http://www.gamedev.net/reference/articles/article2003.asp
QList<PathNode*> openList;
QList<PathNode*> closedList;
......@@ -249,7 +251,7 @@ void KLinesAnimator::findPath( const FieldPos& from, const FieldPos& to )
// exit conditions:
// a) if closeList contains "to"
// b) we can't find "to" in closedList and openlist is empty
// b) we can't find "to" in closedList and openlist is empty
// => no path exists
int idx = indexOfNodeWithPos(to, closedList);
if(idx != -1)
......
......@@ -31,7 +31,7 @@ BallItem::BallItem( QGraphicsScene* parent )
m_color = NumColors; // = uninitialized
m_timeLine.setCurveShape( QTimeLine::LinearCurve );
m_timeLine.setDuration(400);
m_timeLine.setDuration(500);
m_timeLine.setLoopCount(0);
m_timeLine.setFrameRange(0, KLinesRenderer::self()->numSelectedFrames()-1);
// starting by going lower
......
balls.jpg

46.8 KB | W: | H:

balls.jpg

1.66 MB | W: | H:

balls.jpg
balls.jpg
balls.jpg
balls.jpg
  • 2-up
  • Swipe
  • Onion skin
field.jpg

338 Bytes | W: | H:

field.jpg

2.13 KB | W: | H:

field.jpg
field.jpg
field.jpg
field.jpg
  • 2-up
  • Swipe
  • Onion skin
......@@ -127,6 +127,12 @@ void KLinesMainWindow::gameOver(int score)
d.exec();
}
void KLinesMainWindow::viewHighScore()
{
KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this);
d.exec();
}
void KLinesMainWindow::startGame()
{
updateScore(0);
......
......@@ -34,9 +34,10 @@ public:
protected:
void initKAction();
public slots:
public Q_SLOTS:
void startGame();
private slots:
private Q_SLOTS:
void viewHighScore();
void updateScore(int score);
void gameOver(int score);
void showNextToggled(bool show);
......
......@@ -14,7 +14,7 @@
* (at your option) any later version. *
* *
***************************************************************************/
#version 3.0
#version 3.0;
// Objectname = Main View
// Objecttype = view
......@@ -22,13 +22,13 @@
// This camera is build for ratio 451:277
#include "colors.inc"
#include "textures.inc"
#declare BallColor = Green
#declare BallColor = Green;
#include "clr.inc"
#declare CELLSIZE = 32
#declare PIXTIME = 10
#declare BALLDOWN = 3
#declare BALLSPACE = 4
#declare CELLSIZE = 32;
#declare PIXTIME = 10;
#declare BALLDOWN = 3;
#declare BALLSPACE = 8;
#warning concat("XXXX clock:",str(clock,5,2),"\n")
......@@ -36,11 +36,11 @@
// --------------------burning ball-------------------
#range (0,1.001)
#declare explosion = 1
#declare jump = 0
#declare n = 0
#declare explosion = 1;
#declare jump = 0;
#declare n = 0;
#declare t0 = 0
#declare t0 = 0;
#declare t1 = 0.2
#declare t2 = 0.5
#declare t3 = 0.8
......@@ -142,6 +142,10 @@
#warning concat("XXXX X:",str(X,5,2),"\n")
#declare tc = PIXTIME - tt*PIXTIME
#if (tc > PIXTIME / 2)
#declare tc = PIXTIME - tc
#end
#declare tc = tc * 2
#warning concat("XXXX tc:",str(tc,5,2),"\n")
// ball position
......@@ -207,30 +211,27 @@ background
// fire
#if (explosion = 1)
sphere { 0, 1
pigment { color rgbt<0,0,0,1>
}
halo {
emitting
spherical_mapping
poly
max_value 40
exponent 0.1
linear
turbulence tur
pigment { color rgbt<0,0,0,1> }
interior {
media {
intervals 1
samples 1,1
emission 1
// spherical_mapping
// poly
// max_value 40
// exponent 0.1
// linear
// turbulence tur
// phase pf
lambda 2-pf
frequency 1
octaves 6
color_map {
[ 0 color rgbt <1, 0, 0, 1> ]
[ 0.2 color rgbt <1, 0, 0, 1-1*trf> ]
[ 0.5 color rgbt <1, 0, 0, 1-3*trf> ]
[ 0.9 color rgbt <1, 1, 0, 1-4*trf> ]
[ 1 color rgbt <1, 1, 0.5, 1-6*trf> ]
}
samples 30
// lambda 2-pf
// frequency 1
// octaves 6
// samples 30
}
hollow
}
//hollow
scale<15,15,15>
translate <-0.5,-0.5,0>
}
......
#!/bin/sh
echo "#declare BallColor = $2" >clr.inc
#### jumping balls
povray -w30 -h30 -V1 -P +A +KI10 +KF11 +KFF10 -Iball.pov +Oa$1.tga
povray -w300 -h300 -V1 -P +A +KI10 +KF11 +KFF13 -Iball.pov +Oa$1.tga
#### borning balls
povray -w30 -h30 -V1 -P +A +KI5 +KF6 +KFF6 +SF2 +EF5 -Iball.pov +Ob$1.tga
povray -w300 -h300 -V1 -P +A +KI5 +KF6 +KFF6 +SF2 +EF5 -Iball.pov +Ob$1.tga
#### burning balls balls
povray -w30 -h30 -V1 -P +A +KI0 +KF1 +KFF11 +SF1 +EF5 -Iball.pov +Oe$1.tga
povray -w300 -h300 -V1 -P +A +KI0 +KF1 +KFF11 +SF1 +EF5 -Iball.pov +Oe$1.tga
montage -geometry 30x30 -tile 100x1 -page 570x30 a$1??.tga b$1?.tga e$1??.tga bl_$1.tga
mogrify -crop 570x30+0+0 bl_$1.tga
montage -geometry 300x300 -tile 100x1 -page 5700x300 a$1??.tga b$1?.tga e$1??.tga bl_$1.tga
mogrify -crop 5700x300+0+0 bl_$1.tga
#declare CELLSIZE = 32
#declare CELLSIZE = 32;
#include "colors.inc"
camera
......
if (povray -w32 -h32 -V1 -P +A +K10 -Ifield.pov +Ofield.tga)
if (povray -w320 -h320 -V1 -P +A +K10 -Ifield.pov +Ofield.tga)
then
mogrify -raise 1x1 field.tga
mogrify -raise 10x10 field.tga
fi
......@@ -15,10 +15,10 @@ balls.sh Violet "rgb<1,0,1>"
balls.sh Cyan "rgb<0,1,1>"
balls.sh Brown "rgb<1/2,1/3,0>"
#### montage balls ( 20x7 cells each 30x30)
#### montage balls ( 20x7 cells each 300x300)
montage -geometry 570x30 -tile 1x10 bl_*.tga balls.tga
mogrify -crop 570x210+0+0 balls.tga
montage -geometry 5700x300 -tile 1x10 bl_*.tga balls.tga
mogrify -crop 5700x2100+0+0 balls.tga
#### convert to jpeg
......@@ -33,4 +33,4 @@ cp *jpg ../
#### clean
#clean.sh
\ No newline at end of file
#clean.sh
......@@ -57,3 +57,4 @@ Test_Abort_Count=100
; directory. Up to 25 such paths may be specified.
Library_Path=/usr/lib/povray3
Library_Path=/usr/lib/povray3/include
Library_Path=/usr/share/povray-3.6/include
......@@ -33,9 +33,9 @@ KLinesRenderer* KLinesRenderer::self()
KLinesRenderer::KLinesRenderer()
: m_cellSize(32)
{
m_fieldPix = QPixmap( KStandardDirs::locate( "appdata", "field.jpg" ));
m_firePix = QPixmap( KStandardDirs::locate( "appdata", "fire.jpg" ));
m_ballsPix = QPixmap( KStandardDirs::locate( "appdata", "balls.jpg" ));
m_fieldPix = QImage( KStandardDirs::locate( "appdata", "field.jpg" ));
m_firePix = QImage( KStandardDirs::locate( "appdata", "fire.jpg" ));
m_ballsPix = QImage( KStandardDirs::locate( "appdata", "balls.jpg" ));
}
// these are the notes for all *Pixmap() functions below:
......@@ -43,31 +43,36 @@ KLinesRenderer::KLinesRenderer()
// FIXME dimsuz: hardcoded "magic" numbers
// FIXME dimsuz: scale to emulate future svg support
// Switching to svg will make this fixmes obsolete
QPixmap KLinesRenderer::ballPixmap(BallColor color) const
{
// col, row, width, height - hardcoded. balls.jpg has such a format.
return m_ballsPix.copy( 7*30, static_cast<int>(color)*30, 30, 30 ).scaled( m_cellSize, m_cellSize );
return selectedPixmap( color, 3 );
}
QPixmap KLinesRenderer::firePixmap(int frame) const
{
int ballsize = m_firePix.height();
// col, row, width, height - hardcoded. balls.jpg has such a format.
return m_firePix.copy(frame*30, 0, 30, 30 ).scaled( m_cellSize, m_cellSize );
return QPixmap::fromImage( m_firePix.copy(frame*ballsize, 0, ballsize, ballsize ).
scaled( m_cellSize, m_cellSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
QPixmap KLinesRenderer::bornPixmap(BallColor color, int frame) const
{
int ballsize = m_ballsPix.height() / 7;
// col, row, width, height - hardcoded. balls.jpg has such a format.
return m_ballsPix.copy( 13*30 + frame*30, static_cast<int>(color)*30, 30, 30 ).scaled( m_cellSize, m_cellSize );
return QPixmap::fromImage( m_ballsPix.copy( 13*ballsize + frame*ballsize, static_cast<int>(color)*ballsize, ballsize, ballsize ).
scaled( m_cellSize * .9, m_cellSize * .9, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
QPixmap KLinesRenderer::selectedPixmap( BallColor color, int frame ) const
{
return m_ballsPix.copy( frame*30, static_cast<int>(color)*30, 30, 30 ).scaled( m_cellSize, m_cellSize );
int ballsize = m_ballsPix.height() / 7;
return QPixmap::fromImage( m_ballsPix.copy( frame*ballsize, static_cast<int>(color)*ballsize, ballsize, ballsize ).
scaled( m_cellSize * .9, m_cellSize *.9, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
QPixmap KLinesRenderer::backgroundTilePixmap() const
{
return m_fieldPix.scaled( m_cellSize, m_cellSize );
return QPixmap::fromImage( m_fieldPix.scaled( m_cellSize, m_cellSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
......@@ -52,9 +52,9 @@ private:
KLinesRenderer& operator=( const KLinesRenderer& );
~KLinesRenderer() { }
QPixmap m_ballsPix; // to be removed when SVG comes to us
QPixmap m_fieldPix; // to be removed when SVG comes to us
QPixmap m_firePix; // to be removed when SVG comes to us
QImage m_ballsPix; // to be removed when SVG comes to us
QImage m_fieldPix; // to be removed when SVG comes to us
QImage m_firePix; // to be removed when SVG comes to us
/**
* This is the size of the scene's cell.
......
......@@ -129,7 +129,7 @@ void KLinesScene::resizeScene(int width,int height)
m_focusItem->setRect( QRect(0,0, m_cellSize, m_cellSize) );
m_focusItem->setPos( fieldToPix( focusRectFieldPos ) );
kDebug() << "resize:" << width << "," << height << "; cellSize: " << m_cellSize << endl;
//kDebug() << "resize:" << width << "," << height << "; cellSize: " << m_cellSize << endl;
}
void KLinesScene::endTurn()
......@@ -247,7 +247,7 @@ void KLinesScene::removeAnimFinished()
return;
}
if(m_itemsToDelete.isEmpty() && m_placeBalls)
if( m_itemsToDelete.isEmpty() && m_placeBalls)
{
// slot bornAnimFinished() will be called
// when born animation finishes
......@@ -313,7 +313,7 @@ void KLinesScene::bornAnimFinished()
void KLinesScene::searchAndErase()
{
// FIXME dimsuz: put more comments about bounds in for loops
// horizontal chunks searching
for(int x=0; x<FIELD_SIZE-4; ++x)
for(int y=0;y<FIELD_SIZE; ++y)
......@@ -374,7 +374,7 @@ void KLinesScene::searchAndErase()
BallColor col = m_field[x][y]->color();
int tmpx = x+1;
int tmpy = y+1;
while(tmpx < FIELD_SIZE && tmpy < FIELD_SIZE &&
while(tmpx < FIELD_SIZE && tmpy < FIELD_SIZE &&
m_field[tmpx][tmpy] && m_field[tmpx][tmpy]->color() == col)
{
tmpx++;
......@@ -404,7 +404,7 @@ void KLinesScene::searchAndErase()
BallColor col = m_field[x][y]->color();
int tmpx = x+1;
int tmpy = y-1;
while(tmpx < FIELD_SIZE && tmpy >=0 &&
while(tmpx < FIELD_SIZE && tmpy >=0 &&
m_field[tmpx][tmpy] && m_field[tmpx][tmpy]->color() == col)
{
tmpx++;
......
......@@ -77,7 +77,7 @@ public:
* Field coords to pixel coords
*/
inline QPointF fieldToPix(const FieldPos& fpos) const {
return QPointF( fpos.x*m_cellSize, fpos.y*m_cellSize );
return QPointF( fpos.x*m_cellSize + m_cellSize * 0.05 , fpos.y*m_cellSize + m_cellSize * 0.05 );
}
/**
* Pixel coords to field coords
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment