
-----------------------------------
PerylDemise
Thu Mar 23, 2006 10:04 pm

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?

-----------------------------------
Tony
Thu Mar 23, 2006 11:01 pm


-----------------------------------
each of your x/y pairs are the coordinates of point. two pairs, two points, one distance between them :wink:

-----------------------------------
PerylDemise
Thu Mar 23, 2006 11:10 pm


-----------------------------------
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]
Thu Mar 23, 2006 11:39 pm


-----------------------------------
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
Fri Mar 24, 2006 12:10 am


-----------------------------------
Wow. Thank you ;D That helped a lot. :3 The point system seems to be working now :D

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
Fri Mar 24, 2006 12:22 am


-----------------------------------
yourVariable := yourFunction (yourParameters)

Or like

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]
Fri Mar 24, 2006 12:24 am


-----------------------------------
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
Mon Mar 27, 2006 9:48 pm


-----------------------------------
Thank you so much ;D This has been a lot of help :3
