aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-11-02 20:48:31 -0500
committerClyne Sullivan <tullivan99@gmail.com>2015-11-02 20:48:31 -0500
commitf8ebf8fd3d5691cd45566281a1f54c5ecbc43762 (patch)
tree35633b779419c0df9cdb2408838189d529357abf /src
parent07d73ea992641198a887f000bf44b874c8e11574 (diff)
updated goals
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp2
-rw-r--r--src/gameplay.cpp2
-rw-r--r--src/inventory.cpp1
-rw-r--r--src/ui.cpp6
-rw-r--r--src/world.cpp161
5 files changed, 62 insertions, 110 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index acc45bd..42ed5a9 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -176,7 +176,7 @@ void Entity::draw(void){ //draws the entities
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
if(near){
- ui::setFontSize(14);
+ ui::setFontSize(10);
ui::putText(loc.x,loc.y-ui::fontSize-HLINE/2,"%s",name);
}
}
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 964794f..f986ce3 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -37,8 +37,6 @@ void initEverything(void){
World *test=new World();
test->generate(SCREEN_WIDTH * 2);
test->addLayer(400);
-
- test->addPlatform(150,100,100,10);
test->addHole(100,150);
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 33af0a8..11f2ad7 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -92,6 +92,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){
void Inventory::draw(void){
unsigned int i=0;
float y=SCREEN_HEIGHT/2,xoff;
+ ui::setFontSize(12);
ui::putText(offset.x-SCREEN_WIDTH/2,y,"Inventory:");
while(item[i].count){
y-=HLINE*12;
diff --git a/src/ui.cpp b/src/ui.cpp
index fa8cf9c..d138a0a 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -136,7 +136,7 @@ namespace ui {
pw=putChar(xo,yo,s[i])+fontSize*.1;
xo+=pw;
}
- }while(s[i++]);
+ }while(s[++i]);
return xo;
}
float putText(const float x,const float y,const char *str,...){ // putText() simply runs 'str' and the extra arguments though
@@ -174,10 +174,10 @@ namespace ui {
x=player->loc.x-SCREEN_WIDTH/2+HLINE*8;
y=SCREEN_HEIGHT-HLINE*8;
glRectf(x,y,x+SCREEN_WIDTH-HLINE*16,y-SCREEN_HEIGHT/4);
- setFontSize(16);
+ setFontSize(12);
putString(x+HLINE,y-fontSize-HLINE,dialogBoxText);
}
- setFontSize(16);
+ setFontSize(12);
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){
diff --git a/src/world.cpp b/src/world.cpp
index dccca21..36993b0 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -7,6 +7,10 @@
// or not calculated at all, so GEN_INC is also used to decrease 'lineCount' in functions like draw()
// and detect().
+#define GEN_MIN 40
+#define GEN_MAX 70
+#define GEN_INIT 60
+
#define GRASS_HEIGHT 4 // Defines how long the grass layer of a line should be in multiples of HLINE.
@@ -57,7 +61,7 @@ void World::generate(unsigned int width){ // Generates the world and sets all va
* Set an initial y to base generation off of, as generation references previous lines.
*/
- line[0].y=80;
+ line[0].y=GEN_INIT;
/*
* Populate every GEN_INCth line structure. The remaining lines will be based off of these.
@@ -69,9 +73,9 @@ void World::generate(unsigned int width){ // Generates the world and sets all va
* Generate a y value, ensuring it stays within a reasonable range.
*/
- line[i].y=rand() % 8 - 4 + line[i-GEN_INC].y; // Add +/- 4 to the previous line
- if(line[i].y < 40)line[i].y = 40; // Minimum bound
- else if(line[i].y > 70)line[i].y = 70; // Maximum bound
+ line[i].y=rand() % 8 - 4 + line[i-GEN_INC].y; // Add +/- 4 to the previous line
+ if(line[i].y < GEN_MIN)line[i].y = GEN_MIN; // Minimum bound
+ else if(line[i].y > GEN_MAX)line[i].y = GEN_MAX; // Maximum bound
}
@@ -88,7 +92,7 @@ void World::generate(unsigned int width){ // Generates the world and sets all va
*
*/
- if(!i||!(i%GEN_INC)){
+ if(!(i%GEN_INC)){
inc=(line[i + GEN_INC].y - line[i].y) / (float)GEN_INC;
@@ -124,7 +128,7 @@ void World::generate(unsigned int width){ // Generates the world and sets all va
* Calculate the x coordinate to start drawing this world from so that it is centered at (0,0).
*/
- x_start=0 - getWidth(this) / 2 + GEN_INC / 2 * HLINE;
+ x_start=0 - getWidth(this) / 2;
/*
* Nullify pointers to other worlds.
@@ -257,60 +261,6 @@ LOOP2:
glEnd();
/*
- * If we're drawing the closest/last world, handle and draw the player and entities in
- * the world.
- */
-
- if(current==this){
-
- /*
- * Calculate the line that the player is on
- */
-
- int ph = (p->loc.x + p->width / 2 - x_start) / HLINE;
-
- /*
- * If the player is on the ground, flatten the grass where the player is standing
- * by setting line.gs to false.
- */
-
- if(p->ground==1){
- for(i=0;i<lineCount-GEN_INC;i++){
- if(i < ph + 6 &&
- i > ph - 6 )
- cline[i].gs=false;
- else cline[i].gs=true;
- }
- }else{
- for(i=0;i<lineCount-GEN_INC;i++){
- cline[i].gs=true;
- }
- }
-
- /*
- * Draw the player.
- */
-
- p->draw();
-
- /*
- * Draw non-structure entities.
- */
-
- for(i=0;i<entity.size();i++){
- if(entity[i]->inWorld==this && entity[i]->type != STRUCTURET)
- entity[i]->draw();
- }
-
- }else{
-
- /*for(i=0;i<lineCount-GEN_INC;i++){
- cline[i].gs=true;
- }*/
-
- }
-
- /*
* Draw grass on every line.
*/
@@ -359,21 +309,58 @@ LOOP2:
glEnd();
/*
- * Restore the inverted shading if it was inverted above.
+ * If we're drawing the closest/last world, handle and draw the player and entities in
+ * the world.
*/
- shade*=-1;
+ if(current==this){
+
+ /*
+ * Calculate the line that the player is on
+ */
+
+ int ph = (p->loc.x + p->width / 2 - x_start) / HLINE;
+
+ /*
+ * If the player is on the ground, flatten the grass where the player is standing
+ * by setting line.gs to false.
+ */
+
+ if(p->ground==1){
+ for(i=0;i<lineCount-GEN_INC;i++){
+ if(i < ph + 6 &&
+ i > ph - 6 )
+ cline[i].gs=false;
+ else cline[i].gs=true;
+ }
+ }else{
+ for(i=0;i<lineCount-GEN_INC;i++){
+ cline[i].gs=true;
+ }
+ }
+
+ /*
+ * Draw the player.
+ */
+
+ p->draw();
+
+ /*
+ * Draw non-structure entities.
+ */
+
+ for(i=0;i<entity.size();i++){
+ if(entity[i]->inWorld==this && entity[i]->type != STRUCTURET)
+ entity[i]->draw();
+ }
+
+ }
/*
- * Draw platforms...
+ * Restore the inverted shading if it was inverted above.
*/
- safeSetColor(255+shade*2,0+shade,0+shade);
-
- for(i=0;i<current->platform.size();i++){
- glRectf(current->platform[i].p1.x, current->platform[i].p1.y + yoff - DRAW_Y_OFFSET,
- current->platform[i].p2.x, current->platform[i].p2.y + yoff - DRAW_Y_OFFSET);
- }
+ shade*=-1;
/*
* Draw the next closest world if it exists.
@@ -439,37 +426,7 @@ void World::singleDetect(Entity *e){
* Otherwise, if the entity is above the line...
*/
- }else if(e->loc.y > line[i].y - .002 * deltaTime){
-
- /*
- * Check for any potential platform collision (i.e. landing on a platform)
- */
-
- for(i=0;i<platform.size();i++){
-
- if(((e->loc.x + e->width > platform[i].p1.x) & (e->loc.x + e->width < platform[i].p2.x)) || // Check X left bounds
- ((e->loc.x < platform[i].p2.x) & (e->loc.x>platform[i].p1.x))){ // Check X right bounds
- if(e->loc.y > platform[i].p1.y && e->loc.y < platform[i].p2.y){ // Check Y bounds
-
- /*
- * Check if the entity is falling onto the platform so
- * that it doesn't snap to it when attempting to jump
- * through it.
- *
- */
-
- if(e->vel.y<=0){
-
- e->ground=2;
-
- e->vel.y=0;
- e->loc.y=platform[i].p2.y;
-
- //return; // May not be necessary
- }
- }
- }
- }
+ }else{
/*
* Handle gravity.
@@ -566,10 +523,6 @@ World *World::goWorldFront(Player *p){
return this;
}
-void World::addPlatform(float x,float y,float w,float h){
- platform.push_back((Platform){{x,y},{x+w,y+h}});
-}
-
World *World::goInsideStructure(Player *p){
unsigned int i;
for(i=0;i<build.size();i++){