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

Username:   Password: 
 RegisterRegister   
 Question about target shooting game.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
nightfeng2




PostPosted: Mon Jan 10, 2011 9:59 am   Post subject: Question about target shooting game.

Turing:


setscreen ("graphics:640;480,offscreenonly")
var targetx, targety, Mx, My, button : int
targetx := 320
targety := 240
loop
    drawfilloval (targetx, targety, 50, 50, 2)
    drawfilloval (targetx, targety, 2, 2, 1)


    mousewhere (Mx, My, button)
    drawoval (Mx, My, 100, 100, 2)
    drawfilloval (Mx, My, 3, 3, 1)
    View.Update
    cls
    exit when Mx = targetx and My = targety and button = 1


end loop



so in the above code, ur supposed to hit the blue dot in the green circle, however, it is way to small, people cant aim that good, how can i make it bigger so its easier.
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Mon Jan 10, 2011 10:38 am   Post subject: RE:Question about target shooting game.

If you had written this code yourself, you would know the answer pretty easily. Read the code you've posted carefully:

1. Which part handles getting the mouse coordinates?
2. Which part handles checking that your mouse is in the correct location?
3. What do you want that part to do instead of what it does right now?
TokenHerbz




PostPosted: Mon Jan 10, 2011 11:57 am   Post subject: RE:Question about target shooting game.

or even, which part draws the "Blue circle" you want to make larger?? Now increase the size of it..
TerranceN




PostPosted: Mon Jan 10, 2011 3:25 pm   Post subject: RE:Question about target shooting game.

The problem is that you only check if the mouse is on the EXACT same co-ordinate as the centre of the target, the size of the target will make no difference. You need to check to see if the mouse position is inside the target instead. Since the target is a circle, this fairly straightforward. All points on a circle are the same distance from the centre of the circle, this distance is the radius. If the distance from the centre of the target to the mouse is less than the radius of the circle, it is inside the circle. Also, you can find the distance formula here. Hope that helps.
nightfeng2




PostPosted: Mon Jan 10, 2011 5:11 pm   Post subject: RE:Question about target shooting game.

THANK YOU TerranceN, u gave me the idea to do it xD

thank you all =D
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  [ 5 Posts ]
Jump to:   


Style:  
Search: