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 - raycrasher

Pages: 1 [2]
16
SFML projects / Cloud Wars - WIP
« on: July 18, 2012, 02:38:12 pm »
Hello!

I would like to present my pet project, Cloud Wars - a space tactical game in the spirit of Battleships Forever(http://www.wyrdysm.com/games.php), but with significant RPG elements. It is still very much a work in progress - all that is finished are the Ship Editor, the GUI (libRocket), the Lua script bindings (Diluculum and SLB), resource managers, particle systems, Box2d physics, and other bits and pieces. The ship sprites are from community resources from Battleships Forever (I have asked permission), slightly edited. All other resources are made by me or from public domain graphics (such as nebulae)

The reason why I'm posting this unfinished project is that I just want to hear ideas from the community for me to mull over whenever I'm stuck. If you want a look at the code, I can send you the code and data.

Some areas on which I need feedback are on the following:

  • Steering behaviors with Box2d. I already read Steering Behaviors for Autonomous Characters (www.red3d.com/cwr/steer/ ) and I'm basing the code from this. The thing that I'm not sure of is how to apply the resultant steering vector to the ship. Thrusters? Pull the ship by the nose? (I tried the latter, it works, but you get some kind of pendulum effect (can be mitigated), and I can't simulate thrusters.) Also, prioritizing/blending steering vectors.
  • A console-based alternative input system, using a syntax somewhat similar to natural language. For example, typing "Leviathan attack all", or "Grizzly retreat BaseRallyPoint" will give the corresponding orders to the named ships. Of course you can use the mouse/keyboard shortcuts, but you can set advanced orders through a console, like "All ships set DefensivePerimeter at WarpPointAlpha radius 500m until enemy detected at Sector Beta or timeout 5min". Automatic suggestions are also available as you type.
  • Control ANY entity, from small fighters, to large ships, to fleets. Different control systems for fighters, gunships, ships and fleets.

I can also offer working code for sprite batching, particle systems, the libRocket GUI interfaces, and the Lua scripting system if anyone's interested.

Thank you for SFML - it's a really great library!



Screenies:

17
SFML projects / SFGUI
« on: February 11, 2012, 06:29:28 am »
Thanks for the quick reply!

I tried loading 128 buttons with images - hangs. Each would be about 10x10 to 70x70 pixels.

I will now try another variant of Trial 1 - Create a TabStrip-like control (Notebook, is it?), and separate the sprites by category into separate pages. Just need to know how would I implement scrolling through said buttons, since each category will have about 40 sprites each minimum. I'm looking at the test.cpp example as I type this, and yes, ScrolledWindow would be the way.

*copypasta mode* :D

Anyway, I was wondering why you used your own sfg::Image for image display - isn't sf::Sprite sufficient?

18
SFML projects / 613 Image buttons
« on: February 11, 2012, 05:47:36 am »
Hello,

I am having some problems trying to create a window where I can display 618 image buttons for the user to choose from.

Trial 1
Loaded the 618 sprites into buttons, and added said buttons to a window. Result: compiles ok, loads ok (according to debugging), but hangs when the GUI updates or displays. 618 buttons loaded without images works though. Loading only a few sprites also works ok.

Trial 2
Loaded the whole spritesheet texture instead of individual sprites; I was thinking of drawing the buttons (with transparent background) over the image, like hot-spots. Displays ok, but I have a 1024x1024 spritesheet, and the window really needs to scroll in order to show the entire sheet. Besides, this is suboptimal, since I cannot sort the sprites according to category.

Trial 2.5
Tried using ScrolledWindow: Runs but does not display the texture. Then I noticed ScrolledWindow looks and feels like a control since it can't be dragged around, so I added it to a regular Window. Crash. Back to Trial 2.

Help! :(

19
Feature requests / sf::XML
« on: January 30, 2012, 09:06:22 am »
boost::property_tree has an XML reader/writer, among others.

20
Graphics / [Theory] Sprite Layering
« on: January 30, 2012, 09:01:08 am »
I have been getting very good results using boost::multi_index, like this:

Code: [Select]

    struct DrawOrder {};
    struct UpdateOrder {};

    typedef multi_index_container<
        shared_ptr<WorldObject>,
        indexed_by<
            ordered_non_unique<tag<DrawOrder>,member<WorldObject,double,&WorldObject::drawPriority> >,
            ordered_non_unique<tag<UpdateOrder>,member<WorldObject,double,&WorldObject::updatePriority> >
        >
    > WorldObjectGroup;

    typedef WorldObjectGroup::index<DrawOrder>::type ObjectsByDrawOrder;
    typedef WorldObjectGroup::index<UpdateOrder>::type ObjectsByUpdateOrder;

    WorldObjectGroup objects; // our object list

///////////////////////////////////////////////////////////////////////////////
// Update all objects:

void World::Update(Duration deltaTime) {

    ObjectsByUpdateOrder &updateList = objects.get<UpdateOrder>();

    ObjectsByUpdateOrder::iterator iter, obj;

    for(iter=updateList.begin(); iter!=updateList.end(); ) {
        obj=iter;
        iter++;

        if(not (*obj)->Update(deltaTime)) {
            updateList.erase(obj);
        }
    }
}


///////////////////////////////////////////////////////////////////////////////
// Draw all objects:

void World::Render() {
    ObjectsByDrawOrder &renderList = objects.get<DrawOrder>();

    GameWindow.SetView(camera.view);
    sf::View view;


    for(auto obj : renderList) {
        view=camera.view;
        sf::Transformable xform = obj->transform;
        if(obj->parallax != 1.0f) {
            view.SetCenter(view.GetCenter() * obj->parallax);
            GameWindow.SetView(view);
            //xform.SetPosition(camera.view.GetCenter() * obj->parallax);

        }

        obj->Render(GameWindow, sf::Transform());
    }
}



Sorry for the mess of code, it's just a copy-paste from the current project I'm working on.

So I get my objects sorted not only according to z-order, but by update order as well! Also, if you're developing a top-down RPG like Zelda or whatnot you could always add an index using the Y coordinate of your object, so you could have characters going behind buildings, etc.

Hope this helps!

21
Graphics / infinitely repeating background
« on: January 30, 2012, 08:49:29 am »
Thanks for the reply! :D

I will try your solution of drawing the same background multiple times; it seems that I would need 4 sprites since the camera can move along both the x and y axis. Be posting the results of the experiment soon! :D

22
Graphics / infinitely repeating background
« on: January 27, 2012, 05:29:46 am »
Hello,

How do I implement an infinitely repeating background that will work well with parallax and camera movement/zooming?

I was thinking about using a small texture with repeating on, and a scaled sprite with an overly large texture rectangle, but it wouldn't be infinite, wouldn't it? ;) And I'm not sure about the math involved in drawing the backgrounds side by side while accounting for camera location and zoom.

FYI, for the parallax, I used a custom Transform passed to window.Render() in which the position of an object is multiplied by a parallax factor and the scale by the zoom factor; and for the camera I used sf::View. The system works quite perfectly, but I am baffled about how to implement the infinite background.

Thanks in advance!  :D

23
SFML projects / SFGUI
« on: January 26, 2012, 12:00:30 pm »
Thank you. I guess I'll just have to live with the increased memory requirements, at least until the next SFGUI release. Thanks for the help!

24
SFML projects / SFGUI
« on: January 25, 2012, 07:32:32 am »
Hello,

Is there a way to use sf::Sprite as the image of a button? See, I have a bunch of sprites already loaded from a giant texture, and it currently looks like if I use sfg::Image I have to load that texture again.

I'm currently looking in the source, maybe I'll add a constructor to sfg::Image that accepts an sf::Sprite.

Thank you for your hard work in SFGUI!

Pages: 1 [2]