Welcome to Phrogram Sign in | Join | Help


ATOM Project

  •  09-22-2006, 8:01 PM

    ATOM Project

    Teddy,

    I think we should just keep moving from right here.

    The last thing we were doing was making a sprite travel in a circle in the window. Do you have any code written to do this?

    Here's something I wrote:

    Program AQuickCircle
     Method Main()
      Define WindowWidth  As Int  = 300
      Define WindowHeight  As Int  = ConvertToInt(WindowWidth *.75)
      
      Define Radius   As Int  = 50
      Define CenterX   As Decimal = WindowWidth /2
      Define CenterY   As Decimal = WindowHeight /2
      Define SpriteX   As Decimal = 0
      Define SPriteY   As Decimal = 0
      Define PI    As Decimal = 3.14159265
      Define CircleInRadians As Decimal = 2 * PI
      Define Slice   As Decimal = CircleInRadians / 30
      
      Define SecondsToLoop As Decimal = 0.0
      Define StartTime  As Decimal = 0.0
      
      Define InnerLoop  As Decimal = 0
      Define OuterLoop  As Int  = 0
      Define NumOuterLoops As Int  = 30
      
      SetScreenSize(WindowWidth, WindowHeight)
      SetDeviceCoordinates()
      Clear(White)
      
      LoadSprite("Electron", "Bulb_Blue_lighto.png")
      HideSprite("Electron")
      ScaleSprite("Electron", .05)

      StartTime = TickCount()
      For OuterLoop = 1 To NumOuterLoops
       For InnerLoop = 0 To CircleInRadians Step Slice
        SpriteX = Cos(InnerLoop)*Radius+CenterX
        SpriteY = Sin(InnerLoop)*Radius+CenterY
        MoveSpriteToPoint("Electron", SpriteX, SpriteY)
        StampSprite("Electron")
       Next
      Next
      SecondsToLoop = RoundToPlace((TickCount()-StartTime)*.0001, 2)
      ConsoleWriteLine("LoopTime: " + SecondsToLoop + " seconds using radians and StampSprite to draw it " + NumOuterLoops + " times.")
      ShowConsole()
      Delay(5000)
      HideConsole()
     End Method
    End Program

    Filed under:
View Complete Thread