Does anybody have any idea how I can make the mouse control a bit more difficult in my darts game. Please see code for how it works at the moment (Pls excuse the artwork) I feel its a bit easy.
Rem 180 Clone
Rem By Mark Winfield
Rem Using Polar Coordinates to work out where the dart hits the board
Rem October 2005
Sync On
Rem Set Screen Parameters and Global Variables
Width = 640
Height = 480
dim PointsX(20,2)
dim PointsY(20,2)
MemWidth = Width
MemHeight = Height
CenterX = int(Width/2)
CenterY = int(Height/2)
PI# = 3.14
HitX = 0
HitY = 0
Score = 0
Points = 0
ink 255,0
DoubleMaxRadius = 144
BullRadius = 5
OuterBullRadius = 10
TrebleMinRadius = 90
TrebleMaxRadius = TrebleMinRadius - 7
DoubleMinRadius = DoubleMaxRadius - 7
Rem PosX# and PosY# are the coordinates of the dart
PosX# = 100
PosY# = 100
DartInPlay=1
Position Mouse PosX#,PosY#
gosub CalcLinePoints
gosub DrawBoard
do
Rem MainLoop
sync
dx = MouseMoveX()
dy = MouseMoveY()
if PosX# = (PosX# + dx)
dx = OldDx
PosX# = PosX# - (dx/2)
else
PosX# = PosX# + dx
endif
if PosY# = (PosY# + dy)
dy = OldDy
PosY# = PosY# - dy
else
PosY# = PosY# + dy
endif
Rem Update Mouse Pos
Position Mouse PosX#,PosY#
oldDx = dx
oldDy = dy
if MouseClick() = 1
HitX = MouseX()
HitY = MouseY()
gosub ThrowDart
position Mouse HitX,HitY
endif
loop
CalcLinePoints:
For Count = 1 to 20
PolarR# = DoubleMaxRadius
PolarV# = (Count * 18) -9
V# = PolarV#
PointX# = int(PolarR#*SIN(V#))
PointY# = int(PolarR#*COS(V#))
PointsX(Count,1) = PointX# + CenterX
PointsY(Count,1) = PointY# + CenterY
PolarR# = OuterBullRadius
V# = PolarV#
PointX# = (PolarR#*SIN(V#))
PointY# = (PolarR#*COS(V#))
PointsX(Count,2) = PointX# + CenterX
PointsY(Count,2) = PointY# + CenterY
Next Count
return
DrawBoard:
Rem Draw the Rings on the board
X=CenterX
Y =CenterY
Circle X,Y,DoubleMaxRadius+40
Circle X,Y,DoubleMaxRadius
Circle X,Y,BullRadius
Circle X,Y,OuterBullRadius
Circle X,Y,TrebleMinRadius
Circle X,Y,TrebleMaxRadius
Circle X,Y,DoubleMinRadius
Rem Now Draw The Lines
For Count = 1 to 20
Line PointsX(Count,1),PointsY(Count,1),PointsX(Count,2),PointsY(Count,2)
Next Count
Rem Stick The Numbers on the board
text 310,75,"20"
text 265,85,"5"
text 365,85,"1"
text 220,105,"12"
text 405,105,"18"
text 190,140,"9"
text 440,140,"4"
text 160,180,"14"
text 460,180,"13"
text 150,230,"11"
text 470,230,"6"
text 170,280,"8"
text 465,280,"10"
text 180,320,"16"
text 445,320,"15"
text 220,360,"7"
text 405,360,"2"
text 260,380,"19"
text 360,380,"17"
text 320,390,"3"
return
function text_over_sprite(spritenumber,x,y,text$)
Rem Big Thankz To Ric for the original function
create bitmap 31,screen width(),screen height()
text 0,0,text$
get image 31,0,0,text width(text$),text height(text$),1
delete bitmap 31
sprite spritenumber,x,y,31
endfunction
ThrowDart:
Rem This function converts X and Y to polar coordinates
Rem It uses the angle to determin the number
Rem And the radius to determin any modifiers
PointX# = HitX - CenterX
PointY# = CenterY - HitY
Points = 0
Multiplier = 1
X#=PointX#
Y#=PointY#
Rem This is the point on the Radius
PolarR# = int(SQRT((X#*X#)+(Y#*Y#)))
Rem Now Calculate the angle
PolarV# = ATANFULL(Y#,X#)
Rem Adjust For angles -180 to 0
if PolarV# < 0 then PolarV# = PolarV# + 360
If PolarV# >= 0 AND PolarV#<=9 Then Points=6
If PolarV# > 9 AND PolarV#<= 27 Then Points=13
If PolarV# > 27 AND PolarV#<=45 Then Points= 4
If PolarV# > 45 And PolarV#<=63 Then Points = 18
If PolarV# > 63 AND PolarV#<=81 Then Points=1
If PolarV# > 81 AND PolarV#<=99 Then Points=20
If PolarV# > 99 AND PolarV#<=117 Then Points=5
If PolarV# > 117 AND PolarV#<=135 Then Points=12
If PolarV# > 135 AND PolarV#<=153 Then Points=9
If PolarV# > 153 AND PolarV#<=171 Then Points=14
If PolarV# > 171 AND PolarV#<=189 Then Points=11
If PolarV# > 189 AND PolarV#<=207 Then Points=8
If PolarV# > 207 AND PolarV#<=225 Then Points=16
If PolarV# > 225 AND PolarV#<=243 Then Points=7
If PolarV# > 243 AND PolarV#<=261 Then Points=19
If PolarV# > 261 AND PolarV#<=279 Then Points=3
If PolarV# > 279 AND PolarV#<=297 Then Points=17
If PolarV# > 297 AND PolarV#<=315 Then Points=2
If PolarV# > 315 AND PolarV#<=333 Then Points=15
If PolarV# > 333 AND PolarV#<=351 Then Points=10
If PolarV# > 351 AND PolarV#<=360 Then Points=6
If PolarR# <= BullRadius then Points = 50
If PolarR# <= OuterBullRadius AND PolarR# > BullRadius then Points = 25
if PolarR# <= TrebleMinRadius AND PolarR# >= TrebleMaxRadius then Multiplier = 3
If PolarR# >= DoubleMinRadius AND PolarR# <= DoubleMaxRadius then Multiplier = 2
Ink 255,0
Points = Points * Multiplier
Msg$= "Points:" +str$(Points)
text_over_sprite(100,0,0,Msg$)
ink RGB(255,0,0),0
Dot HitX,HitY
Inc DartInPlay
sleep 500
return