Results 1 to 5 of 5

Thread: rotate shapes... look at enclosed [resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    352

    rotate shapes... look at enclosed [resolved]

    Ok... in the enclosed project, i have three shapes. How can i make it so that the shapes would like turn around in a circle, shape1 would slowly move into shape2's position, shape2 to shape3 and so forth. A sort of tween, does anyone know how i would be able to accomplish this?

    Thx in advance!
    Attached Files Attached Files
    Last edited by MXAlPhA; Dec 18th, 2002 at 07:08 PM.

  2. #2
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    add a timer, set the interval to 10, then add this code:

    VB Code:
    1. Option Explicit
    2. Const Pi As Double = 3.14159265358979
    3. Dim Angle As Single
    4. Dim CW As Boolean
    5.  
    6. Private Sub Command1_Click()
    7. If Timer1.Enabled = True And CW = True Then
    8.     Timer1.Enabled = False
    9. ElseIf Timer1.Enabled = False Then
    10.     Timer1.Enabled = True
    11. End If
    12. CW = True
    13. End Sub
    14.  
    15. Private Sub Command2_Click()
    16. If Timer1.Enabled = True And CW = False Then
    17.     Timer1.Enabled = False
    18. ElseIf Timer1.Enabled = False Then
    19.     Timer1.Enabled = True
    20. End If
    21. CW = False
    22. End Sub
    23.  
    24. Private Sub Timer1_Timer()
    25. Dim CenterX As Single
    26. Dim CenterY As Single
    27. Dim TempAngle As Single
    28. CenterX = Me.ScaleWidth / 2
    29. CenterY = Me.ScaleHeight / 2
    30. Angle = Angle + 2
    31. If Angle > 360 Then Angle = Angle - 360
    32.  
    33. If CW = True Then
    34.     TempAngle = Angle
    35. Else
    36.     TempAngle = 360 - Angle
    37. End If
    38.  
    39. Shape1.Left = CenterX + Sin(TempAngle * (Pi / 180)) * 1000
    40. Shape1.Top = CenterY + Cos(TempAngle * (Pi / 180)) * 1000
    41.  
    42. Shape2.Left = CenterX + Sin((TempAngle + 120) * (Pi / 180)) * 1000
    43. Shape2.Top = CenterY + Cos((TempAngle + 120) * (Pi / 180)) * 1000
    44.  
    45. Shape3.Left = CenterX + Sin((TempAngle + 240) * (Pi / 180)) * 1000
    46. Shape3.Top = CenterY + Cos((TempAngle + 240) * (Pi / 180)) * 1000
    47.  
    48. End Sub
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    352
    That's amazing!!! thx... we just learned about sin and cosine in my math class a couple of days ago!! REFERENCE TRIANGLES!!! AHHH!!

  4. #4
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    heheh
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2002
    Posts
    352
    one question... i understand how the code works, just wondering what grade or whe were you learning in school when you learned this? I'm in my last year of required mathematics in my school, and well, we just barely covered half of the math you have in your code.


    Basically, i want to know if this is something that i should be able to do with computers at my mathematics level or something that is in a higher level math course.


    From your open source code, i can see you're MUCH more ahead of me in math.

    And your pong game, was it developed using any directx or opengl api's? or just like plain vb?
    Last edited by MXAlPhA; Dec 18th, 2002 at 07:05 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width