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
4a9aa467
Commit
4a9aa467
authored
Mar 04, 2010
by
alistert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved bullets and launching platforms.
parent
2a31393c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
41 deletions
+54
-41
bullet.cpp
src/level/bullet.cpp
+16
-14
bullet.h
src/level/bullet.h
+5
-5
eventframe.cpp
src/level/event/eventframe.cpp
+30
-19
playerframe.cpp
src/player/playerframe.cpp
+3
-3
No files found.
src/level/bullet.cpp
View file @
4a9aa467
...
...
@@ -52,14 +52,14 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
direction
=
source
->
getFacing
()
?
1
:
0
;
direction
|=
lower
?
2
:
0
;
x
=
source
->
getX
()
+
(
source
->
getFacing
()
?
PXO_R
:
PXO_L
);
y
=
source
->
getY
()
-
F8
;
dx
=
level
->
getBullet
(
type
)[
B_XSPEED
+
direction
]
*
500
*
F1
;
if
(
type
==
4
)
{
// TNT
type
=
-
1
;
sprite
=
level
->
getSprite
(
130
);
dx
=
0
;
dy
=
0
;
time
=
ticks
+
T_TNT
;
...
...
@@ -68,6 +68,8 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
}
else
{
sprite
=
level
->
getSprite
(((
unsigned
char
*
)
level
->
getBullet
(
type
))
[
B_SPRITE
+
direction
]);
dx
=
level
->
getBullet
(
type
)[
B_XSPEED
+
direction
]
*
500
*
F1
;
dy
=
level
->
getBullet
(
type
)[
B_YSPEED
+
direction
]
*
250
*
F1
;
time
=
ticks
+
T_BULLET
;
...
...
@@ -75,6 +77,9 @@ Bullet::Bullet (Player *sourcePlayer, bool lower, unsigned int ticks) {
}
x
=
source
->
getX
()
+
(
source
->
getFacing
()
?
PXO_R
:
PXO_L
)
-
ITOF
(
sprite
->
getWidth
()
>>
1
);
y
=
source
->
getY
()
-
F8
-
ITOF
(
sprite
->
getHeight
()
>>
1
);
return
;
}
...
...
@@ -90,6 +95,7 @@ Bullet::Bullet (Event *sourceEvent, bool facing, unsigned int ticks) {
source
=
NULL
;
type
=
sourceEvent
->
getProperty
(
E_BULLET
);
direction
=
facing
?
1
:
0
;
sprite
=
level
->
getSprite
(((
unsigned
char
*
)
level
->
getBullet
(
type
))
[
B_SPRITE
+
direction
]);
anim
=
level
->
getAnim
(
sourceEvent
->
getProperty
(
facing
?
E_LSHOOTANIM
:
E_RSHOOTANIM
));
x
=
sourceEvent
->
getX
()
+
anim
->
getShootX
();
...
...
@@ -125,6 +131,7 @@ Bullet::Bullet (Bird *sourceBird, bool lower, unsigned int ticks) {
type
=
30
;
direction
=
source
->
getFacing
()
?
1
:
0
;
direction
|=
lower
?
2
:
0
;
sprite
=
level
->
getSprite
(((
unsigned
char
*
)
level
->
getBullet
(
type
))
[
B_SPRITE
+
direction
]);
x
=
sourceBird
->
getX
()
+
(
source
->
getFacing
()
?
PXO_R
:
PXO_L
);
y
=
sourceBird
->
getY
();
dx
=
level
->
getBullet
(
type
)[
B_XSPEED
+
direction
]
*
500
*
F1
;
...
...
@@ -230,7 +237,8 @@ bool Bullet::step (unsigned int ticks, int msps) {
// Check if a player has been hit
for
(
count
=
0
;
count
<
nPlayers
;
count
++
)
{
if
(
players
[
count
].
overlap
(
x
,
y
,
F1
,
F1
))
{
if
(
players
[
count
].
overlap
(
x
,
y
,
ITOF
(
sprite
->
getWidth
()),
ITOF
(
sprite
->
getHeight
())))
{
// If the hit was successful, destroy the bullet
if
(
players
[
count
].
hit
(
source
,
ticks
))
return
true
;
...
...
@@ -249,7 +257,8 @@ bool Bullet::step (unsigned int ticks, int msps) {
while
(
event
)
{
// Check if the event has been hit
if
(
event
->
overlap
(
x
,
y
,
0
,
0
))
{
if
(
event
->
overlap
(
x
,
y
,
ITOF
(
sprite
->
getWidth
()),
ITOF
(
sprite
->
getHeight
())))
{
// If the event is hittable, hit it and destroy the bullet
if
(
event
->
hit
(
source
,
ticks
))
return
true
;
...
...
@@ -304,19 +313,12 @@ bool Bullet::step (unsigned int ticks, int msps) {
void
Bullet
::
draw
(
int
change
)
{
Sprite
*
sprite
;
if
(
next
)
next
->
draw
(
change
);
if
(
type
==
-
1
)
sprite
=
level
->
getSprite
(
130
);
else
sprite
=
level
->
getSprite
(((
unsigned
char
*
)
level
->
getBullet
(
type
))
[
B_SPRITE
+
direction
]);
// Show the bullet
sprite
->
draw
(
FTOI
(
getDrawX
(
change
))
-
(
sprite
->
getWidth
()
>>
1
)
-
FTOI
(
viewX
),
FTOI
(
getDrawY
(
change
))
-
(
sprite
->
getHeight
()
>>
1
)
-
FTOI
(
viewY
));
FTOI
(
getDrawX
(
change
))
-
FTOI
(
viewX
),
FTOI
(
getDrawY
(
change
))
-
FTOI
(
viewY
));
return
;
...
...
src/level/bullet.h
View file @
4a9aa467
...
...
@@ -8,7 +8,7 @@
* 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
* the GNU General Public License, version 2.0
...
...
@@ -51,21 +51,21 @@
class
Bird
;
class
Event
;
class
Player
;
class
Sprite
;
class
Bullet
:
public
Movable
{
private
:
Bullet
*
next
;
Player
*
source
;
// If NULL, was fired by an event
Sprite
*
sprite
;
int
type
;
// -1 is TNT, otherwise indexes the bullet set
int
direction
;
// 0: Left, 1: Right, 2: L (lower), 3: R (lower)
unsigned
int
time
;
// Time at which the bullet will self-destruct
public
:
Bullet
(
Player
*
sourcePlayer
,
bool
lower
,
unsigned
int
ticks
);
Bullet
(
Event
*
sourceEvent
,
bool
facing
,
unsigned
int
ticks
);
Bullet
(
Player
*
sourcePlayer
,
bool
lower
,
unsigned
int
ticks
);
Bullet
(
Event
*
sourceEvent
,
bool
facing
,
unsigned
int
ticks
);
Bullet
(
Bird
*
sourceBird
,
bool
lower
,
unsigned
int
ticks
);
~
Bullet
();
...
...
src/level/event/eventframe.cpp
View file @
4a9aa467
...
...
@@ -362,8 +362,7 @@ bool Event::step (unsigned int ticks, int msps) {
else
if
(
y
>
localPlayer
->
getY
())
dy
=
-
ES_SLOW
;
else
dy
=
0
;
}
else
if
(
!
localPlayer
->
getFacing
()
&&
(
x
>
localPlayer
->
getX
()
+
F32
))
{
}
else
if
(
!
localPlayer
->
getFacing
()
&&
(
x
>
localPlayer
->
getX
()
+
F32
))
{
dx
=
-
ES_FAST
;
...
...
@@ -382,26 +381,19 @@ bool Event::step (unsigned int ticks, int msps) {
case
34
:
// Launching
platform
// Launching
event
if
(
ticks
>
level
->
getEventTime
(
gridX
,
gridY
))
{
if
(
y
<=
TTOF
(
gridY
)
+
F16
-
(
set
[
E_YAXIS
]
*
F2
))
{
level
->
setEventTime
(
gridX
,
gridY
,
ticks
+
(
set
[
E_MOVEMENTSP
]
*
1000
));
dy
=
0
;
}
else
dy
=
-
(
y
+
(
set
[
E_YAXIS
]
*
F2
)
-
TTOF
(
gridY
))
/
100
;
if
(
animType
==
E_LEFTANIM
)
dy
=
-
(
F16
+
y
-
(
TTOF
(
gridY
)
-
(
set
[
E_MULTIPURPOSE
]
*
F12
)))
*
10
;
else
dy
=
(
F16
+
y
-
(
TTOF
(
gridY
)
-
(
set
[
E_MULTIPURPOSE
]
*
F12
)))
*
10
;
}
else
{
if
(
y
<
TTOF
(
gridY
)
+
F16
)
dy
=
(
y
+
(
set
[
E_YAXIS
]
*
F2
)
-
TTOF
(
gridY
))
/
100
;
else
{
y
=
TTOF
(
gridY
)
+
F16
;
dy
=
0
;
}
dy
=
TTOF
(
gridY
)
+
F16
-
y
;
dy
=
((
dy
<<
10
)
/
msps
)
*
set
[
E_MOVEMENTSP
];
}
...
...
@@ -734,6 +726,25 @@ bool Event::step (unsigned int ticks, int msps) {
break
;
case
34
:
// Launching event
if
(
ticks
>
level
->
getEventTime
(
gridX
,
gridY
))
{
if
(
y
<=
F16
+
TTOF
(
gridY
)
-
(
set
[
E_MULTIPURPOSE
]
*
F12
))
animType
=
E_RIGHTANIM
;
else
if
(
y
>=
F16
+
TTOF
(
gridY
))
{
animType
=
E_LEFTANIM
;
level
->
setEventTime
(
gridX
,
gridY
,
ticks
+
(
set
[
E_YAXIS
]
*
50
));
}
}
else
animType
=
E_LEFTANIM
;
break
;
case
36
:
// Walk from side to side and down hills, staying on-screen
...
...
@@ -872,8 +883,8 @@ bool Event::step (unsigned int ticks, int msps) {
if
(
set
[
E_MODIFIER
]
==
6
)
{
if
(
width
&&
height
&&
players
[
count
].
overlap
(
x
,
y
-
height
,
width
-
F8
,
height
)
&&
(
players
[
count
].
getY
()
<=
y
+
(
PYS_FALL
/
msps
)
-
height
)
&&
players
[
count
].
overlap
(
x
,
y
-
height
,
width
-
F8
,
F8
)
&&
(
players
[
count
].
getY
()
<=
F8
+
((
PYS_FALL
*
msps
)
>>
10
)
+
y
-
height
)
&&
!
level
->
checkMaskDown
(
players
[
count
].
getX
()
+
PXO_MID
,
PYO_TOP
+
y
-
height
))
{
// Player is on a platform
...
...
@@ -881,7 +892,7 @@ bool Event::step (unsigned int ticks, int msps) {
players
[
count
].
setEvent
(
gridX
,
gridY
);
players
[
count
].
setPosition
(
players
[
count
].
getX
()
+
((
dx
*
msps
)
>>
10
),
players
[
count
].
getY
()
+
((
dy
*
msps
)
>>
10
)
);
F4
+
y
-
height
);
}
else
players
[
count
].
clearEvent
(
gridX
,
gridY
);
...
...
src/player/playerframe.cpp
View file @
4a9aa467
...
...
@@ -306,9 +306,9 @@ void Player::control (unsigned int ticks, int msps) {
// Remove the bullet from the arsenal
if
(
ammoType
!=
-
1
)
ammo
[
ammoType
]
--
;
/* If the current ammo type has been exhausted
, use the previous
non-exhausted ammo type */
while
((
ammoType
>
-
1
)
&&
!
ammo
[
ammoType
]
)
ammoType
--
;
/* If the current ammo type has been exhausted
or TNT has been used,
use the previous
non-exhausted ammo type */
while
((
(
ammoType
>
-
1
)
&&
!
ammo
[
ammoType
])
||
(
ammoType
==
3
)
)
ammoType
--
;
}
...
...
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