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

Pages: [1] 2 3 ... 5
1
SFML projects / Re: Dark Ruins
« on: July 02, 2016, 06:01:26 pm »
End of June Update

Significant improvements to GUI Table to support movable geometry, tool-tips, buttons, and skill icons.

2
Graphics / Re: Nothing drawing to screen
« on: July 02, 2016, 04:59:31 pm »
Hi,

The code example you provided seems to be incomplete, what does your main cpp look like and what are you trying to draw?


I see you are trying to draw test, but what is test?
window.draw(test);
 

3
General / Re: Issues with Pong and Game Loop
« on: June 18, 2016, 04:19:54 pm »
Hi,

After you move the ball you should store its position again right away since its used in a condition immediately afterwards, but you didn't update the position variable.

        // Move the ball
        Ball.move(BallX, BallY);
        //Move the computer controlled paddle

        //Move the paddle up
        if (BallPos.y < PaddlePos.y)
 

same for the paddle

4
General / Re: Issues with Pong and Game Loop
« on: June 18, 2016, 04:17:02 pm »
Hi,

After you move the ball you should store its position again right away since its used in a condition immediately afterwards, but you didn't update the position variable.

        // Move the ball
        Ball.move(BallX, BallY);
        //Move the computer controlled paddle

        //Move the paddle up
        if (BallPos.y < PaddlePos.y)
 

5
In this project I wanted to change my code desing to be more modular, so the classes should not contain the more variables and function than they need.

Thank you Brax for the code example, now I understand your point much better.
I think I may want to investigate the method you are talking about as my code gets more complex.

6
Hi.  I personally dont see whats wrong with having game objects draw themselves.  In fact all of mine do.  It sounds like you may be trying to optimize too early but example code could help in understanding your concern.

7
SFML projects / Re: Jeffrey the Robot
« on: June 03, 2016, 04:41:47 am »
Erdrick, what size were you running the game at? By default the game window should by 800x600 and I tested it and I can see the next jump at that size.

Don't worry that much about it!  Pretty sure I didn't resize the window, if I try it again I'll let you know if its an issue.  Basic experience is fun.. point is just keep working at it.

8
SFML projects / Re: Jeffrey the Robot
« on: June 02, 2016, 03:57:19 am »
Hi, I downloaded it and played it too.  No deaths!  Although there was a scary jump in the first level before I realized I could maximize the window and see more of the screen.

Thanks for sharing, had fun.

9
SFML projects / Re: Dark Ruins
« on: June 01, 2016, 04:31:32 am »
I wanted to provide an end of May update.

This update features a slight re-design of the interface, the new GUI table I built, and the addition of the mini-map.

10
SFML projects / Re: Graphical User Interface Library
« on: May 29, 2016, 05:50:56 am »
Congratulations on publishing this and thank you for including images of the GUI controls you created!

I think you could eventually expand your images to have an example of each kind of control, so people can get an idea of how they look in action, try them, and provide feedback.


11
General / Re: Callback implementation question
« on: May 26, 2016, 05:37:25 am »
Thank you Arcade and Laurent for your replies, they were both useful and I got a minimal example working while I decide exactly how to implement in my program.  Thank you!

#include <functional>
#include <iostream>

int main()
{
        // There's no complexity with callbacks. Forget inheritance and virtual functions.

        class Button
        {
                public:
                        std::function<void()> callback;
        };

        class Menu
        {
                public:
                        void open() {
                                std::cout << "I was opened" << std::endl;
                        };
        };

        Button button;
        Menu menu;
       
        //button.callback = std::bind(&Menu::open, std::ref(menu));  // Bind implementation
        // or...
        button.callback = [&] {menu.open(); };          // Lamda implementation
        button.callback();                                                      // Returns "I was opened"

        return 0;
}

 

Recoil, I'm glad I could ask a useful question.

12
Hey that's awesome, I'm glad my years of otherwise useless corporate existance surfaced something of value!

13
General / Callback implementation question
« on: May 25, 2016, 05:57:49 pm »
Thanks to both of you for your reply, I will review and report back

14
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.

15
Graphics / Re: I'm missing something about resizable windows
« on: May 25, 2016, 03:52:56 am »
When you create a window you define a VideoMode with the number of pixels in width and number of pixels height.

The total number of pixels does not change if you re-size the Window.  It would only change if you altered the VideoMode.

This is actually a good thing as it keeps your screen resolution constant for drawing purposes.
If you later want to program in order to support multiple resolutions, that's a different matter.




Pages: [1] 2 3 ... 5
anything