04-10-2013, 10:12 PM
im drawing lines between the points now (with DRAW
)
but they seem to go up and right for some reason,
here is the code
triship arrays are two dimensional, one dimension for which ship it refers to
and the other dimension for the points

but they seem to go up and right for some reason,
here is the code
triship arrays are two dimensional, one dimension for which ship it refers to
and the other dimension for the points
Code:
#include <FSin.bas>
#include <SP/Fill.bas>
Dim fsinarray(361) as Fixed
for iter=0 to 360
fsinarray(iter)=fSin(iter)
next
Dim fcosarray(361) as Fixed
for iter=0 to 360
fcosarray(iter)=fCos(iter)
next
Dim trishipx(2,12) as UByte
Dim trishipy(2,12) as UByte
Dim drawtrishipx(2,12) as UByte
dim drawtrishipy(2,12) as UByte
Dim fc, fs, tx, ty As Fixed
trishipx(0,0)=62
trishipy(0,0)=58
trishipx(0,1)=58
trishipy(0,1)=58
trishipx(0,2)=58
trishipy(0,2)=62
trishipx(0,3)=58
trishipy(0,3)=54
trishipx(0,4)=60
trishipy(0,4)=58
trishipx(0,5)=60
trishipy(0,5)=62
trishipx(1,0)=162
trishipy(1,0)=158
trishipx(1,1)=158
trishipy(1,1)=158
trishipx(1,2)=158
trishipy(1,2)=162
trishipx(1,3)=158
trishipy(1,3)=154
trishipx(1,4)=160
trishipy(1,4)=158
trishipx(1,5)=160
trishipy(1,5)=162
Dim trishipangle as Integer
Function rotate(degrees as Integer) as Integer
dim pointx as Ubyte
dim pointy as Ubyte
for trishipiter =0 to 1
if trishipiter=0 then
pointx=54
pointy=54
end if
if trishipiter=1 then
pointx=100
pointy=100
end if
if trishipiter=2 then
pointx=154
pointy=54
end if
for x=0 to 5
'Local theta:Float=1
fc = fcosarray(degrees)
fs = fsinarray(degrees)
tx = trishipx(trishipiter,x) - pointx
ty = trishipy(trishipiter,x) - pointy
drawtrishipx(trishipiter,x)= fc * tx - fs * ty + pointx
drawtrishipy(trishipiter,x)= fs * tx + fc * ty + pointy
'transformedX= fCos(degrees) * (trishipx(x)-pointx) - fSin(degrees) * (trishipy(x)-pointy) + pointx
'transformedY = fSin(degrees) * (trishipx(x)-pointx) + fCos(degrees) * (trishipy(x)-pointy) + pointy
Next
next
return 1
End Function
Function drawship() as Integer
for trishipiter=0 to 1
for x=0 to 5
'plotPoint(drawtrishipx(trishipiter,x),drawtrishipy(trishipiter,x))
if x<5 then
PLOT drawtrishipx(trishipiter,x), drawtrishipy(trishipiter,x)
DRAW drawtrishipx(trishipiter,x+1), drawtrishipy(trishipiter,x+1)
end if
if x=5 then
PLOT drawtrishipx(trishipiter,x), drawtrishipy(trishipiter,x)
DRAW drawtrishipx(trishipiter,0), drawtrishipy(trishipiter,0)
end if
next
next
return 1
End Function
While 1
CLS
trishipangle=trishipangle+1
if trishipangle>360 then
trishipangle=0
end if
'for x=0 to 5
'plotPoint(drawtrishipx(x),drawtrishipy(x))
'next
rotate(trishipangle)
drawship()
Wend
SUB plotPoint (x as uByte, y as uByte)
ASM
ld d,(IX+5) ;'X
ld e,(IX+7) ;'Y
ld a, 191
sub e
ret c
ld e, a
and a
rra
scf
rra
and a
rra
xor e
and 248
xor e
ld h, a
ld a, d
rlca
rlca
rlca
xor e
and 199
xor e
rlca
rlca
ld l, a
ld a, d
and 7
ld b, a
inc b
ld a, 1
plotPoint_loop:
rrca
djnz plotPoint_loop
;cpl
ld b, a
ld a, (hl)
or b
ld (hl), a
END ASM
EDIT-
after drawing my own lines I could draw a rotating part of a spaceship
(featuring britlions fill routine)
http://www.4shared.com/file/DLgxB2PY/rotate_1.html
looks like it will have to be...turn based spaceship combat
END SUB