Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KReversi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Games
KReversi
Commits
0fb6a7f8
Commit
0fb6a7f8
authored
Oct 30, 2013
by
Denis Kuplyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed order of chip's turning.
Now chips are turned "as wave" from the players move.
parent
a89e3607
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
6 deletions
+51
-6
kreversiview.cpp
kreversiview.cpp
+26
-3
kreversiview.h
kreversiview.h
+5
-0
qml/Board.qml
qml/Board.qml
+4
-0
qml/Cell.qml
qml/Cell.qml
+2
-0
qml/Chip.qml
qml/Chip.qml
+10
-3
qml/Table.qml
qml/Table.qml
+4
-0
No files found.
kreversiview.cpp
View file @
0fb6a7f8
...
...
@@ -22,7 +22,7 @@
KReversiView
::
KReversiView
(
KReversiGame
*
game
,
QWidget
*
parent
)
:
KgDeclarativeView
(
parent
),
m_delay
(
ANIMATION_SPEED_NORMAL
),
m_game
(
0
),
m_demoMode
(
false
),
m_showLastMove
(
false
),
m_showLegalMoves
(
false
),
m_showLabels
(
false
)
m_showLabels
(
false
)
,
m_maxDelay
(
0
)
{
qmlRegisterType
<
ColorScheme
>
(
"ColorScheme"
,
1
,
0
,
"ColorScheme"
);
...
...
@@ -111,6 +111,30 @@ KReversiView::~KReversiView()
void
KReversiView
::
updateBoard
()
{
KReversiPos
lastmove
=
m_game
?
m_game
->
getLastMove
()
:
KReversiPos
();
for
(
int
i
=
0
;
i
<
8
;
i
++
)
for
(
int
j
=
0
;
j
<
8
;
j
++
)
{
int
delay
=
0
;
if
(
lastmove
.
isValid
())
delay
=
qMax
(
abs
(
i
-
lastmove
.
row
),
abs
(
j
-
lastmove
.
col
));
QMetaObject
::
invokeMethod
(
m_qml_root
,
"setPreAnimationTicks"
,
Q_ARG
(
QVariant
,
i
),
Q_ARG
(
QVariant
,
j
),
Q_ARG
(
QVariant
,
delay
));
}
m_maxDelay
=
0
;
if
(
m_game
)
{
PosList
changed_chips
=
m_game
->
changedChips
();
for
(
int
i
=
0
;
i
<
changed_chips
.
size
();
i
++
)
{
int
delay
=
0
;
if
(
lastmove
.
isValid
())
delay
=
qMax
(
abs
(
changed_chips
[
i
].
row
-
lastmove
.
row
),
abs
(
changed_chips
[
i
].
col
-
lastmove
.
col
));
m_maxDelay
=
qMax
(
m_maxDelay
,
delay
);
}
}
for
(
int
i
=
0
;
i
<
8
;
i
++
)
for
(
int
j
=
0
;
j
<
8
;
j
++
)
{
QString
new_state
=
""
;
...
...
@@ -235,13 +259,12 @@ void KReversiView::onPlayerMove(int row, int col)
m_game
->
makePlayerMove
(
row
,
col
,
false
);
}
void
KReversiView
::
slotGameMoveFinished
()
{
m_hint
=
KReversiPos
();
updateBoard
();
emit
moveFinished
();
m_delayTimer
.
singleShot
(
m_delay
,
this
,
SLOT
(
slotOnDelay
()));
m_delayTimer
.
singleShot
(
m_delay
*
(
m_maxDelay
+
2
)
,
this
,
SLOT
(
slotOnDelay
()));
}
void
KReversiView
::
slotGameOver
()
...
...
kreversiview.h
View file @
0fb6a7f8
...
...
@@ -225,5 +225,10 @@ private:
* If true board labels will be rendered
*/
bool
m_showLabels
;
/**
* Used to handle animation duration due to sequental turning of chips
*/
int
m_maxDelay
;
};
#endif
qml/Board.qml
View file @
0fb6a7f8
...
...
@@ -41,6 +41,10 @@ Item {
function
setLastMove
(
row
,
column
,
value
)
{
cells
.
itemAt
(
row
*
Globals
.
COLUMN_COUNT
+
column
).
isLastMove
=
value
}
function
setPreAnimationTicks
(
row
,
column
,
value
)
{
cells
.
itemAt
(
row
*
Globals
.
COLUMN_COUNT
+
column
).
chipPreAnimationTicks
=
value
}
CanvasItem
{
id
:
boardBackground
...
...
qml/Cell.qml
View file @
0fb6a7f8
...
...
@@ -25,6 +25,7 @@ Item {
property
bool
isHint
:
false
property
string
chipImagePrefix
:
"
chip_bw
"
property
int
chipAnimationTime
:
25
*
12
property
int
chipPreAnimationTicks
:
0
property
string
chipState
:
""
CanvasItem
{
...
...
@@ -49,6 +50,7 @@ Item {
imagePrefix
:
parent
.
chipImagePrefix
+
"
_
"
animationTime
:
parent
.
chipAnimationTime
preAnimationTicks
:
parent
.
chipPreAnimationTicks
onClicked
:
cellContainer
.
clicked
()
}
...
...
qml/Chip.qml
View file @
0fb6a7f8
...
...
@@ -23,6 +23,7 @@ Item {
property
int
currentFrame
:
1
property
string
imagePrefix
:
"
chip_bw_
"
property
int
animationTime
:
25
*
12
property
int
preAnimationTicks
:
0
signal
clicked
...
...
@@ -126,9 +127,15 @@ Item {
]
Behavior
on
currentFrame
{
NumberAnimation
{
duration
:
animationTime
easing.type
:
Easing
.
InOutQuad
SequentialAnimation
{
PauseAnimation
{
duration
:
preAnimationTicks
*
animationTime
}
NumberAnimation
{
duration
:
animationTime
easing.type
:
Easing
.
InOutQuad
}
}
}
}
qml/Table.qml
View file @
0fb6a7f8
...
...
@@ -43,6 +43,10 @@ Item {
function
setLastMove
(
row
,
column
,
value
)
{
board
.
setLastMove
(
row
,
column
,
value
)
}
function
setPreAnimationTicks
(
row
,
column
,
value
)
{
board
.
setPreAnimationTicks
(
row
,
column
,
value
);
}
function
showPopup
(
text
)
{
popup
.
show
(
text
,
"
SHOWING
"
);
...
...
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