Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
beadandó 3
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
Borostyán József Bálint
beadandó 3
Commits
2e746543
Commit
2e746543
authored
1 month ago
by
Borostyán József Bálint
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
14aaa5e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
jatekter.cpp
+69
-0
69 additions, 0 deletions
jatekter.cpp
with
69 additions
and
0 deletions
jatekter.cpp
0 → 100644
+
69
−
0
View file @
2e746543
#include
"jatekter.hpp"
#include
"graphics.hpp"
using
namespace
genv
;
JatekTer
::
JatekTer
(
int
x_
,
int
y_
,
int
cs
,
JatekMester
&
jm
)
:
Widget
(
x_
,
y_
,
cs
*
jm
.
get
(
0
,
0
),
cs
*
6
),
jatek
(
jm
),
cellsize
(
cs
)
{}
void
JatekTer
::
draw
()
const
{
for
(
int
r
=
0
;
r
<
6
;
++
r
)
{
for
(
int
c
=
0
;
c
<
7
;
++
c
)
{
int
px
=
x
+
c
*
cellsize
;
int
py
=
y
+
r
*
cellsize
;
gout
<<
color
(
0
,
0
,
255
)
<<
move_to
(
px
,
py
)
<<
box
(
cellsize
,
cellsize
);
gout
<<
color
(
0
,
0
,
0
)
<<
move_to
(
px
+
2
,
py
+
2
)
<<
box
(
cellsize
-
4
,
cellsize
-
4
);
int
val
=
jatek
.
get
(
r
,
c
);
if
(
val
==
1
)
gout
<<
color
(
255
,
0
,
0
);
else
if
(
val
==
2
)
gout
<<
color
(
255
,
255
,
0
);
else
continue
;
int
cx
=
px
+
cellsize
/
2
;
int
cy
=
py
+
cellsize
/
2
;
int
r
=
cellsize
/
2
-
5
;
for
(
int
dy
=
-
r
;
dy
<=
r
;
++
dy
)
for
(
int
dx
=
-
r
;
dx
<=
r
;
++
dx
)
if
(
dx
*
dx
+
dy
*
dy
<=
r
*
r
)
gout
<<
move_to
(
cx
+
dx
,
cy
+
dy
)
<<
dot
;
}
}
int
winner
=
jatek
.
getWinner
();
// nyertes kiiras
if
(
winner
==
1
)
{
gout
<<
move_to
(
50
,
50
)
<<
color
(
255
,
255
,
255
)
<<
text
(
"Piros nyert!"
);
}
else
if
(
winner
==
2
)
{
gout
<<
move_to
(
50
,
50
)
<<
color
(
255
,
255
,
255
)
<<
text
(
"Sarga nyert!"
);
}
// dontetlen ellenorzes
else
{
bool
full
=
true
;
for
(
int
sor
=
0
;
sor
<
6
;
++
sor
)
{
for
(
int
oszlop
=
0
;
oszlop
<
7
;
++
oszlop
)
{
if
(
jatek
.
get
(
sor
,
oszlop
)
==
0
)
{
full
=
false
;
}
}
}
if
(
full
)
{
gout
<<
move_to
(
50
,
50
)
<<
color
(
255
,
255
,
255
)
<<
text
(
"Dontetlen!"
);
}
}
}
void
JatekTer
::
handle
(
event
ev
)
{
if
(
ev
.
type
==
ev_mouse
&&
ev
.
button
==
btn_left
)
{
int
oszlop
=
(
ev
.
pos_x
-
x
)
/
cellsize
;
if
(
jatek
.
ellenoriz
()
==
0
)
{
jatek
.
lepes
(
oszlop
);
}
}
}
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