Community Project: BlitzMax Examples in Helpfiles

BlitzMax Forums/BlitzMax Programming/Community Project: BlitzMax Examples in Helpfiles

Rem

'
' Sin
'
' returns the sine value of a given angle (in degrees), 360 degrees represent one cyclic period.
'

Graphics 640,480

SetColor 128,128,128; DrawRect 0,240,360,1

SetColor 0,255,255

For Local t:Int=0 To 359
	Plot t,240+Sin(t)*80
Next

Flip

Repeat WaitKey() Until KeyDown(KEY_ESCAPE)
End


'
' Cos
'
' returns the cosine value of a given angle (in degrees), 360 degrees represent one cyclic period.
'

Graphics 640,480

SetColor 128,128,128; DrawRect 0,240,360,1

SetColor 0,255,255

For Local t:Int=0 To 359
	Plot t,240+Cos(t)*80
Next

Flip

Repeat WaitKey() Until KeyDown(KEY_ESCAPE)
End


'
' ATan2
'
' returns the angle in degrees between two points by giving the width and height between then.
'

Print ATan2(4,4)
'4^|    / (45 degrees)
'  |   / 
'  |  /
'  | /
'  |/
'  +-----
'       4>
End


'
' How to draw a 'dotted' circle using Sin/Cos
'
'

Graphics 640,480

Local radius:Int=80

SetColor 0,255,255

For Local t:Int=0 To 359 Step 4
	Plot 320+Sin(t)*radius, 240+Cos(t)*radius
Next

Flip

Repeat WaitKey() Until KeyDown(KEY_ESCAPE)
End

'
' How to draw a 'dotted' flower using Sin/Cos
'

Graphics 640,480

Local radius:Int

SetColor 0,255,255

For Local t:Int=0 To 359 Step 4
	radius=Sin(t*8)*40+80
	Plot 320+Sin(t)*radius, 240+Cos(t)*radius
Next

Flip

Repeat WaitKey() Until KeyDown(KEY_ESCAPE)
End

EndRem


Someone ought to write appendixes about typical design patterns, and their applications.