Capacitación básica en Computación
Star Field Simulator
Graphical Animated Small Basic Program Gallery
Star Field Simulator Microsoft Small Basic
‘ Program Listing: GPZ070
- 5. ‘ Krueg – Starfield — Sept. 2012
- 6. Delay = 60 ‘Delay for smooth framrate
- 7. StarQty = 80 ‘Number of stars, Too many and it slows the program
- 8. SetupWindow()
- 9. CreateStars()
- 10. While (“True”)
- 11. MoveStars()
- 12. RefreshRate() ‘Comment out this line to see the jerkiness of the array proccessing
- 13. EndWhile
- 14. Sub RefreshRate
- 15. While Clock.ElapsedMilliseconds < FrameRate
- 16. EndWhile
- 17. FrameRate = Clock.ElapsedMilliseconds + Delay
- 18. EndSub
- 19. Sub MoveStars
- 20. For i = 1 To StarQty
- 21. StarY[i] = StarY[i] + StarHeight[i] * 1.5
- 22. If StarY[i] > gh Then
- 23. StarY[i] = StarY[i] – gh
- 24. StarX[i] = Math.GetRandomNumber(gw – 10) + 5
- 25. EndIf
- 26. Shapes.Move(Star[i],StarX[i],StarY[i]) ‘Checking which moves smother, Shapes.Move or Shapes.Animate
- 27. ‘Shapes.Animate(Star[i],StarX[i],StarY[i],0)
- 28. EndFor
- 29. EndSub
- 30. Sub CreateStars
- 31. For i = 1 To StarQty
- 32. GraphicsWindow.PenColor = “White”
- 33. GraphicsWindow.BrushColor = “White”
- 34. StarWidth[i] = Math.GetRandomNumber(2)
- 35. If i < (StarQty * .9) Then
- 36. StarHeight[i] = Math.GetRandomNumber(3) ‘Create more small stars than big
- 37. Else
- 38. StarHeight[i] = Math.GetRandomNumber(4)+4
- 39. EndIf
- 40. Star[i] = Shapes.AddEllipse(StarWidth[i],StarHeight[i])
- 41. Shapes.SetOpacity(Star[i],StarHeight[i]*5+50)
- 42. StarX[i] = Math.GetRandomNumber(gw – 10) + 5
- 43. StarY[i] = Math.GetRandomNumber(gh)
- 44. Shapes.Move(Star[i],StarX[i],StarY[i])
- 45. EndFor
- 46. EndSub
- 47. Sub SetupWindow
- 48. gw = 800
- 49. gh = 600
- 50. GraphicsWindow.Top = 5
- 51. GraphicsWindow.Left = 5
- 52. GraphicsWindow.Width = gw
- 53. GraphicsWindow.Height = gh
- 54. GraphicsWindow.BackgroundColor = “Black”
- 55. EndSub
- 56. ‘ Copyright (c) Microsoft Corporation. All rights reserved.
%d bloggers like this:
No comments:
Post a Comment