i was interested how fast CoolBasic these trigonometrically handled.
I would say, very good!
Maybe you may it use for movements in a game.
For example:
Invaders, Breakout, whatever.
For the Ball as graphic, create a Ball or square with 16x16 pixel.
Here is the example:
Code: Select all
SCREEN 1024,768,16,1
Global Ball,i
Ball = LoadImage("Ball.bmp")
'Main
Cosinus(120,45,8,4)
Cosinus(120,45,16,5)
Cosinus(120,12,32,6)
Cosinus(120,22,48,7)
Cosinus(120,Tan(-45),64,7)
Cosinus(120,Sqrt(8),80,8)
DrawScreen
WaitKey
End
Function Cosinus(z,wi,ho,t)
For i=0 To z
DrawImage Ball,i*8 + 0,(Cos(i*wi)+t)*ho
DrawImage Ball,i*8 + 64,(Cos(i*wi)+t)*ho
DrawImage Ball,i*8 + 128,(Cos(i*wi)+t)*ho
DrawImage Ball,i*8 + 192,(Cos(i*wi)+t)*ho
Next i
EndFunction