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
b482cdbe
Commit
b482cdbe
authored
Apr 01, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved font handling. Little more on bonus levels.
parent
c0b880a1
Changes
22
Show whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
367 additions
and
338 deletions
+367
-338
baselevel.cpp
src/baselevel.cpp
+3
-1
baselevel.h
src/baselevel.h
+2
-1
bonus.cpp
src/bonus/bonus.cpp
+26
-36
game.cpp
src/game/game.cpp
+7
-5
game.h
src/game/game.h
+1
-1
file.cpp
src/io/file.cpp
+12
-3
font.cpp
src/io/gfx/font.cpp
+163
-226
font.h
src/io/gfx/font.h
+8
-7
sprite.cpp
src/io/gfx/sprite.cpp
+3
-4
video.cpp
src/io/gfx/video.cpp
+0
-3
video.h
src/io/gfx/video.h
+1
-2
demolevel.cpp
src/level/demolevel.cpp
+2
-2
level.cpp
src/level/level.cpp
+15
-16
levelframe.cpp
src/level/levelframe.cpp
+9
-4
levelload.cpp
src/level/levelload.cpp
+4
-1
main.cpp
src/main.cpp
+13
-7
menu.cpp
src/menu/menu.cpp
+4
-5
player.cpp
src/player/player.cpp
+11
-1
player.h
src/player/player.h
+13
-2
playerframe.cpp
src/player/playerframe.cpp
+57
-0
scene.h
src/scene/scene.h
+7
-7
sceneload.cpp
src/scene/sceneload.cpp
+6
-4
No files found.
src/baselevel.cpp
View file @
b482cdbe
...
@@ -37,12 +37,14 @@ BaseLevel::BaseLevel () {
...
@@ -37,12 +37,14 @@ BaseLevel::BaseLevel () {
// Arbitrary initial value
// Arbitrary initial value
smoothfps
=
50.0
f
;
smoothfps
=
50.0
f
;
paused
=
false
;
return
;
return
;
}
}
void
BaseLevel
::
timeCalcs
(
bool
paused
)
{
void
BaseLevel
::
timeCalcs
()
{
// Calculate smoothed fps
// Calculate smoothed fps
smoothfps
=
smoothfps
+
1.0
f
-
smoothfps
=
smoothfps
+
1.0
f
-
...
...
src/baselevel.h
View file @
b482cdbe
...
@@ -57,8 +57,9 @@ class BaseLevel {
...
@@ -57,8 +57,9 @@ class BaseLevel {
unsigned
int
endTime
;
unsigned
int
endTime
;
float
smoothfps
;
float
smoothfps
;
int
items
;
int
items
;
bool
paused
;
void
timeCalcs
(
bool
paused
);
void
timeCalcs
();
void
drawStats
(
int
stats
);
void
drawStats
(
int
stats
);
public
:
public
:
...
...
src/bonus/bonus.cpp
View file @
b482cdbe
...
@@ -55,7 +55,11 @@ int Bonus::loadTiles (char *fileName) {
...
@@ -55,7 +55,11 @@ int Bonus::loadTiles (char *fileName) {
}
}
file
->
skipRLE
();
file
->
skipRLE
();
// Load palette
file
->
loadPalette
(
palette
);
file
->
loadPalette
(
palette
);
// Load tile graphics
tileSet
=
file
->
loadSurface
(
32
,
32
*
60
);
tileSet
=
file
->
loadSurface
(
32
,
32
*
60
);
delete
file
;
delete
file
;
...
@@ -200,25 +204,23 @@ int Bonus::play () {
...
@@ -200,25 +204,23 @@ int Bonus::play () {
const
char
*
options
[
3
]
=
{
"continue game"
,
"setup options"
,
"quit game"
};
const
char
*
options
[
3
]
=
{
"continue game"
,
"setup options"
,
"quit game"
};
PaletteEffect
*
levelPE
;
PaletteEffect
*
levelPE
;
bool
p
aused
,
pmenu
;
bool
p
menu
,
pmessage
;
int
stats
,
option
;
int
stats
,
option
;
SDL_Rect
src
,
dst
;
SDL_Rect
src
,
dst
;
int
x
,
y
;
int
x
,
y
;
fixed
pX
,
pY
,
pDirection
;
int
msps
;
int
mspf
;
tickOffset
=
globalTicks
;
tickOffset
=
globalTicks
;
ticks
=
16
;
ticks
=
16
;
prevStepTicks
=
0
;
prevStepTicks
=
0
;
pme
nu
=
paused
=
false
;
pme
ssage
=
pmenu
=
false
;
option
=
0
;
option
=
0
;
stats
=
S_NONE
;
stats
=
S_NONE
;
// Arbitrary position
// Arbitrary position
localPlayer
->
setPosition
(
TTOF
(
32
)
+
F16
,
TTOF
(
7
)
+
F16
);
localPlayer
->
setPosition
(
TTOF
(
32
)
+
F16
,
TTOF
(
7
)
+
F16
);
pDirection
=
FQ
;
while
(
true
)
{
while
(
true
)
{
...
@@ -226,12 +228,12 @@ int Bonus::play () {
...
@@ -226,12 +228,12 @@ int Bonus::play () {
if
(
controls
.
release
(
C_ESCAPE
))
{
if
(
controls
.
release
(
C_ESCAPE
))
{
if
(
!
gameMode
)
paused
=
!
paused
;
pmenu
=
!
pmenu
;
pmenu
=
!
pmenu
;
option
=
0
;
}
}
if
(
controls
.
release
(
C_PAUSE
)
&&
!
gameMode
)
paused
=
!
paused
;
if
(
controls
.
release
(
C_PAUSE
)
)
pmessage
=
!
pmessage
;
if
(
controls
.
release
(
C_STATS
))
{
if
(
controls
.
release
(
C_STATS
))
{
...
@@ -254,7 +256,7 @@ int Bonus::play () {
...
@@ -254,7 +256,7 @@ int Bonus::play () {
case
0
:
// Continue
case
0
:
// Continue
p
aused
=
p
menu
=
false
;
pmenu
=
false
;
break
;
break
;
...
@@ -288,35 +290,23 @@ int Bonus::play () {
...
@@ -288,35 +290,23 @@ int Bonus::play () {
}
}
timeCalcs
(
paused
)
;
if
(
!
gameMode
)
paused
=
pmessage
||
pmenu
;
mspf
=
ticks
-
prevTicks
;
timeCalcs
()
;
// Milliseconds per step
msps
=
ticks
-
prevStepTicks
;
prevStepTicks
=
ticks
;
pX
=
localPlayer
->
getX
();
pY
=
localPlayer
->
getY
();
if
(
!
paused
)
{
if
(
!
paused
)
{
if
(
controls
.
getState
(
C_UP
))
{
// Apply controls to local player
for
(
x
=
0
;
x
<
PCONTROLS
;
x
++
)
pX
+=
fixed
(
sin
(
pDirection
*
6.283185
/
1024.0
)
*
64
*
mspf
);
localPlayer
->
setControl
(
x
,
controls
.
getState
(
x
));
pY
-=
fixed
(
cos
(
pDirection
*
6.283185
/
1024.0
)
*
64
*
mspf
);
}
if
(
controls
.
getState
(
C_DOWN
))
{
pX
-=
fixed
(
sin
(
pDirection
*
6.283185
/
1024.0
)
*
32
*
mspf
);
pY
+=
fixed
(
cos
(
pDirection
*
6.283185
/
1024.0
)
*
32
*
mspf
);
}
if
(
controls
.
getState
(
C_LEFT
))
pDirection
-=
mspf
/
2
;
if
(
controls
.
getState
(
C_RIGHT
))
pDirection
+=
mspf
/
2
;
localPlayer
->
setPosition
(
pX
,
pY
);
// Process players
for
(
x
=
0
;
x
<
nPlayers
;
x
++
)
players
[
x
].
bonusStep
(
ticks
,
msps
);
}
}
...
@@ -324,8 +314,8 @@ int Bonus::play () {
...
@@ -324,8 +314,8 @@ int Bonus::play () {
src
.
w
=
32
;
src
.
w
=
32
;
src
.
h
=
32
;
src
.
h
=
32
;
int
vX
=
FTOI
(
pX
)
-
(
canvasW
>>
1
);
int
vX
=
FTOI
(
localPlayer
->
getX
()
)
-
(
canvasW
>>
1
);
int
vY
=
FTOI
(
pY
)
-
(
canvasH
>>
1
);
int
vY
=
FTOI
(
localPlayer
->
getY
()
)
-
(
canvasH
>>
1
);
for
(
y
=
0
;
y
<=
ITOT
(
canvasH
-
1
)
+
1
;
y
++
)
{
for
(
y
=
0
;
y
<=
ITOT
(
canvasH
-
1
)
+
1
;
y
++
)
{
...
@@ -384,8 +374,8 @@ int Bonus::play () {
...
@@ -384,8 +374,8 @@ int Bonus::play () {
// Draw the "player"
// Draw the "player"
drawRect
(
drawRect
(
(
canvasW
>>
1
)
+
fixed
(
sin
(
pDirection
*
6.283185
/
1024.0
)
*
3
)
-
4
,
(
canvasW
>>
1
)
+
fixed
(
sin
(
localPlayer
->
getDirection
()
*
6.283185
/
1024.0
)
*
3
)
-
4
,
(
canvasH
>>
1
)
-
fixed
(
cos
(
pDirection
*
6.283185
/
1024.0
)
*
3
)
-
4
,
8
,
8
,
0
);
(
canvasH
>>
1
)
-
fixed
(
cos
(
localPlayer
->
getDirection
()
*
6.283185
/
1024.0
)
*
3
)
-
4
,
8
,
8
,
0
);
drawRect
((
canvasW
>>
1
)
-
4
,
(
canvasH
>>
1
)
-
4
,
8
,
8
,
22
);
drawRect
((
canvasW
>>
1
)
-
4
,
(
canvasH
>>
1
)
-
4
,
8
,
8
,
22
);
...
@@ -401,7 +391,7 @@ int Bonus::play () {
...
@@ -401,7 +391,7 @@ int Bonus::play () {
// If paused, draw "PAUSE"
// If paused, draw "PAUSE"
if
(
paused
&&
!
pmenu
)
if
(
paused
&&
!
pmenu
)
fontmn1
->
showString
(
"
PAUSE
"
,
(
canvasW
>>
1
)
-
44
,
32
);
fontmn1
->
showString
(
"
pause
"
,
(
canvasW
>>
1
)
-
44
,
32
);
// Draw statistics
// Draw statistics
drawStats
(
stats
);
drawStats
(
stats
);
...
...
src/game/game.cpp
View file @
b482cdbe
...
@@ -103,11 +103,11 @@ int Game::setLevel (char *fileName) {
...
@@ -103,11 +103,11 @@ int Game::setLevel (char *fileName) {
}
}
int
Game
::
setBonus
(
char
*
fileName
)
{
int
Game
::
setBonus
(
int
ext
)
{
if
(
bonusFile
)
delete
[]
bonusFile
;
if
(
bonusFile
)
delete
[]
bonusFile
;
if
(
fileName
)
bonusFile
=
createString
(
fileName
);
if
(
level
>=
0
)
bonusFile
=
createFileName
(
F_BONUSMAP
,
ext
);
else
bonusFile
=
NULL
;
else
bonusFile
=
NULL
;
return
E_NONE
;
return
E_NONE
;
...
@@ -130,6 +130,8 @@ int Game::play () {
...
@@ -130,6 +130,8 @@ int Game::play () {
sendTime
=
checkTime
=
0
;
sendTime
=
checkTime
=
0
;
level
=
NULL
;
if
(
levelFile
)
{
if
(
levelFile
)
{
// Load and play the level
// Load and play the level
...
@@ -146,10 +148,10 @@ int Game::play () {
...
@@ -146,10 +148,10 @@ int Game::play () {
levelRet
=
level
->
play
();
levelRet
=
level
->
play
();
}
}
else
levelRet
=
WON
;
if
(
bonusFile
)
{
if
(
bonusFile
&&
(
levelRet
==
WON
)
)
{
// Load and play the bonus level
// Load and play the bonus level
...
@@ -177,7 +179,7 @@ int Game::play () {
...
@@ -177,7 +179,7 @@ int Game::play () {
}
}
if
(
!
level
File
)
continue
;
if
(
!
level
)
continue
;
switch
(
levelRet
)
{
switch
(
levelRet
)
{
...
...
src/game/game.h
View file @
b482cdbe
...
@@ -96,7 +96,7 @@ class Game {
...
@@ -96,7 +96,7 @@ class Game {
virtual
~
Game
();
virtual
~
Game
();
virtual
int
setLevel
(
char
*
fileName
);
virtual
int
setLevel
(
char
*
fileName
);
int
setBonus
(
char
*
fileName
);
int
setBonus
(
int
ext
);
int
play
();
int
play
();
void
view
(
int
change
);
void
view
(
int
change
);
virtual
void
send
(
unsigned
char
*
buffer
);
virtual
void
send
(
unsigned
char
*
buffer
);
...
...
src/io/file.cpp
View file @
b482cdbe
...
@@ -212,7 +212,7 @@ unsigned char * File::loadRLE (int length) {
...
@@ -212,7 +212,7 @@ unsigned char * File::loadRLE (int length) {
rle
=
fgetc
(
f
);
rle
=
fgetc
(
f
);
if
(
rle
>
127
)
{
if
(
rle
&
128
)
{
byte
=
fgetc
(
f
);
byte
=
fgetc
(
f
);
...
@@ -223,7 +223,7 @@ unsigned char * File::loadRLE (int length) {
...
@@ -223,7 +223,7 @@ unsigned char * File::loadRLE (int length) {
}
}
}
else
if
(
rle
>
0
)
{
}
else
if
(
rle
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
...
@@ -303,7 +303,16 @@ char * File::loadString () {
...
@@ -303,7 +303,16 @@ char * File::loadString () {
SDL_Surface
*
File
::
loadSurface
(
int
width
,
int
height
)
{
SDL_Surface
*
File
::
loadSurface
(
int
width
,
int
height
)
{
return
createSurface
(
loadRLE
(
width
*
height
),
width
,
height
);
SDL_Surface
*
surface
;
unsigned
char
*
pixels
;
pixels
=
loadRLE
(
width
*
height
);
surface
=
createSurface
(
pixels
,
width
,
height
);
delete
[]
pixels
;
return
surface
;
}
}
...
...
src/io/gfx/font.cpp
View file @
b482cdbe
...
@@ -36,9 +36,9 @@
...
@@ -36,9 +36,9 @@
Font
::
Font
(
const
char
*
fileName
)
{
Font
::
Font
(
const
char
*
fileName
)
{
File
*
file
;
File
*
file
;
unsigned
char
*
pixels
,
*
character
;
unsigned
char
*
pixels
;
int
rle
,
pos
,
byte
,
count
,
next
,
fileSize
;
int
fileSize
;
int
c
hr
,
width
,
height
,
y
;
int
c
ount
,
size
,
width
,
height
;
// Load font from a font file
// Load font from a font file
...
@@ -52,143 +52,96 @@ Font::Font (const char * fileName) {
...
@@ -52,143 +52,96 @@ Font::Font (const char * fileName) {
}
}
file
->
seek
(
19
,
true
);
width
=
file
->
loadChar
()
<<
2
;
h
=
file
->
loadChar
()
<<
1
;
w
=
new
unsigned
char
[
128
];
pixels
=
new
unsigned
char
[
width
*
h
*
128
];
memset
(
pixels
,
0
,
width
*
h
*
128
);
file
->
seek
(
23
,
true
);
w
[
0
]
=
width
>>
1
;
file
->
seek
(
20
,
true
);
lineHeight
=
file
->
loadChar
()
<<
1
;
fileSize
=
file
->
getSize
();
for
(
chr
=
1
;
chr
<
128
;
chr
++
)
{
// Create the first character
file
->
seek
(
2
,
false
);
pixels
=
new
unsigned
char
[
3
*
lineHeight
];
next
=
file
->
loadChar
();
if
(
file
->
tell
()
>
fileSize
)
break
;
memset
(
pixels
,
0
,
3
*
lineHeight
);
characters
[
0
]
=
createSurface
(
pixels
,
3
,
lineHeight
);
SDL_SetColorKey
(
characters
[
0
],
SDL_SRCCOLORKEY
,
0
);
next
+=
file
->
loadChar
()
<<
8
;
delete
[]
pixels
;
next
+=
file
->
tell
();
file
->
seek
(
1
,
false
);
w
[
chr
]
=
file
->
loadChar
();
file
->
seek
(
1
,
false
);
height
=
file
->
loadChar
();
character
=
new
unsigned
char
[(
w
[
chr
]
*
height
)
+
1
];
// Create remaining characters
pos
=
0
;
fileSize
=
file
->
getSize
();
nCharacters
=
128
;
while
(
pos
<
w
[
chr
]
*
height
)
{
file
->
seek
(
23
,
true
);
rle
=
file
->
loadChar
();
for
(
count
=
1
;
count
<
128
;
count
++
)
{
if
(
rle
>
127
)
{
size
=
file
->
loadShort
();
byte
=
file
->
loadChar
();
if
(
file
->
tell
()
>=
fileSize
)
{
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
nCharacters
=
count
;
character
[
pos
++
]
=
byte
;
break
;
if
(
pos
>=
w
[
chr
]
*
height
)
break
;
}
}
}
else
if
(
rle
>
0
)
{
if
(
size
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
character
[
pos
++
]
=
file
->
loadChar
();
pixels
=
file
->
loadRLE
(
size
);
if
(
pos
>=
w
[
chr
]
*
height
)
break
;
}
width
=
pixels
[
0
];
width
+=
pixels
[
1
]
<<
8
;
height
=
pixels
[
2
];
height
+=
pixels
[
3
]
<<
8
;
}
else
break
;
characters
[
count
]
=
createSurface
(
pixels
+
4
,
width
,
height
);
SDL_SetColorKey
(
characters
[
count
],
SDL_SRCCOLORKEY
,
0
);
}
delete
[]
pixels
;
character
[
pos
]
=
character
[
pos
-
1
];
}
else
characters
[
count
]
=
createSurface
(
NULL
,
1
,
1
);
for
(
y
=
0
;
y
<
height
;
y
++
)
memcpy
(
pixels
+
(((
chr
*
h
)
+
y
)
*
width
),
character
+
(
y
*
w
[
chr
])
+
1
,
w
[
chr
]);
delete
[]
character
;
w
[
chr
]
+=
2
;
file
->
seek
(
next
,
true
);
}
}
delete
file
;
delete
file
;
for
(;
chr
<
128
;
chr
++
)
w
[
chr
]
=
width
>>
1
;
surface
=
createSurface
(
pixels
,
width
,
h
*
128
);
SDL_SetColorKey
(
surface
,
SDL_SRCCOLORKEY
,
0
);
// Create ASCII->font map
// Create ASCII->font map
if
(
!
strcmp
(
fileName
,
"fontmn1.0fn"
))
{
for
(
count
=
0
;
count
<
33
;
count
++
)
map
[
count
]
=
0
;
map
[
33
]
=
107
;
// !
for
(
count
=
0
;
count
<
48
;
count
++
)
map
[
count
]
=
0
;
map
[
34
]
=
116
;
// "
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
-
8
;
map
[
35
]
=
0
;
// #
for
(;
count
<
65
;
count
++
)
map
[
count
]
=
0
;
map
[
36
]
=
63
;
// $
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
64
;
map
[
37
]
=
0
;
// %
map
[
38
]
=
0
;
// &
map
[
39
]
=
115
;
// '
map
[
40
]
=
111
;
// (
map
[
41
]
=
112
;
// )
map
[
42
]
=
0
;
// *
map
[
43
]
=
105
;
// +
map
[
44
]
=
101
;
// ,
map
[
45
]
=
104
;
// -
map
[
46
]
=
102
;
// .
map
[
47
]
=
108
;
// /
for
(
count
=
48
;
count
<
58
;
count
++
)
map
[
count
]
=
count
+
5
;
// Numbers
map
[
58
]
=
114
;
// :
map
[
59
]
=
113
;
// ;
map
[
60
]
=
0
;
// <
map
[
61
]
=
106
;
// =
map
[
62
]
=
0
;
// >
map
[
63
]
=
103
;
// ?
map
[
64
]
=
0
;
// @
for
(
count
=
65
;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
38
;
// Upper-case letters
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
96
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
96
;
// Lower-case letters
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
else
if
(
!
strcmp
(
fileName
,
"fontmn2.0fn"
))
{
for
(
count
=
0
;
count
<
128
;
count
++
)
{
for
(
count
=
0
;
count
<
43
;
count
++
)
map
[
count
]
=
0
;
map
[
33
]
=
89
;
map
[
34
]
=
96
;
map
[
39
]
=
95
;
map
[
43
]
=
87
;
map
[
44
]
=
83
;
map
[
45
]
=
86
;
map
[
46
]
=
84
;
map
[
47
]
=
90
;
count
=
48
;
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
+
5
;
map
[
58
]
=
94
;
map
[
59
]
=
93
;
map
[
60
]
=
0
;
map
[
61
]
=
88
;
map
[
62
]
=
0
;
map
[
63
]
=
85
;
map
[
64
]
=
0
;
count
=
65
;
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
38
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
96
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
else
{
if
(
map
[
count
]
>=
nCharacters
)
map
[
count
]
=
0
;
for
(
count
=
0
;
count
<
40
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
42
;
count
++
)
map
[
count
]
=
count
+
25
;
for
(;
count
<
48
;
count
++
)
map
[
count
]
=
0
;
map
[
44
]
=
101
;
map
[
45
]
=
104
;
map
[
46
]
=
102
;
for
(;
count
<
58
;
count
++
)
map
[
count
]
=
count
+
5
;
for
(;
count
<
65
;
count
++
)
map
[
count
]
=
0
;
map
[
63
]
=
103
;
for
(;
count
<
91
;
count
++
)
map
[
count
]
=
count
-
64
;
for
(;
count
<
97
;
count
++
)
map
[
count
]
=
0
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
70
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
0
;
}
}
...
@@ -204,10 +157,10 @@ Font::Font (File *file, bool big) {
...
@@ -204,10 +157,10 @@ Font::Font (File *file, bool big) {
// Load font from panel.000
// Load font from panel.000
if
(
big
)
h
=
8
;
if
(
big
)
lineHeight
=
8
;
else
h
=
7
;
else
lineHeight
=
7
;
pixels
=
new
unsigned
char
[
320
*
h
];
pixels
=
new
unsigned
char
[
320
*
lineHeight
];
if
(
big
)
{
if
(
big
)
{
...
@@ -232,7 +185,7 @@ Font::Font (File *file, bool big) {
...
@@ -232,7 +185,7 @@ Font::Font (File *file, bool big) {
}
}
// RLE decompression and horizontal to vertical character rearrangement
// RLE decompression and horizontal to vertical character rearrangement
while
(
pos
<
320
*
h
)
{
while
(
pos
<
320
*
lineHeight
)
{
rle
=
file
->
loadChar
();
rle
=
file
->
loadChar
();
...
@@ -243,7 +196,7 @@ Font::Font (File *file, bool big) {
...
@@ -243,7 +196,7 @@ Font::Font (File *file, bool big) {
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
for
(
count
=
0
;
count
<
(
rle
&
127
);
count
++
)
{
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
(((
pos
%
320
)
>>
3
)
*
8
*
h
)]
=
index
;
(((
pos
%
320
)
>>
3
)
*
8
*
lineHeight
)]
=
index
;
pos
++
;
pos
++
;
}
}
...
@@ -253,7 +206,7 @@ Font::Font (File *file, bool big) {
...
@@ -253,7 +206,7 @@ Font::Font (File *file, bool big) {
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
for
(
count
=
0
;
count
<
rle
;
count
++
)
{
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
pixels
[(
pos
&
7
)
+
((
pos
/
320
)
*
8
)
+
(((
pos
%
320
)
>>
3
)
*
8
*
h
)]
=
file
->
loadChar
();
(((
pos
%
320
)
>>
3
)
*
8
*
lineHeight
)]
=
file
->
loadChar
();
pos
++
;
pos
++
;
}
}
...
@@ -262,6 +215,13 @@ Font::Font (File *file, bool big) {
...
@@ -262,6 +215,13 @@ Font::Font (File *file, bool big) {
}
}
for
(
count
=
0
;
count
<
40
;
count
++
)
characters
[
count
]
=
createSurface
(
pixels
+
(
count
*
8
*
lineHeight
),
8
,
lineHeight
);
nCharacters
=
40
;
delete
[]
pixels
;
if
(
big
)
{
if
(
big
)
{
...
@@ -278,10 +238,6 @@ Font::Font (File *file, bool big) {
...
@@ -278,10 +238,6 @@ Font::Font (File *file, bool big) {
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
87
;
for
(;
count
<
123
;
count
++
)
map
[
count
]
=
count
-
87
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
39
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
39
;
// Set font dimensions
w
=
new
unsigned
char
[
40
];
for
(
count
=
0
;
count
<
40
;
count
++
)
w
[
count
]
=
8
;
}
else
{
}
else
{
// Create ASCII->font map
// Create ASCII->font map
...
@@ -290,14 +246,8 @@ Font::Font (File *file, bool big) {
...
@@ -290,14 +246,8 @@ Font::Font (File *file, bool big) {
for
(;
count
<
60
;
count
++
)
map
[
count
]
=
count
-
48
;
for
(;
count
<
60
;
count
++
)
map
[
count
]
=
count
-
48
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
12
;
for
(;
count
<
128
;
count
++
)
map
[
count
]
=
12
;
// Set font dimensions
w
=
new
unsigned
char
[
13
];
for
(
count
=
0
;
count
<
13
;
count
++
)
w
[
count
]
=
8
;
}
}
surface
=
createSurface
(
pixels
,
8
,
40
*
h
);
return
;
return
;
}
}
...
@@ -305,51 +255,47 @@ Font::Font (File *file, bool big) {
...
@@ -305,51 +255,47 @@ Font::Font (File *file, bool big) {
Font
::~
Font
()
{
Font
::~
Font
()
{
SDL_FreeSurface
(
surface
);
int
count
;
delete
[]
w
;
for
(
count
=
0
;
count
<
nCharacters
;
count
++
)
SDL_FreeSurface
(
characters
[
count
]);
return
;
return
;
}
}
int
Font
::
showString
(
const
char
*
s
,
int
x
,
int
y
)
{
int
Font
::
showString
(
const
char
*
string
,
int
x
,
int
y
)
{
SDL_Rect
src
,
dst
;
SDL_Surface
*
surface
;
SDL_Rect
dst
;
unsigned
int
count
;
unsigned
int
count
;
int
xOffset
,
yOffset
;
int
xOffset
,
yOffset
;
// Determine the characters' dimensions
src
.
x
=
0
;
src
.
h
=
h
;
// Determine the position at which to draw the first character
// Determine the position at which to draw the first character
xOffset
=
x
;
xOffset
=
x
;
yOffset
=
y
;
yOffset
=
y
;
// Go through each character of the string
// Go through each character of the string
for
(
count
=
0
;
s
[
count
];
count
++
)
{
for
(
count
=
0
;
s
tring
[
count
];
count
++
)
{
if
(
s
[
count
]
==
'\n'
)
{
if
(
s
tring
[
count
]
==
'\n'
)
{
xOffset
=
x
;
xOffset
=
x
;
yOffset
+=
h
;
yOffset
+=
lineHeight
;
}
else
{
}
else
{
// Determine the character's position on the screen
// Determine the character's position on the screen
src
.
w
=
w
[(
int
)(
map
[(
int
)(
s
[
count
])])];
dst
.
y
=
yOffset
;
dst
.
y
=
yOffset
;
dst
.
x
=
xOffset
;
dst
.
x
=
xOffset
;
// Determine the character's position in the font
// Determine the character's surface
if
(
s
[
count
]
>=
0
)
src
.
y
=
map
[(
int
)(
s
[
count
])]
*
h
;
surface
=
characters
[
int
(
map
[
int
(
string
[
count
])])];
else
src
.
y
=
0
;
// Draw the character to the screen
// Draw the character to the screen
SDL_BlitSurface
(
surface
,
&
src
,
canvas
,
&
dst
);
SDL_BlitSurface
(
surface
,
NULL
,
canvas
,
&
dst
);
xOffset
+=
s
rc
.
w
;
xOffset
+=
s
urface
->
w
+
2
;
}
}
...
@@ -360,68 +306,58 @@ int Font::showString (const char * s, int x, int y) {
...
@@ -360,68 +306,58 @@ int Font::showString (const char * s, int x, int y) {
}
}
int
Font
::
showSceneString
(
const
char
*
s
,
int
x
,
int
y
)
{
int
Font
::
showSceneString
(
const
unsigned
char
*
string
,
int
x
,
int
y
)
{
SDL_Rect
src
,
dst
;
SDL_Surface
*
surface
;
SDL_Rect
dst
;
unsigned
int
count
;
unsigned
int
count
;
int
xOffset
;
int
offset
;
// Determine the characters' dimensions
src
.
x
=
0
;
src
.
h
=
h
;
// Determine the position at which to draw the first character
// Determine the position at which to draw the first character
xO
ffset
=
x
;
o
ffset
=
x
;
// Go through each character of the string
// Go through each character of the string
for
(
count
=
0
;
s
[
count
];
count
++
)
{
for
(
count
=
0
;
s
tring
[
count
];
count
++
)
{
// Determine the character's position on the screen
// Determine the character's position on the screen
src
.
w
=
w
[(
int
)(
s
[
count
])];
if
(
s
[
count
]
==
0x7F
)
src
.
w
-=
3
;
dst
.
y
=
y
;
dst
.
y
=
y
;
dst
.
x
=
xO
ffset
;
dst
.
x
=
o
ffset
;
// Determine the character's
position in the font
// Determine the character's
surface
if
(
s
[
count
]
>=
0
)
src
.
y
=
s
[
count
]
*
h
;
if
(
s
tring
[
count
]
<
nCharacters
)
surface
=
characters
[
int
(
string
[
count
])]
;
else
s
rc
.
y
=
0
;
else
s
urface
=
characters
[
0
]
;
// Draw the character to the screen
// Draw the character to the screen
SDL_BlitSurface
(
surface
,
&
src
,
canvas
,
&
dst
);
SDL_BlitSurface
(
surface
,
NULL
,
canvas
,
&
dst
);
xOffset
+=
src
.
w
-
1
;
offset
+=
surface
->
w
+
1
;
}
}
return
xO
ffset
;
return
o
ffset
;
}
}
void
Font
::
showNumber
(
int
n
,
int
x
,
int
y
)
{
void
Font
::
showNumber
(
int
n
,
int
x
,
int
y
)
{
SDL_Rect
src
,
dst
;
SDL_Surface
*
surface
;
SDL_Rect
dst
;
int
count
,
offset
;
int
count
,
offset
;
// Determine the characters' dimensions
src
.
x
=
0
;
src
.
h
=
h
;
// n being 0 is a special case. It must not be considered to be a trailing
// n being 0 is a special case. It must not be considered to be a trailing
// zero, as these are not displayed.
// zero, as these are not displayed.
if
(
!
n
)
{
if
(
!
n
)
{
// Determine 0's surface
surface
=
characters
[
int
(
map
[
int
(
'0'
)])];
// Determine 0's position on the screen
// Determine 0's position on the screen
src
.
w
=
w
[(
int
)(
map
[(
int
)
'0'
])];
dst
.
y
=
y
;
dst
.
y
=
y
;
dst
.
x
=
x
-
src
.
w
;
dst
.
x
=
x
-
surface
->
w
;
// Determine 0's position in the font
src
.
y
=
map
[(
int
)
'0'
]
*
h
;
// Draw 0 to the screen
// Draw 0 to the screen
SDL_BlitSurface
(
surface
,
&
src
,
canvas
,
&
dst
);
SDL_BlitSurface
(
surface
,
NULL
,
canvas
,
&
dst
);
return
;
return
;
...
@@ -436,17 +372,17 @@ void Font::showNumber (int n, int x, int y) {
...
@@ -436,17 +372,17 @@ void Font::showNumber (int n, int x, int y) {
while
(
count
)
{
while
(
count
)
{
// Determine the digit's surface
surface
=
characters
[
int
(
map
[
'0'
+
(
count
%
10
)])];
offset
-=
surface
->
w
;
// Determine the digit's position on the screen
// Determine the digit's position on the screen
src
.
w
=
w
[(
int
)(
map
[
'0'
+
(
count
%
10
)])];
offset
-=
src
.
w
;
dst
.
y
=
y
;
dst
.
y
=
y
;
dst
.
x
=
offset
;
dst
.
x
=
offset
;
// Determine the digit's position in the font
src
.
y
=
map
[
'0'
+
(
count
%
10
)]
*
h
;
// Draw the digit to the screen
// Draw the digit to the screen
SDL_BlitSurface
(
surface
,
&
src
,
canvas
,
&
dst
);
SDL_BlitSurface
(
surface
,
NULL
,
canvas
,
&
dst
);
count
/=
10
;
count
/=
10
;
...
@@ -455,16 +391,15 @@ void Font::showNumber (int n, int x, int y) {
...
@@ -455,16 +391,15 @@ void Font::showNumber (int n, int x, int y) {
// If needed, draw the negative sign
// If needed, draw the negative sign
if
(
n
<
0
)
{
if
(
n
<
0
)
{
// Determine the negative sign's position on the screen
// Determine the negative sign's surface
src
.
w
=
w
[(
int
)(
map
[(
int
)
'-'
])];
surface
=
characters
[
int
(
map
[
int
(
'-'
)])];
dst
.
y
=
y
;
dst
.
x
=
offset
-
src
.
w
;
// Determine the negative sign's position on the screen
// Determine the negative sign's position on the screen
src
.
y
=
map
[(
int
)
'-'
]
*
h
;
dst
.
y
=
y
;
dst
.
x
=
offset
-
surface
->
w
;
// Draw the negative sign to the screen
// Draw the negative sign to the screen
SDL_BlitSurface
(
surface
,
&
src
,
canvas
,
&
dst
);
SDL_BlitSurface
(
surface
,
NULL
,
canvas
,
&
dst
);
}
}
...
@@ -484,7 +419,8 @@ void Font::mapPalette (int start, int length, int newStart, int newLength) {
...
@@ -484,7 +419,8 @@ void Font::mapPalette (int start, int length, int newStart, int newLength) {
palette
[
count
].
r
=
palette
[
count
].
g
=
palette
[
count
].
b
=
palette
[
count
].
r
=
palette
[
count
].
g
=
palette
[
count
].
b
=
(
count
*
newLength
/
length
)
+
newStart
;
(
count
*
newLength
/
length
)
+
newStart
;
SDL_SetPalette
(
surface
,
SDL_LOGPAL
,
palette
,
start
,
length
);
for
(
count
=
0
;
count
<
nCharacters
;
count
++
)
SDL_SetPalette
(
characters
[
count
],
SDL_LOGPAL
,
palette
,
start
,
length
);
return
;
return
;
...
@@ -493,7 +429,10 @@ void Font::mapPalette (int start, int length, int newStart, int newLength) {
...
@@ -493,7 +429,10 @@ void Font::mapPalette (int start, int length, int newStart, int newLength) {
void
Font
::
restorePalette
()
{
void
Font
::
restorePalette
()
{
::
restorePalette
(
surface
);
int
count
;
for
(
count
=
0
;
count
<
nCharacters
;
count
++
)
::
restorePalette
(
characters
[
count
]);
return
;
return
;
...
@@ -502,7 +441,7 @@ void Font::restorePalette () {
...
@@ -502,7 +441,7 @@ void Font::restorePalette () {
int
Font
::
getHeight
()
{
int
Font
::
getHeight
()
{
return
h
;
return
lineHeight
;
}
}
...
@@ -518,7 +457,7 @@ int Font::getStringWidth (const char *string) {
...
@@ -518,7 +457,7 @@ int Font::getStringWidth (const char *string) {
// Only get the width of the first line
// Only get the width of the first line
if
(
string
[
count
]
==
'\n'
)
return
stringWidth
;
if
(
string
[
count
]
==
'\n'
)
return
stringWidth
;
stringWidth
+=
w
[(
int
)(
string
[
count
])]
;
stringWidth
+=
characters
[
int
(
map
[
int
(
string
[
count
])])]
->
w
+
2
;
}
}
...
@@ -527,18 +466,16 @@ int Font::getStringWidth (const char *string) {
...
@@ -527,18 +466,16 @@ int Font::getStringWidth (const char *string) {
}
}
int
Font
::
getSceneStringWidth
(
const
char
*
string
)
{
int
Font
::
getSceneStringWidth
(
const
unsigned
char
*
string
)
{
int
count
;
int
count
;
int
width
,
stringWidth
=
0
;
int
stringWidth
=
0
;
// Go through each character of the string
// Go through each character of the string
for
(
count
=
0
;
string
[
count
];
count
++
)
{
for
(
count
=
0
;
string
[
count
];
count
++
)
{
width
=
w
[(
int
)(
string
[
count
])];
if
(
string
[
count
]
<
nCharacters
)
stringWidth
+=
characters
[
int
(
string
[
count
])]
->
w
+
1
;
if
(
string
[
count
]
==
0x7F
)
width
-=
3
;
else
stringWidth
+=
characters
[
0
]
->
w
+
1
;
stringWidth
+=
width
-
1
;
}
}
...
...
src/io/gfx/font.h
View file @
b482cdbe
...
@@ -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
...
@@ -36,9 +36,9 @@ class File;
...
@@ -36,9 +36,9 @@ class File;
class
Font
{
class
Font
{
private
:
private
:
SDL_Surface
*
surface
;
SDL_Surface
*
characters
[
128
];
unsigned
char
*
w
;
int
nCharacters
;
unsigned
char
h
;
// Dimensions of the letters
unsigned
char
lineHeight
;
char
map
[
128
];
// Maps ASCII values to letter positions
char
map
[
128
];
// Maps ASCII values to letter positions
public
:
public
:
...
@@ -47,13 +47,14 @@ class Font {
...
@@ -47,13 +47,14 @@ class Font {
~
Font
();
~
Font
();
int
showString
(
const
char
*
s
,
int
x
,
int
y
);
int
showString
(
const
char
*
s
,
int
x
,
int
y
);
int
showSceneString
(
const
char
*
s
,
int
x
,
int
y
);
int
showSceneString
(
const
unsigned
char
*
s
,
int
x
,
int
y
);
void
showNumber
(
int
n
,
int
x
,
int
y
);
void
showNumber
(
int
n
,
int
x
,
int
y
);
void
mapPalette
(
int
start
,
int
length
,
int
newStart
,
int
newLength
);
void
mapPalette
(
int
start
,
int
length
,
int
newStart
,
int
newLength
);
void
restorePalette
();
void
restorePalette
();
int
getHeight
();
int
getHeight
();
int
getStringWidth
(
const
char
*
string
);
int
getStringWidth
(
const
char
*
string
);
int
getSceneStringWidth
(
const
char
*
string
);
int
getSceneStringWidth
(
const
unsigned
char
*
string
);
};
};
// Variables
// Variables
...
...
src/io/gfx/sprite.cpp
View file @
b482cdbe
...
@@ -45,13 +45,12 @@ Sprite::~Sprite () {
...
@@ -45,13 +45,12 @@ Sprite::~Sprite () {
void
Sprite
::
clearPixels
()
{
void
Sprite
::
clearPixels
()
{
unsigned
char
*
data
;
unsigned
char
data
;
if
(
pixels
)
SDL_FreeSurface
(
pixels
);
if
(
pixels
)
SDL_FreeSurface
(
pixels
);
data
=
new
unsigned
char
[
1
];
data
=
SKEY
;
*
data
=
SKEY
;
pixels
=
createSurface
(
&
data
,
1
,
1
);
pixels
=
createSurface
(
data
,
1
,
1
);
SDL_SetColorKey
(
pixels
,
SDL_SRCCOLORKEY
,
SKEY
);
SDL_SetColorKey
(
pixels
,
SDL_SRCCOLORKEY
,
SKEY
);
return
;
return
;
...
...
src/io/gfx/video.cpp
View file @
b482cdbe
...
@@ -53,9 +53,6 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
...
@@ -53,9 +53,6 @@ SDL_Surface * createSurface (unsigned char * pixels, int width, int height) {
if
(
SDL_MUSTLOCK
(
ret
))
SDL_UnlockSurface
(
ret
);
if
(
SDL_MUSTLOCK
(
ret
))
SDL_UnlockSurface
(
ret
);
// Free redundant pixel data
delete
[]
pixels
;
}
}
return
ret
;
return
ret
;
...
...
src/io/gfx/video.h
View file @
b482cdbe
...
@@ -71,8 +71,7 @@ EXTERN SDL_Surface *panelAmmo[5];
...
@@ -71,8 +71,7 @@ EXTERN SDL_Surface *panelAmmo[5];
// Functions
// Functions
EXTERN
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
EXTERN
SDL_Surface
*
createSurface
(
unsigned
char
*
pixels
,
int
width
,
int
height
);
int
height
);
EXTERN
void
createScreen
();
EXTERN
void
createScreen
();
EXTERN
void
usePalette
(
SDL_Color
*
palette
);
EXTERN
void
usePalette
(
SDL_Color
*
palette
);
EXTERN
void
restorePalette
(
SDL_Surface
*
surface
);
EXTERN
void
restorePalette
(
SDL_Surface
*
surface
);
...
...
src/level/demolevel.cpp
View file @
b482cdbe
...
@@ -113,7 +113,7 @@ int DemoLevel::play () {
...
@@ -113,7 +113,7 @@ int DemoLevel::play () {
if
(
controls
.
release
(
C_STATS
))
stats
^=
S_SCREEN
;
if
(
controls
.
release
(
C_STATS
))
stats
^=
S_SCREEN
;
timeCalcs
(
false
);
timeCalcs
();
...
@@ -171,7 +171,7 @@ int DemoLevel::play () {
...
@@ -171,7 +171,7 @@ int DemoLevel::play () {
drawStats
(
stats
);
drawStats
(
stats
);
fontmn1
->
showString
(
"
DEMO
"
,
(
canvasW
>>
1
)
-
36
,
32
);
fontmn1
->
showString
(
"
demo
"
,
(
canvasW
>>
1
)
-
36
,
32
);
}
}
...
...
src/level/level.cpp
View file @
b482cdbe
...
@@ -525,7 +525,7 @@ int Level::play () {
...
@@ -525,7 +525,7 @@ int Level::play () {
{
"continue game"
,
"save game"
,
"load game"
,
"setup options"
,
"quit game"
};
{
"continue game"
,
"save game"
,
"load game"
,
"setup options"
,
"quit game"
};
PaletteEffect
*
levelPE
;
PaletteEffect
*
levelPE
;
char
*
string
;
char
*
string
;
bool
p
aused
,
pmenu
;
bool
p
message
,
pmenu
;
int
stats
,
option
;
int
stats
,
option
;
unsigned
int
returnTime
;
unsigned
int
returnTime
;
int
perfect
;
int
perfect
;
...
@@ -537,7 +537,7 @@ int Level::play () {
...
@@ -537,7 +537,7 @@ int Level::play () {
ticks
=
16
;
ticks
=
16
;
prevStepTicks
=
0
;
prevStepTicks
=
0
;
pme
nu
=
paused
=
false
;
pme
ssage
=
pmenu
=
false
;
option
=
0
;
option
=
0
;
stats
=
S_NONE
;
stats
=
S_NONE
;
...
@@ -547,18 +547,16 @@ int Level::play () {
...
@@ -547,18 +547,16 @@ int Level::play () {
while
(
true
)
{
while
(
true
)
{
// Do general processing
if
(
loop
(
NORMAL_LOOP
)
==
E_QUIT
)
return
E_QUIT
;
if
(
loop
(
NORMAL_LOOP
)
==
E_QUIT
)
return
E_QUIT
;
if
(
controls
.
release
(
C_ESCAPE
))
{
if
(
controls
.
release
(
C_ESCAPE
))
{
if
(
!
gameMode
)
paused
=
!
paused
;
pmenu
=
!
pmenu
;
pmenu
=
!
pmenu
;
option
=
0
;
option
=
0
;
}
}
if
(
controls
.
release
(
C_PAUSE
)
&&
!
gameMode
)
paused
=
!
paused
;
if
(
controls
.
release
(
C_PAUSE
)
)
pmessage
=
!
pmessage
;
if
(
controls
.
release
(
C_STATS
))
{
if
(
controls
.
release
(
C_STATS
))
{
...
@@ -581,7 +579,7 @@ int Level::play () {
...
@@ -581,7 +579,7 @@ int Level::play () {
case
0
:
// Continue
case
0
:
// Continue
p
aused
=
p
menu
=
false
;
pmenu
=
false
;
break
;
break
;
...
@@ -623,8 +621,9 @@ int Level::play () {
...
@@ -623,8 +621,9 @@ int Level::play () {
}
}
if
(
!
gameMode
)
paused
=
pmessage
||
pmenu
;
timeCalcs
(
paused
);
timeCalcs
();
...
@@ -689,7 +688,7 @@ int Level::play () {
...
@@ -689,7 +688,7 @@ int Level::play () {
// If paused, draw "PAUSE"
// If paused, draw "PAUSE"
if
(
paused
&&
!
pmenu
)
if
(
paused
&&
!
pmenu
)
fontmn1
->
showString
(
"
PAUSE
"
,
(
canvasW
>>
1
)
-
44
,
32
);
fontmn1
->
showString
(
"
pause
"
,
(
canvasW
>>
1
)
-
44
,
32
);
// If this is a competitive game, draw the score
// If this is a competitive game, draw the score
...
@@ -745,27 +744,27 @@ int Level::play () {
...
@@ -745,27 +744,27 @@ int Level::play () {
// Display statistics & bonuses
// Display statistics & bonuses
// TODO: Display percentage symbol
// TODO: Display percentage symbol
fontmn1
->
showString
(
"
TIME
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
-
60
);
fontmn1
->
showString
(
"
time
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
-
60
);
fontmn1
->
showNumber
(
timeBonus
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
60
);
fontmn1
->
showNumber
(
timeBonus
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
60
);
fontmn1
->
showString
(
"
ENEMIES
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
-
40
);
fontmn1
->
showString
(
"
enemies
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
-
40
);
if
(
enemies
)
if
(
enemies
)
fontmn1
->
showNumber
((
localPlayer
->
getEnemies
()
*
100
)
/
enemies
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
40
);
fontmn1
->
showNumber
((
localPlayer
->
getEnemies
()
*
100
)
/
enemies
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
40
);
else
else
fontmn1
->
showNumber
(
0
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
40
);
fontmn1
->
showNumber
(
0
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
40
);
fontmn1
->
showString
(
"
ITEMS
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
-
20
);
fontmn1
->
showString
(
"
items
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
-
20
);
if
(
items
)
if
(
items
)
fontmn1
->
showNumber
((
localPlayer
->
getItems
()
*
100
)
/
items
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
20
);
fontmn1
->
showNumber
((
localPlayer
->
getItems
()
*
100
)
/
items
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
20
);
else
else
fontmn1
->
showNumber
(
0
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
20
);
fontmn1
->
showNumber
(
0
,
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
-
20
);
fontmn1
->
showString
(
"
PERFECT
"
,
(
canvasW
>>
1
)
-
152
,
canvasH
>>
1
);
fontmn1
->
showString
(
"
perfect
"
,
(
canvasW
>>
1
)
-
152
,
canvasH
>>
1
);
fontmn1
->
showNumber
(
perfect
,
(
canvasW
>>
1
)
+
124
,
canvasH
>>
1
);
fontmn1
->
showNumber
(
perfect
,
(
canvasW
>>
1
)
+
124
,
canvasH
>>
1
);
fontmn1
->
showString
(
"
SCORE
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
+
40
);
fontmn1
->
showString
(
"
score
"
,
(
canvasW
>>
1
)
-
152
,
(
canvasH
>>
1
)
+
40
);
fontmn1
->
showNumber
(
localPlayer
->
getScore
(),
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
+
40
);
fontmn1
->
showNumber
(
localPlayer
->
getScore
(),
(
canvasW
>>
1
)
+
124
,
(
canvasH
>>
1
)
+
40
);
}
}
...
...
src/level/levelframe.cpp
View file @
b482cdbe
...
@@ -183,6 +183,7 @@ void Level::draw () {
...
@@ -183,6 +183,7 @@ void Level::draw () {
SDL_Rect
src
,
dst
;
SDL_Rect
src
,
dst
;
int
vX
,
vY
;
int
vX
,
vY
;
int
x
,
y
,
bgScale
;
int
x
,
y
,
bgScale
;
unsigned
int
change
;
// Set tile drawing dimensions
// Set tile drawing dimensions
...
@@ -275,12 +276,16 @@ void Level::draw () {
...
@@ -275,12 +276,16 @@ void Level::draw () {
}
}
// Calculate change since last step
change
=
paused
?
0
:
ticks
-
prevStepTicks
;
// Show active events
// Show active events
event
=
firstEvent
;
event
=
firstEvent
;
while
(
event
)
{
while
(
event
)
{
event
->
draw
(
ticks
,
ticks
-
prevStepTicks
);
event
->
draw
(
ticks
,
change
);
event
=
event
->
getNext
();
event
=
event
->
getNext
();
}
}
...
@@ -288,7 +293,7 @@ void Level::draw () {
...
@@ -288,7 +293,7 @@ void Level::draw () {
// Show the players
// Show the players
for
(
x
=
0
;
x
<
nPlayers
;
x
++
)
for
(
x
=
0
;
x
<
nPlayers
;
x
++
)
players
[
x
].
draw
(
ticks
,
ticks
-
prevStepTicks
);
players
[
x
].
draw
(
ticks
,
change
);
// Show bullets
// Show bullets
...
@@ -296,7 +301,7 @@ void Level::draw () {
...
@@ -296,7 +301,7 @@ void Level::draw () {
while
(
bullet
)
{
while
(
bullet
)
{
bullet
->
draw
(
ticks
-
prevStepTicks
);
bullet
->
draw
(
change
);
bullet
=
bullet
->
getNext
();
bullet
=
bullet
->
getNext
();
}
}
...
...
src/level/levelload.cpp
View file @
b482cdbe
...
@@ -285,6 +285,7 @@ int Level::loadSprites (char * fileName) {
...
@@ -285,6 +285,7 @@ int Level::loadSprites (char * fileName) {
// Free redundant data
// Free redundant data
delete
[]
pixels
;
delete
[]
pixels
;
delete
[]
sorted
;
// Check if the next sprite exists
// Check if the next sprite exists
...
@@ -403,6 +404,8 @@ int Level::loadTiles (char * fileName) {
...
@@ -403,6 +404,8 @@ int Level::loadTiles (char * fileName) {
tileSet
=
createSurface
(
buffer
,
TTOI
(
1
),
TTOI
(
tiles
));
tileSet
=
createSurface
(
buffer
,
TTOI
(
1
),
TTOI
(
tiles
));
SDL_SetColorKey
(
tileSet
,
SDL_SRCCOLORKEY
,
TKEY
);
SDL_SetColorKey
(
tileSet
,
SDL_SRCCOLORKEY
,
TKEY
);
delete
[]
buffer
;
return
tiles
;
return
tiles
;
}
}
...
...
src/main.cpp
View file @
b482cdbe
...
@@ -346,7 +346,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -346,7 +346,8 @@ int loadMain (int argc, char *argv[]) {
}
}
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
sorted
=
pixels
;
// Re-use the allocated memory
delete
[]
pixels
;
file
->
seek
(
8264
,
true
);
file
->
seek
(
8264
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
pixels
=
file
->
loadRLE
(
64
*
27
);
...
@@ -359,7 +360,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -359,7 +360,8 @@ int loadMain (int argc, char *argv[]) {
}
}
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
sorted
=
pixels
;
// Re-use the allocated memory
delete
[]
pixels
;
file
->
seek
(
9550
,
true
);
file
->
seek
(
9550
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
pixels
=
file
->
loadRLE
(
64
*
27
);
...
@@ -372,7 +374,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -372,7 +374,8 @@ int loadMain (int argc, char *argv[]) {
}
}
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
sorted
=
pixels
;
// Re-use the allocated memory
delete
[]
pixels
;
file
->
seek
(
11060
,
true
);
file
->
seek
(
11060
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
pixels
=
file
->
loadRLE
(
64
*
27
);
...
@@ -385,7 +388,8 @@ int loadMain (int argc, char *argv[]) {
...
@@ -385,7 +388,8 @@ int loadMain (int argc, char *argv[]) {
}
}
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
sorted
=
pixels
;
// Re-use the allocated memory
delete
[]
pixels
;
file
->
seek
(
12258
,
true
);
file
->
seek
(
12258
,
true
);
pixels
=
file
->
loadRLE
(
64
*
27
);
pixels
=
file
->
loadRLE
(
64
*
27
);
...
@@ -398,7 +402,9 @@ int loadMain (int argc, char *argv[]) {
...
@@ -398,7 +402,9 @@ int loadMain (int argc, char *argv[]) {
}
}
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
pixels
;
// Don't re-use the allocated memory
delete
[]
pixels
;
delete
[]
sorted
;
// Load fonts
// Load fonts
...
...
src/menu/menu.cpp
View file @
b482cdbe
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,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
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
Menu
::
Menu
()
{
Menu
::
Menu
()
{
File
*
file
;
File
*
file
;
unsigned
char
*
pixels
;
unsigned
char
pixel
;
time_t
currentTime
;
time_t
currentTime
;
int
count
,
col
;
int
count
,
col
;
...
@@ -154,9 +154,8 @@ Menu::Menu () {
...
@@ -154,9 +154,8 @@ Menu::Menu () {
for
(;
count
<
11
;
count
++
)
{
for
(;
count
<
11
;
count
++
)
{
pixels
=
new
unsigned
char
[
1
];
pixel
=
0
;
*
pixels
=
0
;
screens
[
count
+
3
]
=
createSurface
(
&
pixel
,
1
,
1
);
screens
[
count
+
3
]
=
createSurface
(
pixels
,
1
,
1
);
}
}
...
...
src/player/player.cpp
View file @
b482cdbe
...
@@ -212,6 +212,7 @@ void Player::reset () {
...
@@ -212,6 +212,7 @@ void Player::reset () {
shield
=
0
;
shield
=
0
;
floating
=
false
;
floating
=
false
;
facing
=
true
;
facing
=
true
;
direction
=
FQ
;
reaction
=
PR_NONE
;
reaction
=
PR_NONE
;
reactionTime
=
0
;
reactionTime
=
0
;
jumpHeight
=
ITOF
(
92
);
jumpHeight
=
ITOF
(
92
);
...
@@ -403,6 +404,8 @@ bool Player::takeEvent (unsigned char gridX, unsigned char gridY, unsigned int t
...
@@ -403,6 +404,8 @@ bool Player::takeEvent (unsigned char gridX, unsigned char gridY, unsigned int t
case
37
:
// Diamond
case
37
:
// Diamond
if
(
game
)
game
->
setBonus
(
0
);
// Yellow flash
// Yellow flash
firstPE
=
new
FlashPaletteEffect
(
255
,
255
,
0
,
320
,
firstPE
);
firstPE
=
new
FlashPaletteEffect
(
255
,
255
,
0
,
320
,
firstPE
);
...
@@ -694,6 +697,13 @@ bool Player::getFacing () {
...
@@ -694,6 +697,13 @@ bool Player::getFacing () {
}
}
fixed
Player
::
getDirection
()
{
return
direction
;
}
Anim
*
Player
::
getAnim
()
{
Anim
*
Player
::
getAnim
()
{
return
level
->
getAnim
(
anims
[
animType
]);
return
level
->
getAnim
(
anims
[
animType
]);
...
...
src/player/player.h
View file @
b482cdbe
...
@@ -114,6 +114,10 @@
...
@@ -114,6 +114,10 @@
#define PYS_SINK ITOF(150)
#define PYS_SINK ITOF(150)
#define PYS_JUMP ITOF(-350)
#define PYS_JUMP ITOF(-350)
#define PRS_REVERSE ITOF(-32)
#define PRS_RUN ITOF(64)
#define PRS_ROLL ITOF(96)
// Player accelerations
// Player accelerations
#define PXA_REVERSE 900
#define PXA_REVERSE 900
#define PXA_STOP 1000
#define PXA_STOP 1000
...
@@ -123,6 +127,10 @@
...
@@ -123,6 +127,10 @@
#define PYA_GRAVITY 2750
#define PYA_GRAVITY 2750
#define PYA_SINK 1000
#define PYA_SINK 1000
#define PRA_REVERSE 450
#define PRA_STOP 500
#define PRA_RUN 100
// Player colours
// Player colours
#define PC_WHITE 0
#define PC_WHITE 0
#define PC_SGREEN 16
#define PC_SGREEN 16
...
@@ -173,6 +181,7 @@ class Player : public Movable {
...
@@ -173,6 +181,7 @@ class Player : public Movable {
int
shield
;
/* 0 = none, 1 = 1 yellow, 2 = 2 yellow, 3 = 1 orange, 4 = 2 orange, 5 = 3 orange, 6 = 4 orange */
int
shield
;
/* 0 = none, 1 = 1 yellow, 2 = 2 yellow, 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
;
fixed
direction
;
unsigned
char
animType
;
unsigned
char
animType
;
unsigned
char
eventX
;
unsigned
char
eventX
;
unsigned
char
eventY
;
/* Position of an event (spring, platform, bridge) */
unsigned
char
eventY
;
/* Position of an event (spring, platform, bridge) */
...
@@ -222,12 +231,14 @@ class Player : public Movable {
...
@@ -222,12 +231,14 @@ class Player : public Movable {
void
setPosition
(
fixed
newX
,
fixed
newY
);
void
setPosition
(
fixed
newX
,
fixed
newY
);
void
setSpeed
(
fixed
newDx
,
fixed
newDy
);
void
setSpeed
(
fixed
newDx
,
fixed
newDy
);
bool
getFacing
();
bool
getFacing
();
fixed
getDirection
();
Anim
*
getAnim
();
Anim
*
getAnim
();
unsigned
char
getTeam
();
unsigned
char
getTeam
();
void
send
(
unsigned
char
*
data
);
void
send
(
unsigned
char
*
data
);
void
receive
(
unsigned
char
*
buffer
);
void
receive
(
unsigned
char
*
buffer
);
void
control
(
unsigned
int
ticks
,
int
msps
);
void
control
(
unsigned
int
ticks
,
int
msps
);
void
move
(
unsigned
int
ticks
,
int
msps
);
void
move
(
unsigned
int
ticks
,
int
msps
);
void
bonusStep
(
unsigned
int
ticks
,
int
msps
);
void
view
(
unsigned
int
ticks
,
int
mspf
);
void
view
(
unsigned
int
ticks
,
int
mspf
);
void
draw
(
unsigned
int
ticks
,
int
change
);
void
draw
(
unsigned
int
ticks
,
int
change
);
int
reacted
(
unsigned
int
ticks
);
int
reacted
(
unsigned
int
ticks
);
...
...
src/player/playerframe.cpp
View file @
b482cdbe
...
@@ -621,6 +621,63 @@ void Player::move (unsigned int ticks, int msps) {
...
@@ -621,6 +621,63 @@ void Player::move (unsigned int ticks, int msps) {
}
}
void
Player
::
bonusStep
(
unsigned
int
ticks
,
int
msps
)
{
// Bonus stages use polar coordinates for movement (but not position)
// Treat dx as change in radius
if
(
pcontrols
[
C_UP
])
{
// Walk/run forwards
if
(
dx
<
0
)
dx
+=
PRA_REVERSE
*
msps
;
else
if
(
dx
<
PRS_RUN
)
dx
+=
PRA_RUN
*
msps
;
facing
=
true
;
}
else
if
(
pcontrols
[
C_DOWN
])
{
// Walk/run back
if
(
dx
>
0
)
dx
-=
PRA_REVERSE
*
msps
;
else
if
(
dx
>
PRS_REVERSE
)
dx
-=
PRA_RUN
*
msps
;
facing
=
false
;
}
else
{
// Slow down
if
(
dx
>
0
)
{
if
(
dx
<
PRA_STOP
*
msps
)
dx
=
0
;
else
dx
-=
PRA_STOP
*
msps
;
}
if
(
dx
<
0
)
{
if
(
dx
>
-
PRA_STOP
*
msps
)
dx
=
0
;
else
dx
+=
PRA_STOP
*
msps
;
}
}
if
(
pcontrols
[
C_LEFT
])
direction
-=
msps
>>
1
;
if
(
pcontrols
[
C_RIGHT
])
direction
+=
msps
>>
1
;
// Apply trajectory
x
+=
fixed
(
sin
(
direction
*
6.283185
/
1024.0
)
*
dx
*
msps
)
>>
10
;
y
-=
fixed
(
cos
(
direction
*
6.283185
/
1024.0
)
*
dx
*
msps
)
>>
10
;
return
;
}
void
Player
::
view
(
unsigned
int
ticks
,
int
mspf
)
{
void
Player
::
view
(
unsigned
int
ticks
,
int
mspf
)
{
int
oldViewX
,
oldViewY
,
speed
;
int
oldViewX
,
oldViewY
,
speed
;
...
...
src/scene/scene.h
View file @
b482cdbe
...
@@ -67,7 +67,7 @@ class Font;
...
@@ -67,7 +67,7 @@ class Font;
class
SceneText
{
class
SceneText
{
public
:
public
:
char
*
text
;
unsigned
char
*
text
;
int
alignment
;
int
alignment
;
int
fontId
;
int
fontId
;
int
x
;
int
x
;
...
...
src/scene/sceneload.cpp
View file @
b482cdbe
...
@@ -659,20 +659,20 @@ void Scene::loadScripts (File *f) {
...
@@ -659,20 +659,20 @@ void Scene::loadScripts (File *f) {
if
(
datalen
>
0
)
{
if
(
datalen
>
0
)
{
text
->
text
=
f
->
loadBlock
(
datalen
+
1
);
f
->
seek
(
-
1
,
false
);
f
->
seek
(
-
1
,
false
);
text
->
text
=
f
->
loadString
();
// Convert number placeholders
// Convert number placeholders
for
(
int
pos
=
1
;
pos
<
datalen
;
pos
++
)
{
for
(
int
pos
=
1
;
pos
<
datalen
;
pos
++
)
{
if
(
text
->
text
[
pos
]
==
-
117
)
{
if
(
text
->
text
[
pos
]
==
0x8B
)
{
if
(
loop
>=
9
)
if
(
loop
>=
9
)
text
->
text
[
pos
-
1
]
=
((
loop
+
1
)
/
10
)
+
53
;
text
->
text
[
pos
-
1
]
=
((
loop
+
1
)
/
10
)
+
53
;
text
->
text
[
pos
]
=
((
loop
+
1
)
%
10
)
+
53
;
text
->
text
[
pos
]
=
((
loop
+
1
)
%
10
)
+
53
;
}
else
if
(
text
->
text
[
pos
]
==
-
118
)
{
}
else
if
(
text
->
text
[
pos
]
==
0x8A
)
{
if
(
scriptItems
>=
10
)
if
(
scriptItems
>=
10
)
text
->
text
[
pos
-
1
]
=
(
scriptItems
/
10
)
+
53
;
text
->
text
[
pos
-
1
]
=
(
scriptItems
/
10
)
+
53
;
...
@@ -683,9 +683,11 @@ void Scene::loadScripts (File *f) {
...
@@ -683,9 +683,11 @@ void Scene::loadScripts (File *f) {
}
}
text
->
text
[
datalen
]
=
0
;
}
else
{
}
else
{
text
->
text
=
new
char
[
1
];
text
->
text
=
new
unsigned
char
[
1
];
text
->
text
[
0
]
=
0
;
text
->
text
[
0
]
=
0
;
}
}
...
...
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