1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
#include "Gui.h"
#include "TileBase.h"
#include "Menu.h"
#include "Util.h"
#include "Player.h"
#include "Map.h"
#include "Defines.h"
#include <windows.h>
#include <string>
Letter::~Letter()
{
}
Letter::Letter()
{
}
Letter::Letter(int X,int Y,const char* Content)
{
tile = TileBase(getScreenWidth()/2 - 140,getScreenHeight()/2 - 200,280,400,0,0,texture_gui_addr("paper"));
tile_small = TileBase(X,Y,22,32,0,0,texture_gui_addr("paper_small"));
is_open = false;
std::string buffer = Content;
size_t sentence_start = 0;
size_t sentence_end = buffer.find_first_of(".?!",sentence_start);
while(sentence_end != std::string::npos)
{
char line[sentence_end];
strcpy(line, buffer.substr(sentence_start, sentence_end-sentence_start+1).c_str());
lines.push_back("aab");//EVEN WHEN USING CONSTANTS SAME RESULT
///VALUES ARE GOOD HERE, CHECKED WITH COUT
sentence_start = buffer.find_first_not_of(" /t/n", sentence_end+1);
sentence_end = buffer.find_first_of(".?!",sentence_start);
}
}
void Letter::Move(char axis, float speed)
{
tile_small.Move(axis,speed);
}
void Letter::draw()
{
if(!is_open)
if(tile_small.IsOnScreen())
tile_small.draw();
}
void Letter::update()
{
extern Player player;
extern Map world;
extern bool updated;
extern SDL_Event currentEvent;
if(is_open)
if(updated)
if(currentEvent.type == SDL_MOUSEBUTTONUP)
if(currentEvent.button.button == SDL_BUTTON_LEFT)
is_open = false;
if(updated)
if(currentEvent.type == SDL_KEYDOWN)
if(currentEvent.key.keysym.sym == SDLK_SPACE)
if(tile_small.ContainsPoint(player.getX()+16,player.getY()+16))
{
for(unsigned int i=0;i<lines.size();i++)
{
std::cout<<lines[i]<<std::endl;//ERONATED VALUES
world.addTextAnim(tile.getX()+20, tile.getY() + (i+1)*20,random(2,3),EMPTY,lines[i].c_str(),White);
}
}
}
void Letter::open()
{
is_open = true;
}
void Letter::close()
{
is_open = false;;
}
bool Letter::isOpen()
{
return is_open;
}
|