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

Pages: [1]
1
General / Callback implementation question
« on: May 25, 2016, 04:43:54 am »
Hi,

This is not so much a direct technical question (yet) but a call for help to move in the right direction.
I hope this is not too long of a question, but fear it may be.

Problem statement
=================

1.) i have a game class
2.) i have a generic button class
3.) i have a generic menu class
4.) I have button and menu members of game class and they both are drawn on the screen
5.) I want, when the button is pressed, for the menu to open if its currently closed
   
This got me to thinking that my generic button class needs some way of storing a callback function for what to do when the button is pressed.

I started researching callback functions, function pointers, std::function, std::bind, etc and with those were examples that made basic assumptions.

Some of the examples were dealing only with basic functions and not member functions of specific objects.

After looking at a lot of answers and syntax I realized the TOP answer here came closest to describing what I'm trying to do, but still not quite because its hard-coding class type and I haven't really tried using templates at all yet.

http://stackoverflow.com/questions/10537131/how-to-pass-a-method-as-callback-to-another-class

It may be what I'm trying to do is just too far beyond my current C++ skill level?.

On the same question, there was an answer by Ed Heal that looked like an intriguing alternative that may not be as complicated to implement, wondering what people here thought of his answer to use pure virtual functions instead of typedef with std::function to avoid some of the complexity.

Thanks.

2
Graphics / sf::Drawable and const question
« on: May 18, 2016, 06:32:38 am »
Hi,

I have a class that is inheriting from sf::Drawable and in the draw() pure virtual function that I am defining for this class I decided that I wanted to loop through a vector of objects and draw some sf::Text output by re-using the same member object and just changing the string, position, and then drawing it.

I soon ran into problems because the draw() function is declared as const.

void gui_table::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
        // apply the transform
        states.transform *= getTransform();

        // draw the table background
        target.draw(m_vertices);

        // draw the column names
        std::vector<column>::iterator itr;

        for (itr = m_column_headers.begin(); itr != m_column_headers.end(); ++itr) {
                m_text.setPosition(itr->rect.left + 5, itr->rect.top + 5);
                m_text.setString(itr->value);
                target.draw(m_text);
        }
}
 

Severity   Code   Description   Project   File   Line   Suppression State
Error   C2679   binary '=': no operator found which takes a right-hand operand of type 'std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<gui_table::column>>>' (or there is no acceptable conversion)   Dark Ruins   C:\Users\Erdrick\Documents\Visual Studio 2015\Projects\Dark Ruins\Dark Ruins\gui_table.cpp   64   

This got me to thinking about why draw() is declared as const?  I guess we should not expect to change things here, but I was thinking which of several approaches would be best.

1.) Should I be setting up a vector of sf::Text ahead of time to draw before i get to the draw() function?
2.) Should I make my own draw() function that is not const?
3.) Is there another recommended approach for what I am trying to do?



3
SFML projects / Dark Ruins
« on: May 08, 2016, 06:06:53 am »
Hey Everybody!

This is the development log for

Game: Dark Ruins

Summary

Dark Ruins is a unique combination of simulation, strategy, and role-playing.

Written in C++ and utilizing the SFML 2.3 library, Dark Ruins is a new game that will allow you to personally manage a guild of adventurers that engage in dungeon-delving conquests for both treasure and personal growth.

Add greenhorn heroes to your guild and send them into dungeons to learn new skills, accumulate weapons, armor, and magical artifacts while discovering their true potential over time.

Make financial decisions to invest in your guild, merchants, and support systems.  Strive to build a hall of fame fantasy roster that can tackle the game’s toughest challenges!





Change Log

Content subject to change; Focused on learning, having fun, progress, and adherence to vision in roughly that order.

06/2016
        + GUI Table Improvements
                - Button support
                - Movable geometry
                - Tool-tip support
                - Skill Icons support

05/2016
        + Added GUI table class and features
                - Column headers
                - Add Rows
                - Icon support
                - Sort by Column
                - Highlight/Select Rows
        + Minimap
   + Multiple Enemy Combat
   + Game States
      - Intro (SFML Intro, thanks Hapax/eXpl0it3r)
      - Title Screen (Night in ruins, created by AdhirAnimator.. thanks)
      - Gameplay

04/2016
   + Vertex based tile map
   + Random recruit naming
   + Scrollable text box
   + Scrollable View with Follow Capability
   + Pathfinding algorithm
   + Button
   + Single Enemy Combat

03/2016
   + Basic game systems
       - Map
      - Item/Inventory
      - Currency
      - Guild Member
      - Resource Manager (Thor, thanks Nexus)
   + Smooth Unit Movement

Thanks SFML community!  Looking forward to having more as we go along.

4
Graphics / RectangleShape bug or user error?
« on: April 10, 2016, 06:28:16 am »
Hi,

I found something odd about RectangleShape that I'm not sure if I should report as a bug.

After calling setSize and setPosition (example below)

        sf::RectangleShape m_healthbar;

        m_healthbar.setSize(sf::Vector2f(m_bounding_box_width * .7f, m_bounding_box.getSize().y * .1f));
        m_healthbar.setPosition(m_xpos +
                (m_bounding_box_width * .025f) +
                (m_healthbar_label_text.getLocalBounds().width) +
                10
                , m_ypos + (m_bounding_box_height * .025f) + m_font_size + 5);

        auto dbx = m_healthbar.getPosition().x;         // This returns 1620.59998, which is what I want
        auto dby = m_healthbar.getPosition().y;         // This returns  151.00000, which is what I want
        auto dbl = m_healthbar.getLocalBounds();        // This returns left and top each as 0, seems wrong?
        auto dbg = m_healthbar.getGlobalBounds();       // This returns left as 1620.59998
                                                           //and top as 151.00000, which is perfect

 

I don't understand why getLocalBounds is returning left and top each as 0.  Later in the code I tried to use getLocalBounds to get the position of the shape and it didn't work because it was returning 0 for left and top.  After switching to getGlobalBounds it started working the way I wanted.

Thank you!

5
Hi,

This is my first message in the SFML forums.  Thank you to those of you who are building and/or supporting this library.

I have this statement in my code somewhere

sf::SoundBuffer buffer;
 

and I'm using Visual Studio 2015 with a console window on the side.  The following message appears on the console after this statement executes:

AL lib: (EE) MMDevApiMsgProc: Unexpected message: 49376

This is not causing any warnings or failures at compile/link time but I was wondering if anyone else saw this before and knows what it is?

Thanks!


Pages: [1]
anything