aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/entities.cpp6
-rw-r--r--src/main.cpp22
-rw-r--r--src/ui.cpp23
-rw-r--r--src/world.cpp5
4 files changed, 41 insertions, 15 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 85505ce..8ccd5e1 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -11,6 +11,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
vel.y = 0;
right = false;
left = false;
+ near = false;
ticksToUse = 0;
canMove = false;
ground = false;
@@ -62,8 +63,9 @@ void Entity::getName(){
if((fgets(bufs,16,(FILE*)names)) != NULL){
std::puts(bufs);
bufs[strlen(bufs)-1] = 0;
- name = bufs;
+ strcpy(name,bufs);
}
+ free(bufs);
//delete(bufs);
}
@@ -89,6 +91,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
subtype = 0;
alive = true;
canMove = true;
+ near = false;
}
void NPC::addAIFunc(int (*func)(NPC *)){
@@ -110,6 +113,7 @@ Structures::Structures(){ //sets the structure type
type = STRUCTURET;
speed = 0;
alive = true;
+ near = false;
}
unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure based off of type and coords
diff --git a/src/main.cpp b/src/main.cpp
index ea19668..d39bd92 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -76,8 +76,7 @@ int main(int argc, char *argv[]){
}
ui::initFonts();
- ui::setFontFace("ttf/VCR_OSD_MONO_1.001.ttf");
- ui::setFontSize(16);
+ ui::setFontFace("ttf/Perfect DOS VGA 437.ttf");
initRand(millis()); // fix
glViewport(0,0,SCREEN_WIDTH, SCREEN_HEIGHT);
@@ -187,8 +186,9 @@ void render(){
}else if(debugDiv%10==0){
rndy = player->loc.y;
}
- ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-ui::fontSize,"FPS: %d\nD: %d G:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f",
- fps,d,player->ground,SCREEN_WIDTH,SCREEN_HEIGHT,entity.size(),player->loc.x,rndy);
+ ui::setFontSize(16);
+ ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-ui::fontSize,"FPS: %d\nD: %d G:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nQc: %u",
+ fps,d,player->ground,SCREEN_WIDTH,SCREEN_HEIGHT,entity.size(),player->loc.x,rndy,player->qh.current.size());
}
ui::draw(); // Draw any UI elements if they need to be
@@ -213,8 +213,6 @@ void render(){
glVertex2i(mx,my-HLINE*3.5);
glEnd();
- ui::putText(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT/2,"Quest count: %d",player->qh.current.size());
-
glPopMatrix(); //take the matrix(s) off the stack to pass them to the renderer
SDL_GL_SwapWindow(window); //give the stack to SDL to render it
}
@@ -226,11 +224,13 @@ void logic(){
if(entity[i]->alive&&entity[i]->type == NPCT){
entity[i]->wander((rand()%120 + 30), &entity[i]->vel);
if( pow((entity[i]->loc.x - player->loc.x),2) + pow((entity[i]->loc.y - player->loc.y),2) <= pow(40*HLINE,2)){
- if(mx >= entity[i]->loc.x && mx <= entity[i]->loc.x + entity[i]->width && my >= entity[i]->loc.y && my <= entity[i]->loc.y + entity[i]->width
- && (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT))){
- entity[i]->interact();
- std::cout <<"["<<i<<"] -> "<< entity[i]->name << ", " << (std::string)(entity[i]->gender == MALE ? "Male" : "Female") << std::endl;
- }
+ if(mx >= entity[i]->loc.x && mx <= entity[i]->loc.x + entity[i]->width && my >= entity[i]->loc.y && my <= entity[i]->loc.y + entity[i]->width){
+ entity[i]->near=true;
+ if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(SDL_BUTTON_RIGHT)){
+ entity[i]->interact();
+ std::cout <<"["<<i<<"] -> "<< entity[i]->name << ", " << (std::string)(entity[i]->gender == MALE ? "Male" : "Female") << std::endl;
+ }
+ }else entity[i]->near=false;
}
}
}
diff --git a/src/ui.cpp b/src/ui.cpp
index c14b4ff..de875b9 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -78,7 +78,25 @@ namespace ui {
h=ftf->glyph->bitmap.rows;
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,ftex);
- if(c=='-')y+=fontSize/3;
+ switch(c){
+ case '^':
+ case '*':
+ case '`':
+ case '\'':
+ case '\"':
+ case '-':y+=fontSize/3;break;
+ case '~':
+ case '<':
+ case '>':
+ case '+':
+ case '=':y+=fontSize/5;break;
+ case 'g':
+ case 'q':
+ case 'y':
+ case 'p':
+ case 'j':y-=fontSize/4;break;
+ default:break;
+ }
glBegin(GL_QUADS);
glColor3ub(255,255,255);
glTexCoord2f(0,1);glVertex2f(x,y);
@@ -97,7 +115,7 @@ namespace ui {
float xo=x,yo=y;
do{
if(s[i]=='\n'){
- yo-=fontSize*1.15;
+ yo-=fontSize*1.05;
xo=x;
}else if(s[i]==' '){
xo+=fontSize/2;
@@ -125,6 +143,7 @@ namespace ui {
if(dialogBoxExists){
glColor3ub(0,0,0);
glRectf(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT,player->loc.x+SCREEN_WIDTH/2,SCREEN_HEIGHT-SCREEN_HEIGHT/4);
+ setFontSize(16);
putString(player->loc.x-SCREEN_WIDTH/2,SCREEN_HEIGHT-fontSize,dialogBoxText);
}
}
diff --git a/src/world.cpp b/src/world.cpp
index 1d56643..2a0e471 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -117,7 +117,10 @@ LOOP2: // Draw each world
for(i=0;i<entity.size()+1;i++){
if(entity[i]->inWorld==this){
entity[i]->draw();
- ui::putText(entity[i]->loc.x,entity[i]->loc.y,"%d",i);
+ if(entity[i]->near){
+ ui::setFontSize(14);
+ ui::putText(entity[i]->loc.x,entity[i]->loc.y-ui::fontSize-HLINE/2,"%s",entity[i]->name);
+ }
}
}
}