Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - game_maker

Pages: [1] 2 3 4
1
General discussions / Re: "Web SFML" using HTML5/Javascript/WebGL
« on: October 30, 2013, 12:08:08 pm »
Hi! "Web SFML" is only possible if someone create a Javascript library similar to SFML coding. However, we have too many javascript libraries around us. Reinventing the wheel would be laborious. So, my suggestion is: modify a good library.

I like EnchantJS. Why do not you take a look at it? You'll like it.

2
General discussions / Re: Android/iOS "Soon"
« on: October 13, 2013, 12:22:04 am »
Excellent news. Thanks SFML-Team for your great job.

3
Network / Re: Request: Problem with accents
« on: September 24, 2013, 03:26:15 am »
Trying to use your solution.

#include <windows.h>
#include <iostream>
#include <sstream>

std::string gethex(int decimal) {
  std::stringstream stream;
  stream << "%" << std::hex << decimal;

  return stream.str();
  }

std::string encode(std::string str)
{
std::string unreserved = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~";
std::string r = "";

    for (int i = 0; i < str.length(); i++ )
    {
      char charcode = str.at(i);

      if (unreserved.find(charcode) != -1) {
        r += charcode;
      } else {
        if (charcode < 128) {
          r += gethex(charcode);
        }
        else
        if (charcode > 127 && charcode < 2048) {
          r += gethex((charcode >> 6) | 0xC0);
          r += gethex((charcode & 0x3F) | 0x80);
        }
        else
        if (charcode > 2047 && charcode < 65536) {
          r += gethex((charcode >> 12) | 0xE0);
          r += gethex(((charcode >> 6) & 0x3F) | 0x80);
          r += gethex((charcode & 0x3F) | 0x80);
        }
        else
        if (charcode > 65535) {
          r += gethex((charcode >> 18) | 0xF0);
          r += gethex(((charcode >> 12) & 0x3F) | 0x80);
          r += gethex(((charcode >> 6) & 0x3F) | 0x80);
          r += gethex((charcode & 0x3F) | 0x80);
        }

      }
    }

return r;
}
 

Now the problem is that the accentued characters become UTF-16 encoded.

Let's say 'á' is 'ff%ff%e1', but I need it be '%c3%a1'.

I need to convert utf-16 (hex) to utf-8 (hex), like above.

Pedro Henrique.

4
Network / Re: Request: Problem with accents
« on: September 24, 2013, 03:13:52 am »
I translated the algorithm to C++ (it compiles fine).

Now I have a problem... out of range:

std::string gethex(char decimal) {
  std::string hexchars = "0123456789ABCDEFabcdef";
  return "%" + hexchars.at(decimal>>4) + hexchars.at(decimal & 0xF);
}

Quote
I have no way of knowing what parts of it you'd need help with.
I don't have experience with bitwise operators. Here you go, :D.

Thanks.

5
Network / Re: Request: Problem with accents
« on: September 24, 2013, 02:29:27 am »
Ixrec, let's say I wanna translate "água" to "%c3%a9gua".

I found a javascript algorithm. I am trying to adapt it.

Can you help me?

#include <windows.h>
#include <iostream>

std::string gethex(char decimal) {
  std::string hexchars = "0123456789ABCDEFabcdef";
  return "%" + hexchars.at(decimal >> 4) + hexchars.at(decimal & 0xF);
  }

std::string encode(std::string str)
{
std::string unreserved = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_.~";
std::string r = "";

    for (int i = 0; i < str.size(); i++ )
    {
      char charcode = str.at(i);

      if (unreserved.find(charcode) != std::string::npos) {
        r += gethex(charcode);
      } else {
        if (charcode < 128) {
          r += gethex(charcode);
        }
        else
        if (charcode > 127 && charcode < 2048) {
          r += gethex((charcode >> 6) | 0xC0);
          r += gethex((charcode & 0x3F) | 0x80);
        }
        else
        if (charcode > 2047 && charcode < 65536) {
          r += gethex((charcode >> 12) | 0xE0);
          r += gethex(((charcode >> 6) & 0x3F) | 0x80);
          r += gethex((charcode & 0x3F) | 0x80);
        }
        else
        if (charcode > 65535) {
          r += gethex((charcode >> 18) | 0xF0);
          r += gethex(((charcode >> 12) & 0x3F) | 0x80);
          r += gethex(((charcode >> 6) & 0x3F) | 0x80);
          r += gethex((charcode & 0x3F) | 0x80);
        }

      }

    }
return r;
}

6
Network / Re: Request: Problem with accents
« on: September 24, 2013, 12:25:28 am »
I wanna convert from std::string to UTF-8 hexadecimal.

I do not use C++11.

I created a tool for translating texts anywhere.

sf::Http http("http://translate.google.com.br/");
sf::Http::Request request("/translate_a/t", sf::Http::Request::Post);

std::string str_base = "ie=UTF-8&oe=UTF-8&hl=pt-BR&client=t&sc=2&sl=";

string Idiomas[] = { "Portuguese", "Spanish", "English", "Estonian", "Arabic", "Russian", "Japanese", "French", "German", "Italian" };

string Idioms[] = { "pt", "es", "en", "et", "ar", "ru", "ja", "fr", "de", "it"};

std::string PegarClipboard()
{
  if (!OpenClipboard(NULL)) return " ";
  HANDLE hData = GetClipboardData(CF_TEXT);
  if (hData == NULL) return " ";
  char * pszText = static_cast<char*>( GlobalLock(hData) );
  if (pszText == NULL) return " ";
  std::string text( pszText );
  GlobalUnlock( hData );
  CloseClipboard();
  return text;
}

void SetClipboard(std::string txt)
{
    OpenClipboard(NULL);
        EmptyClipboard();
        HGLOBAL hg=GlobalAlloc(GMEM_MOVEABLE,txt.size()+1);
        if (!hg){
                CloseClipboard();
                return;
        }
        memcpy(GlobalLock(hg),txt.c_str(),txt.size()+1);
        GlobalUnlock(hg);
        SetClipboardData(CF_TEXT,hg);
        CloseClipboard();
        GlobalFree(hg);
}

std::string Traduzir(std::string str, unsigned short language1, unsigned short language2)
{
    str = str_base+Idioms[language1]+"&tl="+Idioms[language2]+"&q="+str;
    request.setField("Content-Language", Idioms[language2]);
    request.setBody(str);


    sf::Http::Response response = http.sendRequest(request);

    if (response.getStatus() == sf::Http::Response::Ok)
    {
        std::string resposta(response.getBody());
        for(unsigned short i=6; i<resposta.size(); i+=1)
        {
            if (resposta.at(i) == '"')
            {
                std::string sub = resposta.substr(4, i - 4);
                cout <<sub;
                return sub;
            }
        }
    }
    else
        cout<<response.getStatus();
    return "Translation error.";
}
 

This is my almost complete code.

7
Network / Re: Request: Problem with accents
« on: September 23, 2013, 11:37:36 pm »
(I am using Windows 7.)
Thanks Laurent.

I translate the text in the clipboard.

I did this process:

1 - Open Notepad.
2 - Type "%c3%a1gua".
3 - Copy it.
4 - Translate it (using the program).
5 - The result is: water.

So, I know I must encode it to Hexadecimal UTF-8 format.

Does anyone know how to convert it (obviously in C++)?

I made a good research, but I did not find a solution.

Thanks in advance.

8
Network / Request: Problem with accents
« on: September 23, 2013, 04:07:53 am »
Good night, mates!

After multiple tests, I am sure the problem is request.setBody().

It accepts a parameter (std::string). My program gets the text value of clipboard and puts it in request.setBody().

Ex:

std::string Blablabla(std::string str)
{
sf::Http http("http://translate.google.com.br/");
sf::Http::Request request("/translate_a/t", sf::Http::Request::Post);
str = "client=t&sl=en&sc=2&prev=btn&ssel=0&tsel=0&q="+str+"&tl="+Idioms[option];
request.setBody(str);
...
std::string resposta(response.getBody());
return resposta;
}

If I pass "água" (water) as parameter, the request is sent without the 'special' chars ('á', 'ã','ó').

Where is the problem?

Thanks in advance,

Pedro Henrique.

9
General discussions / Re: Android/iOS "Soon"
« on: August 03, 2013, 12:56:36 am »
It's awesome.

Thank you!

10
General discussions / Re: Android/iOS "Soon"
« on: August 02, 2013, 12:35:48 am »
Will the bindings support iOS and Android? Which ones?

11
SFML website / Re: New website
« on: April 30, 2013, 08:42:03 pm »
Excellent job! The site is awesome! I loved it.

Thanks for the new tutorials.

12
General / Re: SFML and Thor 1.1
« on: January 31, 2013, 05:40:01 pm »
I downloaded the GIT version. Now it works perfectly.

Thor is amazing!

Thanks!

13
General / Re: SFML and Thor 1.1
« on: January 31, 2013, 05:22:05 pm »
shared_ptr belongs to C++11, right?

Thanks Nexus.

14
General / SFML and Thor 1.1
« on: January 31, 2013, 05:12:10 pm »
Hi!

I am getting errors, and I can not find the problem.

main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
#include "GameManager.h"

using namespace std;

int main()
{
    ...
    GameManager game;

    game.Init();
    game.Load();

    while (window.isOpen())
    {
        ...
        window.clear();
        game.Draw(window);
        window.display();
    }
    return 0;
}
 

GameManager.cpp
#include "GameManager.h"
#include "Resource.h"
GameManager::GameManager(){};
GameManager::~GameManager(){};
phResource rmgr;
 Textura textura = rmgr.sprite_add("Bairros.png");
 sf::Sprite sprite(*textura);
...
void GameManager::Draw(sf::RenderWindow &window)
{
    window.draw(sprite);
}
...
 

ObjectManager.cpp
#include "ObjectManager.h"
...
 

Resource.cpp
#include "Resource.h"

phResource::phResource(){}
phResource::~phResource(){}

Textura phResource::sprite_add(std::string p)
{
TextureKey key = TextureKey::FromFile(p);
return (mgr.Acquire(key));
}
void phResource::sprite_delete(TextureKey key)
{
mgr.Release(key);
}
 

GameManager.h
#ifndef GERAL_H
#define GERAL_H
#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>
#define ScreenWidth 800
#define ScreenHeight 600

class GameManager
{
    public:
        GameManager();
        ~GameManager();

    //Main functions
        void Init();
        void Load();
        void Update(sf::Event event);
        ...
        void Draw(sf::RenderWindow &window);
    //Keyboard
     ...
};

#endif
 

ObjectManager.h
#ifndef OBJECTMANAGER_H
#define OBJECTMANAGER_H
#include <string>
#include <iostream>
#include <SFML/Graphics.hpp>
...
class Objeto
{
public:
   ...
};
#endif
 

Resource.h
#ifndef PH_RESOURCE_H
#define PH_RESOURCE_H
#include<Thor/Resources.hpp>

using thor::Resources::TextureKey;
typedef thor::ResourcePtr<sf::Texture> Textura;

class phResource
{
public:
    thor::ResourceManager<sf::Texture> mgr;

    phResource();
    ~phResource();
    Textura sprite_add(std::string p);
    void sprite_delete(TextureKey key);
};

#endif
 

The errors:

obj\Release\Resource.o:Resource.cpp|| undefined reference to `_imp___ZN4thor9Resources10TextureKey8FromFileERKSsRKN2sf4RectIiEES3_'|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE4findERS4_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE4findERS4_]+0x1f)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'
|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE10_M_insert_EPKSt18_Rb_tree_node_baseSJ_RKSA_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE10_M_insert_EPKSt18_Rb_tree_node_baseSJ_RKSA_]+0x19d)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_]+0x12)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'
|
obj\Release\Resource.o:Resource.cpp:(.text$_ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_[__ZNSt8_Rb_treeIN4thor9Resources10TextureKeyESt4pairIKS2_NS0_6detail12ResourceSlotIN2sf7TextureEEEESt10_Select1stISA_ESt4lessIS2_ESaISA_EE16_M_insert_uniqueERKSA_]+0x55)||undefined reference to `_imp___ZN4thor9ResourcesltERKNS0_10TextureKeyES3_'|
obj\Release\Resource.o:Resource.cpp:(.text$_ZN4thor15ResourceManagerIN2sf7TextureENS_9Resources10TextureKeyEE11AddResourceERKS4_[__ZN4thor15ResourceManagerIN2sf7TextureENS_9Resources10TextureKeyEE11AddResourceERKS4_]+0x62)||undefined reference to `_imp___ZNK4thor9Resources10TextureKey4LoadEv'
|
||=== Build finished: 6 errors, 0 warnings (0 minutes, 5 seconds) ===|
 

I am using: Windows 7, SFML 2.0, Code::Blocks (MinGW), Thor 1.1.

Thanks in advance.

15
SFML website / Re: Copyright
« on: January 30, 2013, 11:38:47 pm »
Oh, now I know.

Bye

Pages: [1] 2 3 4
anything