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
351f3bec
Commit
351f3bec
authored
Jul 01, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Panel is now only loaded when needed.
parent
5c545948
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
140 additions
and
91 deletions
+140
-91
video.h
src/io/gfx/video.h
+0
-4
level.cpp
src/level/level.cpp
+19
-4
level.h
src/level/level.h
+4
-0
levelload.cpp
src/level/levelload.cpp
+111
-3
main.cpp
src/main.cpp
+6
-80
No files found.
src/io/gfx/video.h
View file @
351f3bec
...
@@ -102,10 +102,6 @@ EXTERN SDL_Surface* canvas;
...
@@ -102,10 +102,6 @@ EXTERN SDL_Surface* canvas;
EXTERN
int
viewH
,
canvasW
,
canvasH
;
EXTERN
int
viewH
,
canvasW
,
canvasH
;
#define viewW canvasW
#define viewW canvasW
// Panel
EXTERN
SDL_Surface
*
panel
;
EXTERN
SDL_Surface
*
panelAmmo
[
5
];
EXTERN
Video
video
;
EXTERN
Video
video
;
...
...
src/level/level.cpp
View file @
351f3bec
...
@@ -82,6 +82,20 @@ Level::Level (char* fileName, unsigned char diff, bool checkpoint) {
...
@@ -82,6 +82,20 @@ Level::Level (char* fileName, unsigned char diff, bool checkpoint) {
}
}
void
Level
::
deletePanel
()
{
SDL_FreeSurface
(
panel
);
SDL_FreeSurface
(
panelAmmo
[
0
]);
SDL_FreeSurface
(
panelAmmo
[
1
]);
SDL_FreeSurface
(
panelAmmo
[
2
]);
SDL_FreeSurface
(
panelAmmo
[
3
]);
SDL_FreeSurface
(
panelAmmo
[
4
]);
return
;
}
Level
::~
Level
()
{
Level
::~
Level
()
{
int
count
;
int
count
;
...
@@ -102,6 +116,8 @@ Level::~Level () {
...
@@ -102,6 +116,8 @@ Level::~Level () {
delete
[]
sceneFile
;
delete
[]
sceneFile
;
delete
[]
musicFile
;
delete
[]
musicFile
;
deletePanel
();
delete
font
;
delete
font
;
return
;
return
;
...
@@ -592,9 +608,8 @@ int Level::play () {
...
@@ -592,9 +608,8 @@ int Level::play () {
if
(
timeBonus
==
-
1
)
{
if
(
timeBonus
==
-
1
)
{
timeBonus
=
((
endTime
-
ticks
)
/
60000
)
*
100
;
if
(
ticks
<
endTime
)
timeBonus
=
((
endTime
-
ticks
)
/
60000
)
*
100
;
else
timeBonus
=
0
;
if
(
timeBonus
<
0
)
timeBonus
=
0
;
if
((
levelPlayer
->
getEnemies
()
==
enemies
)
&&
if
((
levelPlayer
->
getEnemies
()
==
enemies
)
&&
(
levelPlayer
->
getItems
()
==
items
))
perfect
=
100
;
(
levelPlayer
->
getItems
()
==
items
))
perfect
=
100
;
...
...
src/level/level.h
View file @
351f3bec
...
@@ -94,6 +94,8 @@ class Scene;
...
@@ -94,6 +94,8 @@ class Scene;
class
Level
:
public
BaseLevel
{
class
Level
:
public
BaseLevel
{
private
:
private
:
SDL_Surface
*
panel
;
SDL_Surface
*
panelAmmo
[
5
];
char
*
musicFile
;
char
*
musicFile
;
char
*
sceneFile
;
char
*
sceneFile
;
Anim
animSet
[
ANIMS
];
Anim
animSet
[
ANIMS
];
...
@@ -114,6 +116,8 @@ class Level : public BaseLevel {
...
@@ -114,6 +116,8 @@ class Level : public BaseLevel {
fixed
waterLevelSpeed
;
fixed
waterLevelSpeed
;
fixed
energyBar
;
fixed
energyBar
;
void
deletePanel
();
int
loadPanel
();
void
loadSprite
(
File
*
file
,
Sprite
*
sprite
);
void
loadSprite
(
File
*
file
,
Sprite
*
sprite
);
int
loadSprites
(
char
*
fileName
);
int
loadSprites
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
int
loadTiles
(
char
*
fileName
);
...
...
src/level/levelload.cpp
View file @
351f3bec
...
@@ -51,6 +51,95 @@
...
@@ -51,6 +51,95 @@
#define SKEY 254
/* Sprite colour key */
#define SKEY 254
/* Sprite colour key */
int
Level
::
loadPanel
()
{
File
*
file
;
unsigned
char
*
pixels
;
unsigned
char
*
sorted
;
int
x
,
y
;
try
{
file
=
new
File
(
F_PANEL
,
false
);
}
catch
(
int
e
)
{
return
e
;
}
pixels
=
file
->
loadRLE
(
46272
);
delete
file
;
// Create the panel background
panel
=
createSurface
(
pixels
,
SW
,
32
);
// De-scramble the panel's ammo graphics
sorted
=
new
unsigned
char
[
64
*
27
];
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
55
*
320
)];
}
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
61
*
320
)];
}
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
68
*
320
)];
}
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
74
*
320
)];
}
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
86
*
320
)];
}
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
sorted
;
delete
[]
pixels
;
return
E_NONE
;
}
void
Level
::
loadSprite
(
File
*
file
,
Sprite
*
sprite
)
{
void
Level
::
loadSprite
(
File
*
file
,
Sprite
*
sprite
)
{
unsigned
char
*
pixels
;
unsigned
char
*
pixels
;
...
@@ -330,18 +419,33 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -330,18 +419,33 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
unsigned
char
startX
,
startY
;
unsigned
char
startX
,
startY
;
difficulty
=
diff
;
// Load font
try
{
try
{
font
=
new
Font
(
false
);
font
=
new
Font
(
false
);
}
catch
(
int
e
)
{
}
catch
(
int
e
)
{
throw
e
;
return
e
;
}
}
difficulty
=
diff
;
// Load panel
count
=
loadPanel
();
if
(
count
<
0
)
{
delete
font
;
return
count
;
}
// Show loading screen
// Show loading screen
...
@@ -367,6 +471,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -367,6 +471,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
}
catch
(
int
e
)
{
}
catch
(
int
e
)
{
delete
[]
string
;
delete
[]
string
;
deletePanel
();
delete
font
;
delete
font
;
return
e
;
return
e
;
...
@@ -434,6 +539,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -434,6 +539,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
}
catch
(
int
e
)
{
}
catch
(
int
e
)
{
deletePanel
();
delete
font
;
delete
font
;
return
e
;
return
e
;
...
@@ -495,6 +601,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -495,6 +601,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
if
(
tiles
<
0
)
{
if
(
tiles
<
0
)
{
delete
file
;
delete
file
;
deletePanel
();
delete
font
;
delete
font
;
return
tiles
;
return
tiles
;
...
@@ -513,6 +620,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
...
@@ -513,6 +620,7 @@ int Level::load (char *fileName, unsigned char diff, bool checkpoint) {
if
(
count
<
0
)
{
if
(
count
<
0
)
{
delete
file
;
delete
file
;
deletePanel
();
delete
font
;
delete
font
;
return
count
;
return
count
;
...
...
src/main.cpp
View file @
351f3bec
...
@@ -66,8 +66,8 @@ extern float sinf (float);
...
@@ -66,8 +66,8 @@ extern float sinf (float);
int
loadMain
(
int
argc
,
char
*
argv
[])
{
int
loadMain
(
int
argc
,
char
*
argv
[])
{
File
*
file
;
File
*
file
;
unsigned
char
*
pixels
,
*
sorted
;
unsigned
char
*
pixels
;
int
count
,
x
,
y
;
int
count
,
x
,
y
;
int
screenW
,
screenH
;
int
screenW
,
screenH
;
int
scaleFactor
;
int
scaleFactor
;
...
@@ -312,7 +312,9 @@ int loadMain (int argc, char *argv[]) {
...
@@ -312,7 +312,9 @@ int loadMain (int argc, char *argv[]) {
// Load the panel
// Load fonts
// Open the panel, which contains two fonts
try
{
try
{
...
@@ -334,69 +336,6 @@ int loadMain (int argc, char *argv[]) {
...
@@ -334,69 +336,6 @@ int loadMain (int argc, char *argv[]) {
delete
file
;
delete
file
;
// Create the panel background
panel
=
createSurface
(
pixels
,
SW
,
32
);
// De-scramble the panel's ammo graphics
sorted
=
new
unsigned
char
[
64
*
27
];
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
55
*
320
)];
}
panelAmmo
[
0
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
61
*
320
)];
}
panelAmmo
[
1
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
68
*
320
)];
}
panelAmmo
[
2
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
74
*
320
)];
}
panelAmmo
[
3
]
=
createSurface
(
sorted
,
64
,
27
);
for
(
y
=
0
;
y
<
27
;
y
++
)
{
for
(
x
=
0
;
x
<
64
;
x
++
)
sorted
[(
y
*
64
)
+
x
]
=
pixels
[(
y
*
64
)
+
(
x
>>
2
)
+
((
x
&
3
)
<<
4
)
+
(
86
*
320
)];
}
panelAmmo
[
4
]
=
createSurface
(
sorted
,
64
,
27
);
delete
[]
sorted
;
// Load fonts
panelBigFont
=
NULL
;
panelBigFont
=
NULL
;
panelSmallFont
=
NULL
;
panelSmallFont
=
NULL
;
font2
=
NULL
;
font2
=
NULL
;
...
@@ -425,13 +364,6 @@ int loadMain (int argc, char *argv[]) {
...
@@ -425,13 +364,6 @@ int loadMain (int argc, char *argv[]) {
delete
[]
pixels
;
delete
[]
pixels
;
SDL_FreeSurface
(
panel
);
SDL_FreeSurface
(
panelAmmo
[
0
]);
SDL_FreeSurface
(
panelAmmo
[
1
]);
SDL_FreeSurface
(
panelAmmo
[
2
]);
SDL_FreeSurface
(
panelAmmo
[
3
]);
SDL_FreeSurface
(
panelAmmo
[
4
]);
closeAudio
();
closeAudio
();
delete
[]
characterName
;
delete
[]
characterName
;
...
@@ -462,6 +394,7 @@ int loadMain (int argc, char *argv[]) {
...
@@ -462,6 +394,7 @@ int loadMain (int argc, char *argv[]) {
level
=
NULL
;
level
=
NULL
;
jj2Level
=
NULL
;
jj2Level
=
NULL
;
return
E_NONE
;
return
E_NONE
;
}
}
...
@@ -483,13 +416,6 @@ void freeMain () {
...
@@ -483,13 +416,6 @@ void freeMain () {
delete
fontmn1
;
delete
fontmn1
;
delete
fontmn2
;
delete
fontmn2
;
SDL_FreeSurface
(
panel
);
SDL_FreeSurface
(
panelAmmo
[
0
]);
SDL_FreeSurface
(
panelAmmo
[
1
]);
SDL_FreeSurface
(
panelAmmo
[
2
]);
SDL_FreeSurface
(
panelAmmo
[
3
]);
SDL_FreeSurface
(
panelAmmo
[
4
]);
#ifdef SCALE
#ifdef SCALE
scaleFactor
=
video
.
getScaleFactor
();
scaleFactor
=
video
.
getScaleFactor
();
...
...
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