Jump to content

Roda da roleta


Go to solution Solved by vikcch,

Recommended Posts

Posted

Boas pessoal,

Bem planeei um projeto na escola para desenvolver uma roleta em VB10, no entanto surgiu-me logo a dúvida como desenvolver a roda e a bola da roleta em movimento, pois nunca trabalhei com movimentos, apenas com objetos para inserção de dados 😕

Ainda não iniciei o projeto, ainda estou no papel na fase de planeamento, gostaria que alguém me pudesse ajudar, já procurei em todo o lado e não consegui encontrar, se alguém me poder indicar um site ou mesmo um tutorial agradecia imenso.. 🙂

Obrigado 👍 👍 👍 :thumbsup:

  • Solution
Posted

Para a roda podes usar uma imagem da roda e a rodares lol...

    Private Function RotateImage(ByVal b As Bitmap, ByVal angle As Single) As Bitmap
    'create a new empty bitmap to hold rotated image
    Dim returnBitmap As New Bitmap(b.Width, b.Height)

    'make a graphics object from the empty bitmap
    Dim g As Graphics = Graphics.FromImage(returnBitmap)

    'move rotation point to center of image
    g.TranslateTransform(CSng(b.Width) / 2, CSng(b.Height) / 2)

    'rotate
    g.RotateTransform(angle)

    'move image back
    g.TranslateTransform(-CSng(b.Width) / 2, -CSng(b.Height) / 2)

    'draw passed in image onto graphics object
    g.DrawImage(b, New Point(0, 0))

    Return returnBitmap
   End Function

   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Static angle As Integer = 10

    PictureBox2.Image = RotateImage(PictureBox1.Image, angle)
    angle += 10
   End Sub

Usa 2 picturesbox e um timer, a picturebox1 serve só para teres acesso à imagem original, podes o meter visible = false ou carregares a imagem para uma variavel bitmap... se rodares a imagem varias vezes sem ser da original começa a ficar desfocada.....

Para a bola acho que o mais simples é algo parecido com isto:

    Private Sub PictureBox3_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox3.Paint

    Dim bolaDiamentro As Single = 10

    Static x As Single = PictureBox3.Width / 2
    Static y As Single = -bolaDiamentro / 2

    Static angle As Single = 0.1

    'tens que acertar aqui os valores que não está perfeito
    x += Math.Cos(angle) * (PictureBox3.Width / 20)
    y += Math.Sin(angle) * (PictureBox3.Height / 20)

    e.Graphics.FillEllipse(Brushes.Black, New RectangleF(x, y, bolaDiamentro, bolaDiamentro))
    angle += 0.1

   End Sub

   Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
    PictureBox3.Invalidate()
   End Sub

para saber onde a bola caiu, deves ter que fazer uma formula para que assim que lançes a bola saibas logo o que vai sair....

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.