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

Username:   Password: 
 RegisterRegister   
 Need help with Mouse.Where
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Dittatore




PostPosted: Thu Apr 11, 2013 5:11 pm   Post subject: Need help with Mouse.Where

Mouse.Where (x, y, button)
if x >= 323 and x <= 328 and y >= 195 and y <= 205 and button = 1 then
drawfilloval (x, y, 10, 10, black)
end if


Can anyone please tell me how to repeat "if x >= (n) and x <= (n) and y >= (n) and y<= (n) and button = 1 then" without actually typing that almost exact line 225 times?
Sponsor
Sponsor
Sponsor
sponsor
Nathan4102




PostPosted: Thu Apr 11, 2013 5:17 pm   Post subject: RE:Need help with Mouse.Where

CODE:
for i : 1..225
  %insert code here
end for


This would repeat the code inbetween the for's 225 times. Is this what you're looking for?
Panphobia




PostPosted: Thu Apr 11, 2013 5:18 pm   Post subject: RE:Need help with Mouse.Where

Elaborate please, by repeat do mean to do it over and over again, if so you can just use a loop, and also you can simplify your second if statement of "if x >= (n) and x <= (n) and y >= (n) and y<= (n) and button = 1 then" to "if x = (n) and y = (n) and button = 1 then", that would only be if you are using the same number for all of them, otherwise you should call them differently like "if x >= (n) and x <= (a) and y >= (b) and y<= (e) and button = 1 then", you can use the for loop like Nathan said, or if you do not know how many times you want to repeat it just use
Turing:
loop
exit when (condition for breaking loop)
end loop
Dittatore




PostPosted: Thu Apr 11, 2013 5:39 pm   Post subject: Re: Need help with Mouse.Where

Quote:
Elaborate please

Sorry, I should've make it more clear.
The code should be "if x >= (n) and x <= (a) and y >= (b) and y<= (e) and button = 1 then". The number for (n), (a), (b), (e) would be different each time.
Clayton




PostPosted: Fri Apr 12, 2013 7:48 am   Post subject: RE:Need help with Mouse.Where

The answer to your question very much depends on what the expected values of n, a, b, and e are. If they are multiples of each other, or have some sort of distinguishable pattern, then yes, this can be easily done in a few simple lines of code.

What exactly is it that you're trying to do here? A full explanation would help a lot with figuring out how to help you Smile
Dittatore




PostPosted: Wed Apr 17, 2013 3:59 pm   Post subject: Re: Need help with Mouse.Where

Quote:
What exactly is it that you're trying to do here?

I'm trying to make a game called Gomoku.

The gameplay should be like this
http://www.roundgames.com/game/Go+Bang
Raknarg




PostPosted: Wed Apr 17, 2013 6:23 pm   Post subject: RE:Need help with Mouse.Where

I think he more meant the point of that code in general
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  [ 7 Posts ]
Jump to:   


Style:  
Search: