the triangle can be moved around with the arrow keys
but for some reason the more down and left you move it the more off the aiming is until eventually it doesn't work at all
can anyone help me with this please i cant seem to figure this out
Code: Select all
DIM SHARED degtorad AS DOUBLE
DECLARE SUB mouse (Funk)
COMMON SHARED sx AS INTEGER
COMMON SHARED sy AS INTEGER
TYPE playership
theta AS DOUBLE
x AS INTEGER
y AS INTEGER
xt AS INTEGER
yt AS INTEGER
END TYPE
COMMON SHARED ssx AS INTEGER
COMMON SHARED ssy AS INTEGER
common shared k as string
DIM SHARED p AS playership
DECLARE SUB drawship (p AS playership)
DECLARE SUB megaline (x AS INTEGER, y AS INTEGER, theta AS DOUBLE, r AS DOUBLE, col AS INTEGER)
DEF FNptrig
IF p.x - h > 0 THEN
IF p.y - v > 0 THEN
FNptrig = (ATN(ABS(p.y - v) / ABS(p.y - h)) * 180 / 3.14159) + 180
ELSEIF p.y - v <> 0 THEN
FNptrig = 90 - (ATN(ABS(p.y - v) / ABS(p.y - h)) * 180 / 3.14159) + 90
END IF
ELSEIF p.x - h <0> 0 THEN
FNptrig = 90 - (ATN(ABS(p.y - v) / ABS(p.y - h)) * 180 / 3.14159) - 90
ELSEIF p.x - h <> 0 THEN
FNptrig = (ATN(ABS(p.y - v) / ABS(p.y - h)) * 180 / 3.14159)
END IF
END IF
END DEF
degtorad = 3.14159 / 180
SCREEN 9, 0, 0, 1
p.theta = 30
p.x = 300
p.y = 200
DO
k=inkey$
if k=chr$(0)+"H" then
p.y=p.y-4
if p.y<0 then
end if
end if
if k=chr$(0)+"P" then
p.y=p.y+4
end if
if k=chr$(0)+"M" then
p.x=p.x+4
end if
if k=chr$(0)+"K" then
p.x=p.x-4
end if
CALL mouse(3)
p.theta = FNptrig
CALL drawship(p)
print p.theta
PCOPY 0, 1
CLS
LOOP WHILE 1 = 1
SUB drawship (ship AS playership)
CALL megaline(ship.x, ship.y, (ship.theta + 90) * degtorad, 10, 15)
LINE (sx, sy)-((40 * COS(ship.theta * degtorad)) + ship.x, (40 * SIN(ship.theta * degtorad) + ship.y)), 15
CALL megaline(ship.x, ship.y, (ship.theta - 90) * degtorad, 10, 15)
LINE (sx, sy)-((40 * COS(ship.theta * degtorad)) + ship.x, (40 * SIN(ship.theta * degtorad) + ship.y)), 15
END SUB
SUB megaline (x AS INTEGER, y AS INTEGER, theta AS DOUBLE, r AS DOUBLE, col AS INTEGER) 'draws angular lines
sx = (r * COS(theta)) + x
sy = (r * SIN(theta)) + y
LINE (x, y)-(sx, sy), col 'math and lines
END SUB
SUB mouse (Funk)
SHARED B, h, v
POKE 100, 184: POKE 101, Funk: POKE 102, 0
POKE 103, 205: POKE 104, 51: POKE 105, 137
POKE 106, 30: POKE 107, 170: POKE 108, 10
POKE 109, 137: POKE 110, 14: POKE 111, 187
POKE 112, 11: POKE 113, 137: POKE 114, 22
POKE 115, 204: POKE 116, 12: POKE 117, 203
CALL Absolute(100)
B = PEEK(&HAAA)
h = PEEK(&HBBB) + PEEK(&HBBC) * 256
v = PEEK(&HCCC) + PEEK(&HCCD) * 256
LINE (h + 12, v)-(h - 12, v), 4
LINE (h, v - 12)-(h, v + 12), 4
END SUB