aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-01-21 09:24:53 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-01-21 09:24:53 -0500
commit482e007d33699ff8afbc6017f6a73fedc889311b (patch)
treefc430057637ad7a1fe085cb193684968e178405c /src
parent1ab18d0a0e80b1f7dff8ad90e41cc520198f7fcf (diff)
parent44804d69ea1af2490fedf54ea2cb273e3f5ab219 (diff)
Finished basic player sprite
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp18
-rw-r--r--src/ui.cpp10
-rw-r--r--src/world.cpp48
3 files changed, 59 insertions, 17 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index fb5aca3..7f7d798 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -149,6 +149,7 @@ Structures::~Structures(){
Mob::Mob(int sub){
type = MOBT;
+ aggressive = false;
maxHealth = health = 50;
@@ -533,6 +534,23 @@ unsigned int Structures::spawn(BUILD_SUB sub, float x, float y){
void Mob::wander(int timeRun){
static int direction; //variable to decide what direction the entity moves
static unsigned int heya=0,hi=0;
+ static bool YAYA = false;
+
+ if(aggressive && !YAYA &&
+ player->loc.x + (width / 2) > loc.x && player->loc.x + (width / 2) < loc.x + width &&
+ player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height ){
+ Arena *a = new Arena(currentWorld,player,this);
+ a->setBackground(BG_FOREST);
+ a->setBGM("assets/music/embark.wav");
+ ui::toggleWhiteFast();
+ YAYA = true;
+ ui::waitForCover();
+ YAYA = false;
+ currentWorld = a;
+ ui::toggleWhiteFast();
+ //player->health-=5;
+ }
+
switch(subtype){
case MS_RABBIT:
if(!ticksToUse){
diff --git a/src/ui.cpp b/src/ui.cpp
index 49acd4f..e2cc39f 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -722,19 +722,17 @@ DONE:
case SDLK_s:
break;
case SDLK_w:
- /*if(inBattle){
+ if(inBattle){
tmp = currentWorld;
currentWorld = ((Arena *)currentWorld)->exitArena(player);
if(tmp != currentWorld){
//delete &tmp;
toggleBlackFast();
}
- }else{*/
- if((tmp = currentWorld->goInsideStructure(player)) != currentWorld){
- delete currentWorld;
+ }else{
+ if((tmp = currentWorld->goInsideStructure(player)) != currentWorld)
currentWorld = tmp;
- }
- //}*/
+ }
break;
case SDLK_i:
/*currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible
diff --git a/src/world.cpp b/src/world.cpp
index af960d5..113d98a 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -144,7 +144,7 @@ void World::generate(unsigned int width){ // Generates the world and sets all va
if(width <= 0)
abort();
- lineCount = width + GEN_INC;
+ lineCount = (width + GEN_INC) / HLINE;
/*
* Allocate enough memory for the world to be stored.
@@ -375,8 +375,13 @@ void World::draw(Player *p){
current=current->infront;
goto LLLOOP;
}*/
- cx_start = current->x_start * 1.5;
- width = (-x_start) << 1;
+
+ if(current->x_start < SCREEN_WIDTH * -.5 )
+ cx_start = current->x_start * 1.5;
+ else
+ cx_start = (int)(SCREEN_WIDTH * -.5);
+
+ width = (-cx_start) << 1;
glEnable(GL_TEXTURE_2D);
@@ -534,7 +539,10 @@ void World::draw(Player *p){
* corners don't stick out.
*/
- for(auto &part : particles){if(part->behind)part->draw();}
+ for(auto &part : particles){
+ if(part->behind)
+ part->draw();
+ }
for(auto &b : current->build){
b->draw();
}
@@ -574,6 +582,12 @@ void World::draw(Player *p){
}
glBegin(GL_QUADS);
+
+ glTexCoord2i(0 ,0);glVertex2i(v_offset - (SCREEN_WIDTH / 1.5),0);
+ glTexCoord2i(64,0);glVertex2i(v_offset + (SCREEN_WIDTH / 1.5),0);
+ glTexCoord2i(64,1);glVertex2i(v_offset + (SCREEN_WIDTH / 1.5),base);
+ glTexCoord2i(0 ,1);glVertex2i(v_offset - (SCREEN_WIDTH / 1.5),base);
+
for(i=is;i<(unsigned)ie-GEN_INC;i++){
cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
if(!cline[i].y){
@@ -796,15 +810,15 @@ void World::singleDetect(Entity *e){
}
}
break;
- case PLAYERT:
- std::cout<<"RIP "<<e->name<<"."<<std::endl;
- exit(0);
+ default:
break;
}
entity.erase(entity.begin()+i);
return;
}
}
+ std::cout<<"RIP "<<e->name<<"."<<std::endl;
+ exit(0);
}
/*
@@ -1196,27 +1210,34 @@ void World::load(void){
for(auto &n : npc){
std::getline(iss,line);
+ if(line == "dOnE")return;
if((n->dialogIndex = std::stoi(line)) != 9999)
n->addAIFunc(commonAIFunc,false);
else n->clearAIFunc();
std::getline(iss,line);
+ if(line == "dOnE")return;
n->loc.x = std::stoi(line);
std::getline(iss,line);
+ if(line == "dOnE")return;
n->loc.y = std::stoi(line);
}
for(auto &b : build){
std::getline(iss,line);
+ if(line == "dOnE")return;
b->loc.x = std::stoi(line);
std::getline(iss,line);
+ if(line == "dOnE")return;
b->loc.y = std::stoi(line);
}
for(auto &m : mob){
std::getline(iss,line);
+ if(line == "dOnE")return;
m->loc.x = std::stoi(line);
std::getline(iss,line);
+ if(line == "dOnE")return;
m->loc.y = std::stoi(line);
}
@@ -1234,11 +1255,10 @@ IndoorWorld::IndoorWorld(void){
}
IndoorWorld::~IndoorWorld(void){
- std::cout<<"A\n";
delete bgTex;
delete[] star;
delete[] line;
-
+
deleteEntities();
}
@@ -1350,12 +1370,13 @@ void IndoorWorld::draw(Player *p){
extern bool inBattle;
-Arena::Arena(World *leave,Player *p){
- generate(300);
+Arena::Arena(World *leave,Player *p,Mob *m){
+ generate(800);
addMob(MS_DOOR,100,100);
inBattle = true;
exit = leave;
pxy = p->loc;
+ mmob = m;
star = new vec2[100];
memset(star,0,100 * sizeof(vec2));
@@ -1376,6 +1397,7 @@ World *Arena::exitArena(Player *p){
ui::toggleBlackFast();
ui::waitForCover();
p->loc = pxy;
+ mmob->alive = false;
return exit;
}else{
return this;
@@ -1454,6 +1476,10 @@ World *loadWorldFromXML(const char *path){
tmp->addMob(type,getRand() % tmp->getTheWidth() / 2,100);
else
tmp->addMob(type,spawnx,wxml->FloatAttribute("y"));
+
+ if(wxml->QueryBoolAttribute("aggressive",&dialog) == XML_NO_ERROR)
+ tmp->mob.back()->aggressive = dialog;
+
}else if(!strcmp(name,"npc")){
const char *npcname;