Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
openjazz
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
openjazz
Commits
6e631c48
Commit
6e631c48
authored
Mar 01, 2010
by
AlisterT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixes.
parent
5421b4d6
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
230 additions
and
166 deletions
+230
-166
controls.h
src/io/controls.h
+1
-1
paletteeffects.cpp
src/io/gfx/paletteeffects.cpp
+2
-2
sound.cpp
src/io/sound.cpp
+3
-3
bullet.cpp
src/level/bullet.cpp
+3
-3
event.cpp
src/level/event/event.cpp
+21
-16
event.h
src/level/event/event.h
+1
-1
eventframe.cpp
src/level/event/eventframe.cpp
+110
-83
level.cpp
src/level/level.cpp
+8
-8
level.h
src/level/level.h
+7
-8
levelframe.cpp
src/level/levelframe.cpp
+14
-3
levelload.cpp
src/level/levelload.cpp
+6
-3
bird.cpp
src/player/bird.cpp
+3
-3
player.cpp
src/player/player.cpp
+2
-2
player.h
src/player/player.h
+7
-7
playerframe.cpp
src/player/playerframe.cpp
+42
-23
No files found.
src/io/controls.h
View file @
6e631c48
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
#define CONTROLS 11
#define CONTROLS 11
// Time interval
// Time interval
#define T_KEY
5
00
#define T_KEY
2
00
// Class
// Class
...
...
src/io/gfx/paletteeffects.cpp
View file @
6e631c48
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -537,7 +537,7 @@ void WaterPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
...
@@ -537,7 +537,7 @@ void WaterPaletteEffect::apply (SDL_Color *shownPalette, bool direct,
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
if
(
next
)
next
->
apply
(
shownPalette
,
direct
,
mspf
);
position
=
localPlayer
->
getY
()
-
level
->
getWaterLevel
(
0
);
position
=
localPlayer
->
getY
()
-
level
->
getWaterLevel
();
if
(
position
<=
0
)
return
;
if
(
position
<=
0
)
return
;
...
...
src/io/sound.cpp
View file @
6e631c48
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -63,7 +63,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
...
@@ -63,7 +63,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
SDL_MixAudio
(
stream
,
SDL_MixAudio
(
stream
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
len
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
len
,
SDL_MIX_MAXVOLUME
>>
1
);
SDL_MIX_MAXVOLUME
>>
2
);
sounds
[
count
].
position
+=
len
;
sounds
[
count
].
position
+=
len
;
...
@@ -74,7 +74,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
...
@@ -74,7 +74,7 @@ void audioCallback (void * userdata, unsigned char * stream, int len) {
SDL_MixAudio
(
stream
,
SDL_MixAudio
(
stream
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
sounds
[
count
].
data
+
sounds
[
count
].
position
,
sounds
[
count
].
length
-
sounds
[
count
].
position
,
sounds
[
count
].
length
-
sounds
[
count
].
position
,
SDL_MIX_MAXVOLUME
>>
1
);
SDL_MIX_MAXVOLUME
>>
2
);
sounds
[
count
].
position
=
-
1
;
sounds
[
count
].
position
=
-
1
;
...
...
src/level/bullet.cpp
View file @
6e631c48
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -202,7 +202,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -202,7 +202,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
// If the event is within range, hit it
// If the event is within range, hit it
if
(
event
->
overlap
(
x
-
F160
,
y
-
F100
,
2
*
F160
,
2
*
F100
))
if
(
event
->
overlap
(
x
-
F160
,
y
-
F100
,
2
*
F160
,
2
*
F100
))
event
->
hit
(
source
,
ticks
);
event
->
hit
(
source
,
t
rue
,
t
icks
);
event
=
event
->
getNext
();
event
=
event
->
getNext
();
...
@@ -245,7 +245,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
...
@@ -245,7 +245,7 @@ bool Bullet::step (unsigned int ticks, int msps) {
if
(
event
->
overlap
(
x
,
y
,
0
,
0
))
{
if
(
event
->
overlap
(
x
,
y
,
0
,
0
))
{
// If the event is hittable, hit it and destroy the bullet
// If the event is hittable, hit it and destroy the bullet
if
(
event
->
hit
(
source
,
ticks
))
return
true
;
if
(
event
->
hit
(
source
,
false
,
ticks
))
return
true
;
}
}
...
...
src/level/event/event.cpp
View file @
6e631c48
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -43,11 +43,14 @@
...
@@ -43,11 +43,14 @@
Event
::
Event
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
)
{
Event
::
Event
(
unsigned
char
gX
,
unsigned
char
gY
,
Event
*
nextEvent
)
{
x
=
TTOF
(
gX
);
y
=
TTOF
(
gY
+
1
);
dx
=
0
;
dy
=
0
;
next
=
nextEvent
;
next
=
nextEvent
;
gridX
=
gX
;
gridX
=
gX
;
gridY
=
gY
;
gridY
=
gY
;
x
=
TTOF
(
gX
);
y
=
TTOF
(
gY
+
1
);
flashTime
=
0
;
flashTime
=
0
;
// Choose initial settings
// Choose initial settings
...
@@ -56,6 +59,7 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
...
@@ -56,6 +59,7 @@ Event::Event (unsigned char gX, unsigned char gY, Event *nextEvent) {
case
21
:
// Destructible block
case
21
:
// Destructible block
case
25
:
// Float up / Belt
case
25
:
// Float up / Belt
case
37
:
// Sucker tubes
case
38
:
// Sucker tubes
case
38
:
// Sucker tubes
case
40
:
// Monochrome
case
40
:
// Monochrome
case
57
:
// Bubbles
case
57
:
// Bubbles
...
@@ -141,15 +145,17 @@ void Event::destroy (unsigned int ticks) {
...
@@ -141,15 +145,17 @@ void Event::destroy (unsigned int ticks) {
}
}
bool
Event
::
hit
(
Player
*
source
,
unsigned
int
ticks
)
{
bool
Event
::
hit
(
Player
*
source
,
bool
TNT
,
unsigned
int
ticks
)
{
int
hitsRemaining
;
int
hitsRemaining
;
// Deal with bullet collisions
// Deal with bullet collisions
// Check if event has already been destroyed
if
((
animType
==
E_LFINISHANIM
)
||
(
animType
==
E_RFINISHANIM
)
||
if
((
animType
==
E_LFINISHANIM
)
||
(
animType
==
E_RFINISHANIM
)
||
(
ticks
<
flashTime
))
return
false
;
(
ticks
<
flashTime
))
return
false
;
hitsRemaining
=
level
->
hitEvent
(
source
,
gridX
,
gridY
);
hitsRemaining
=
level
->
hitEvent
(
gridX
,
gridY
,
source
,
TNT
);
// If the event cannot be hit, do not register hit
// If the event cannot be hit, do not register hit
if
(
hitsRemaining
<
0
)
return
false
;
if
(
hitsRemaining
<
0
)
return
false
;
...
@@ -177,28 +183,27 @@ fixed Event::getWidth () {
...
@@ -177,28 +183,27 @@ fixed Event::getWidth () {
fixed
width
;
fixed
width
;
if
(
animType
&&
(
getProperty
(
animType
)
>=
0
))
{
if
(
!
animType
)
return
F32
;
width
=
ITOF
(
level
->
getAnim
(
getProperty
(
animType
))
->
getWidth
());
// Blank sprites for e.g. invisible springs
if
(
getProperty
(
animType
)
<=
0
)
return
0
;
if
((
width
==
F1
)
&&
(
getHeight
()
==
F1
))
return
F32
;
return
width
;
width
=
ITOF
(
level
->
getAnim
(
getProperty
(
animType
))
->
getWidth
())
;
}
// Blank sprites for e.g. invisible springs
if
((
width
==
F1
)
&&
(
getHeight
()
==
F1
))
return
F32
;
return
F32
;
return
width
;
}
}
fixed
Event
::
getHeight
()
{
fixed
Event
::
getHeight
()
{
if
(
animType
&&
(
getProperty
(
animType
)
>=
0
))
if
(
!
animType
)
return
F32
;
return
ITOF
(
level
->
getAnim
(
getProperty
(
animType
))
->
getHeight
());
if
(
getProperty
(
animType
)
<=
0
)
return
0
;
return
F32
;
return
ITOF
(
level
->
getAnim
(
getProperty
(
animType
))
->
getHeight
())
;
}
}
...
...
src/level/event/event.h
View file @
6e631c48
...
@@ -94,7 +94,7 @@ class Event : public Movable {
...
@@ -94,7 +94,7 @@ class Event : public Movable {
Event
*
getNext
();
Event
*
getNext
();
void
removeNext
();
void
removeNext
();
bool
hit
(
Player
*
source
,
unsigned
int
ticks
);
bool
hit
(
Player
*
source
,
bool
TNT
,
unsigned
int
ticks
);
bool
isFrom
(
unsigned
char
gX
,
unsigned
char
gY
);
bool
isFrom
(
unsigned
char
gX
,
unsigned
char
gY
);
fixed
getWidth
();
fixed
getWidth
();
fixed
getHeight
();
fixed
getHeight
();
...
...
src/level/event/eventframe.cpp
View file @
6e631c48
This diff is collapsed.
Click to expand it.
src/level/level.cpp
View file @
6e631c48
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -272,7 +272,7 @@ void Level::clearEvent (unsigned char gridX, unsigned char gridY) {
...
@@ -272,7 +272,7 @@ void Level::clearEvent (unsigned char gridX, unsigned char gridY) {
}
}
int
Level
::
hitEvent
(
Player
*
source
,
unsigned
char
gridX
,
unsigned
char
gridY
)
{
int
Level
::
hitEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
,
Player
*
source
,
bool
TNT
)
{
GridElement
*
ge
;
GridElement
*
ge
;
unsigned
char
buffer
[
MTL_L_GRID
];
unsigned
char
buffer
[
MTL_L_GRID
];
...
@@ -286,7 +286,8 @@ int Level::hitEvent (Player *source, unsigned char gridX, unsigned char gridY) {
...
@@ -286,7 +286,8 @@ int Level::hitEvent (Player *source, unsigned char gridX, unsigned char gridY) {
if
(
!
hitsToKill
)
return
-
1
;
if
(
!
hitsToKill
)
return
-
1
;
// Increase the hit count
// Increase the hit count
ge
->
hits
++
;
if
(
TNT
)
ge
->
hits
=
hitsToKill
;
else
ge
->
hits
++
;
// Check if the event has been killed
// Check if the event has been killed
if
(
ge
->
hits
==
hitsToKill
)
{
if
(
ge
->
hits
==
hitsToKill
)
{
...
@@ -389,7 +390,7 @@ void Level::setWaterLevel (unsigned char gridY) {
...
@@ -389,7 +390,7 @@ void Level::setWaterLevel (unsigned char gridY) {
unsigned
char
buffer
[
MTL_L_PROP
];
unsigned
char
buffer
[
MTL_L_PROP
];
waterLevel
=
TTOF
(
gridY
);
waterLevel
Target
=
TTOF
(
gridY
);
if
(
gameMode
)
{
if
(
gameMode
)
{
...
@@ -407,10 +408,9 @@ void Level::setWaterLevel (unsigned char gridY) {
...
@@ -407,10 +408,9 @@ void Level::setWaterLevel (unsigned char gridY) {
}
}
fixed
Level
::
getWaterLevel
(
int
phase
)
{
fixed
Level
::
getWaterLevel
()
{
if
(
phase
&
1024
)
return
waterLevel
-
((
phase
&
1023
)
*
32
);
return
waterLevel
;
return
waterLevel
-
((
1024
-
(
phase
&
1023
))
*
32
);
}
}
...
@@ -475,7 +475,7 @@ void Level::receive (unsigned char *buffer) {
...
@@ -475,7 +475,7 @@ void Level::receive (unsigned char *buffer) {
}
else
if
(
buffer
[
2
]
==
1
)
{
}
else
if
(
buffer
[
2
]
==
1
)
{
waterLevel
=
TTOF
(
buffer
[
3
]);
waterLevel
Target
=
TTOF
(
buffer
[
3
]);
}
else
if
(
buffer
[
2
]
==
2
)
{
}
else
if
(
buffer
[
2
]
==
2
)
{
...
...
src/level/level.h
View file @
6e631c48
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -118,6 +118,8 @@ class Level {
...
@@ -118,6 +118,8 @@ class Level {
unsigned
int
endTime
;
unsigned
int
endTime
;
int
enemies
,
items
;
int
enemies
,
items
;
fixed
waterLevel
;
fixed
waterLevel
;
fixed
waterLevelTarget
;
fixed
waterLevelSpeed
;
fixed
energyBar
;
fixed
energyBar
;
int
stage
;
int
stage
;
...
@@ -148,23 +150,20 @@ class Level {
...
@@ -148,23 +150,20 @@ class Level {
bool
checkMaskDown
(
fixed
x
,
fixed
y
);
bool
checkMaskDown
(
fixed
x
,
fixed
y
);
bool
checkSpikes
(
fixed
x
,
fixed
y
);
bool
checkSpikes
(
fixed
x
,
fixed
y
);
void
setNext
(
int
nextLevel
,
int
nextWorld
);
void
setNext
(
int
nextLevel
,
int
nextWorld
);
void
setTile
(
unsigned
char
gridX
,
unsigned
char
gridY
,
void
setTile
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
char
tile
);
unsigned
char
tile
);
signed
char
*
getEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
signed
char
*
getEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
getEventHits
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
char
getEventHits
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
int
getEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
);
unsigned
int
getEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
);
void
clearEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
void
clearEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
);
int
hitEvent
(
Player
*
source
,
unsigned
char
gridX
,
int
hitEvent
(
unsigned
char
gridX
,
unsigned
char
gridY
,
Player
*
source
,
bool
TNT
);
unsigned
char
gridY
);
void
setEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
int
time
);
void
setEventTime
(
unsigned
char
gridX
,
unsigned
char
gridY
,
unsigned
int
time
);
signed
char
*
getBullet
(
unsigned
char
bullet
);
signed
char
*
getBullet
(
unsigned
char
bullet
);
Sprite
*
getSprite
(
unsigned
char
sprite
);
Sprite
*
getSprite
(
unsigned
char
sprite
);
Anim
*
getAnim
(
unsigned
char
anim
);
Anim
*
getAnim
(
unsigned
char
anim
);
Anim
*
getMiscAnim
(
unsigned
char
anim
);
Anim
*
getMiscAnim
(
unsigned
char
anim
);
void
addTimer
();
void
addTimer
();
void
setWaterLevel
(
unsigned
char
gridY
);
void
setWaterLevel
(
unsigned
char
gridY
);
fixed
getWaterLevel
(
int
phase
);
fixed
getWaterLevel
();
void
playSound
(
int
sound
);
void
playSound
(
int
sound
);
void
setStage
(
int
stage
);
void
setStage
(
int
stage
);
int
getStage
();
int
getStage
();
...
...
src/level/levelframe.cpp
View file @
6e631c48
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -133,6 +133,14 @@ int Level::step () {
...
@@ -133,6 +133,14 @@ int Level::step () {
}
}
// Handle change in water level
if
(
waterLevel
<
waterLevelTarget
)
waterLevelSpeed
+=
100
*
msps
;
else
waterLevelSpeed
-=
100
*
msps
;
if
(
waterLevelSpeed
>
40000
)
waterLevelSpeed
=
40000
;
if
(
waterLevelSpeed
<
-
40000
)
waterLevelSpeed
=
-
40000
;
waterLevel
+=
(
waterLevelSpeed
*
msps
)
>>
10
;
return
E_NONE
;
return
E_NONE
;
...
@@ -303,8 +311,11 @@ void Level::draw () {
...
@@ -303,8 +311,11 @@ void Level::draw () {
}
}
// Uncomment the following for a line showing the water level
// Temporary lines showing the water level
/* drawRect(0, FTOI(getWaterLevel(ticks) - viewY), screenW, 2, 24); */
drawRect
(
0
,
FTOI
(
waterLevel
-
viewY
),
screenW
,
2
,
24
);
drawRect
(
0
,
FTOI
(
waterLevel
-
viewY
)
+
3
,
screenW
,
1
,
24
);
drawRect
(
0
,
FTOI
(
waterLevel
-
viewY
)
+
6
,
screenW
,
1
,
24
);
drawRect
(
0
,
FTOI
(
waterLevel
-
viewY
)
+
10
,
screenW
,
1
,
24
);
SDL_SetClipRect
(
screen
,
NULL
);
SDL_SetClipRect
(
screen
,
NULL
);
...
...
src/level/levelload.cpp
View file @
6e631c48
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -610,6 +610,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -610,6 +610,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
grid
[
y
][
x
].
bg
=
buffer
[((
y
+
(
x
*
LH
))
<<
1
)
+
1
]
>>
7
;
grid
[
y
][
x
].
bg
=
buffer
[((
y
+
(
x
*
LH
))
<<
1
)
+
1
]
>>
7
;
grid
[
y
][
x
].
event
=
buffer
[((
y
+
(
x
*
LH
))
<<
1
)
+
1
]
&
127
;
grid
[
y
][
x
].
event
=
buffer
[((
y
+
(
x
*
LH
))
<<
1
)
+
1
]
&
127
;
grid
[
y
][
x
].
hits
=
0
;
grid
[
y
][
x
].
hits
=
0
;
grid
[
y
][
x
].
time
=
0
;
}
}
...
@@ -823,9 +824,11 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -823,9 +824,11 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
setNext
(
x
,
y
);
setNext
(
x
,
y
);
// Thanks to Doubble Dutch for th
is next bit
// Thanks to Doubble Dutch for th
e water level bytes
file
->
seek
(
4
,
false
);
file
->
seek
(
4
,
false
);
waterLevel
=
ITOF
(
file
->
loadShort
());
waterLevelTarget
=
ITOF
(
file
->
loadShort
());
waterLevel
=
waterLevelTarget
-
F8
;
waterLevelSpeed
=
0
;
// Thanks to Feline and the JCS94 team for the next bits:
// Thanks to Feline and the JCS94 team for the next bits:
...
...
src/player/bird.cpp
View file @
6e631c48
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -118,11 +118,11 @@ bool Bird::step (unsigned int ticks, int msps) {
...
@@ -118,11 +118,11 @@ bool Bird::step (unsigned int ticks, int msps) {
}
}
if
(
y
>
level
->
getWaterLevel
(
ticks
)
-
F24
)
{
if
(
y
>
level
->
getWaterLevel
()
-
F24
)
{
// Always stay above water
// Always stay above water
y
=
level
->
getWaterLevel
(
ticks
)
-
F24
;
y
=
level
->
getWaterLevel
()
-
F24
;
dy
=
0
;
dy
=
0
;
}
else
{
}
else
{
...
...
src/player/player.cpp
View file @
6e631c48
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -678,7 +678,7 @@ void Player::floatUp (signed char *newEvent, int speed) {
...
@@ -678,7 +678,7 @@ void Player::floatUp (signed char *newEvent, int speed) {
void
Player
::
belt
(
int
speed
)
{
void
Player
::
belt
(
int
speed
)
{
dx
+=
speed
*
16
0
;
dx
+=
speed
*
2
0
;
return
;
return
;
...
...
src/player/player.h
View file @
6e631c48
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -98,11 +98,11 @@
...
@@ -98,11 +98,11 @@
#define T_WARP 1000
#define T_WARP 1000
// Player offsets
// Player offsets
#define PXO_
L (F12 - F10)
#define PXO_
MID F16
#define PXO_
ML (F12 - F4
)
#define PXO_
L (PXO_MID - F10
)
#define PXO_M
ID F12
#define PXO_M
L (PXO_MID - F4)
#define PXO_MR (
F12
+ F4)
#define PXO_MR (
PXO_MID
+ F4)
#define PXO_R (
F12
+ F10)
#define PXO_R (
PXO_MID
+ F10)
#define PYO_TOP (-F20)
#define PYO_TOP (-F20)
#define PYO_MID (-F10)
#define PYO_MID (-F10)
...
@@ -176,7 +176,7 @@ class Player : public Movable {
...
@@ -176,7 +176,7 @@ class Player : public Movable {
3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */
3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */
bool
floating
;
// false = normal, true = boarding/bird/etc.
bool
floating
;
// false = normal, true = boarding/bird/etc.
bool
facing
;
bool
facing
;
unsigned
int
lookTime
;
/* Negative if looking up, positive if looking
int
lookTime
;
/* Negative if looking up, positive if looking
down, 0 if neither */
down, 0 if neither */
int
reaction
;
int
reaction
;
unsigned
int
reactionTime
;
unsigned
int
reactionTime
;
...
...
src/player/playerframe.cpp
View file @
6e631c48
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
* Part of the OpenJazz project
* Part of the OpenJazz project
*
*
*
*
* Copyright (c) 2005-20
09
Alister Thomson
* Copyright (c) 2005-20
10
Alister Thomson
*
*
* OpenJazz is distributed under the terms of
* OpenJazz is distributed under the terms of
* the GNU General Public License, version 2.0
* the GNU General Public License, version 2.0
...
@@ -153,7 +153,7 @@ void Player::control (unsigned int ticks, int msps) {
...
@@ -153,7 +153,7 @@ void Player::control (unsigned int ticks, int msps) {
if
(
dy
<
-
PXS_RUN
)
dy
=
-
PXS_RUN
;
if
(
dy
<
-
PXS_RUN
)
dy
=
-
PXS_RUN
;
if
(
dy
>
PXS_RUN
)
dy
=
PXS_RUN
;
if
(
dy
>
PXS_RUN
)
dy
=
PXS_RUN
;
}
else
if
(
y
>
level
->
getWaterLevel
(
ticks
))
{
}
else
if
(
y
+
PYO_MID
>
level
->
getWaterLevel
(
))
{
if
(
pcontrols
[
C_JUMP
])
{
if
(
pcontrols
[
C_JUMP
])
{
...
@@ -213,8 +213,8 @@ void Player::control (unsigned int ticks, int msps) {
...
@@ -213,8 +213,8 @@ void Player::control (unsigned int ticks, int msps) {
jumpY
=
y
-
jumpHeight
;
jumpY
=
y
-
jumpHeight
;
// Increase jump height if walking/running
// Increase jump height if walking/running
if
(
dx
<
0
)
jumpY
+=
dx
>>
4
;
if
(
dx
<
0
)
jumpY
+=
dx
>>
3
;
else
if
(
dx
>
0
)
jumpY
-=
dx
>>
4
;
else
if
(
dx
>
0
)
jumpY
-=
dx
>>
3
;
event
=
NULL
;
event
=
NULL
;
...
@@ -248,9 +248,19 @@ void Player::control (unsigned int ticks, int msps) {
...
@@ -248,9 +248,19 @@ void Player::control (unsigned int ticks, int msps) {
dy
=
(
jumpY
-
y
-
F64
)
*
4
;
dy
=
(
jumpY
-
y
-
F64
)
*
4
;
// Avoid jumping to fast, unless caused by an event
// Spring speed limit
if
(
!
event
&&
(
dy
<
(
ITOF
(
-
92
)
-
F64
)
*
4
))
if
(
event
&&
(
event
[
E_MODIFIER
]
==
29
))
{
dy
=
(
ITOF
(
-
92
)
-
F64
)
*
4
;
if
((
event
[
E_MULTIPURPOSE
]
==
0
)
&&
(
dy
<
PYS_JUMP
))
dy
=
PYS_JUMP
;
if
((
event
[
E_MULTIPURPOSE
]
>
0
)
&&
(
dy
<
event
[
E_MULTIPURPOSE
]
*
-
F20
))
dy
=
event
[
E_MULTIPURPOSE
]
*
-
F20
;
}
// Avoid jumping too fast, unless caused by an event
if
(
!
event
&&
(
dy
<
PYS_JUMP
))
dy
=
PYS_JUMP
;
}
else
{
}
else
{
...
@@ -261,7 +271,8 @@ void Player::control (unsigned int ticks, int msps) {
...
@@ -261,7 +271,8 @@ void Player::control (unsigned int ticks, int msps) {
}
}
// Stop looking
// Stop looking
if
(
!
pcontrols
[
C_UP
]
&&
!
pcontrols
[
C_DOWN
])
lookTime
=
0
;
if
(
!
pcontrols
[
C_UP
]
&&
(
lookTime
<
0
))
lookTime
=
0
;
if
(
!
pcontrols
[
C_DOWN
]
&&
(
lookTime
>
0
))
lookTime
=
0
;
}
}
...
@@ -534,22 +545,19 @@ void Player::view (unsigned int ticks, int mspf) {
...
@@ -534,22 +545,19 @@ void Player::view (unsigned int ticks, int mspf) {
// Find new position
// Find new position
viewX
=
x
+
F8
-
(
viewW
<<
9
);
viewX
=
x
+
F8
-
(
viewW
<<
9
);
viewY
=
y
-
F24
-
(
viewH
<<
9
);
if
(
!
lookTime
||
(
ticks
<
1000
+
lookTime
)
||
(
ticks
<
1000
-
lookTime
))
{
if
((
lookTime
>
0
)
&&
((
int
)
ticks
>
1000
+
lookTime
))
{
viewY
=
y
-
F24
-
(
viewH
<<
9
);
}
else
if
(
lookTime
>
0
)
{
if
(
ticks
<
2000
+
lookTime
)
// Look down
viewY
=
y
-
F24
-
(
64
*
(
lookTime
+
1000
-
ticks
))
-
(
viewH
<<
9
);
if
((
int
)
ticks
<
2000
+
lookTime
)
viewY
+=
64
*
(
ticks
-
(
1000
+
lookTime
)
);
else
viewY
=
y
+
F64
-
F24
-
(
viewH
<<
9
)
;
else
viewY
+=
F64
;
}
else
{
}
else
if
((
lookTime
<
0
)
&&
((
int
)
ticks
>
1000
-
lookTime
))
{
if
(
ticks
<
2000
-
lookTime
)
// Look up
viewY
=
y
-
F24
-
(
64
*
(
lookTime
-
1000
+
ticks
))
-
(
viewH
<<
9
);
if
((
int
)
ticks
<
2000
-
lookTime
)
viewY
-=
64
*
(
ticks
-
(
1000
-
lookTime
)
);
else
viewY
=
y
-
F64
-
F24
-
(
viewH
<<
9
)
;
else
viewY
-=
F64
;
}
}
...
@@ -595,7 +603,7 @@ void Player::draw (unsigned int ticks, int change) {
...
@@ -595,7 +603,7 @@ void Player::draw (unsigned int ticks, int change) {
(
reactionTime
-
ticks
>
PRT_HURT
-
PRT_HURTANIM
))
(
reactionTime
-
ticks
>
PRT_HURT
-
PRT_HURTANIM
))
anim
=
anims
[
facing
?
PA_RHURT
:
PA_LHURT
];
anim
=
anims
[
facing
?
PA_RHURT
:
PA_LHURT
];
else
if
(
y
>
level
->
getWaterLevel
(
ticks
))
else
if
(
y
+
PYO_MID
>
level
->
getWaterLevel
(
))
anim
=
anims
[
facing
?
PA_RSWIM
:
PA_LSWIM
];
anim
=
anims
[
facing
?
PA_RSWIM
:
PA_LSWIM
];
else
if
(
floating
)
anim
=
anims
[
facing
?
PA_RBOARD
:
PA_LBOARD
];
else
if
(
floating
)
anim
=
anims
[
facing
?
PA_RBOARD
:
PA_LBOARD
];
...
@@ -639,12 +647,12 @@ void Player::draw (unsigned int ticks, int change) {
...
@@ -639,12 +647,12 @@ void Player::draw (unsigned int ticks, int change) {
else
if
(
pcontrols
[
C_FIRE
])
else
if
(
pcontrols
[
C_FIRE
])
anim
=
anims
[
facing
?
PA_RSHOOT
:
PA_LSHOOT
];
anim
=
anims
[
facing
?
PA_RSHOOT
:
PA_LSHOOT
];
else
if
((
lookTime
<
0
)
&&
(
ticks
>
1000
-
lookTime
))
else
if
((
lookTime
<
0
)
&&
(
(
int
)
ticks
>
1000
-
lookTime
))
anim
=
anims
[
PA_LOOKUP
];
anim
=
anims
[
PA_LOOKUP
];
else
if
(
lookTime
>
0
)
{
else
if
(
lookTime
>
0
)
{
if
(
ticks
<
1000
+
lookTime
)
if
(
(
int
)
ticks
<
1000
+
lookTime
)
anim
=
anims
[
facing
?
PA_RCROUCH
:
PA_LCROUCH
];
anim
=
anims
[
facing
?
PA_RCROUCH
:
PA_LCROUCH
];
else
anim
=
anims
[
PA_LOOKDOWN
];
else
anim
=
anims
[
PA_LOOKDOWN
];
...
@@ -691,6 +699,17 @@ void Player::draw (unsigned int ticks, int change) {
...
@@ -691,6 +699,17 @@ void Player::draw (unsigned int ticks, int change) {
an
->
restorePalette
();
an
->
restorePalette
();
// Uncomment the following to see the area of the player
/*drawRect(FTOI(getDrawX(change) + PXO_L - viewX),
FTOI(getDrawY(change) + PYO_TOP - viewY),
FTOI(PXO_R - PXO_L),
FTOI(-PYO_TOP), 89);
drawRect(FTOI(getDrawX(change) + PXO_ML - viewX),
FTOI(getDrawY(change) + PYO_TOP - viewY),
FTOI(PXO_MR - PXO_ML),
FTOI(-PYO_TOP), 88);*/
if
(
reaction
==
PR_INVINCIBLE
)
{
if
(
reaction
==
PR_INVINCIBLE
)
{
// Show invincibility stars
// Show invincibility stars
...
...
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