Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Heart.sdf
Binary file not shown.
Binary file modified Heart.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Z - Jump/Select
Z - Jump/Back
X - Shoot/Select
C - Change Weapons
Enter - Select
Space - Pause/Select
Space - Pause/Unpause
Arrow keys - Move
Escape - Quit

Expand Down
Binary file added anims/bg/bbg_04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/bg/bg_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/hp/hp_3_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/hp/hp_3_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/hp/hp_3_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/hp/hp_3_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/items/blaster.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/items/blaster_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/items/card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/items/sword.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/items/sword_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/menu/equip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/menu/here.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/menu/long_select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified anims/menu/map_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified anims/menu/map_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified anims/menu/map_full.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added anims/menu/unseen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
153 changes: 89 additions & 64 deletions heart/Alonebot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,28 @@ Alonebot::Alonebot( float x, float y, int d, Alonebot* p ) {
armOffset = Vector2D( 0.f, 0.f );

if( p == 0 || p->currentHP < 1 ) {
maxHP = 3; // TODO: Load shit from savefile
currentHP = 3;
maxHP = 12; // TODO: Load shit from savefile
currentHP = 12;
setWeap( 0 );
offHandWeap = 0;
chargeCur = 0.f;
chargeInc = 0.f;
chargeMax = 0;
std::fill( visited, visited + MAX_ROOMS, false );
}
else {
w = p->w;
h = p->h;
maxHP = p->maxHP;
currentHP = p->currentHP;
setWeap( p->weapon );
offHandWeap = p->offHandWeap;
for( std::set<int>::iterator i = p->items.begin(); i != p->items.end(); ++i )
items.emplace( *i );
for( std::set<int>::iterator i = p->equips.begin(); i != p->equips.end(); ++i )
equips.emplace( *i );
for( int i=0; i<MAX_ROOMS; i++ )
visited[i] = p->visited[i];
chargeCur = p->chargeCur;
chargeInc = p->chargeInc;
chargeMax = p->chargeMax;
Expand Down Expand Up @@ -88,7 +95,7 @@ void Alonebot::init( FMOD::System* fmodSys ) {
texture = LoadTexture( std::string( "..\\anims\\chars\\alonebot.png" ) );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
loadVA( (float)w, (float)h );
loadVA( w, h );
defaultHeight = h;
defaultWidth = w;
arm[0] = LoadTexture( std::string( "..\\anims\\weapons\\arm.png" ) );
Expand All @@ -114,11 +121,16 @@ void Alonebot::init( FMOD::System* fmodSys ) {
swrdFrames[i] = LoadTexture( std::string( "..\\anims\\weapons\\sword\\sword_" + s.str() ) + ".png" );
}
crouchFrame = LoadTexture( std::string( "..\\anims\\crouch\\alonebot_crouch.png" ) );
for( int i=0; i<4; i++ ) {
for( int i=0; i<3; i++ ) {
std::stringstream s;
s << i;
HP[i] = LoadTexture( std::string( "..\\anims\\hp\\hp_" + s.str() + ".png" ) );
}
for( int i=0; i<4; i++ ) {
std::stringstream s;
s << i;
HP[i+3] = LoadTexture( std::string( "..\\anims\\hp\\hp_3_" + s.str() + ".png" ) );
}
for( int i=0; i<3; i++ ) {
std::stringstream s;
s << i;
Expand Down Expand Up @@ -147,6 +159,19 @@ void Alonebot::init( FMOD::System* fmodSys ) {
heartBeat.start( );
}

void Alonebot::add( Item* i ) {
// Add equipment to equipment inventory
if( i->equip )
equips.emplace( i->id );
// Or an item to item inventory
else {
items.emplace( i->id );
// If it's a heart container, increase maxHP and restore to full
if( i->id >= 100 )
currentHP = maxHP = maxHP + 4;
}
}

GLuint Alonebot::getTex( ) {
int ticks = heartBeat.get_ticks( );
int temp = 0;
Expand Down Expand Up @@ -270,7 +295,7 @@ GLuint Alonebot::getArm( ) {
return shotFrames[temp];
}

int Alonebot::getDeath( ) {
int Alonebot::getDeathTime( ) {
if( !movable )
return heartBeat.get_ticks( ) - deathStart;
return 0;
Expand All @@ -285,18 +310,18 @@ void Alonebot::drawHP( ) {
glPushMatrix( );
glTranslatef( 8.f, 40.f, 0.f ); // Offset
glBindTexture( GL_TEXTURE_2D, charge[0] );
float w, h;
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
int w, h;
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3f( 0.f, 0.f, 0.f );
glVertex2i( 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3f( w, 0.f, 0.f );
glVertex2i( w, 0 );
glTexCoord2i( 1, 1 );
glVertex3f( w, h, 0.f );
glVertex2i( w, h );
glTexCoord2i( 0, 1 );
glVertex3f( 0.f, h, 0.f );
glVertex2i( 0, h );
glEnd( );
glTranslatef( 2.f, 2.f, 0.f );
glBindTexture( GL_TEXTURE_2D, charge[1] );
Expand All @@ -308,48 +333,48 @@ void Alonebot::drawHP( ) {
else if( chargeTime.get_ticks( ) >= 100 )
chargeTime.stop( );
}
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
if( chargeCur == 0 && chargeTime.is_started( ) ) { // Cooldown for shooting
w *= ( (float)chargeMax - chargeTime.get_ticks( ) ) / chargeMax;
w = (int)( w * ( (float)chargeMax - chargeTime.get_ticks( ) ) / chargeMax );
if( weapon == 1 ) // Hidden for blaster
w = 0;
}
else // And for charging
w *= chargeCur / 100.f;
w = (int)( w * chargeCur / 100.f );
if( w < 0 )
w = 0;
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3f( 0.f, 0.f, 0.f );
glVertex2i( 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3f( w, 0.f, 0.f );
glVertex2i( w, 0 );
glTexCoord2i( 1, 1 );
glVertex3f( w, h, 0.f );
glVertex2i( w, h );
glTexCoord2i( 0, 1 );
glVertex3f( 0.f, h, 0.f );
glVertex2i( 0, h );
glEnd( );
glPopMatrix( );
}
for( int i=0; i<3; i++ ) { // Draw HP bar
if( i == 1 ) { // Middle portions
for( int j=0; j<maxHP-2; j++ ) { // For loop drawing middle portions of HP bar
for( int j=0; j<maxHP/4-2; j++ ) { // For loop drawing middle portions of HP bar
glPushMatrix( );
// Offset
glTranslatef( 34.f + 20.f*j, 8.f, 0.f );
glBindTexture( GL_TEXTURE_2D, HP[i] );
float w, h;
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
int w, h;
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3f( 0.f, 0.f, 0.f );
glVertex2i( 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3f( w, 0.f, 0.f );
glVertex2i( w, 0 );
glTexCoord2i( 1, 1 );
glVertex3f( w, h, 0.f );
glVertex2i( w, h );
glTexCoord2i( 0, 1 );
glVertex3f( 0.f, h, 0.f );
glVertex2i( 0, h );
glEnd( );
glPopMatrix( );
}
Expand All @@ -358,41 +383,41 @@ void Alonebot::drawHP( ) {
glPushMatrix( );
glTranslatef( 8.f, 8.f, 0.f ); // Offset
if( i > 0 )
glTranslatef( 26.f + 20.f*(maxHP-2), 0.f, 0.f ); // Alter transformations for last piece
glTranslatef( 26.f + 20.f*(maxHP/4-2), 0.f, 0.f ); // Alter transformations for last piece
glBindTexture( GL_TEXTURE_2D, HP[i] );
float w, h;
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
int w, h;
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3f( 0.f, 0.f, 0.f );
glVertex2i( 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3f( w, 0.f, 0.f );
glVertex2i( w, 0 );
glTexCoord2i( 1, 1 );
glVertex3f( w, h, 0.f );
glVertex2i( w, h );
glTexCoord2i( 0, 1 );
glVertex3f( 0.f, h, 0.f );
glVertex2i( 0, h );
glEnd( );
glPopMatrix( );
}
}

for( int i=0; i<currentHP; i++ ) { // Draw hearts
glPushMatrix( );
glTranslatef( 14.f + 20.f * i, 8.f, 0.f ); // Offset
glBindTexture( GL_TEXTURE_2D, HP[3] );
float w, h;
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameterfv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
glTranslatef( 14.f + 20.f * (i / 4), 8.f, 0.f ); // Offset
glBindTexture( GL_TEXTURE_2D, HP[3 + i % 4] );
int w, h;
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3f( 0.f, 0.f, 0.f );
glVertex2i( 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3f( w, 0.f, 0.f );
glVertex2i( w, 0 );
glTexCoord2i( 1, 1 );
glVertex3f( w, h, 0.f );
glVertex2i( w, h );
glTexCoord2i( 0, 1 );
glVertex3f( 0.f, h, 0.f );
glVertex2i( 0, h );
glEnd( );
glPopMatrix( );
}
Expand All @@ -416,7 +441,7 @@ void Alonebot::crouch( ) {
h -= 18;
pos.y += 18.f;
defaultHeight = h;
loadVA( (float)w, (float)h );
loadVA( w, h );
}
}

Expand All @@ -426,7 +451,7 @@ void Alonebot::stand( ) {
h += 18;
pos.y -= 18.f;
defaultHeight = h;
loadVA( (float)w, (float)h );
loadVA( w, h );
idle.stop( );
}
}
Expand Down Expand Up @@ -568,25 +593,25 @@ void Alonebot::setWeap( int w ) {
if( movable ) {
switch( w ) {
case 0: {
weapon = 0;
chargeCur = 0.f;
chargeInc = 0.f;
chargeMax = 1;
break;
weapon = 0;
chargeCur = 0.f;
chargeInc = 0.f;
chargeMax = 1;
break;
}
case 1: {
weapon = 1;
chargeCur = 0.f;
chargeInc = 100.f;
chargeMax = 80;
break;
case 1: { // Blaster
weapon = 1;
chargeCur = 0.f;
chargeInc = 100.f;
chargeMax = 80;
break;
}
case 2: {
weapon = 2;
chargeCur = 0.f;
chargeInc = 70.f;
chargeMax = 240;
break;
case 2: { // Sword
weapon = 2;
chargeCur = 0.f;
chargeInc = 70.f;
chargeMax = 240;
break;
}
}
}
Expand Down
22 changes: 15 additions & 7 deletions heart/Alonebot.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,49 @@ class Alonebot : public Organ {
private:
static const int COURAGEDURATION = 1000;
static const int COURAGETIMEOUT = 250;
GLuint HP[4];

GLuint HP[7];
GLuint arm[1];
GLuint charge[3];
GLuint crouchFrame;
GLuint hitFrames[6];
GLuint idleFrames[4];
GLuint jumpFrames[4];

GLuint* weapFrames[3];
GLuint blstFrames[3];
GLuint swrdFrames[3];
GLuint* shotFrames;

float MAX_FALL_SPEED, MAX_X_SPEED, X_ACCEL;
int blinkMod;

public:
static const int MAX_ROOMS = 17;

bool visited[MAX_ROOMS];
Vector2D armOffset;
std::set<int> items;
std::set<int> equips;
int maxHP, currentHP;
int weapon, offHandWeap, chargeMax;
float jumpSpeed, chargeCur, chargeInc;
Timer jumpTime, courage, idle, chargeTime;
int jumpStart, shotStart, crouchStart, deathStart;
bool walking, jumping, crouching, canJump, canDrop, drop, canDmg;
float jumpSpeed, chargeCur, chargeInc;
Vector2D armOffset;
int maxHP, currentHP;
int weapon, chargeMax;
std::set<int> items;
FMOD::Sound *jumpSFX, *landSFX, *hurtSFX, *doorSFX, *itemSFX, *blstSFX, *swrdSFX;

Alonebot( float x = 0.f, float y = 0.f, int d = 1, Alonebot* p = 0 );
~Alonebot( );

void init( FMOD::System* fmodSys );
void add( Item* i );
void jump( );
void stand( );
void shoot( );
void crouch( );
void drawHP( );
int getDeath( );
int getDeathTime( );
GLuint getTex( );
GLuint getArm( );
int getCourage( );
Expand Down
Loading