Commit 2a788bc0 authored by newspaz's avatar newspaz

Various changes to implement medivo boss behavior. Medivo boss behavior isn't...

Various changes to implement medivo boss behavior. Medivo boss behavior isn't finished yet but works up until the spikes.

anim.cpp, anim.h
*) Changes in animations to properly support accessory positions.
*) Changes in animations to properly support accessory shooting positions.

bullet.cpp, bullet.h
*) New constructor for a custom bullet starting position

levelframe.cpp
*) Support medivo boss

event.cpp, eventframe.cpp
*) Small changes in getAnim()
*) Small changes in step method

guardians.cpp, guardians.h
*) Made the eight shape in the first stage.
*) Made the jumping behavior, but this doesn't work as it should yet.
*) Did not implement the overlap method yet.
parent 2aa89ee4
...@@ -96,7 +96,7 @@ int Anim::getHeight () { ...@@ -96,7 +96,7 @@ int Anim::getHeight () {
fixed Anim::getShootX () { fixed Anim::getShootX () {
return ITOF(shootX + xOffsets[frame]); return ITOF(shootX + (xOffsets[frame] << 2));
} }
...@@ -108,6 +108,34 @@ fixed Anim::getShootY () { ...@@ -108,6 +108,34 @@ fixed Anim::getShootY () {
} }
fixed Anim::getAccessoryX () {
return ITOF(accessoryX << 2);
}
fixed Anim::getAccessoryY () {
return ITOF(accessoryY - yOffset);
}
fixed Anim::getAccessoryShootX () {
return ITOF(shootX + (accessoryX << 2) + xOffsets[frame]);
}
fixed Anim::getAccessoryShootY () {
return ITOF(shootY + accessoryY + yOffsets[frame] - yOffset);
}
fixed Anim::getOffset () { fixed Anim::getOffset () {
if (!ignoreDefaultYOffset && yOffset == 0) if (!ignoreDefaultYOffset && yOffset == 0)
...@@ -118,6 +146,13 @@ fixed Anim::getOffset () { ...@@ -118,6 +146,13 @@ fixed Anim::getOffset () {
} }
Anim* Anim::getAccessory() {
return level->getAnim(accessory);
}
void Anim::draw (fixed x, fixed y) { void Anim::draw (fixed x, fixed y) {
// In case yOffset is zero, and the ignore default offset flag is set, // In case yOffset is zero, and the ignore default offset flag is set,
......
...@@ -61,7 +61,12 @@ class Anim { ...@@ -61,7 +61,12 @@ class Anim {
int getHeight (); int getHeight ();
fixed getShootX (); fixed getShootX ();
fixed getShootY (); fixed getShootY ();
fixed getAccessoryX ();
fixed getAccessoryY ();
fixed getAccessoryShootX ();
fixed getAccessoryShootY ();
fixed getOffset (); fixed getOffset ();
Anim* getAccessory ();
void draw (fixed x, fixed y); void draw (fixed x, fixed y);
void drawScaled (fixed x, fixed y, fixed scale); void drawScaled (fixed x, fixed y, fixed scale);
void disableDefaultOffset (); void disableDefaultOffset ();
......
...@@ -114,6 +114,29 @@ Bullet::Bullet (Event* sourceEvent, bool facing, unsigned int ticks) { ...@@ -114,6 +114,29 @@ Bullet::Bullet (Event* sourceEvent, bool facing, unsigned int ticks) {
} }
Bullet::Bullet (fixed xStart, fixed yStart, int bullet, bool facing, unsigned int ticks) {
// Properties based on a given bullet type and starting position
next = level->bullets;
source = NULL;
type = bullet;
direction = facing? 1: 0;
sprite = level->getSprite(((unsigned char *)level->getBullet(type))[B_SPRITE + direction]);
x = xStart;
y = yStart;
dx = level->getBullet(type)[B_XSPEED + direction] * 500 * F1;
dy = level->getBullet(type)[B_YSPEED + direction] * 250 * F1;
time = ticks + T_BULLET;
level->playSound(level->getBullet(type)[B_STARTSOUND]);
return;
}
Bullet::Bullet (Bird* sourceBird, bool lower, unsigned int ticks) { Bullet::Bullet (Bird* sourceBird, bool lower, unsigned int ticks) {
// Properties based on the bird and its player // Properties based on the bird and its player
......
...@@ -70,6 +70,7 @@ class Bullet : public Movable { ...@@ -70,6 +70,7 @@ class Bullet : public Movable {
Bullet (LevelPlayer* sourcePlayer, bool lower, unsigned int ticks); Bullet (LevelPlayer* sourcePlayer, bool lower, unsigned int ticks);
Bullet (Event* sourceEvent, bool facing, unsigned int ticks); Bullet (Event* sourceEvent, bool facing, unsigned int ticks);
Bullet (Bird* sourceBird, bool lower, unsigned int ticks); Bullet (Bird* sourceBird, bool lower, unsigned int ticks);
Bullet (fixed xStart, fixed yStart, int bullet, bool facing, unsigned int ticks);
~Bullet (); ~Bullet ();
LevelPlayer* getSource (); LevelPlayer* getSource ();
......
...@@ -270,6 +270,9 @@ Anim* Event::getAnim (unsigned char property) { ...@@ -270,6 +270,9 @@ Anim* Event::getAnim (unsigned char property) {
case E_LSHOOTANIM: case E_LSHOOTANIM:
case E_RSHOOTANIM: case E_RSHOOTANIM:
if (getProperty(property) < 0)
return level->getAnim(getProperty(property) + 128);
return level->getAnim(getProperty(property)); return level->getAnim(getProperty(property));
default: default:
......
...@@ -963,23 +963,16 @@ void Event::draw (unsigned int ticks, int change) { ...@@ -963,23 +963,16 @@ void Event::draw (unsigned int ticks, int change) {
fixed changeX = getDrawX(change); fixed changeX = getDrawX(change);
fixed changeY = getDrawY(change); fixed changeY = getDrawY(change);
anim = getAnim(animType);
// Check if an explosive effect should be drawn // Check if an explosive effect should be drawn
drawExplosion = false; drawExplosion = false;
if (set[animType] < 0) { if (set[animType] < 0) {
anim = level->getAnim(set[animType] + 128);
// Explosions may only occur with finish animations // Explosions may only occur with finish animations
drawExplosion = (animType == E_RFINISHANIM || animType == E_LFINISHANIM); drawExplosion = (animType == E_RFINISHANIM || animType == E_LFINISHANIM);
} }
else {
anim = level->getAnim(set[animType]);
}
// Decide on the frame to draw // Decide on the frame to draw
anim->setFrame(frame + gridX + gridY, true); anim->setFrame(frame + gridX + gridY, true);
......
...@@ -26,13 +26,16 @@ ...@@ -26,13 +26,16 @@
#include "../level.h" #include "../level.h"
#include "../bullet.h"
#include "guardians.h" #include "guardians.h"
#include "io/gfx/video.h" #include "io/gfx/video.h"
#include "player/player.h" #include "player/player.h"
#include "util.h"
DeckGuardian::DeckGuardian (unsigned char gX, unsigned char gY) {
Guardian::Guardian(unsigned char gX, unsigned char gY) {
x = TTOF(gX); x = TTOF(gX);
y = TTOF(gY + 1); y = TTOF(gY + 1);
...@@ -51,6 +54,13 @@ DeckGuardian::DeckGuardian (unsigned char gX, unsigned char gY) { ...@@ -51,6 +54,13 @@ DeckGuardian::DeckGuardian (unsigned char gX, unsigned char gY) {
} }
DeckGuardian::DeckGuardian (unsigned char gX, unsigned char gY) : Guardian(gX, gY) {
return;
}
bool DeckGuardian::overlap (fixed left, fixed top, fixed width, fixed height) { bool DeckGuardian::overlap (fixed left, fixed top, fixed width, fixed height) {
if (stage == 0) if (stage == 0)
...@@ -167,3 +177,232 @@ void DeckGuardian::draw (unsigned int ticks, int change) { ...@@ -167,3 +177,232 @@ void DeckGuardian::draw (unsigned int ticks, int change) {
} }
MedGuardian::MedGuardian(unsigned char gX, unsigned char gY) : Guardian(gX, gY) {
animType = E_LEFTANIM;
stage = 1;
direction = 1;
shoot = false;
return;
}
/*bool MedGuardian::overlap(fixed left, fixed top, fixed width, fixed height) {
return false;
}*/
Event* MedGuardian::step(unsigned int ticks, int msps) {
Anim *anim = getAnim(animType);
if (level->getEventHits(gridX, gridY) == getProperty(E_HITSTOKILL) / 2)
stage = 1;
fixed sin = fSin(ticks / 2);
fixed cos = fCos(ticks / 2);
// Stage 0: Move in an eight shape and fire the occasional shot
if (stage == 0) {
if (direction == 1) {
// Lower right part of the eight
animType = E_LEFTANIM;
dx = TTOF(gridX) + (sin * 96) - x + ITOF(96);
dy = TTOF(gridY) - (cos * 64) - y;
if (cos > 0) direction = 2;
}
if (direction == 2) {
// Upper left part of the eight
animType = E_LEFTANIM;
dx = TTOF(gridX) - (sin * 96) - x - ITOF(96);
dy = TTOF(gridY) - (cos * 64) - y;
if (cos < 0) direction = 3;
}
if (direction == 3) {
// Lower left part of the eight
animType = E_RIGHTANIM;
dx = TTOF(gridX) - (sin * 96) - x - ITOF(96);
dy = TTOF(gridY) - (cos * 64) - y;
if (cos > 0) direction = 4;
}
if (direction == 4) {
// Upper right part of the eight
animType = E_RIGHTANIM;
dx = TTOF(gridX) + (sin * 96) - x + ITOF(96);
dy = TTOF(gridY) - (cos * 64) - y;
if (cos < 0) direction = 1;
}
// Decide if there should be a shot
if ((ticks % (getProperty(E_BULLETSP) * 25) >
(unsigned int)(getProperty(E_BULLETSP) * 25) - T_SHOOT)) {
level->setEventTime(gridX, gridY, ticks + T_SHOOT);
shoot = true;
}
// Shoot if there is a shot
if (level->getEventTime(gridX, gridY) &&
(ticks > level->getEventTime(gridX, gridY)) &&
shoot) {
if ((getProperty(E_BULLET) < 32) &&
(level->getBullet(getProperty(E_BULLET))[B_SPRITE] != 0))
level->bullets = new Bullet(
x + anim->getAccessoryShootX(),
y + anim->getAccessoryShootY(),
getProperty(E_BULLET), (animType != E_LEFTANIM), ticks);
shoot = false;
}
}
// Stage 1: Hop back and forth destroying the bottom row of tiles
if (stage == 1) {
if (direction < 5) {
// Move up or down towards the starting position for hopping
if (y > TTOF(gridY) - ITOF(48))
direction = 5;
else
direction = 6;
}
// Move up to the correct height
if (direction == 5) {
if (y > TTOF(gridY) - ITOF(48)) {
dx = 0;
dy = ITOF(-2);
}
else direction = 7;
}
// Move down to the correct height
if (direction == 6) {
if (y < TTOF(gridY) - ITOF(48)) {
dx = 0;
dy = ITOF(2);
} else direction = 7;
}
// Hop back and forth
if (direction == 7) {
if (level->checkMaskUp(x, y - anim->getOffset()) ||
level->checkMaskUp(x + getWidth(), y - anim->getOffset()))
animType = (animType == E_LEFTANIM) ? E_RIGHTANIM : E_LEFTANIM;
if (cos < 0)
dy = sin * -7;
else
dy = sin * 7;
if (animType == E_RIGHTANIM)
dx = ((cos < 0 ? -cos : cos) * 7);
else
dx = ((cos < 0 ? -cos : cos) * -7);
}
// Stand still and shake
/*if (direction == 6) {
// Set a timer
if (level->getEventTime(gridX, gridY) &&
(ticks > level->getEventTime(gridX, gridY))) {
dx = 0;
dy = 0;
}
else
level->setEventTime(gridX, gridY, ticks + 2000);
}*/
}
dx = ((dx << 10) / msps);
dy = ((dy << 10) / msps);
x += (dx * msps) >> 10;
y += (dy * msps) >> 10;
return this;
}
void MedGuardian::draw(unsigned int ticks, int change) {
Anim *anim;
Anim *accessory;
if (next) next->draw(ticks, change);
fixed xChange = getDrawX(change);
fixed yChange = getDrawY(change);
if (getProperty(E_ANIMSP))
frame = ticks / (getProperty(E_ANIMSP) * 40);
else
frame = ticks / 20;
if (stage == 0)
anim = getAnim(animType);
else
anim = getAnim(animType == E_LEFTANIM ? E_LFINISHANIM : E_RFINISHANIM);
anim->setFrame(frame + gridX + gridY, true);
anim->draw(xChange, yChange);
accessory = anim->getAccessory();
accessory->setFrame(frame + gridX + gridY, true);
accessory->disableDefaultOffset();
accessory->draw(xChange + (anim->getAccessoryX()), yChange + anim->getAccessoryY());
return;
}
...@@ -29,11 +29,20 @@ ...@@ -29,11 +29,20 @@
// Class // Class
class DeckGuardian : public Event {
private: class Guardian : public Event {
protected:
int stage; int stage;
public:
Guardian (unsigned char gX, unsigned char gY);
};
class DeckGuardian : public Guardian {
public: public:
DeckGuardian (unsigned char gX, unsigned char gY); DeckGuardian (unsigned char gX, unsigned char gY);
...@@ -43,5 +52,22 @@ class DeckGuardian : public Event { ...@@ -43,5 +52,22 @@ class DeckGuardian : public Event {
}; };
class MedGuardian : public Guardian {
private:
unsigned char direction;
bool shoot;
public:
MedGuardian (unsigned char gX, unsigned char gY);
//bool overlap (fixed left, fixed top, fixed width, fixed height);
Event* step (unsigned int ticks, int msps);
void draw (unsigned int ticks, int change);
};
#endif #endif
...@@ -84,6 +84,12 @@ int Level::step () { ...@@ -84,6 +84,12 @@ int Level::step () {
break; break;
case 41:
events = new MedGuardian(x, y);
break;
case 60: case 60:
events = new DeckGuardian(x, y); events = new DeckGuardian(x, y);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment