Author |
Message |
PerylDemise

|
Posted: 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

|
|
 |
Tony

|
Posted: 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  |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
 |
PerylDemise

|
Posted: 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?  |
|
|
|
|
 |
[Gandalf]

|
Posted: 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

|
Posted: 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
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

|
Posted: 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]

|
Posted: 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

|
Posted: 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

|
|
 |
|