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

Author Topic: Zeven  (Read 9024 times)

0 Members and 1 Guest are viewing this topic.

nfries88

  • Newbie
  • *
  • Posts: 42
    • View Profile
Zeven
« Reply #15 on: December 03, 2010, 01:14:46 am »
I have to say that this doesn't look very useful to someone who is not looking for a robust and flexible structure to their code, which may be why Ceylo doesn't get the point in it.

Or it may be the fact that the need to append your event structure with every event received and the update methods, as he pointed out, make the solution slightly less robust.

What exactly do these update functions do?

Zinlibs

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Zeven
« Reply #16 on: December 06, 2010, 01:10:28 pm »
Sorry if I don't have responded earlier, but the method of update has just been improved. For the moment, it is just an overlay of the current public interface, and the performances are lower than before. If you approve the new system, I will adapt the code to no longer use the Events class, and the performances should return to the normal. Here are the changes :

Code: [Select]

////////////////////////////////////////////////////////////
/// Headers
////////////////////////////////////////////////////////////
#include <SFML/Graphics.hpp>
#include <iostream>
#include <Zeven/sfZeven/sfZeven.hpp>

void Hello()
{
   std::cout << "Hello world" << std::endl;
}

////////////////////////////////////////////////////////////
/// Entry point of the application
////////////////////////////////////////////////////////////
int main()
{

// Creation and settings of the SFML rendering window
   sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Zeven sample");
   
// Limitation of the framerate
   App.SetFramerateLimit(40);

// Creation of the area
   sf::FloatRect area(0, 0, 100, 100);

// Creation of a shape which represent the area
   sf::Shape::Rectangle rectangle(area.Left, area.Top, area.Width, area.Height, sf::Color::Red);

// Get the event handler
   zin::sfEventHandler<zin::sfListener>& EventHandler = zin::sfEventHandler::GetInstance();

// Creation of the mouse over listener
   zin::sfMouseOverListener mouseOver(area);

// Connection to the function Hello
    mouseOver.ConnectTo(sigc::ptr_fun(&Hello));

// Register the listener
    EventHandler.Register(mouseOver);

// Main process loop
   while( App.IsOpened() )
   {
       
   // Rest of the processor
      sf::Sleep(0.02);
       
   // Create an empty event
      sf::Event Event;

   // Event loop
      while( App.GetEvent(Event) )
      {
      // Send an SFML event to the event handler
         EventHandler.Recept(Event);
         
      // Close window to exit the program
         if( Event.Type == sf::Event::Closed )
            App.Close();
       
      // Esc to exit the program
         if( Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Escape )
            App.Close();
      }

   // Send the mouse position
      EventHandler.Recept(App.ConvertCoords(App.GetInput().GetMouseX(), App.GetInput().GetMouseY()));

   // Update the event handler
      EventHandler.Update();

   // Clear the screen
      App.Clear();
       
   // Add drawable in the stack
      App.Draw(rectangle);
       
   // Displaying in the rendering window
      App.Display();
   }

   return EXIT_SUCCESS;
}
Zoost & Zoom libraries : An easy way to create and handle geometric objets, animate and use them for better graphics !