summaryrefslogtreecommitdiff
path: root/noncore/games/bounce/game.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/bounce/game.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/bounce/game.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/noncore/games/bounce/game.cpp b/noncore/games/bounce/game.cpp
index bbd3d0b..5ef9f15 100644
--- a/noncore/games/bounce/game.cpp
+++ b/noncore/games/bounce/game.cpp
@@ -27,13 +27,13 @@ using namespace Opie::Core;
/* QT */
#include <qtimer.h>
/* STD */
#include <stdlib.h>
-#define TILE_SIZE 9
+#define TILE_SIZE 9
#define TILE_FIRST ((FIELD_WIDTH-2)*(FIELD_HEIGHT-2))
#define TILE_FREE (TILE_FIRST + 0)
#define TILE_BORDER (TILE_FIRST + 1)
#define TILE_WALLEND (TILE_FIRST + 2)
#define TILE_WALLUP (TILE_FIRST + 3)
@@ -64,13 +64,13 @@ void Arrow::update()
void Arrow::changeDirection()
{
m_vertical = ! m_vertical;
update();
}
-
+
Ball::Ball(QCanvasPixmapArray* array, QCanvas* canvas)
: QCanvasSprite( array, canvas ), m_animDelay( 0 ), m_soundDelay( MS2TICKS(BALL_ANIM_DELAY)/2 )
{
}
@@ -97,13 +97,13 @@ void Ball::advance(int stage)
if ( collide(xVelocity(), 0) ) reflectX = true;
if ( collide(0, yVelocity()) ) reflectY = true;
if ( !reflectX && !reflectY && collide(xVelocity(), yVelocity()) ) reflectX = reflectY = true;
// emit collision
QRect r = boundingRect();
- r.moveBy( xVelocity(), yVelocity() );
+ r.moveBy( static_cast<int>(xVelocity()), static_cast<int>( yVelocity() ) );
JezzField* field = (JezzField *)canvas();
int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE );
int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE );
int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE );
int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE );
@@ -122,13 +122,13 @@ void Ball::advance(int stage)
QCanvasSprite::advance( stage );
}
bool Ball::collide( double dx, double dy )
{
QRect r = boundingRect();
- r.moveBy( dx, dy );
+ r.moveBy( static_cast<int>( dx ), static_cast<int>( dy ) );
JezzField* field = (JezzField *)canvas();
int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE );
int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE );
int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE );
int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE );
@@ -296,13 +296,13 @@ void JezzView::changeCursor()
/*************************************************************************/
JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name )
: QWidget( parent, name ), m_wall1( 0 ), m_wall2( 0 ),
m_text( 0 ), m_running( false ), m_percent( 0 ), m_pictured( false )
{
- QString path = QPEApplication::qpeDir()+"pics/bounce/";
+ QString path = QPEApplication::qpeDir()+"pics/bounce/";
// load gfx
m_ballPixmaps = new QCanvasPixmapArray( path + "ball%1.png", 25 );
for ( unsigned n=0; n < m_ballPixmaps->count(); n++ )
m_ballPixmaps->image(n)->setOffset( 0, 0 );
@@ -344,13 +344,13 @@ JezzGame::JezzGame( int ballNum, QWidget *parent, const char *name )
ball->setVelocity( ((rand() & 1)*2-1)*2, ((rand() & 1)*2-1)*2 );
ball->setFrame( rand() % 25 );
ball->move( 4*TILE_SIZE + ( rand() - 50 ) % ( (FIELD_WIDTH-8)*TILE_SIZE ),
4*TILE_SIZE + rand() % ( (FIELD_HEIGHT-8)*TILE_SIZE ) );
ball->show();
}
-
+
// create arrow
arrow = new Arrow( m_arrowPixmaps, m_field );
arrow->show();
// create text label
m_text = new QCanvasText( m_field );
@@ -371,13 +371,13 @@ JezzGame::~JezzGame()
delete m_field;
delete m_ballPixmaps;
}
void JezzGame::display( QString text, int size )
{
- odebug << "This function \"display\" shouldn't be called!!!" << oendl;
+ odebug << "This function \"display\" shouldn't be called!!!" << oendl;
if ( !text.isEmpty() )
{
QFont font( "Helvetica", size, QFont::Bold );
font.setStyleHint( QFont::Helvetica );
m_text->setFont( font );
m_text->setText( text );
@@ -410,13 +410,14 @@ void JezzGame::makeBlack()
for ( int y=0; y<FIELD_HEIGHT; y++ )
for ( int x=0; x<FIELD_WIDTH; x++ )
m_buf[x][y] = m_field->tile( x, y );
// fill areas that contains a ball
for ( Ball *ball=m_balls.first(); ball!=0; ball=m_balls.next() )
- fill( ball->x()/TILE_SIZE, ball->y()/TILE_SIZE );
+ fill( static_cast<int>( ball->x()/TILE_SIZE ),
+ static_cast<int>( ball->y()/TILE_SIZE ) );
// areas still free can be blacked now
for ( int y=0; y<FIELD_HEIGHT; y++ )
for ( int x=0; x<FIELD_WIDTH; x++ )
{
if ( m_buf[x][y]==TILE_FREE )