aboutsummaryrefslogtreecommitdiffstats
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
parent1ab18d0a0e80b1f7dff8ad90e41cc520198f7fcf (diff)
parent44804d69ea1af2490fedf54ea2cb273e3f5ab219 (diff)
Finished basic player sprite
-rw-r--r--Changelog30
-rw-r--r--assets/names_en-us6
-rw-r--r--include/entities.h1
-rw-r--r--include/world.h3
-rw-r--r--src/entities.cpp18
-rw-r--r--src/ui.cpp10
-rw-r--r--src/world.cpp48
-rw-r--r--xml/playerSpawnHill1.xml43
8 files changed, 126 insertions, 33 deletions
diff --git a/Changelog b/Changelog
index b88ebe4..0916173 100644
--- a/Changelog
+++ b/Changelog
@@ -387,9 +387,6 @@
- continued to document header files through doxygen
- added border to dialogBox
- fix entity movement handling; npcs stop when you talk to them
-<<<<<<< HEAD
- - added sword animation?
-=======
- added sword animation?
12/9/2015,
@@ -411,7 +408,6 @@
- imrpoved BGM handling
- continued work on particles, made a fountain
- added sanic
-=======
~ Broke 5000 lines of code/doc, now with some file Doxygen'd
@@ -424,7 +420,6 @@
- fixed fading bugs
- continued fixing general game bugs
- fixed structure spawn issues
-=======
12/15/2015:
===========
@@ -508,7 +503,7 @@
- xml'd npc dialogs
- drafted page xml
-1/11/2015:
+1/11/2016:
==========
- improved npc dialog xmling
@@ -516,7 +511,7 @@
- textures?
- music?
-1/12/2015:
+1/12/2016:
==========
- world linking xml'd
@@ -524,7 +519,7 @@
- shaderssss
- more music
-1/13/2015:
+1/13/2016:
==========
- discovered how intel and nvidia gpus handle lighting
@@ -532,7 +527,7 @@
- xml'd settings for screen dimensions
- xml'd item giving through npc dialog
-1/14/2015:
+1/14/2016:
==========
- pondered on non-random generation
@@ -541,22 +536,33 @@
- began to incorporate XML into the world class for dynamic world loading...
-1/16/2015:
+1/16/2016:
==========
- removed layers
- switched world linking from pointers to file names, rewrote all world-linking code
- worlds are now loaded dynamically
-1/19/2015:
+1/19/2016:
==========
- memory management
- began reconsidering save/load stuff
-1/20/2015:
+1/20/2016:
==========
- can save npc dialog positions
- worked on player sprite redesign
- greatly simplified/documented gameplay.cpp
+
+1/21/2016:
+==========
+
+ - can save most mob positions
+ - fixed world widths, background drawing
+ - added aggressive flag to mobs, player enters arena on impact
+ - added world load fault handlers
+ - worked on player sprite redesign
+
+ ~ A little over 5200 lines of code
diff --git a/assets/names_en-us b/assets/names_en-us
index bc2c212..f3f252f 100644
--- a/assets/names_en-us
+++ b/assets/names_en-us
@@ -1,7 +1,7 @@
+mAndreas
mByron
mClark
mJarrett
-mJohnny
mHarrison
mFrederick
mPercy
@@ -46,7 +46,7 @@ mPhilip
mBroderick
mAshley
mMauro
-mDaren
+mDarien
mRigoberto
mChuck
mAndy
@@ -107,4 +107,4 @@ fStarla
fMonserrate
fAnn
fAshley
-fAbby Ross \ No newline at end of file
+fAbby Ross
diff --git a/include/entities.h b/include/entities.h
index 56b3078..ab33988 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -208,6 +208,7 @@ public:
class Mob : public Entity{
public:
+ bool aggressive;
double init_y;
void (*hey)(Mob *callee);
diff --git a/include/world.h b/include/world.h
index 3209284..baa4575 100644
--- a/include/world.h
+++ b/include/world.h
@@ -300,8 +300,9 @@ class Arena : public World {
private:
vec2 pxy;
World *exit;
+ Mob *mmob;
public:
- Arena(World *leave,Player *p);
+ Arena(World *leave,Player *p,Mob *m);
~Arena(void);
World *exitArena(Player *p);
};
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;
diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml
new file mode 100644
index 0000000..7911bfd
--- /dev/null
+++ b/xml/playerSpawnHill1.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<World>
+ <style background="0" bgm="assets/music/embark.wav" />
+ <generation type="Random" width="1600" />
+
+ <link right="playerSpawnHill2.xml" />
+
+ <mob type="1" aggressive="true" />
+
+ <npc name="Ralph" hasDialog="true" />
+ <npc name="Johnny" hasDialog="true" />
+ <structure type="5" inside="playerSpawnHill1_Building1.xml" />
+
+</World>
+
+<Dialog name="Ralph">
+
+ <text id="0">
+ Hello there!
+ <option text="Hello" nextid="1" />
+ <option text="Frig" nextid="2" />
+ </text>
+
+ <text id="1">
+ gg.
+ </text>
+
+ <text id="2" call="Johnny" callid="1">
+ what you have done it to trick Microsoft
+ </text>
+
+</Dialog>
+
+<Dialog name="Johnny">
+ <text id="0" nextid="1" stop="true">
+ Sup bro!
+ </text>
+
+ <text id="1" >
+ My name's Johnny.
+ <give id="0" count="1" />
+ </text>
+</Dialog>