Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Blaze-Brigade
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Susan Yuen
Blaze-Brigade
Commits
dd187df6
Commit
dd187df6
authored
8 years ago
by
Susan Yuen
Browse files
Options
Downloads
Patches
Plain Diff
Updated map scrolling to only occur when game window is in focus
parent
8aa0b9a2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
+24
-21
24 additions, 21 deletions
src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
with
24 additions
and
21 deletions
src/Blaze-Brigade/Blaze_Brigade/MouseHandler.cs
+
24
−
21
View file @
dd187df6
...
...
@@ -41,34 +41,37 @@ namespace Controller
// enable scrolling around the map
#
region
Map
scrolling
const
int
scrollSpeed
=
3
;
// change in pixels while scrolling
const
int
scrollSpeed
=
3
;
// change in pixels while scrolling
const
int
boundaryX
=
-
640
;
const
int
boundaryY
=
-
320
;
// scroll map to the left
if
(
currentMouseState
.
X
<=
0
&&
camera
.
Position
.
X
<
0
)
if
(
Game
.
Instance
.
IsActive
)
// if game window is in focus
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
+
scrollSpeed
,
camera
.
Position
.
Y
);
}
// scroll map to the left
if
(
currentMouseState
.
X
<=
0
&&
camera
.
Position
.
X
<
0
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
+
scrollSpeed
,
camera
.
Position
.
Y
);
}
//Debug.WriteLine(camera.Position.X);
//Debug.WriteLine(camera.Position.X);
// scroll map to the right
if
(
currentMouseState
.
X
>=
GameState
.
SCREEN_WIDTH
&&
camera
.
Position
.
X
>
boundaryX
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
-
scrollSpeed
,
camera
.
Position
.
Y
);
}
// scroll map to the right
if
(
currentMouseState
.
X
>=
GameState
.
SCREEN_WIDTH
&&
camera
.
Position
.
X
>
boundaryX
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
-
scrollSpeed
,
camera
.
Position
.
Y
);
}
// scroll map downwards
if
(
currentMouseState
.
Y
>=
GameState
.
SCREEN_HEIGHT
&&
camera
.
Position
.
Y
>
boundaryY
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
,
camera
.
Position
.
Y
-
scrollSpeed
);
}
// scroll map downwards
if
(
currentMouseState
.
Y
>=
GameState
.
SCREEN_HEIGHT
&&
camera
.
Position
.
Y
>
boundaryY
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
,
camera
.
Position
.
Y
-
scrollSpeed
);
}
// scroll map upwards
if
(
currentMouseState
.
Y
<=
0
&&
camera
.
Position
.
Y
<
0
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
,
camera
.
Position
.
Y
+
scrollSpeed
);
// scroll map upwards
if
(
currentMouseState
.
Y
<=
0
&&
camera
.
Position
.
Y
<
0
)
{
camera
.
Position
=
new
Vector2
(
camera
.
Position
.
X
,
camera
.
Position
.
Y
+
scrollSpeed
);
}
}
#
endregion
...
...
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