Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Is there any reason why my teacher makes us use a for loop to draw static objects?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MrMac




PostPosted: Wed Mar 11, 2015 10:24 pm   Post subject: Is there any reason why my teacher makes us use a for loop to draw static objects?

Let's say I want to draw a filled object. For example, a box.


Our teacher makes us, instead of using
Turing:

drawfillbox(0,0,100,100,black)

We actually do:
Turing:

for x : 0..100
drawline(x,0,x,100,black)
end for


She doesn't care if we use a for loop if the object is moving, however. Is there any real reason why she makes us do the for loop for a static filled object? I can't figure it out for the life of me.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Wed Mar 11, 2015 10:53 pm   Post subject: RE:Is there any reason why my teacher makes us use a for loop to draw static objects?

The only reason I can think of is that she wants you to demonstrate that you know how to use the 'for' loop correctly.

There's no technical advantage over drawfillbox or Draw.FillBox. In fact, it's probably a lot slower -- though that won't matter to school assignments.
Dan




PostPosted: Wed Mar 11, 2015 11:01 pm   Post subject: RE:Is there any reason why my teacher makes us use a for loop to draw static objects?

The only reason I could think of is that it is part of the assignment to teach you how to use for loops. Otherwise it seems rather unnecessary and is likely even less efficient.

Edit: Did not see DemonWasp's post when I posted, looks like he beat me to it. If any one wanted to figure out if it really is slower or why, I know drawfillbox eventually calls the Rectangle function in the Gdi32.lib Library (https://msdn.microsoft.com/en-us/library/windows/desktop/dd162898%28v=vs.85%29.aspx), my guess would be that windows optimizes the drawing of a polygon like a rectangle over a bunch of line segments (but I am to lazy to research it).
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: