Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
progBead3
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
Horváth Ádám
progBead3
Commits
cc3b9186
Commit
cc3b9186
authored
1 year ago
by
Horváth Ádám
Browse files
Options
Downloads
Patches
Plain Diff
lehet végleges
parent
ac661019
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
application.cpp
+221
-0
221 additions, 0 deletions
application.cpp
with
221 additions
and
0 deletions
application.cpp
0 → 100644
+
221
−
0
View file @
cc3b9186
#include
"application.hpp"
#include
"checkbox.hpp"
using
namespace
genv
;
Application
::
Application
(
int
boardSize
)
{
gout
.
open
(
boardSize
*
40
,
boardSize
*
40
);
// Minden négyzet mérete 40x40 pixel
for
(
int
i
=
0
;
i
<
boardSize
;
i
++
)
{
for
(
int
j
=
0
;
j
<
boardSize
;
j
++
)
{
widgets
.
push_back
(
new
CheckBox
(
this
,
j
*
40
,
i
*
40
,
40
,
40
));
}
}
}
void
Application
::
gameover
(
int
sz
)
{
game
=
false
;
//gout << move_to(0, 0) << color(0, 0, 0) << box(800, 800);
gout
<<
color
(
0
,
0
,
0
)
<<
move_to
(
100
,
300
)
<<
box
(
800
,
800
);
if
(
sz
==
0
)
{
gout
<<
move_to
(
100
,
300
)
<<
color
(
255
,
255
,
255
)
<<
text
(
" Game over!
\n
Döntetlen! Jatek bezarasa: ESC,
\n
Uj jatek inditasa: space-t."
)
<<
refresh
;
}
else
if
(
sz
%
2
==
0
)
{
gout
<<
move_to
(
0
,
0
)
<<
color
(
0
,
0
,
0
)
<<
box
(
1000
,
1000
)
<<
move_to
(
100
,
300
)
<<
color
(
255
,
255
,
255
)
<<
text
(
" Game over!
\n
X nyert! Jatek bezarasa: ESC,
\n
Uj jatek inditasa: space-t."
)
<<
refresh
;
}
else
{
gout
<<
move_to
(
100
,
300
)
<<
color
(
255
,
255
,
255
)
<<
text
(
" Game over!
\n
O nyert! Jatek bezarasa: ESC,
\n
Uj jatek inditasa: space-t."
)
<<
refresh
;
}
}
bool
Application
::
checker
(
int
focus
,
int
index
)
{
if
(
"first"
==
"first"
)
{
int
counter
=
0
;
int
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
++
;
}
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
--
;
}
if
(
counter
>=
6
)
{
return
true
;
}
}
if
(
"second"
==
"second"
)
{
int
counter
=
0
;
int
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
=
valt
+
15
;
}
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
=
valt
-
15
;
}
if
(
counter
>=
6
)
{
return
true
;
}
}
if
(
"third"
==
"third"
)
{
int
counter
=
0
;
int
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
=
valt
+
16
;
}
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
=
valt
-
16
;
}
if
(
counter
>=
6
)
{
return
true
;
}
}
if
(
"fourth"
==
"fourth"
)
{
int
counter
=
0
;
int
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
=
valt
+
14
;
}
valt
=
focus
;
while
(
widgets
[
valt
]
->
value_sz
()
!=
0
&&
widgets
[
valt
]
->
value_sz
()
%
2
==
index
%
2
)
{
counter
++
;
valt
=
valt
-
14
;
}
if
(
counter
>=
6
)
{
return
true
;
}
}
return
false
;
}
void
Application
::
event_loop
()
{
event
ev
;
int
focus
=
-
1
;
int
sz
=
0
;
while
(
gin
>>
ev
)
{
if
(
ev
.
type
==
ev_key
&&
ev
.
keycode
==
key_escape
)
{
break
;
}
if
(
ev
.
type
==
ev_key
&&
ev
.
keycode
==
key_space
&&
game
==
false
)
{
for
(
Widget
*
w
:
widgets
)
{
w
->
value
(
0
);
}
game
=
true
;
}
if
(
ev
.
type
==
ev_mouse
&&
ev
.
button
==
btn_left
)
{
for
(
size_t
i
=
0
;
i
<
widgets
.
size
();
i
++
)
{
if
(
widgets
[
i
]
->
is_selected
(
ev
.
pos_x
,
ev
.
pos_y
))
focus
=
i
;
}
}
if
(
focus
!=-
1
)
{
widgets
[
focus
]
->
handle
(
ev
);
if
(
widgets
[
focus
]
->
is_checked
()
&&
widgets
[
focus
]
->
value_sz
()
==
0
)
{
sz
++
;
widgets
[
focus
]
->
value
(
sz
);
}
}
if
(
game
)
{
for
(
Widget
*
w
:
widgets
)
{
w
->
draw
();
}
}
if
(
focus
!=-
1
)
{
if
(
checker
(
focus
,
widgets
[
focus
]
->
value_sz
()))
{
gameover
(
widgets
[
focus
]
->
value_sz
());
}
}
if
(
sz
==
225
)
{
gameover
(
0
);
}
gout
<<
refresh
;
}
}
void
Application
::
registerWidget
(
Widget
*
widget
)
{
widgets
.
push_back
(
widget
);
}
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