aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2015-09-30 19:46:44 -0400
committerClyne Sullivan <tullivan99@gmail.com>2015-09-30 19:46:44 -0400
commit67b62dde3dfd4fddba82940894f5b3416eee4c06 (patch)
tree8ba3646df76230750900ca2bc0c31f907bde6a87
parent7fbac4fc005baed6bc94d342cf7df2c8ad7a359a (diff)
more fonts, entity name displays
-rw-r--r--Changelog3
-rw-r--r--include/entities.h1
-rw-r--r--src/entities.cpp6
-rw-r--r--src/main.cpp22
-rw-r--r--src/ui.cpp23
-rw-r--r--src/world.cpp5
-rw-r--r--ttf/8-BIT WONDER.TTFbin0 -> 14328 bytes
-rw-r--r--ttf/PIXEAB__.TTFbin0 -> 57408 bytes
-rw-r--r--ttf/PIXEARG_.TTFbin0 -> 57520 bytes
-rw-r--r--ttf/Perfect DOS VGA 437 Win.ttfbin0 -> 82676 bytes
-rw-r--r--ttf/Perfect DOS VGA 437.ttfbin0 -> 81192 bytes
11 files changed, 45 insertions, 15 deletions
diff --git a/Changelog b/Changelog
index 901918d..fa7b5de 100644
--- a/Changelog
+++ b/Changelog
@@ -54,3 +54,6 @@
- began work on giving names to NPCs
- began working on config file
- created a bug file
+
+ - added displaying of entity names on mouse hover
+ - found more fonts
diff --git a/include/entities.h b/include/entities.h
index 3d2bbef..b58d569 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -23,6 +23,7 @@ public:
// |-> 1 Merchant
vec2 loc; //location and velocity of the entity
vec2 vel;
+ bool near;
bool right,left, canMove; //movement variables
bool alive; //the flag for whether or not the entity is alive
unsigned char ground; //variable for testing what ground the entity is on to apply certain traits
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);
+ }
}
}
}
diff --git a/ttf/8-BIT WONDER.TTF b/ttf/8-BIT WONDER.TTF
new file mode 100644
index 0000000..6d9b397
--- /dev/null
+++ b/ttf/8-BIT WONDER.TTF
Binary files differ
diff --git a/ttf/PIXEAB__.TTF b/ttf/PIXEAB__.TTF
new file mode 100644
index 0000000..c0cc3d9
--- /dev/null
+++ b/ttf/PIXEAB__.TTF
Binary files differ
diff --git a/ttf/PIXEARG_.TTF b/ttf/PIXEARG_.TTF
new file mode 100644
index 0000000..8eaf339
--- /dev/null
+++ b/ttf/PIXEARG_.TTF
Binary files differ
diff --git a/ttf/Perfect DOS VGA 437 Win.ttf b/ttf/Perfect DOS VGA 437 Win.ttf
new file mode 100644
index 0000000..d03b1c5
--- /dev/null
+++ b/ttf/Perfect DOS VGA 437 Win.ttf
Binary files differ
diff --git a/ttf/Perfect DOS VGA 437.ttf b/ttf/Perfect DOS VGA 437.ttf
new file mode 100644
index 0000000..f5cbfc0
--- /dev/null
+++ b/ttf/Perfect DOS VGA 437.ttf
Binary files differ