aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-10-28 11:55:21 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-10-28 11:55:21 -0400
commit193af27884fc910b4ffa7212ec772894c03e36ee (patch)
treece3a10772b3af81815261a11959da6e715eaa96f /src
parenta3e3f43a51e4a8137dff779f38b358b5b8608e4e (diff)
Locked camera to world bounds and added basic mountain backdrop
Diffstat (limited to 'src')
-rw-r--r--src/inventory.cpp6
-rw-r--r--src/ui.cpp8
-rw-r--r--src/world.cpp5
3 files changed, 10 insertions, 9 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 1adcbab..2eb0087 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -86,10 +86,10 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){
void Inventory::draw(void){
unsigned int i=0;
float y=SCREEN_HEIGHT/2,xoff;
- ui::putText(player->loc.x-SCREEN_WIDTH/2,y,"Inventory:");
+ ui::putText(offset.x-SCREEN_WIDTH/2,y,"Inventory:");
while(item[i].count){
y-=HLINE*12;
- xoff=ui::putText(player->loc.x-SCREEN_WIDTH/2,y,"%d x ",item[i].count);
+ xoff=ui::putText(offset.x-SCREEN_WIDTH/2,y,"%d x ",item[i].count);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,ITEM_TEX[item[i].id-1]);
if(sel==i)glColor3ub(255,0,255);
@@ -101,7 +101,7 @@ void Inventory::draw(void){
glTexCoord2i(0,0);glVertex2i(xoff ,y+HLINE*10);
glEnd();
y-=ui::fontSize*1.15;
- ui::putText(player->loc.x-SCREEN_WIDTH/2,y,"%s",itemName[(unsigned)item[i].id]);
+ ui::putText(offset.x-SCREEN_WIDTH/2,y,"%s",itemName[(unsigned)item[i].id]);
glDisable(GL_TEXTURE_2D);
i++;
}
diff --git a/src/ui.cpp b/src/ui.cpp
index 9d7de8a..8f19e34 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -174,13 +174,13 @@ namespace ui {
putString(x+HLINE,y-fontSize-HLINE,dialogBoxText);
}
setFontSize(16);
- putText(((SCREEN_WIDTH/2)+player->loc.x)-125,SCREEN_HEIGHT-fontSize,"Health: %u/%u",player->health>0?(unsigned)player->health:0,
+ putText(((SCREEN_WIDTH/2)+offset.x)-125,SCREEN_HEIGHT-fontSize,"Health: %u/%u",player->health>0?(unsigned)player->health:0,
(unsigned)player->maxHealth);
if(player->alive){
glColor3ub(255,0,0);
- glRectf((SCREEN_WIDTH/2+player->loc.x)-125,
+ glRectf((SCREEN_WIDTH/2+offset.x)-125,
SCREEN_HEIGHT-32,
- ((SCREEN_WIDTH/2+player->loc.x)-125)+((player->health/player->maxHealth)*100),
+ ((SCREEN_WIDTH/2+offset.x)-125)+((player->health/player->maxHealth)*100),
SCREEN_HEIGHT-32+12);
}
}
@@ -188,7 +188,7 @@ namespace ui {
static bool left=false,right=false;
static vec2 premouse={0,0};
SDL_Event e;
- mouse.x=premouse.x+player->loc.x-(SCREEN_WIDTH/2);
+ mouse.x=premouse.x+offset.x-(SCREEN_WIDTH/2);
mouse.y=SCREEN_HEIGHT-premouse.y;
while(SDL_PollEvent(&e)){
switch(e.type){
diff --git a/src/world.cpp b/src/world.cpp
index 168ac4c..9fe76b0 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -42,6 +42,7 @@ World::World(void){
}
void World::generate(unsigned int width){ // Generates the world and sets all variables contained in the World class.
+ worldWidth = width;
unsigned int i;
float inc;
@@ -199,7 +200,7 @@ LOOP2:
* the 'for' loop below that draws the layer.
*/
- v_offset=(p->loc.x + p->width / 2 - current->x_start) / HLINE;
+ v_offset=(offset.x + p->width / 2 - current->x_start) / HLINE;
// is -> i start
@@ -208,7 +209,7 @@ LOOP2:
// ie -> i end
- ie=v_offset + (SCREEN_WIDTH / 2 / HLINE) + GEN_INC;
+ ie=v_offset + (SCREEN_WIDTH / 2 / HLINE) + GEN_INC + HLINE;
if(ie>current->lineCount)ie=current->lineCount; // Maximum bound
/*