Need guides in understanding the codes
Aug 28, 2013 at 10:35am UTC
Hi guys, can someone explain me on what does these codes did? this is only part of the code...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
// Create the window of the application
sf::RenderWindow myWindow(sf::VideoMode(myWorldWidth, myWorldHeight, 32), "Battleship!" );
myWindow.setVerticalSyncEnabled(true );
bool showHardwareMouse;
bool started;
bool drag;
float dragOffsetX, dragOffsetY;
bool LeftMouseButtonDown = false ;
bool reset = true ;
//----- Main Loop Start here -----
while (myWindow.isOpen())
{
if (reset)
{
// Reset
showHardwareMouse = true ;
drag = false ;
dragOffsetX = dragOffsetY = 0.0f;
started = true ;
reset = false ;
}
the program is actually based on SFML library, what does
dragOffsetX = dragOffsetY = 0.0f; means?
and this is how actually the program work like...
http://i1146.photobucket.com/albums/o530/HTHVampire/C%20plus%20plus/Capture2_zps1fe188cd.jpg
I will post the full codes of it if you guys can't get it. Thanks!
Aug 28, 2013 at 11:47am UTC
The meaning of:
1 2
float dragOffsetX, dragOffsetY;
dragOffsetX = dragOffsetY = 0.0f;
is that first a float value 0.0 is assigned to float variable named dragOffsetY,
and since the return value of that expression is 0.0,
a float value 0.0 is assigned to float variable named dragOffsetX.
The logical meaning of those assignments depends on the rest of the code.
Topic archived. No new replies allowed.