Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bead3_papbe5
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Papp Benjámin
bead3_papbe5
Commits
0c4c6484
Commit
0c4c6484
authored
May 20, 2024
by
Papp Benjámin
Browse files
Options
Downloads
Patches
Plain Diff
POST HATÁRIDŐs kiegészítő commit, de nem akartam befejezetlenül hagyni: won/draw ablak hozzáadva
parent
9b3f9c9a
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
mester.cpp
+15
-9
15 additions, 9 deletions
mester.cpp
mester.h
+2
-1
2 additions, 1 deletion
mester.h
palya.cpp
+22
-6
22 additions, 6 deletions
palya.cpp
palya.h
+2
-0
2 additions, 0 deletions
palya.h
with
41 additions
and
16 deletions
mester.cpp
+
15
−
9
View file @
0c4c6484
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
using
namespace
genv
;
using
namespace
genv
;
Mester
::
Mester
()
Mester
::
Mester
(
Palya
*
_p
)
:
p
(
_p
)
{
{
player1
=
new
Player
(
"Player1"
,
1
);
player1
=
new
Player
(
"Player1"
,
1
);
player2
=
new
Player
(
"Player2"
,
2
);
player2
=
new
Player
(
"Player2"
,
2
);
...
@@ -155,17 +155,23 @@ int Mester::vertic_vizsg(Palyamezo* f, int szam){
...
@@ -155,17 +155,23 @@ int Mester::vertic_vizsg(Palyamezo* f, int szam){
bool
Mester
::
streak_vizsgalo
(
Palyamezo
*
vizsgalt
){
bool
Mester
::
streak_vizsgalo
(
Palyamezo
*
vizsgalt
){
int
vizsgalt_index
=
vizsgalt
->
index
;
int
vizsgalt_index
=
vizsgalt
->
index
;
if
(
moncsok_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
||
monno_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
||
horizont_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
||
vertic_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
){
if
(
moncsok_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
||
monno_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
||
horizont_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
||
vertic_vizsg
(
vizsgalt
,
vizsgalt_index
)
>=
5
)
std
::
cout
<<
"streak"
<<
std
::
endl
;
{
return
true
;}
return
true
;}
else
{
return
false
;}
else
{
std
::
cout
<<
"not really"
<<
std
::
endl
;
return
false
;}
}
}
void
Mester
::
gameover
()
{
void
Mester
::
gameover
()
{
/*if(player1->get_pontszam() == 3)
if
(
player1
->
get_pontszam
()
==
3
)
p->won()*/
p
->
won
(
player1
->
get_name
());
if
(
player2
->
get_pontszam
()
==
3
)
p
->
won
(
player2
->
get_name
());
if
(
turn
==
400
){
if
(
player1
->
get_pontszam
()
>
player2
->
get_pontszam
())
p
->
won
(
player1
->
get_name
());
else
{
if
(
player2
->
get_pontszam
()
>
player1
->
get_pontszam
())
p
->
won
(
player2
->
get_name
());
else
{
if
(
player1
->
get_pontszam
()
==
player2
->
get_pontszam
())
p
->
dontetlen
();}}}
}
}
void
Mester
::
szabalyzat
(
Palyamezo
*
f
){
void
Mester
::
szabalyzat
(
Palyamezo
*
f
){
...
...
This diff is collapsed.
Click to expand it.
mester.h
+
2
−
1
View file @
0c4c6484
...
@@ -9,13 +9,14 @@ class Player;
...
@@ -9,13 +9,14 @@ class Player;
class
Mester
class
Mester
{
{
Palya
*
p
;
Player
*
aktiv
;
Player
*
aktiv
;
std
::
vector
<
Palyamezo
*>
negyzetek
;
std
::
vector
<
Palyamezo
*>
negyzetek
;
bool
lepes
=
false
;
bool
lepes
=
false
;
int
turn
=
0
;
int
turn
=
0
;
int
focused_index
=
200
;
int
focused_index
=
200
;
public:
public:
Mester
();
Mester
(
Palya
*
_p
);
Player
*
player1
;
Player
*
player1
;
Player
*
player2
;
Player
*
player2
;
void
set_negyzetek
(
std
::
vector
<
Palyamezo
*>
v
);
void
set_negyzetek
(
std
::
vector
<
Palyamezo
*>
v
);
...
...
This diff is collapsed.
Click to expand it.
palya.cpp
+
22
−
6
View file @
0c4c6484
...
@@ -18,7 +18,7 @@ Palya::Palya()
...
@@ -18,7 +18,7 @@ Palya::Palya()
negyzet
->
draw
();
negyzet
->
draw
();
}
}
}
}
mesztor
=
new
Mester
();
mesztor
=
new
Mester
(
this
);
title
=
new
TextWidget
(
this
,
410
,
30
,
200
,
50
,
"Tic-tac-toe"
);
title
=
new
TextWidget
(
this
,
410
,
30
,
200
,
50
,
"Tic-tac-toe"
);
title
->
draw
();
title
->
draw
();
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
24
);
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
24
);
...
@@ -36,12 +36,14 @@ Palya::Palya()
...
@@ -36,12 +36,14 @@ Palya::Palya()
}
}
void
Palya
::
jatek
(
event
ev
){
void
Palya
::
jatek
(
event
ev
){
if
(
!
vege
){
mesztor
->
set_negyzetek
(
palyaterulet
);
mesztor
->
set_negyzetek
(
palyaterulet
);
for
(
Palyamezo
*
negyzet
:
palyaterulet
){
for
(
Palyamezo
*
negyzet
:
palyaterulet
){
mesztor
->
iranyitas
(
negyzet
,
ev
);
mesztor
->
iranyitas
(
negyzet
,
ev
);
mesztor
->
szabalyzat
(
negyzet
);
mesztor
->
szabalyzat
(
negyzet
);
}
}
}
}
}
void
Palya
::
grafikai_valtozas
(){
void
Palya
::
grafikai_valtozas
(){
pontok1
->
set_text
(
to_string
(
mesztor
->
player1
->
get_pontszam
()));
pontok1
->
set_text
(
to_string
(
mesztor
->
player1
->
get_pontszam
()));
...
@@ -52,8 +54,22 @@ void Palya::grafikai_valtozas(){
...
@@ -52,8 +54,22 @@ void Palya::grafikai_valtozas(){
void
Palya
::
won
(
string
gyoztes
)
{
void
Palya
::
won
(
string
gyoztes
)
{
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
35
);
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
35
);
TextWidget
*
ablak
=
new
TextWidget
(
this
,
4
5
0
,
4
5
0
,
15
0
,
15
0
,
gyoztes
);
TextWidget
*
ablak
=
new
TextWidget
(
this
,
4
0
0
,
4
0
0
,
23
0
,
20
0
,
gyoztes
+
" won!"
);
ablak
->
draw
();
ablak
->
draw
();
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
24
);
TextWidget
*
kilepes
=
new
TextWidget
(
this
,
400
,
750
,
250
,
100
,
"Press 'Esc' to exit!"
);
kilepes
->
draw
();
vege
=
true
;
}
void
Palya
::
dontetlen
(){
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
35
);
TextWidget
*
ablak
=
new
TextWidget
(
this
,
400
,
400
,
230
,
200
,
"Draw!"
);
ablak
->
draw
();
gout
<<
font
(
"LiberationSans-Regular.ttf"
,
24
);
TextWidget
*
kilepes
=
new
TextWidget
(
this
,
400
,
750
,
250
,
100
,
"Press 'Esc' to exit!"
);
kilepes
->
draw
();
vege
=
true
;
}
}
Palya
::~
Palya
()
{}
Palya
::~
Palya
()
{}
This diff is collapsed.
Click to expand it.
palya.h
+
2
−
0
View file @
0c4c6484
...
@@ -11,6 +11,7 @@ class Palya
...
@@ -11,6 +11,7 @@ class Palya
{
{
const
int
XX
=
1000
;
const
int
XX
=
1000
;
const
int
YY
=
1000
;
const
int
YY
=
1000
;
bool
vege
=
false
;
TextWidget
*
title
;
TextWidget
*
title
;
TextWidget
*
bo3
;
TextWidget
*
bo3
;
TextWidget
*
nev1
;
TextWidget
*
nev1
;
...
@@ -24,6 +25,7 @@ public:
...
@@ -24,6 +25,7 @@ public:
void
jatek
(
genv
::
event
ev
);
void
jatek
(
genv
::
event
ev
);
void
grafikai_valtozas
();
void
grafikai_valtozas
();
void
won
(
std
::
string
gyoztes
);
void
won
(
std
::
string
gyoztes
);
void
dontetlen
();
~
Palya
();
~
Palya
();
};
};
...
...
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