Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
puzzleplayer
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
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
Floris
puzzleplayer
Commits
d77b73ed
Commit
d77b73ed
authored
3 months ago
by
Floris
Browse files
Options
Downloads
Patches
Plain Diff
input fixes deel 2
parent
6f317932
No related branches found
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
PuzzlePlayer/Binary.cs
+2
-2
2 additions, 2 deletions
PuzzlePlayer/Binary.cs
PuzzlePlayer/Board.cs
+1
-1
1 addition, 1 deletion
PuzzlePlayer/Board.cs
PuzzlePlayer/PuzzleForm.cs
+8
-5
8 additions, 5 deletions
PuzzlePlayer/PuzzleForm.cs
with
11 additions
and
8 deletions
PuzzlePlayer/Binary.cs
+
2
−
2
View file @
d77b73ed
...
...
@@ -463,7 +463,7 @@ namespace PuzzlePlayer_Namespace
}
public
override
void
TileClick
(
Point
p
,
int
x
)
{
if
(
boardState
[
p
.
X
,
p
.
Y
]
==
-
1
)
if
(
boardState
[
p
.
X
,
p
.
Y
]
==
emptySpace
)
{
boardState
[
p
.
X
,
p
.
Y
]
=
x
;
return
;
...
...
@@ -475,7 +475,7 @@ namespace PuzzlePlayer_Namespace
}
if
(
boardState
[
p
.
X
,
p
.
Y
]
==
1
-
x
)
{
boardState
[
p
.
X
,
p
.
Y
]
=
-
1
;
boardState
[
p
.
X
,
p
.
Y
]
=
emptySpace
;
}
}
...
...
This diff is collapsed.
Click to expand it.
PuzzlePlayer/Board.cs
+
1
−
1
View file @
d77b73ed
...
...
@@ -37,7 +37,7 @@ namespace PuzzlePlayer_Namespace
*/
public
abstract
class
Board
{
p
rotected
const
int
emptySpace
=
-
1
;
// for every puzzle -1 represents a empty space
p
ublic
const
int
emptySpace
=
-
1
;
// for every puzzle -1 represents a empty space
public
string
description
;
public
int
drawFactor
;
// setting this to 1 always works
...
...
This diff is collapsed.
Click to expand it.
PuzzlePlayer/PuzzleForm.cs
+
8
−
5
View file @
d77b73ed
...
...
@@ -25,7 +25,6 @@ namespace PuzzlePlayer_Namespace
private
readonly
BufferedGraphics
bufferedGraphics
;
private
Board
board
;
public
Board
Board
//updating the Board member will immediately call board.Draw method so that the board is updated visually
{
get
{
return
board
;
}
set
...
...
@@ -64,7 +63,6 @@ namespace PuzzlePlayer_Namespace
Dock
=
DockStyle
.
Top
,
Font
=
SettingForm
.
mainFont
,
};
ToolStripMenuItem
menuSettings
=
new
ToolStripMenuItem
{
BackColor
=
Color
.
FromArgb
(
54
,
57
,
62
),
...
...
@@ -83,7 +81,6 @@ namespace PuzzlePlayer_Namespace
this
.
Resize
+=
(
object
o
,
EventArgs
ea
)
=>
UpdateUI
();
this
.
Move
+=
(
object
o
,
EventArgs
ea
)
=>
this
.
Focus
();
this
.
KeyPress
+=
(
object
o
,
KeyPressEventArgs
kea
)
=>
Input
(
kea
.
KeyChar
);
this
.
KeyUp
+=
(
object
o
,
KeyEventArgs
kea
)
=>
this
.
MouseClick
+=
(
object
o
,
MouseEventArgs
mea
)
=>
{
if
(
mea
.
Button
==
MouseButtons
.
Left
)
...
...
@@ -152,7 +149,7 @@ namespace PuzzlePlayer_Namespace
titlebox
.
Size
=
new
Size
(
180
,
50
);
titlebox
.
BackColor
=
this
.
BackColor
;
titlebox
.
ForeColor
=
Color
.
White
;
titlebox
.
Text
=
"Binary"
;
titlebox
.
Text
=
puzzleType
;
titlebox
.
Font
=
new
Font
(
"Verdana"
,
24
,
FontStyle
.
Bold
);
Controls
.
Add
(
informationbox
);
...
...
@@ -192,7 +189,7 @@ namespace PuzzlePlayer_Namespace
}
public
void
Input
(
char
c
)
//checks if a command binded to the keyboard key and runs it, affects tile that is hovered on if applicable
{
if
(!
"nhs[]1234567890"
.
Contains
(
c
))
return
;
if
(!
$
"nhs[]
{(
char
)
8
}
1234567890"
.
Contains
(
c
))
return
;
switch
(
c
)
{
case
'n'
:
...
...
@@ -209,6 +206,12 @@ namespace PuzzlePlayer_Namespace
}
Point
tile
=
GetTile
(
new
Size
(
Board
.
boardState
.
GetLength
(
0
),
Board
.
boardState
.
GetLength
(
1
)),
boardspace
,
Control
.
MousePosition
);
if
(!(
tile
.
X
>=
0
&&
tile
.
X
<
Board
.
boardState
.
GetLength
(
0
)
&&
tile
.
Y
>=
0
&&
tile
.
Y
<
Board
.
boardState
.
GetLength
(
1
)))
return
;
if
((
int
)
c
==
8
)
{
Board
.
boardState
[
tile
.
X
,
tile
.
Y
]
=
Board
.
emptySpace
;
this
.
Invalidate
();
return
;
}
if
(
c
==
'['
||
c
==
']'
)
// '[' = 91, ']' = 93
{
Board
.
TileClick
(
tile
,
(
c
-
91
)
/
2
);
...
...
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