Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Commander-Genius
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
24
Issues
24
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gerhard Stein
Commander-Genius
Commits
07bac5c0
Commit
07bac5c0
authored
Jun 16, 2011
by
Gerstrong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now camera moves when keen looks up or down (Galaxy)
parent
d1958b4f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
8 deletions
+62
-8
src/engine/CCamera.cpp
src/engine/CCamera.cpp
+16
-8
src/engine/CCamera.h
src/engine/CCamera.h
+8
-0
src/engine/galaxy/ai/CPlayerLevel.cpp
src/engine/galaxy/ai/CPlayerLevel.cpp
+32
-0
src/engine/galaxy/ai/CPlayerLevel.h
src/engine/galaxy/ai/CPlayerLevel.h
+6
-0
No files found.
src/engine/CCamera.cpp
View file @
07bac5c0
...
...
@@ -19,6 +19,8 @@ CCamera::CCamera(CMap *pmap, Uint32 x, Uint32 y, CObject *p_attacher) :
CObject
(
pmap
,
x
,
y
,
OBJ_NONE
),
mp_AttachedObject
(
p_attacher
)
{
m_relcam
.
x
=
0
;
m_relcam
.
y
=
0
;
sprite
=
BLANKSPRITE
;
solid
=
false
;
m_attached
=
true
;
...
...
@@ -71,27 +73,33 @@ void CCamera::process(const bool force)
m_moving
=
false
;
const
Uint32
attached_x
=
mp_AttachedObject
->
getXPosition
()
+
m_relcam
.
x
;
const
Uint32
attached_y
=
mp_AttachedObject
->
getYPosition
()
+
m_relcam
.
y
;
const
Uint32
local_x
=
getXPosition
();
const
Uint32
local_y
=
getYPosition
();
// Make the camera move and tell if it's scrolling through the m_moving variable
if
(
mp_AttachedObject
->
getXPosition
()
>
getXPosition
()
)
if
(
attached_x
>
local_x
)
{
moveRight
(
mp_AttachedObject
->
getXPosition
()
-
getXPosition
()
);
moveRight
(
attached_x
-
local_x
);
m_moving
|=
true
;
}
else
if
(
mp_AttachedObject
->
getXPosition
()
<
getXPosition
()
)
else
if
(
attached_x
<
local_x
)
{
moveLeft
(
getXPosition
()
-
mp_AttachedObject
->
getXPosition
()
);
moveLeft
(
local_x
-
attached_x
);
m_moving
|=
true
;
}
if
(
mp_AttachedObject
->
getYPosition
()
>
getYPosition
()
)
if
(
attached_y
>
local_y
)
{
moveDown
(
mp_AttachedObject
->
getYPosition
()
-
getYPosition
()
);
moveDown
(
attached_y
-
local_y
);
m_moving
|=
true
;
}
else
if
(
mp_AttachedObject
->
getYPosition
()
<
getYPosition
()
)
else
if
(
attached_y
<
local_y
)
{
moveUp
(
getYPosition
()
-
mp_AttachedObject
->
getYPosition
()
);
moveUp
(
local_y
-
attached_y
);
m_moving
|=
true
;
}
}
...
...
src/engine/CCamera.h
View file @
07bac5c0
...
...
@@ -62,6 +62,14 @@ public:
bool
m_freeze
;
bool
m_moving
;
/**
*
*/
struct
{
int
x
,
y
;
}
m_relcam
;
private:
CObject
*
mp_AttachedObject
;
};
...
...
src/engine/galaxy/ai/CPlayerLevel.cpp
View file @
07bac5c0
...
...
@@ -496,6 +496,7 @@ bool CPlayerLevel::canFallThroughTile()
const
int
MAX_SCROLL_VIEW
=
(
8
<<
CSF
);
void
CPlayerLevel
::
processLookingUp
()
{
...
...
@@ -512,6 +513,9 @@ void CPlayerLevel::processLookingUp()
return
;
}
if
(
m_camera
.
m_relcam
.
y
>
-
MAX_SCROLL_VIEW
)
m_camera
.
m_relcam
.
y
-=
(
2
<<
STC
);
if
(
m_playcontrol
[
PA_Y
]
<
0
)
return
;
...
...
@@ -673,6 +677,10 @@ void CPlayerLevel::processPressDucking()
setAction
(
A_KEEN_FALL
);
g_pSound
->
playSound
(
SOUND_KEEN_FALL
);
}
if
(
m_camera
.
m_relcam
.
y
<
MAX_SCROLL_VIEW
)
m_camera
.
m_relcam
.
y
+=
(
2
<<
STC
);
return
;
}
...
...
@@ -1196,6 +1204,9 @@ void CPlayerLevel::processStanding()
{
/// Keen is standing
// Center the view after Keen looked up or down
centerView
();
// He could walk
if
(
m_playcontrol
[
PA_X
]
<
0
)
{
...
...
@@ -1309,6 +1320,9 @@ void CPlayerLevel::processRunning()
{
// Most of the walking routine is done by the action script itself
// Center the view after Keen looked up or down
centerView
();
// He could stand again, if player doesn't move the dpad
if
(
m_playcontrol
[
PA_X
]
==
0
)
{
...
...
@@ -1506,6 +1520,24 @@ void CPlayerLevel::processFalling()
void
CPlayerLevel
::
centerView
()
{
// If keen looked up or down, this will return the camera to initial position
if
(
m_camera
.
m_relcam
.
y
<
0
)
{
m_camera
.
m_relcam
.
y
+=
(
4
<<
STC
);
if
(
m_camera
.
m_relcam
.
y
>
0
)
m_camera
.
m_relcam
.
y
=
0
;
}
else
if
(
m_camera
.
m_relcam
.
y
>
0
)
{
m_camera
.
m_relcam
.
y
-=
(
4
<<
STC
);
if
(
m_camera
.
m_relcam
.
y
<
0
)
m_camera
.
m_relcam
.
y
=
0
;
}
}
void
CPlayerLevel
::
process
()
...
...
src/engine/galaxy/ai/CPlayerLevel.h
View file @
07bac5c0
...
...
@@ -67,6 +67,10 @@ public:
void
getAnotherLife
(
const
int
&
lc_x
,
const
int
&
lc_y
);
/**
* \brief This will center Keens view after he looked up or down.
*/
void
centerView
();
/**
* \description This is the main process cycle
...
...
@@ -244,6 +248,8 @@ private:
stCheat
&
m_Cheatmode
;
void
(
CPlayerLevel
::*
mp_processState
)();
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment