04-08-2013, 12:59 AM
I was going to make a vector graphics game like asteroids but different
I rotated some points around an origin but even that seems too slow
I was going to draw lines between the points
I rotated some points around an origin but even that seems too slow
I was going to draw lines between the points
Code:
#include <FSin.bas>
Dim trishipx(12) as UByte
Dim trishipy(12) as UByte
Dim drawtrishipx(12) as UByte
dim drawtrishipy(12) as UByte
trishipx(0)=62
trishipy(0)=58
trishipx(1)=58
trishipy(1)=58
trishipx(2)=58
trishipy(2)=62
trishipx(3)=58
trishipy(3)=54
trishipx(4)=60
trishipy(4)=58
trishipx(5)=60
trishipy(5)=62
Dim trishipangle as Integer
Function rotate(degrees as Integer) as Integer
dim transformedX as Ubyte=0
dim transformedY as ubyte=0
dim pointx as Ubyte=54
dim pointy as Ubyte=54
for x=0 to 5
'Local theta:Float=1
transformedX= fCos(degrees) * (trishipx(x)-pointx) - fSin(degrees) * (trishipy(x)-pointy) + pointx
transformedY = fSin(degrees) * (trishipx(x)-pointx) + fCos(degrees) * (trishipy(x)-pointy) + pointy
drawtrishipx(x) = transformedX
drawtrishipy(x) = transformedY
Next
return 1
End Function
Function drawship() as Integer
for x=0 to 5
plotPoint(drawtrishipx(x),drawtrishipy(x))
next
return 1
End Function
While 1
trishipangle=trishipangle+1
if trishipangle>360 then
trishipangle=0
end if
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
END SUB