Brightsign BrightScript 2 Reference Guide Bedienungsanleitung Seite 57

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 59
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 56
57
snake.TurnWest=snkTurnWest
snake.MoveForward=snkMoveForward
snake.MakeLonger=snkMakeLonger
snake.AddSegment=snkAddSegment
snake.EraseEndBit=snkEraseEndBit
REM
REM a "snake" is a list of line segments
REM a line segment is an roAssociativeArray that conains a length and direction (given by the x,y
delta needed to move as it is drawn)
REM
snake.seg_list = CreateObject("roList")
snake.AddSegment(1,0,3)
REM
REM The X,Y pos is the position of the head of the snake
REM
snake.snake_X=x
snake.snake_Y=y
snake.body=191 ' use asc("*") if graphics not enabled.
snake.dx=1 ' default snake direction / move offset
snake.dy=0 ' default snake direction / move offset
return snake
End Function
Sub snkDraw(text_field As Object)
x=m.snake_X
y=m.snake_Y
for each seg in m.seg_list
xdelta=seg.xDelta
ydelta=seg.yDelta
for j=1 to seg.Len
text_field.SetCursorPos(x, y)
text_field.SendByte(m.body)
x=x+xdelta
y=y+ydelta
next
next
End Sub
Sub snkEraseEndBit(text_field As Object)
x=m.snake_X
y=m.snake_Y
for each seg in m.seg_list
x=x+seg.Len*seg.xDelta
y=y+seg.Len*seg.yDelta
next
text_field.SetCursorPos(x, y)
text_field.SendByte(32) ' 32 is ascii space, could use asc(" ")
End Sub
Function snkMoveForward(text_field As Object)As Boolean
m.EraseEndBit(text_field)
tail=m.seg_list.GetTail()
REM
REM the following shows how you can use an AA's member functions to perform the same
REM functions the BrightScript . operator does behind the scenes for you (when used on an AA).
REM there is not point to this longer method other than illustration
REM
len=tail.Lookup("Len") ' same as len = tail.Len (or tail.len, BrightScript syntax is not
case sensative)
len = len-1
if len=0 then
Seitenansicht 56
1 2 ... 52 53 54 55 56 57 58 59

Kommentare zu diesen Handbüchern

Keine Kommentare