Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
harmadik
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamar János
harmadik
Commits
e0f147b8
Commit
e0f147b8
authored
1 year ago
by
Hamar János
Browse files
Options
Downloads
Patches
Plain Diff
menu
parent
cfcb8462
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
4.0.2.pro
+46
-0
46 additions, 0 deletions
4.0.2.pro
application.cpp
+107
-0
107 additions, 0 deletions
application.cpp
main.cpp
+0
-5
0 additions, 5 deletions
main.cpp
with
153 additions
and
5 deletions
4.0.2.pro
0 → 100644
+
46
−
0
View file @
e0f147b8
TEMPLATE
=
app
CONFIG
+=
console
c
++
11
CONFIG
-=
app_bundle
CONFIG
-=
qt
SOURCES
+=
\
application
.
cpp
\
bishop
.
cpp
\
dropdown
.
cpp
\
king
.
cpp
\
knight
.
cpp
\
konyvtar
.
cpp
\
main
.
cpp
\
graphics
/
graphics
.
cpp
\
pawn
.
cpp
\
puppets
.
cpp
\
queen
.
cpp
\
rook
.
cpp
INCLUDEPATH
+=
$$
PWD
/.
DEPENDPATH
+=
$$
PWD
/.
win32
:
CONFIG
(
release
,
debug
|
release
)
:
LIBS
+=
-
L
$$
PWD
/./
-
llibSDL2
.
dll
else
:
win32
:
CONFIG
(
debug
,
debug
|
release
)
:
LIBS
+=
-
L
$$
PWD
/./
-
llibSDL2
.
dll
else
:
unix
:
LIBS
+=
-
L
$$
PWD
/./
-
llibSDL2
.
dll
win32
:
CONFIG
(
release
,
debug
|
release
)
:
LIBS
+=
-
L
$$
PWD
/./
-
llibSDL2_ttf
.
dll
else
:
win32
:
CONFIG
(
debug
,
debug
|
release
)
:
LIBS
+=
-
L
$$
PWD
/./
-
llibSDL2_ttf
.
dll
else
:
unix
:
LIBS
+=
-
L
$$
PWD
/./
-
llibSDL2_ttf
.
dll
INCLUDEPATH
+=
$$
PWD
/
SDL2
DEPENDPATH
+=
$$
PWD
/
SDL2
HEADERS
+=
\
application
.
hpp
\
bishop
.
hpp
\
dropdown
.
hpp
\
king
.
hpp
\
knight
.
hpp
\
konyvtar
.
hpp
\
pawn
.
hpp
\
puppets
.
hpp
\
queen
.
hpp
\
rook
.
hpp
This diff is collapsed.
Click to expand it.
application.cpp
+
107
−
0
View file @
e0f147b8
...
...
@@ -9,6 +9,111 @@ Application::Application()
gout
.
open
(
641
,
641
);
}
void
Application
::
event_loop
()
{
event
ev
;
int
focus
=
-
1
,
szam
=
1
;
bool
in_game
=
false
;
// Új változó a játék állapotának nyomon követésére
while
(
gin
>>
ev
)
{
if
(
!
in_game
)
// Amíg nincs a játékban, ellenőrizzük a "Play" gombot
{
// Play gomb megrajzolása
gout
<<
move_to
(
270
,
300
)
<<
color
(
0
,
255
,
0
)
<<
box
(
100
,
50
);
gout
<<
move_to
(
295
,
330
)
<<
color
(
0
,
0
,
0
)
<<
text
(
"Play"
);
if
(
ev
.
type
==
ev_mouse
&&
ev
.
button
==
btn_left
)
{
if
(
ev
.
pos_x
>=
270
&&
ev
.
pos_x
<=
370
&&
ev
.
pos_y
>=
300
&&
ev
.
pos_y
<=
350
)
{
in_game
=
true
;
// Ha a "Play" gombra kattintunk, belépünk a játékba
background
();
// Újra megrajzoljuk a hátteret a táblával
}
}
gout
<<
refresh
;
continue
;
}
// Eredeti eseménykezelés a játékhoz
if
(
ev
.
type
==
ev_mouse
&&
ev
.
button
==
btn_left
)
{
focus
=
-
1
;
for
(
size_t
i
=
0
;
i
<
puppets
.
size
();
++
i
)
{
if
(
puppets
[
i
]
->
select
(
ev
.
pos_x
,
ev
.
pos_y
))
{
focus
=
i
;
}
}
}
for
(
Puppets
*
w
:
puppets
)
{
w
->
draw
();
}
if
(
focus
!=
-
1
)
{
if
(
szam
%
2
==
0
)
// ha páros akkor a fekete lép
{
if
(
puppets
[
focus
]
->
getColor
()
==
false
)
{
szam
+=
1
;
}
else
{
focus
=
-
1
;
}
}
else
//ha páratlan akkor a fehér lép
{
if
(
puppets
[
focus
]
->
getColor
()
==
true
)
{
szam
+=
1
;
}
else
{
focus
=
-
1
;
}
}
}
if
(
focus
!=
-
1
)
{
puppets
[
focus
]
->
handle
(
ev
);
for
(
size_t
i
=
0
;
i
<
puppets
.
size
();
++
i
)
{
puppets
[
i
]
->
Pos_steps
();
}
for
(
size_t
i
=
0
;
i
<
puppets
.
size
();
++
i
)
{
if
(
puppets
[
i
]
->
is_king
())
{
puppets
[
i
]
->
sakkmatt
();
}
}
for
(
size_t
i
=
0
;
i
<
puppets
.
size
();
++
i
)
{
if
((
puppets
[
i
]
->
getColor
()
&&
puppets
[
i
]
->
getY
()
==
560
)
||
(
!
puppets
[
i
]
->
getColor
()
&&
puppets
[
i
]
->
getY
()
==
0
))
{
if
(
puppets
[
focus
]
->
getX
()
==
puppets
[
i
]
->
getX
()
and
puppets
[
focus
]
->
getY
()
==
puppets
[
i
]
->
getY
()
)
{
removePuppet
(
puppets
[
i
]);
background
();
for
(
Puppets
*
w
:
puppets
)
{
w
->
draw
();
}
break
;
}
}
}
}
gout
<<
refresh
;
}
}
/*
void Application::event_loop()
{
event ev;
...
...
@@ -69,6 +174,7 @@ void Application::event_loop()
if(puppets[i]->is_king())
{
puppets[i]->sakkmatt();
}
}
for (size_t i = 0; i < puppets.size(); ++i)
...
...
@@ -91,6 +197,7 @@ void Application::event_loop()
gout << refresh;
}
}
*/
void
Application
::
background
()
{
gout
<<
move_to
(
0
,
0
)
<<
color
(
0
,
0
,
0
)
<<
box
(
641
,
641
);
...
...
This diff is collapsed.
Click to expand it.
main.cpp
+
0
−
5
View file @
e0f147b8
...
...
@@ -23,7 +23,6 @@ public:
void
init_pieces
()
{
// Fehér bábuk inicializálása
/*
r1_1
=
new
Rook
(
this
,
0
,
0
,
true
);
kn1_1
=
new
Knight
(
this
,
80
,
0
,
true
);
b1_1
=
new
Bishop
(
this
,
160
,
0
,
true
);
...
...
@@ -32,7 +31,6 @@ public:
b1_2
=
new
Bishop
(
this
,
400
,
0
,
true
);
kn1_2
=
new
Knight
(
this
,
480
,
0
,
true
);
r1_2
=
new
Rook
(
this
,
560
,
0
,
true
);
*/
p1_1
=
new
Pawn
(
this
,
0
,
80
,
true
);
p1_2
=
new
Pawn
(
this
,
80
,
80
,
true
);
p1_3
=
new
Pawn
(
this
,
160
,
80
,
true
);
...
...
@@ -41,10 +39,8 @@ public:
p1_6
=
new
Pawn
(
this
,
400
,
80
,
true
);
p1_7
=
new
Pawn
(
this
,
480
,
80
,
true
);
p1_8
=
new
Pawn
(
this
,
560
,
80
,
true
);
p1_8
=
new
Pawn
(
this
,
560
,
150
,
true
);
// Fekete bábuk inicializálása
/*
r2_1
=
new
Rook
(
this
,
0
,
560
,
false
);
kn2_1
=
new
Knight
(
this
,
80
,
560
,
false
);
b2_1
=
new
Bishop
(
this
,
160
,
560
,
false
);
...
...
@@ -53,7 +49,6 @@ public:
b2_2
=
new
Bishop
(
this
,
400
,
560
,
false
);
kn2_2
=
new
Knight
(
this
,
480
,
560
,
false
);
r2_2
=
new
Rook
(
this
,
560
,
560
,
false
);
*/
p2_1
=
new
Pawn
(
this
,
0
,
480
,
false
);
p2_2
=
new
Pawn
(
this
,
80
,
480
,
false
);
p2_3
=
new
Pawn
(
this
,
160
,
480
,
false
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment