Feedback wanted on code style

BlitzMax Forums/BlitzMax Beginners Area/Feedback wanted on code style

Hi guys,

I grabbed a copy of BlitzMax yesterday and have been playing around with it. I think I'm slowly coming to grips with how it works, but I want to make sure I'm using good coding practice. If you have the spare time I'd appreciate some feedback on this code. Am I using good style? Am I using the most appropriate approach? etc.

Any and all feedback appreciated.

Here's the code:

SuperStrict

'Constants For window dimension others
Const SCREEN_WIDTH:Int = 1024
Const SCREEN_HEIGHT:Int = 768
Const MAX_COLOURS:Int = 255

'set window dimensions
Graphics SCREEN_WIDTH, SCREEN_HEIGHT, 0 'Set window size

'basic "star" object has positon on screen and a colour
Type TStar
   Field x:Int, y:Int 'position variables
   Field R:Int, G:Int, B:Int 'colour variables

   'randomly set positon based on window dimensions
   'and randomly set colour upon creation
   Method New()
      Local screenWidth:Int = GraphicsWidth()
      Local screenHeight:Int = GraphicsHeight()
      Self.x = Rnd(screenWidth)
      Self.y = Rnd(screenHeight)
      Self.R = Rnd(MAX_COLOURS)
      Self.G = Rnd(MAX_COLOURS)
      Self.B = Rnd(MAX_COLOURS)
   EndMethod
EndType

'a "star field" object that has its own draw and "movement" methods
Type TStarField
   Field sf:TStar[]
   Field starCount:Int
   Field speed:Int = 1 'movement speed starts at 1 by default
   Field counter:Int 'variable used to count through loops

   Method New()
      starCount = GraphicsWidth() 'width of screen used as a 'good' approx of number of stars
      sf = New TStar[starcount] 'initialise the array
      'populate the field with "stars"
      For counter = 0 To (starCount - 1)
         sf[counter] = New TStar
      Next
   EndMethod

   'draws all the stars to the current buffer
   Method DrawField()
      For counter = 0 To (starCount - 1)
         SetColor(sf[counter].R, sf[counter].G, sf[counter].B)
         Plot sf[counter].x, sf[counter].y
      Next
   EndMethod

   'sets the speed of the movement
   Method SetSpeed(newSpeed:Int)
      speed = newSpeed
   EndMethod

   'move the starfield up the screen
   Method MoveUp()
      For counter = 0 To (starCount - 1)
         'move point to bottom of screen first if it is already at the top
         If sf[counter].y <= 0 
            sf[counter].y = (GraphicsHeight() - 1)
         Else
            sf[counter].y = sf[counter].y - speed         
         EndIf
      Next
   EndMethod

   'move the starfield down the screen
   Method MoveDown()
      For counter = 0 To (starCount - 1)
         'move point to top of screen first if it is already at the bottom
         If sf[counter].y >= (GraphicsHeight() - 1) 
            sf[counter].y = 0
         Else
            sf[counter].y = sf[counter].y + speed         
         EndIf
      Next
   EndMethod

   'move the starfield right on the screen
   Method MoveRight()
      For counter = 0 To (starCount - 1)
         'move point to far left of screen first if it is already at the far right
         If sf[counter].x >= (GraphicsWidth() - 1) 
            sf[counter].x = 0
         Else
            sf[counter].x = sf[counter].x + speed         
         EndIf
      Next
   EndMethod

   'move the starfield left on the screen
   Method MoveLeft()
      For counter = 0 To (starCount - 1)
         'move point to far right of screen first if it is already at the far left
         If sf[counter].x <= 0 
            sf[counter].x = (GraphicsWidth() - 1)
         Else
            sf[counter].x = sf[counter].x - speed         
         EndIf
      Next
   EndMethod
EndType

'Create the starfield object
Global starfield1:TStarField = New TStarField

'main loop

While Not KeyHit(KEY_ESCAPE)

   Cls

   'print instruction text to screen
   SetColor(255,255,255)
   DrawText "Hit [Esc] key to exit", 10,10
   DrawText "Press 1, 2 or 3 to change speed", 10, 25
   Local speedString:String = "Current Speed is: " + String.FromInt(starfield1.speed)
   DrawText speedString, 10, 40 
   
   'check for and change speed
   If KeyDown(KEY_1) Then starfield1.SetSpeed(1)
   If KeyDown(KEY_2) Then starfield1.SetSpeed(2)
   If KeyDown(KEY_3) Then starfield1.SetSpeed(3)
 
   'check for movement key press
   If KeyDown(KEY_UP) Then starfield1.MoveUp()
   If KeyDown(KEY_DOWN) Then starfield1.MoveDown()
   If KeyDown (KEY_LEFT) Then starfield1.MoveLeft()
   If KeyDown (KEY_RIGHT) Then starfield1.MoveRight()
   
   'draw the starfield
   starfield1.DrawField()

   Flip

Wend

End