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

Username:   Password: 
 RegisterRegister   
 Scoring System -- How would I set it up?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
PerylDemise




PostPosted: Thu Mar 23, 2006 10:04 pm   Post subject: Scoring System -- How would I set it up?

ok. Reposting, sorry. For my scoring system, on a dart board.

My dart is an oval *graphic form* and the dart board is in graphic form too. How would I calculate the distance between the two of them?

Would I use the distance formula? :

distance := sqrt[(x2-y2)-(x1-y1)]

If I do, then what goes into each of the variables?
Would the x1 and y1 be the co-ordinates of my dart or the center of the dart board, or something else?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Mar 23, 2006 11:01 pm   Post subject: (No subject)

each of your x/y pairs are the coordinates of point. two pairs, two points, one distance between them Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
PerylDemise




PostPosted: Thu Mar 23, 2006 11:10 pm   Post subject: (No subject)

ok. But for the first set of co-ordinates (x1 and y1), would I get them from the dart that's randomly placed on the screen and then the other two (x2 and y2) come from the dart board position? ^^; Or would it be the opposite? Shifty
[Gandalf]




PostPosted: Thu Mar 23, 2006 11:39 pm   Post subject: (No subject)

It doesn't matter, because it finds the distance, not the displacement.

Also, save yourself the trouble of creating a function for this, or implementing the forumula some other way. Use the Math.Distance (x1, y1, x2, y2 : int) : int function.
PerylDemise




PostPosted: Fri Mar 24, 2006 12:10 am   Post subject: (No subject)

Wow. Thank you ;D That helped a lot. :3 The point system seems to be working now Very Happy

Another quick question though. I have a function set up but I forget how to call upon it within the body of the code. Can anyone help on that part? ^^;
chrispminis




PostPosted: Fri Mar 24, 2006 12:22 am   Post subject: (No subject)

code:
yourVariable := yourFunction (yourParameters)


Or like

code:
put yourFunction (yourParameters)



Or something like that. You get that the above is just generally. Whether you store the result in a variable or display it right away is up to you.

Don't forget that in functions using more than one parameters, to call it with all the parameters specified.
[Gandalf]




PostPosted: Fri Mar 24, 2006 12:24 am   Post subject: (No subject)

code:
var tempProduct : int

function getProduct (i, c : int) : int
    result i * c
end getProduct

for i : 1 .. 5
    for c : 4 .. 6
        put getProduct (i, c)
        %or
        tempProduct := getProduct (i, c)
    end for
end for
PerylDemise




PostPosted: Mon Mar 27, 2006 9:48 pm   Post subject: (No subject)

Thank you so much ;D This has been a lot of help :3
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: