Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Games
KSnakeDuel
Commits
d5fa914a
Commit
d5fa914a
authored
Jan 07, 2015
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use QCDebug
parent
f47a8849
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
67 additions
and
16 deletions
+67
-16
CMakeLists.txt
CMakeLists.txt
+1
-0
ksnakeduel_debug.cpp
ksnakeduel_debug.cpp
+23
-0
ksnakeduel_debug.h
ksnakeduel_debug.h
+27
-0
ktron.cpp
ktron.cpp
+1
-1
player.cpp
player.cpp
+5
-5
playfield.cpp
playfield.cpp
+3
-3
renderer.cpp
renderer.cpp
+2
-2
snakepart.cpp
snakepart.cpp
+1
-1
tron.cpp
tron.cpp
+4
-4
No files found.
CMakeLists.txt
View file @
d5fa914a
...
...
@@ -47,6 +47,7 @@ add_subdirectory(doc)
########### next target ###############
set
(
ktron_SRCS
ksnakeduel_debug.cpp
renderer.cpp
object.cpp
snakepart.cpp
...
...
ksnakeduel_debug.cpp
0 → 100644
View file @
d5fa914a
/* This file is part of the KDE project
Copyright (C) 2014 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "ksnakeduel_debug.h"
Q_LOGGING_CATEGORY
(
KSNAKEDUEL_LOG
,
"ksnakeduel_smtp"
)
ksnakeduel_debug.h
0 → 100644
View file @
d5fa914a
/* This file is part of the KDE project
Copyright (C) 2014 Laurent Montel <montel@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KSNAKEDUEL_DEBUG_H
#define KSNAKEDUEL_DEBUG_H
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY
(
KSNAKEDUEL_LOG
)
#endif
ktron.cpp
View file @
d5fa914a
...
...
@@ -216,7 +216,7 @@ void KTron::updateStatusbar() {
void
KTron
::
blockPause
(
bool
block
)
{
//
k
Debug() << "Setting pause button state to: " << !block;
//
qC
Debug(
KSNAKEDUEL_LOG
) << "Setting pause button state to: " << !block;
m_pauseButton
->
setEnabled
(
!
block
);
}
...
...
player.cpp
View file @
d5fa914a
...
...
@@ -27,7 +27,7 @@
#include "snakepart.h"
#include "settings.h"
#include
<KD
ebug
>
#include
"ksnakeduel_d
ebug
.h"
#include <KLocalizedString>
#include <KUser>
...
...
@@ -61,7 +61,7 @@ int Player::getX()
{
if
(
m_snakeParts
.
isEmpty
())
{
k
Debug
()
<<
"Requested coordinate of nonexistent snake"
;
qC
Debug
(
KSNAKEDUEL_LOG
)
<<
"Requested coordinate of nonexistent snake"
;
return
0
;
}
...
...
@@ -72,7 +72,7 @@ int Player::getY()
{
if
(
m_snakeParts
.
isEmpty
())
{
k
Debug
()
<<
"Requested coordinate of nonexistent snake"
;
qC
Debug
(
KSNAKEDUEL_LOG
)
<<
"Requested coordinate of nonexistent snake"
;
return
0
;
}
...
...
@@ -318,7 +318,7 @@ void Player::movePlayer()
if
(
crashed
(
newX
,
newY
))
{
//
k
Debug() << "Crashed at: (" << newX << ", " << newY << ")";
//
qC
Debug(
KSNAKEDUEL_LOG
) << "Crashed at: (" << newX << ", " << newY << ")";
m_alive
=
false
;
}
...
...
@@ -348,7 +348,7 @@ void Player::movePlayer()
if
(
m_playField
->
getObjectAt
(
newX
,
newY
)
->
getObjectType
()
==
ObjectType
::
Item
)
{
//
k
Debug() << "Boom!";
//
qC
Debug(
KSNAKEDUEL_LOG
) << "Boom!";
emit
fetchedItem
(
m_playerNumber
,
newX
,
newY
);
}
...
...
playfield.cpp
View file @
d5fa914a
...
...
@@ -23,7 +23,7 @@
#include "playfield.h"
#include
<KD
ebug
>
#include
"ksnakeduel_d
ebug
.h"
PlayField
::
PlayField
()
{
...
...
@@ -52,7 +52,7 @@ void PlayField::initialize()
Object
*
PlayField
::
getObjectAt
(
int
x
,
int
y
)
{
if
(
x
<
0
||
x
>=
m_width
||
y
<
0
||
y
>=
m_height
)
{
k
Debug
()
<<
"Inexistent place accessed: ("
<<
x
<<
", "
<<
y
<<
")"
;
qC
Debug
(
KSNAKEDUEL_LOG
)
<<
"Inexistent place accessed: ("
<<
x
<<
", "
<<
y
<<
")"
;
return
0
;
}
...
...
@@ -76,7 +76,7 @@ int PlayField::getHeight()
void
PlayField
::
setObjectAt
(
int
x
,
int
y
,
Object
&
o
)
{
if
(
x
<
0
||
x
>=
m_width
||
y
<
0
||
y
>=
m_height
)
{
k
Debug
()
<<
"Inexistent place accessed: ("
<<
x
<<
", "
<<
y
<<
")"
;
qC
Debug
(
KSNAKEDUEL_LOG
)
<<
"Inexistent place accessed: ("
<<
x
<<
", "
<<
y
<<
")"
;
return
;
}
...
...
renderer.cpp
View file @
d5fa914a
...
...
@@ -31,7 +31,7 @@
#include <KPixmapCache>
#include <QSvgRenderer>
#include
<KD
ebug
>
#include
"ksnakeduel_d
ebug
.h"
#include <kfontutils.h>
#define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
...
...
@@ -262,7 +262,7 @@ int Renderer::calculateOffsetY(int y)
void
Renderer
::
drawPart
(
QPainter
&
painter
,
int
x
,
int
y
,
QString
svgName
)
{
//
k
Debug() << "Drawing part: " << svgName;
//
qC
Debug(
KSNAKEDUEL_LOG
) << "Drawing part: " << svgName;
int
xOffset
=
calculateOffsetX
(
x
+
1
);
int
yOffset
=
calculateOffsetY
(
y
+
1
);
...
...
snakepart.cpp
View file @
d5fa914a
...
...
@@ -23,7 +23,7 @@
#include "snakepart.h"
#include
<KD
ebug
>
#include
"ksnakeduel_d
ebug
.h"
SnakePart
::
SnakePart
(
int
playerNumber
)
:
Object
(
ObjectType
::
SnakePart
)
{
...
...
tron.cpp
View file @
d5fa914a
...
...
@@ -35,7 +35,7 @@
#include <QFocusEvent>
#include <QPixmap>
#include
<KD
ebug
>
#include
"ksnakeduel_d
ebug
.h"
#include <KLocalizedString>
#include <KgDifficulty>
...
...
@@ -181,7 +181,7 @@ Player *Tron::getPlayer(int playerNr)
{
if
(
playerNr
!=
0
&&
playerNr
!=
1
)
{
k
Debug
()
<<
"Inexistent player requested: "
<<
playerNr
;
qC
Debug
(
KSNAKEDUEL_LOG
)
<<
"Inexistent player requested: "
<<
playerNr
;
return
0
;
}
...
...
@@ -208,7 +208,7 @@ void Tron::startGame()
void
Tron
::
itemHit
(
int
playerNumber
,
int
,
int
)
{
//
k
Debug() << "Got Item Hit for " << playerNumber;
//
qC
Debug(
KSNAKEDUEL_LOG
) << "Got Item Hit for " << playerNumber;
newApple
();
players
[
playerNumber
]
->
setEnlargement
(
3
);
...
...
@@ -234,7 +234,7 @@ void Tron::newApple()
y
=
rand
()
%
pf
.
getHeight
();
}
//
k
Debug() << "Drawn apple at (" << x << ", " << y << ")";
//
qC
Debug(
KSNAKEDUEL_LOG
) << "Drawn apple at (" << x << ", " << y << ")";
apple
.
setType
((
int
)(
rand
()
%
3
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment