summaryrefslogtreecommitdiff
path: root/noncore
authordrw <drw>2005-05-20 21:17:24 (UTC)
committer drw <drw>2005-05-20 21:17:24 (UTC)
commit5e7bbe42671f565bef961b44862ddbf68beed774 (patch) (side-by-side diff)
treeccf157157cec64314bae8cbdf846dd9ccefdd4a6 /noncore
parent3394f57eac978fa97ad60fb96bebc67b3783cfc6 (diff)
downloadopie-5e7bbe42671f565bef961b44862ddbf68beed774.zip
opie-5e7bbe42671f565bef961b44862ddbf68beed774.tar.gz
opie-5e7bbe42671f565bef961b44862ddbf68beed774.tar.bz2
Resource -> OResource
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/snake/interface.cpp8
-rw-r--r--noncore/games/snake/obstacle.cpp6
-rw-r--r--noncore/games/snake/snake.cpp5
-rw-r--r--noncore/games/snake/target.cpp4
4 files changed, 10 insertions, 13 deletions
diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp
index 9d9550a..1eeb337 100644
--- a/noncore/games/snake/interface.cpp
+++ b/noncore/games/snake/interface.cpp
@@ -1,113 +1,113 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "interface.h"
-#include <qpe/resource.h>
+#include <opie2/oresource.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) :
QMainWindow(parent,name,f),
canvas(232, 258)
{
setCaption( tr("Snake") );
QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
- QPixmap bg = Resource::loadPixmap("snake/grass");
+ QPixmap bg = Opie::Core::OResource::loadPixmap("snake/grass");
canvas.setBackgroundPixmap(bg);
canvas.setUpdatePeriod(100);
snake = 0;
cv = new QCanvasView(&canvas, this);
pauseTimer = new QTimer(this);
connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
setToolBarsMovable( FALSE );
QToolBar* toolbar = new QToolBar( this);
toolbar->setHorizontalStretchable( TRUE );
- QPixmap newicon = Resource::loadPixmap("ksnake");
+ QPixmap newicon = Opie::Core::OResource::loadPixmap("ksnake");
setIcon(newicon);
(void)new QToolButton(newicon, tr("New Game"), 0,
this, SLOT(newGame()), toolbar, "New Game");
scorelabel = new QLabel(toolbar);
showScore(0);
scorelabel->setBackgroundMode( PaletteButton );
scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
toolbar->setStretchableWidget( scorelabel );
setFocusPolicy(StrongFocus);
setCentralWidget(cv);
QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
gamestopped = true;
waitover = true;
}
SnakeGame::~SnakeGame()
{
delete snake;
}
void SnakeGame::resizeEvent(QResizeEvent *)
{
QSize s = centralWidget()->size();
int fw = style().defaultFrameWidth();
canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
}
void SnakeGame::welcomescreen()
{
QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas);
title->setColor(yellow);
title->setFont( QFont("times", 18, QFont::Bold) );
int w = title->boundingRect().width();
title->move(canvas.width()/2 -w/2, canvas.height()/2-110);
title->show();
- QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title"));
+ QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Opie::Core::OResource::findPixmap("snake/title"));
QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas);
titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85);
titlepic->show();
QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n"
"snake to eat the mouse. You must not\n"
"crash into the walls, edges or its tail."),
&canvas);
w = instr->boundingRect().width();
instr->move(canvas.width()/2-w/2, canvas.height()/2-20);
instr->setColor(white);
instr->show();
QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas);
w = cont->boundingRect().width();
cont->move(canvas.width()/2-w/2, canvas.height()-20);
cont->setColor(yellow);
cont->show();
}
void SnakeGame::newGame()
{
clear();
snake = new Snake(&canvas);
connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) );
diff --git a/noncore/games/snake/obstacle.cpp b/noncore/games/snake/obstacle.cpp
index 4bdefa5..4639f5c 100644
--- a/noncore/games/snake/obstacle.cpp
+++ b/noncore/games/snake/obstacle.cpp
@@ -1,60 +1,58 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "obstacle.h"
#include "codes.h"
-#include <qpe/resource.h>
-
-
+#include <opie2/oresource.h>
Obstacle::Obstacle(QCanvas* canvas, int y)
: QCanvasSprite(0,canvas)
{
newObstacle(y);
}
void Obstacle::newObstacle(int y)
{
- QPixmap obstaclePix( Resource::findPixmap("snake/wall.png") );
+ QPixmap obstaclePix( Opie::Core::OResource::findPixmap("snake/wall") );
if ( obstaclePix.width() > canvas()->width()*3/5 ) {
int w = canvas()->width()*3/5;
w = w - w % 16;
obstaclePix.resize( w, obstaclePix.height() );
}
QList<QPixmap> pixl;
pixl.append( &obstaclePix );
QPoint nullp;
QList<QPoint> pl;
pl.append( &nullp );
QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(pixl, pl);
setSequence(obstaclearray);
int x = ( canvas()->width() - obstaclePix.width() )/2;
x = x - x % 16;
y = y - y % 16;
move(x, y);
setZ( -100 );
show();
canvas()->update();
diff --git a/noncore/games/snake/snake.cpp b/noncore/games/snake/snake.cpp
index 8a683ab..802951c 100644
--- a/noncore/games/snake/snake.cpp
+++ b/noncore/games/snake/snake.cpp
@@ -1,66 +1,65 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "snake.h"
#include "target.h"
-#include <qpe/resource.h>
-
+#include <opie2/oresource.h>
static int Piecekey[4][4] = { {6, 0, 4, 3 }, {0, 6, 2, 1 }, { 1, 3, 5, 0 }, {2, 4, 0, 5 } };
Snake::Snake(QCanvas* c)
{
canvas = c;
score = 0;
snakelist.setAutoDelete(true);
autoMoveTimer = new QTimer(this);
connect( autoMoveTimer, SIGNAL(timeout()), this, SLOT(moveSnake()) );
createSnake();
}
void Snake::createSnake()
{
snakeparts = new QCanvasPixmapArray();
- QString s0 = Resource::findPixmap("snake/s0001");
+ QString s0 = Opie::Core::OResource::findPixmap("snake/s0001");
s0.replace(QRegExp("0001"),"%1");
snakeparts->readPixmaps(s0, 15);
grow = 0;
last = Key_Right;
QCanvasSprite* head = new QCanvasSprite(snakeparts, canvas );
head->setFrame(7);
snakelist.insert(0, head);
head->show();
head->move(34, 16);
QCanvasSprite* body = new QCanvasSprite(snakeparts, canvas );
body->setFrame(6);
snakelist.append( body );
body->show();
body->move(18, 16);
QCanvasSprite* end = new QCanvasSprite(snakeparts, canvas );
end->setFrame(11);
snakelist.append( end );
end->show();
end->move(2, 16);
diff --git a/noncore/games/snake/target.cpp b/noncore/games/snake/target.cpp
index a09af69..f20eb93 100644
--- a/noncore/games/snake/target.cpp
+++ b/noncore/games/snake/target.cpp
@@ -1,55 +1,55 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "target.h"
#include "codes.h"
-#include <qpe/resource.h>
+#include <opie2/oresource.h>
#include <stdlib.h>
Target::Target(QCanvas* canvas)
: QCanvasSprite(0, canvas)
{
- mouse = new QCanvasPixmapArray(Resource::findPixmap("snake/mouse"));
+ mouse = new QCanvasPixmapArray(Opie::Core::OResource::findPixmap("snake/mouse"));
setSequence(mouse);
newTarget();
}
void Target::newTarget()
{
static bool first_time = TRUE;
if (first_time) {
first_time = FALSE;
QTime midnight(0, 0, 0);
srand(midnight.secsTo(QTime::currentTime()) );
}
do {
int x = rand() % (canvas()->width()-10);
x = x - (x % 16) + 2;
int y = rand() % (canvas()->height()-10);
y = y - (y % 16) + 2;
move(x, y);
} while (onTop());
show();
}
bool Target::onTop()
{