- created a generic object class
- began death handling stuffs
- added a quest list in-game
+
+11/13/2015:
+===========
+
+ - began working on cutscene triggers
+ - began working on item dialogs
+
+11/16/2015:
+===========
+
+ - minor bug fixes
+ - began working on arenas
+ - began working on cutscene triggers
+
+11/17/2015:
+===========
+
+ - created basic arena / arena handling
+ - added entity deletion when an entity dies
+ - fixed errors with typewriter-text
+ - finished cutscene triggers
# gamedev
gamedev is a high school project between drumsetmonkey and tcsullivan written in C++ and using SDL2/OpenGL. The goal of this project is to have a completed commercial-grade video game available to Linux and Windows users. We plan on profiting off of the game once we finish it, so once the game reaches its final stages it may become closed source (however, what was uploaded will stay for others to use as a resource).
-
-Link to story outline: https://docs.google.com/document/d/18cavXmE0MTp2GCAvIABPs61qKblVLSbfOb5zmBXoZJw/edit
\ No newline at end of file
enum MOB_SUB {
MS_RABBIT = 1,
- MS_BIRD
+ MS_BIRD,
+ MS_TRIGGER
};
class Entity{
class Mob : public Entity{
public:
- float init_y;
+ double init_y;
+ void (*hey)();
Mob(int);
+ Mob(int,unsigned int);
void wander(int);
};
void addStructure(_TYPE t,float x,float y,World *outside,World *inside);
void addMob(int t,float x,float y);
+ void addMob(int t,float x,float y,void (*hey)());
void addNPC(float x,float y);
void addObject(int, float, float);
class Arena : public World {
private:
- World *exit;
+ vec2 pxy;
+ vec2 door;
+ World *exit;
public:
- void drawDoor(void);
- World *exitArena(void);
+ Arena(World *leave,Player *p);
+ World *exitArena(Player *p);
};
extern int worldShade;
case MS_BIRD:
m->wander((rand()%240 + 15)); // Make the mob wander :)
break;
+ case MS_TRIGGER:
+ m->wander(0);
+ break;
+ default:
+ std::cout<<"Unhandled mob of subtype "<<m->subtype<<"."<<std::endl;
+ break;
}
}
}
*/
if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){
- std::cout << "Picking up!\n";
o->interact();
}
}
if(!maxHealth)health = maxHealth = 1;
- if(type==MOBT)
- Mobp(this)->init_y=loc.y;
+ if(type==MOBT){
+ if(Mobp(this)->subtype == MS_BIRD){
+ Mobp(this)->init_y=loc.y;
+ }
+ }
name = (char*)malloc(16);
getName();
}
Mob::Mob(int sub){
- type = MOBT;
+ type = MOBT;
maxHealth = health = 50;
width = HLINE * 8;
height = HLINE * 8;
tex = new Texturec(1, "assets/robin.png");
+ case MS_TRIGGER:
+ width = HLINE * 8;
+ height = 2000;
+ tex = new Texturec(0);
break;
}
tex->bind(2);
break;
}
- }
- else{
+ }else{
tex->bind(1);
}
}else if(type == MOBT){
switch(subtype){
- case 1: //RABBIT
+ case MS_RABBIT:
if(ground == 0){
tex->bind(1);
}else if(ground == 1){
tex->bind(0);
}
break;
- case 2: //RABBIT
- if(ground == 0){
- tex->bind(0);
- }else if(ground == 1){
- tex->bind(0);
- }
+ case MS_BIRD:
+ tex->bind(0);
+ break;
+ case MS_TRIGGER:
+ goto NOPE;
break;
default:
- break;
+ tex->bind(0);
+ break;
}
}else if(type == OBJECTT){
tex->bind(0);
glTexCoord2i(1,0);glVertex2i(loc.x + width, loc.y + height);
glTexCoord2i(0,0);glVertex2i(loc.x, loc.y + height);
glEnd();
+NOPE:
glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
void Mob::wander(int timeRun){
static int direction; //variable to decide what direction the entity moves
- static unsigned int hey=0,hi=0;
+ static unsigned int heya=0,hi=0;
switch(subtype){
case MS_RABBIT:
if(!ticksToUse){
case MS_BIRD:
if(loc.y<=init_y-.2)vel.y=.02*deltaTime; // TODO handle direction
vel.x=.02*deltaTime;
- if(++hey==200){hey=0;hi^=1;}
+ if(++heya==200){heya=0;hi^=1;}
if(hi)vel.x*=-1;
break;
+ case MS_TRIGGER:
+ if(player->loc.x + player->width / 2 > loc.x &&
+ player->loc.x + player->width / 2 < loc.x + width ){
+ if(player->left)player->loc.x = loc.x + width;
+ else if(player->right) player->loc.x = loc.x - player->width;
+ hey();
+ }
+ break;
default:
break;
}
-}
\ No newline at end of file
+}
return 0;
}
+static Arena *a;
+
+void CUTSCENEEE(void){
+ char opt[]=":K.";
+ player->vel.x = 0;
+ ui::dialogBox(player->name,opt,"No way I\'m gettin\' up this hill.");
+
+ waitForDialog();
+
+ a = new Arena(currentWorld,player);
+
+ currentWorld = a;
+
+ /*player->right = true;
+ player->left = false;
+ player->loc.x += HLINE * 5;*/
+}
+
float playerSpawnHillFunc(float x){
- x=-x;
- return (float)(pow(2,(x+200)/5) + 80);
+ return (float)(pow(2,(-x+200)/5) + 80);
}
void initEverything(void){
unsigned int i;
currentWorld->addStructure(STRUCTURET,(rand()%120*HLINE),10,test,iw);
/*
- * Spawn a mob.
+ * Spawn some mobs.
*/
+
+ playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE);
test->addMob(MS_RABBIT,200,100);
test->addMob(MS_BIRD,-500,500);
- currentWorld->addObject(2, 500,200);
+ test->addObject(2, 500,200);
/*
* Link all the entities that were just created to the initial world, and setup a test AI function.
bool fadeEnable = false;
+
+bool inBattle = false;
+
namespace ui {
/*
* Reset values if a new string is being passed.
*/
- if(!size || ((linc>15)&(strncmp(ret,str,15)))){
+ if(strncmp(ret,str,linc-1)){
memset(ret,0,512); // Zero the buffer
size=strlen(str); // Set the new target string size
linc=0; // Reset the incrementers
if(dialogBoxExists){
glColor3ub(0,0,0);
- x=player->loc.x-SCREEN_WIDTH/2+HLINE*8;
+ x=offset.x-SCREEN_WIDTH/2+HLINE*8;
y=(offset.y+SCREEN_HEIGHT/2)-HLINE*8;
glRectf(x,y,x+SCREEN_WIDTH-HLINE*16,y-SCREEN_HEIGHT/4);
player->ground=false;
player->loc.y-=HLINE*1.5;
}
- if(SDL_KEY==SDLK_w)currentWorld=currentWorld->goInsideStructure(player);
+ if(SDL_KEY==SDLK_w){
+ if(inBattle){
+ currentWorld=((Arena *)currentWorld)->exitArena(player);
+ }else currentWorld=currentWorld->goInsideStructure(player);
+ }
if(SDL_KEY==SDLK_SPACE){ // Jump
if(player->ground){
player->vel.y=.4;
/*
* Draw the layer up until the grass portion, which is done later.
*/
- /*
- * TODO: CLYNE CHANGE THE NAME OF THIS
- */
+
bool hey=false;
glBegin(GL_QUADS);
for(i=is;i<ie-GEN_INC;i++){
}
void World::singleDetect(Entity *e){
- unsigned int i;
+ unsigned int i,j;
/*
* Kill any dead entities.
*/
- if(e->alive&&e->health<=0){
-
- e->alive=false;
- std::cout<<"Killing entity..."<<std::endl;
+ if(!e->alive||e->health<=0){
+
+ for(i=0;i<entity.size();i++){
+ if(entity[i]==e){
+ entity.erase(entity.begin()+i);
+ switch(e->type){
+ case STRUCTURET:
+ for(j=0;j<build.size();j++){
+ if(build[j]==e){
+ build.erase(build.begin()+j);
+ return;
+ }
+ }
+ break;
+ case NPCT:
+ for(j=0;j<npc.size();j++){
+ if(npc[j]==e){
+ npc.erase(npc.begin()+j);
+ return;
+ }
+ }
+ break;
+ case MOBT:
+ for(j=0;j<mob.size();j++){
+ if(mob[j]==e){
+ mob.erase(mob.begin()+j);
+ return;
+ }
+ }
+ break;
+ }
+ return;
+ }
+ }
+
+ std::cout<<"RIP "<<e->name<<"."<<std::endl;
+ exit(0);
+
return;
-
}
/*
if(e->alive){
+ if(e->type == MOBT && Mobp(e)->subtype == MS_TRIGGER)return;
+
/*
* Calculate the line that this entity is currently standing on.
*/
entity.push_back(mob.back());
}
+void World::addMob(int t,float x,float y,void (*hey)()){
+ mob.push_back(new Mob(t));
+ mob.back()->spawn(x,y);
+ mob.back()->hey = hey;
+
+ entity.push_back(mob.back());
+}
+
void World::addNPC(float x,float y){
npc.push_back(new NPC());
npc.back()->spawn(x,y);
p->draw();
}
-void Arena::drawDoor(void){
+extern bool inBattle;
+
+Arena::Arena(World *leave,Player *p){
+ generate(300);
+ door.y = line[299].y;
+ door.x = 100;
+ exit = leave;
+
+ npc.push_back(new NPC());
+ entity.push_back(npc.back());
+ entity.back()->spawn(door.x,door.y);
+ entity.back()->width = HLINE * 12;
+ entity.back()->height = HLINE * 16;
+
+ inBattle = true;
+ pxy = p->loc;
}
-World *Arena::exitArena(void){
- return this;
+World *Arena::exitArena(Player *p){
+ npc[0]->loc.x = door.x;
+ npc[0]->loc.y = door.y;
+ if(p->loc.x + p->width / 2 > door.x &&
+ p->loc.x + p->width / 2 < door.x + HLINE * 12 ){
+ inBattle = false;
+ p->loc = pxy;
+ return exit;
+ }else{
+ return this;
+ }
}