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.


Topics - Krofna

Pages: [1]
1
Graphics / sf::Text, UTF-8 and Debian
« on: October 24, 2013, 11:23:04 am »
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Bug");
    sf::Text text;
    sf::Font font;
    sf::Event event;

    if (!font.loadFromFile("test.ttf"))
        return 0;

    std::basic_string<sf::Uint32> utf32line;
    std::string line = "&#12384;&#12365;&#12414;&#12367;&#12425;";
    sf::Utf8::toUtf32(line.begin(), line.end(), back_inserter(utf32line));
   
    text.setFont(font);
    text.setCharacterSize(30);
    text.setColor(sf::Color::Red);
    text.setString(utf32line);

    while (window.isOpen())
    {
        while (window.pollEvent(event))
            if (event.type == sf::Event::Closed)
                window.close();

        window.clear(sf::Color::White);
        window.draw(text);
        window.display();
    }
}

test.ttf is Freemono from Debian package fonts-freefont-ttf. line variable contains UTF-8 encoded string だきまくら, but code tag somehow breaks it.
And here is some FAQ from irc: Yes, freemono supports kana(see; http://www.gnu.org/software/freefont/coverage.html ), No  wchar_t is not going to work. I see (correct number of) boxes with ? in them.

tl;dr: Should work, doesn't.

2
SFML projects / [WIP] MMORPG project - recruiting
« on: July 25, 2012, 10:15:06 pm »
I named it...

Warrior of Dreamworld

...which is actually just a placeholder name, but w/e...

It is 2D top down MMORPG with real time skill based (you aim manually) combat.
It is written in C++ & SQL.

Additional Dependencies:
(stuff required to compile it)
boost,
MySQL C Connector,
MySQL C++ Connector

(stuff required to run it)
MySQL Server -  http://dev.mysql.com/downloads/mysql/ (30 MB)
MSVC++ redist pack - http://www.microsoft.com/en-us/download/details.aspx?id=5555 (5 MB)

I havent done too much work on it. For now you can:
- Log into (/empty/, there are only players in it) world and move camera around with your mouse
- Move your character around with WASD
- Chat with other players
- Shoot fire bolts and kill other players with it with mouse click

Screenshot: (please dont be hatin' on tiles, its a placeholder)
http://img513.imageshack.us/img513/1837/wodss.png

Video: (Looks pretty bad because its compressed to 3MB, but I guess it does the trick)
http://www.youtube.com/watch?v=XLicqjlSihU&feature=youtu.be

Executables: for windows: https://github.com/krofna/Warrior-of-Dreamworld/downloads
NOTE: Before running server.exe you will need to do following:
- See "stuff required to run it"
- create new database called wod_test_db
- execute the wod_full_db.sql
- modify WorldServerConfig.conf : second line is MySQL server username and third line is password

Source: https://github.com/krofna/Warrior-of-Dreamworld
If you want to compile this, you might want to contact me. Its pretty painful, mainly because of MySQL connector... There are also no make/project files of any kind...

I am also recruiting few programmers (currently working alone :( ), PM me :)

Comments are welcome.

3
Graphics / Clipped sprite?
« on: May 21, 2012, 03:35:07 pm »
This image:
http://img138.imageshack.us/img138/3944/redsolider.png

Somehow gets clipped:
http://img16.imageshack.us/img16/5748/windoww.png

Code:
extern sf::RenderWindow Window;

int Combat::MainLoop()
{
    sf::Texture CombatGUI, CreatureTexture;
    CreatureTexture.loadFromFile(enemy->CombatTextureFileName);
    CombatGUI.loadFromFile("Graphics/CombatScreen.jpg");
    CreatureSprite.setTexture(CreatureTexture);
    CreatureSprite.setPosition(320.0f, 100.0f);

    sf::Event Event;

    while(Window.isOpen())
    {
        while(Window.pollEvent(Event))
        {
            //...
        }
        Window.clear();
        Window.draw(sf::Sprite(CombatGUI));
        Window.draw(ArrowSprite);
        Window.draw(CreatureSprite);
        DrawPlayerStats();
        DrawCommandText(CommandList);
        for(auto itr = CombatTexts.begin(); itr != CombatTexts.end(); ++itr)
            Window.draw(*itr);
        Window.display();
    }
    return 2;
}

Why does that happen?

I'm using 20 days old SFML.

4
General / Weird rendering on debian...
« on: April 11, 2012, 08:36:10 pm »
Compiling&running my game (which runs fine on Windows) on debian I get pinky screen full of artifacts from eariler screens, bunch of mirroring, misplacing, missing elements, etc. Well, just look at the picture:



- Debian 6.0.4, kernel 2.6.32-5-amd64
- ATI HD 6850 Sapphire
- latest SFML 2.0

Any ideas why does this happen?

5
SFML projects / Dreaming Warrior: RPG
« on: March 20, 2012, 09:26:22 am »
Hi guys. I present you my first game: Dreaming Warrior. Its 2D single player tile based role playing game with command driven turn based combat.

You can get the sources @ https://github.com/krofna/Dreaming-Warrior
Or, the compiled binary for Windows @ https://github.com/krofna/Dreaming-Warrior/downloads

How does it look like?

Choose 'New Game':
https://legacy.sfmluploads.org/cache/pics/221_NewGame.png

Pick mage for 'Hard' difficulty and warrior for 'Insane': (You'll see what I mean)
https://legacy.sfmluploads.org/cache/pics/222_Class.png

Write name for your character:
https://legacy.sfmluploads.org/cache/pics/223_Name.png

Navigate your character using arrows and 'collide' with NPCs for interaction:
All humans are friendly; orcs and dragons are unfriendly.
Also be wary of 'random encounters'. You may get attacked from ambush!
Pro tip: Always take quests. If you kill all enemies and quest isnt complete, you're stuck.
https://legacy.sfmluploads.org/cache/pics/224_World.png

Quest Screen:
https://legacy.sfmluploads.org/cache/pics/225_Quest.png

Vendor Screen:
Here you spend money earned by doing quests/killing orcs.
Food regenerates health when used, water regenerates mana.
Potions cost more, but can be used in combat! Red is health, blue is mana.
Esc returns to 'main menu'.
https://legacy.sfmluploads.org/cache/pics/226_Vendor.png

Character Screen:
By pressing 'C' this pops up:
I think its self explanatory, so I won't write too much about it.
You only need to know that 'esc' button returns to 'main menu' and 'enter' either consumes item or increases selected attribute if you have points left.
https://legacy.sfmluploads.org/cache/pics/227_Char.png

Combat:
Self explanatory... Use arrows and 'enter', esc to return to main menu.
https://legacy.sfmluploads.org/cache/pics/228_Combat.png

Pro tips:
S button saves the game. As well as exiting it using X button on window and entering new map. If it crashes (crash is usually exit(1) invoked if something weird is going on) or you exit by using X on console it wont save, I didnt set the atexit();

Want to modify/make your own world?
What you want is modify .txt files in World folder, whole thing is loaded from there, nothing is hard-coded.
Check out World Structure folder for instructions and MapEditor.exe to edit terrain and objects!
Use + and - to advance to next/prev map. Click on objects/textures on right and place them at map on left.
https://legacy.sfmluploads.org/cache/pics/229_MapEdit.png

Bugs/Suggestions?
This is my first serious program which I started writing after 4 months of learning C++, and it may (or may not be) horribly written. It was written in hurry, for high-school-students-programming-contest, but they disliked it and it failed its purpose, so I post it here seeking your opinion.
If you find any bugs, or suggestions, regarding code or game, feel free to notify me, or even open pull request on github ;)

Also, sorry for bad english, may be found both in game and this post :/

P.S.
https://github.com/krofna/Dreaming-Warrior/commit/0d52edcef5583e991a5c40513965f6f5d5f4d41f
Now I have bunch of code with 2 different naming conventions  :evil:

6
Graphics / Performance question
« on: February 19, 2012, 03:47:12 pm »
When loading tiled map, I draw it once on a RenderTexture instance and then I copy its texture into sf::Texture instance which is then drawn on every frame, beacuse that seemed to be very fast and portable way to do it (read: tested & works on shit hardware). But then I figured i need a way to hide part of map from player. Since I could no longer choose what tiles to draw on each frame.
And this is what I did:

Code: [Select]

class Game
{
    //...
    sf::Sprite HideMapHack[24][32];
};
//...
sf::Texture HideHack;
    HideHack.LoadFromFile("Tiles/Hack.png"); //Hack.png is 32x32 completly black tile
    for(int y=0; y<24; ++y)
    {
        for(int x=0; x<32; ++x)
        {
            HideMapHack[y][x].SetTexture(HideHack);
            HideMapHack[y][x].SetPosition(x*32, y*32);
        }
    }


And on every frame, after drawing map, enemies and stuff, I do this:
Code: [Select]
inline int Distance(int x1, int y1, int x2, int y2)
{
    return (int)sqrt((float)(x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
}
//...
void DrawAll()
{
    //...
for(int y=0; y<24; ++y)
    {
        for(int x=0; x<32; ++x)
        {
            if(Distance(Player.GetX()/32, Player.GetY()/32, x, y) > 3)
            {
                Window.Draw(HideMapHack[y][x]);
            }
        }
    }
}


Was that a smart idea? Is there a better way to do this?

7
General / Crash when Game exits
« on: January 28, 2012, 03:34:24 pm »
After an hour of painfull debugging I have figured out that program will crash ON EXIT if during run-time it enters multiple "main" game loops.
Weird? I know right?

This is my example:

GameLoop calls the Encounter:
Code: [Select]
void Game::GameLoop()
{
    Map Map(Window, World, *this);
    Player Player(Map, LoadFileName);

    while(Window.IsOpened())
    {
        sf::Event Event;
        while(Window.PollEvent(Event))
        {
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                return;
            else if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Up))
            {
                switch(Player.Move(NORTH))
                {
//...
                case 2:
                    Encounter(Map, Player, NORTH);
                    break;
                }
            }
//...
        }
        Window.Clear();
        DrawAll(Map, Player);
        Window.Display();
    }
}


Then Encounter creates Combat object and enters new loop:

Code: [Select]
void Game::Encounter(Map &map, Player &player, Orientation Direction)
{
    switch(Direction)
    {
    case NORTH:
        switch(player.InteractsWith)
        {
        case ENEMY:
            for(auto itr = Enemies.begin(); itr != Enemies.end(); itr++)
            {
                if(itr->GetX() == player.GetX()/32 && itr->GetY() == player.GetY()/32-1)
                {
                    Combat Combat(Window, player, *itr);
                    switch(Combat.MainLoop())
                    {
//...
                    }
                    return;
                }
            }
            break;
//...
        }
        break;
//...
}
}


Then in Combat::MainLoop() stuff happens:

Code: [Select]
int Combat::MainLoop()
{
    //...
    while(window.IsOpened())
    {
        while(window.PollEvent(Event))
        {
             //...
        }
        window.Clear();
        //...
        window.Display();
    }
}


Now. For sake of debugging, I put the return; right before while(window.PollEvent(Event)), and program did not crash upon game exit. Also, if i put return on next line, it will crash on exit.

These are crash "details":
Quote
Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   2D Krofna Game Project.exe
  Application Version:   0.0.0.0
  Application Timestamp:   4f240720
  Fault Module Name:   atioglxx.dll
  Fault Module Version:   6.14.10.11318
  Fault Module Timestamp:   4ebb3dc2
  Exception Code:   c0000005
  Exception Offset:   0086c161
  OS Version:   6.1.7600.2.0.0.256.1
  Locale ID:   1050
  Additional Information 1:   0a9e
  Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:   0a9e
  Additional Information 4:   0a9e372d3b4ad19135b953a78882e789



Any idea why this happens?

8
Graphics / sf::RenderTexture issue?
« on: January 01, 2012, 10:48:59 am »
It appears that sf::RenderTexture only work on modern graphic cards (It failed to render texture on ATI Mobility Radeon X1600).
Since I'm making tile-based game, I need more portable and efficient way to do this.

It is to my understanding that drawing tile by tile(between 24*32 and 24*32*2 tiles, depending on number of world objects) on each frame is very slow, so I'm now out of ideas.

How should I fix this problem?

EDIT: This is code

9
Graphics / Why does sf::RenderTexture rotate texture?
« on: December 29, 2011, 01:33:31 pm »
For some weird reason, when I load tile map into sf::RenderTexture, and then display it like this:

Code: [Select]
void Map::ShowMap()
{
    sf::Sprite sprite(RenderMapTexture.GetTexture());//RenderMapTexture is object of sf::RenderTexture
    MapWindow->Draw(sprite);//MapWindow is object of sf::RenderWindow
    //Display is called in game loop right after calling Map::ShowMap();
}


Texture showed gets rotated for 180 degrees. I tried rotating sprite to counter that, but then screen goes black.

This is how it looks like:

http://img854.imageshack.us/img854/6717/rotirano.png

One thing is sure tho; my tiles arent rotated :D

Any idea why this happens?

10
Graphics / Heavy flickering?
« on: December 26, 2011, 03:02:04 pm »
Hey.

I got a weird problem with SFML 2.0; The screen is flickering heavily on Windows 7 x86 using Radeon HD 6850 Sapphire, compiled with MS VC++ 2010.
When ran on other computers it works perfectly.

This is very minimum code required to reproduce problem:

Code: [Select]
#include <SFML\Graphics.hpp>

int main()
{
    sf::RenderWindow Window;
    Window.Create(sf::VideoMode(32, 32, 32), "Test Prozor");
    Window.SetFramerateLimit(60);
    sf::Sprite Sprite;
    sf::Texture Texture;
    Texture.LoadFromFile("zeleno.bmp");
    Sprite.SetTexture(Texture);
    Window.Draw(Sprite);

    while (Window.IsOpened())
    {
        sf::Event Event;
        while(Window.PollEvent(Event))
        {
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                return 0;
        }
        Window.Display();
    }
}


Any idea why is this happening?

11
General / Problem with setting up SFML
« on: November 02, 2011, 03:32:57 pm »
I used the sample program to test if I set up SFML propertly, and it compiled and linked propertly. But when I start the program I get error 'This application has failed to start beacuse sfml-system.dll was not found. Re-installing the application may fix the problem.'
Now this is a bit confusing error beacuse I added
Quote
C:\Documents and Settings\User\Desktop\Mislav\SFML-1.6\lib
at Tools->Options->Projects and Solutions->VC++ Directories

I'm using Visual C++ 2008 Express Edition on Windows XP SP2.

Help would be appreciated :)

Thanks in advance.

Pages: [1]