Ask a questionAsk a question
 

AnswerSome PRO out there?

  • Thursday, June 04, 2009 8:47 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I wan to noe hw i could create a moving animation using VB2005.. The steps to do as well as the codes...please help

Answers

  • Tuesday, June 09, 2009 9:46 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    they are 2 different EVENTS for 1 button..
    any control that you have and can use, like the buttons, labels, textboxes, etc., have events.. stuff what that control can do..
    double click button 1, then on the code page, in the top right side , there is a drop down menu with the control's EVENTS ..  there you can find alot of goodies, like when you press the mouse button, _MouseDown event, and when you let go of the mouse button, _MouseUp event..  select an event and enter the code you would like your application to proceed with..

    let me know if this helps.

    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Tuesday, June 09, 2009 9:52 AM
    •  
  • Thursday, June 11, 2009 8:42 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    i ended up putting something together, just for fun..

    start by creating a new project.
    save the images below, and add them to your resources folder..
    http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/carup.png http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/carright.png http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/cardown.png http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/carleft.png

    on your form, add a panel from the toolbox.  resize the panel the size of your form.  the bigger the form, the more driving room. ;o)
    then add the code below:

    Public Class Form1
    
        Dim bmp As Bitmap = New Bitmap(My.Resources.carup)
        Dim offset As Size = New Size(0, 0)
    
        Private Sub panel1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles Panel1.Paint
            Dim g As Graphics = e.Graphics
            Dim destRect As Rectangle = Me.Panel1.ClientRectangle
            Dim srcRect As Rectangle = New Rectangle(offset.Width, offset.Height, destRect.Width, destRect.Height)
            g.DrawImage(bmp, destRect, srcRect, g.PageUnit)
        End Sub
    
    
        Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            Dim bHandled As Boolean = False
            Select Case e.KeyCode
                Case Keys.Right
                    bmp = My.Resources.carright
                    offset.Width = offset.Width - 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Left
                    bmp = My.Resources.carleft
                    offset.Width = offset.Width + 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Up
                    bmp = My.Resources.carup
                    offset.Height = offset.Height + 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Down
                    bmp = My.Resources.cardown
                    offset.Height = offset.Height - 10
                    Panel1.Refresh()
                    e.Handled = True
            End Select
    
        End Sub
    
    
    End Class
    
    hope you like driving your new car..

    i got the image from image googling for 'top view of car'..


    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Thursday, June 11, 2009 9:57 AM
    •  
  • Wednesday, June 17, 2009 5:36 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    troubling me with vb questions that i actually understand?
    you are funnnnnnny! lol..  i would not be a member of a forum if i did not enjoy helping others or getting help..

    posted above by me:
    "i think this project is about done, and you might have to start looking into some of the above links posted by other members in order to get a real car driving form... one when u run into things, it stops, blows up, flies away, etc.
    "


    that black shading:
    what i noticed, on my p.c. (though i have a decent video card) is that the form kind of glitches when driving the car with my new background..
    that's not my problem to solve.. ;o)


    traveling within the form:
    try this link..
    VB Helper: HowTo: Make a bouncing ball animation in VB .NET

    i know it's not a car driving, but it has code in it to make the ball bounce inside your form and stay inside the form.. you might be able to figure something out.  eventually you will.
    the code on that page works entirely..

    you'll need a timer, and whoever put this code together, has this for the timer:

    Private Sub tmrMoveBall_Tick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles tmrMoveBall.Tick

    just add the code from that tmrMoveBall_Tick ()event (which is the timer's event, they just renamed it) to your Private Sub Timer1_Tick()..

    you can copy the rest of the code and paste it on your form.. also, set your timer to enabled=true and if you want the ball to bounce faster, change the interval in the properties to 1.

    i'm fairly busy right now, but i figured the above information is better than nothing..

    and no, gene9956, never any trouble asking a question on a forum.  what if i go on vacation? lol..
    trujade.
    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Wednesday, June 17, 2009 5:55 AM
    •  
  • Monday, June 22, 2009 3:20 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    gene, when you do finish your sensor project and is available online for viewing/whatever, post a link here so i can see your work.. if not, you can email me from one of the links i posted with my website stuff.. ;o)

    later,
    trujade.

    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Wednesday, June 24, 2009 5:46 AM
    •  

All Replies

  • Thursday, June 04, 2009 9:04 AMCor LigthertMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Gene it is better to put a better question in in the ask row.

    This question that you has stated now, can simply be answered with yes.

    But animations are not my part of the profession

    Cor

  • Thursday, June 04, 2009 9:05 AM_asgar Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    You can use  the paintevent to draw Images or you can use a picturebox and a Timer to move the Image or picturebox.


    Asgar
  • Thursday, June 04, 2009 9:29 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i tried using the picturebox and timer..But it failed.. i wonder if it's something wrong with the coding.. I used 3 picturebox with the same image and set all to visible false .. do u noe exactly how to solve it..?million thanks
  • Thursday, June 04, 2009 10:28 AM_asgar Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     Set PictureBox1.Visible = True

    Can you post some of your code so that we can correct it if something is wrong with it.
    Asgar
  • Thursday, June 04, 2009 11:07 AMDoug__ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Read through the threads in this forum search.  You should find some that have code and explanations.

    http://social.msdn.microsoft.com/Search/en-US/?Refinement=112&query=animation&rq=meta:Search.MSForums.ForumID(0f60fa48-1ceb-41ee-a10a-0dfcee7e19bd)&rn=Visual+Basic+General+Forum

    If some have code written in C#, you can go to one of these websites and convert it to VB.Net (it's free).

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    http://www.carlosag.net/Tools/CodeTranslator/


    Doug
  • Thursday, June 04, 2009 12:14 PMCodeCruiser Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed Answer
    Start by reading here

    http://www.codeproject.com/KB/directx/

    http://hotfilms.org/ebooks/learn-vbulletin-net-through-game-programming-source-code-26428.html



    By the way, posting the question repeatedly and with strange titles wont help at all!!!
    If this post is useful, mark it as answer.
    • Proposed As Answer byEarl Tut Monday, June 08, 2009 6:29 AM
    •  
  • Thursday, June 04, 2009 11:00 PMDoug__ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Make sure you close all of these threads (because you multi-posted) when you get a response in any of them that you think answers your question.


    Doug
  • Friday, June 05, 2009 12:16 AMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Gene it is better to put a better question in in the ask row.

    This question that you has stated now, can simply be answered with yes.

    But animations are not my part of the profession

    Cor


     i noticed, everyone of your replies is  always proposed as answer includes any reply that doesnt even related to OP question. Im not asking you to stop doing it.
    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
  • Friday, June 05, 2009 1:10 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Private

     

    Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Timer2.Enabled =

    False

    Timer3.Enabled =

    False

     

     

     

     

    End Sub

     

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Picture3.Visible =

    False

    Picture1.Visible =

    True

    Timer2.Enabled =

    True

    Timer1.Enabled =

    False

     

    End Sub

     

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

    Picture1.Visible =

    False

    Picture2.Visible =

    True

    Timer3.Enabled =

    True

    Timer2.Enabled =

    False

     

    End Sub

     

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick

    Picture2.Visible =

    False

    Picture3.Visible =

    True

    Timer1.Enabled =

    True

    Timer3.Enabled =

    False

     

    End Sub

     

    Private Sub Picture2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Picture2.Click

     

    End Sub

    End

     

    Class

  • Friday, June 05, 2009 2:16 AMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    What kind object you want to animate, you just post a code here that does nothing.The link below have little code how to animate a ball . http://www.vb-helper.com/howto_net_screen_saver.html
    kaymaf

    I hope this helps, if that is what you want, just mark it as answer so that we can move on
  • Friday, June 05, 2009 3:31 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I want to animate example a car moving using VB2005. Best to be operated using buttons. Thanks.
    • Edited byGene9956 Friday, June 05, 2009 3:52 AM
    •  
  • Friday, June 05, 2009 4:54 AMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It will be very difficult for someone to give you full code on animation of moving car, i will advice you to read about GDI+ graphics class from http://www.bobpowell.net/beginnersgdi.htm so that you can have an idea about graphics animation in .NET

    Also, some example tutorials from the links below.
    http://radar08.codeplex.com/
    http://www.codeproject.com/KB/GDI-plus/CustomAnimation.aspx

    http://visualbasic.about.com/od/learnvbnet/ss/ecvbsbs1701.htm

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
  • Friday, June 05, 2009 5:23 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    thanks anyway
  • Friday, June 05, 2009 5:33 AMCor LigthertMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Gene,

    I gave you a decent answer in the group with a name were more people can reply on than only Pro's which has a decent description of your problem.

    Why are you only replying here?

    Cor
  • Friday, June 05, 2009 5:38 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    try to get away from using so many timers....

    does this help..

    'Imagelist needed
    
    Public Class Form1
        Dim imageNumber As Integer = 0
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            PictureBox1.Image = ImageList1.Images(0)
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            PictureBox1.Image = ImageList1.Images(imageNumber)
            imageNumber = imageNumber + 1
            If imageNumber > ImageList1.Images.Count - 1 Then
                imageNumber = 0
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            If Timer1.Enabled Then
                Timer1.Stop()
            Else
                Timer1.Start()
            End If
        End Sub
    End Class
    
    
    
    just add the images in the imagelist in the order you want them to show. and you can change the interval to 2000 on the timer to slow them down..

    this code should be easy to figure out..

    trujade.


    help out microsoft for helping you.. test run 7
  • Friday, June 05, 2009 5:49 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    u do need to 'noe hw' to post a title for a thread.. this way the members that are capable of answering or might have an idea of how to help out with the answer, will click on the posted thread.. otherwise, it will get skipped.. i still don't see how you got answers, (just/kidding, this is a good forum). foe sizza.... trujade
    help out microsoft for helping you.. test run 7
  • Friday, June 05, 2009 5:53 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
     you just post a code here that does nothing.
    ...
    just thought it was funny.. u crack me up sometimes kaymaf.. keep it up!

    help out microsoft for helping you.. test run 7
  • Friday, June 05, 2009 7:52 AMCodeCruiser Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Why dont you read the links posted by me and other members???
    If this post is useful, mark it as answer.
  • Friday, June 05, 2009 1:06 PMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    try to get away from using so many timers....

    does this help..

    'Imagelist needed
    
    
    
    Public Class Form1
    
        Dim imageNumber As Integer = 0
    
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            PictureBox1.Image = ImageList1.Images(0)
    
        End Sub
    
    
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            PictureBox1.Image = ImageList1.Images(imageNumber)
    
            imageNumber = imageNumber + 1
    
            If imageNumber > ImageList1.Images.Count - 1 Then
    
                imageNumber = 0
    
            End If
    
        End Sub
    
    
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            If Timer1.Enabled Then
    
                Timer1.Stop()
    
            Else
    
                Timer1.Start()
    
            End If
    
        End Sub
    
    End Class
    
    
    
    
    
    
    just add the images in the imagelist in the order you want them to show. and you can change the interval to 2000 on the timer to slow them down..

    this code should be easy to figure out..

    trujade.


    help out microsoft for helping you.. test run 7
      @Trujade, you are doing a slideshow not animation, the OP want to animate a car

    kaymaf

     

    I hope this helps, if that is what you want, just mark it as answer so that we can move on
  • Saturday, June 06, 2009 4:41 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i kinda figured that maybe, just maybe, if he had 3 images for the car to go left, 3 for the car to go right, and one for the car to stay in the middle, then somehow, he might be able to figure it out how to add another button and a timer  and have it do just so.. this is the simplest idea i can think of to get started with such a project..

    another image list?  ...
    help out microsoft for helping you.. test run 7
    • Edited by•.trujade.• Saturday, June 06, 2009 4:42 AMforgot the other image list
    •  
  • Monday, June 08, 2009 5:24 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    anyway thanks for ur reply though i still can't figure out what it is.. manage to create something, however i find it somehw not really what i wanted.. I uses 3 images to create..  using only 1 timer..below r the coding..

    Public

     

    Class Form1

     

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Button1.Enabled =

    True

    PictureBox1.Visible =

    True

    PictureBox2.Visible =

    False

    PictureBox3.Visible =

    False

    Button2.Enabled =

    False

     

     

    End Sub

     

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

    Button2.Enabled =

    True

    PictureBox2.Visible =

    True

    PictureBox1.Visible =

    False

    PictureBox3.Visible =

    False

    Button1.Enabled =

    False

     

     

     

     

    End Sub

     

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

     

     

     

    End Sub

     

     

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Button1.Enabled =

    True

    Button2.Enabled =

    True

    PictureBox3.Visible =

    True

     

    End Sub

    End Class

  • Monday, June 08, 2009 5:53 AM_asgar Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It is not clear from your code what you are trying to do,kindly explain in words what you are trying.
    I think you are rying to show the three pictureboxes in a sequence.

    Asgar
    • Edited by_asgar Monday, June 08, 2009 6:01 AMCorr
    •  
  • Monday, June 08, 2009 6:25 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i inserted 3 pictureboxs.. with 3 different images.. picturebox1  (a vehicle with wheels turning towards the left) picturebox2 ( same vehicle with wheels turning towards the right) picturebox3 (with wheels towards the centre) with all images set to visible true in the properties windows

    With 2 buttons inserted (left) and (right)
    (left button) named as button1
    (right button) named as button 2

    with a timer inserted interval set to 5000 ( so as to make the wheels turn back to centre after 5s once i clicked onto any of the buttons)

    coding for left button

    Button1.Enabled =

    True

    PictureBox1.Visible =

    True

    PictureBox2.Visible =

    False

    PictureBox3.Visible =

    False

    Button2.Enabled =

    False


    coding for right button

    Button2.Enabled =

    True

    PictureBox2.Visible =

    True

    PictureBox1.Visible =

    False

    PictureBox3.Visible =

    False

    Button1.Enabled =

    False

    coding for timer

    Button1.Enabled =

    True

    Button2.Enabled =

    True

    PictureBox3.Visible =

    True

    And once everytime i played, when i clicked on let say left, the wheels will tilt left,after 5 seconds, the wheels will positioned back to centre. Same goes to right buttons.

     


  • Monday, June 08, 2009 6:30 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I hope to create something, which the speed of the vehicle can be adjusted, and the vehicles to move in many directions... but it seems to be quite hard?? And the vehicle to be turning in the way the body of the vehicle is turning, not oni the wheels... it must be somehow like 3D form.. possible? 

  • Monday, June 08, 2009 11:37 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    try this.. have a picturebox.. just one.. add your 3 images from the little arrow on top of the picturebox.. carleft, carright, and carcenter..
    then 2 buttons.. button1, goes left, and button2 goes right...

    then look over this code, should be simple to figure out:

     Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
            PictureBox1.Image = My.Resources.carleft
        End Sub
    
        Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
            PictureBox1.Image = My.Resources.carcenter
        End Sub
    
        Private Sub Button2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseDown
            PictureBox1.Image = My.Resources.carright
        End Sub
    
        Private Sub Button2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button2.MouseUp
            PictureBox1.Image = My.Resources.carcenter
        End Sub
    

    your car should stay in the center unless you click and hold one of the buttons down to go either way.. when u let go, as you see in the MouseUp event, it changes the image back to the carcenter, the image of your car going straight.. when selecting your images, make sure the image to load your form with, is the carcenter.

    hope this help.. sorry it took so long, just got the moh 10th yr.

    trujade



    help out microsoft for helping you.. test run 7
  • Monday, June 08, 2009 11:44 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I hope to create something, which the speed of the vehicle can be adjusted, and the vehicles to move in many directions... but it seems to be quite hard?? And the vehicle to be turning in the way the body of the vehicle is turning, not oni the wheels... it must be somehow like 3D form.. possible? 

    you might be able to place a smaller image with your car, on top of the image with the road. have this image change the location by pressing a button or a key..
    PictureBox1.Location = New Point(10, 45)

     then (after you figure this out let me know how) get the road picture box to scroll down with the keypress of the up/down arrow and have a timer keep track of how long you had the button held down and for every second held, to speed up the scrolling of the road image..  this sounds like a fun project.. let me know how it turns out..

    about my above reply, you do know how to add images to your resource folder, right?  same as adding one image, just select the other images to import with it.

    trujade..

    help out microsoft for helping you.. test run 7
  • Monday, June 08, 2009 4:45 PMReed KimbleModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Gene it is better to put a better question in in the ask row.

    This question that you has stated now, can simply be answered with yes.

    But animations are not my part of the profession

    Cor


    Cor, Please do not propose your own responses as answer.  The "propose as answer" system allows other contributors to "second" your solution.  This lets the OP know that more than one person believes the answer has been given.  If you propose the answer yourself you prevent someone else from seconding your solution.

    You might also want to review the general guidelines found in various sticky posts in the forums as several other contributors are indicating that you may be abusing the forums.
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
  • Monday, June 08, 2009 5:10 PMReed KimbleModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I wan to noe hw i could create a moving animation using VB2005.. The steps to do as well as the codes...please help

    Gene9956,

    Please review the info provided by users like Kaymef, Doug, Asgar, and CodeCruiser.

    You will use a GDI Graphics object or the DirectX API to render animation in VB.Net.  Your performance requirements and complexity of animation will determine which route you need take.

    You will not use multiple PictureBox controls to do animation.  You should abandon that entire line of thinking now.

    Here are some additional threads which may be of help:

    Hang Man Demo (example of rendering a new GDI image from scratch in real-time)
    http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/16346a46-bde4-47c1-97e8-a764f26ceb1a

    2D Animation Game Engine Using DirectX Example
    http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/e2764dd9-86de-4e19-95d6-22b5934b3859/

    Playing Card Game Example (Plus lots of talk on design - scroll to about 1/4 down to find the first Card Game posts)
    http://social.msdn.microsoft.com/Forums/en-US/vblanguage/thread/0955f1fb-bf80-4dea-a1b7-6f11ae2f448e/
    Actually I think a number of threads got merged into this one, so there's all kinds of discussion in here, but the card game stuff shows some good examples of GDI rendering versus trying to manipulate a bunch of user controls.

    If you continue to search the forums, you can find a lot more examples and discussions on GDI rendering, drawing, and animation.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
  • Monday, June 08, 2009 5:11 PMReed KimbleModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Make sure you close all of these threads (because you multi-posted) when you get a response in any of them that you think answers your question.


    Doug

    Doug, if you happen to have the other links please provide them and I'll clean up the duplicate mess.

    Thanks!
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
  • Monday, June 08, 2009 10:35 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    here's one link that i know of Reed Kimble..

    How to create a moving animation using VB2005?
    help out microsoft for helping you.. test run 7
  • Monday, June 08, 2009 10:59 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Can anyone help???

    that's the second link..   i should've thought of this before posting the first link.. 'check gene9956's threads'.. 

    trujade.
    sorry doug.. no marked answer for you.. lol.. aruba? ;o)
    help out microsoft for helping you.. test run 7
  • Tuesday, June 09, 2009 5:40 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi trujade, i tried to add 3 images to 1 picturebox, but somehw unable to .. Only one of the 3 images can be added... 
  • Tuesday, June 09, 2009 9:40 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hey sorry turjade.. i still dun quite understand.. how come 1 button left can have 2 names..

    Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
            PictureBox1.Image = My.Resources.carleft
        End Sub

        Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
            PictureBox1.Image = My.Resources.carcenter
        End Sub



    You r using one button, on the propertities window, how to add another name on it? 1st name(Button_MouseDown)
    and 2nd (Button_MouseUp) using only 1 button...
     How to add the 2nd name on the propertities window?

    Sorry to trouble, coz i really felt lost... :(

  • Tuesday, June 09, 2009 9:46 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    they are 2 different EVENTS for 1 button..
    any control that you have and can use, like the buttons, labels, textboxes, etc., have events.. stuff what that control can do..
    double click button 1, then on the code page, in the top right side , there is a drop down menu with the control's EVENTS ..  there you can find alot of goodies, like when you press the mouse button, _MouseDown event, and when you let go of the mouse button, _MouseUp event..  select an event and enter the code you would like your application to proceed with..

    let me know if this helps.

    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Tuesday, June 09, 2009 9:52 AM
    •  
  • Tuesday, June 09, 2009 9:52 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    oh.. thanks.. I'll try it out and let u know again...
    Thanks! :)
  • Tuesday, June 09, 2009 9:59 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    sounds good.
    in your time off you can view my threads on this forum. alot of stuff to learn from.  just click my name, then select to view  trujade's threads , or just click that link.. start with the last page.  simple stuff to get started with vb.net.

    help out microsoft for helping you.. test run 7
  • Wednesday, June 10, 2009 3:24 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi trujade, i tried to add 3 images to 1 picturebox, but somehw unable to .. Only one of the 3 images can be added... 

    i'm not sure if i answered this but here's how..
    you can only add one picture to the picturebox, correct.  as long as you have the images loaded as i explained somewhere above in this post, then by using this line as a example:

    PictureBox1.Image = My.Resources.carcenter
    


    delete the carcenter and the dot before it and add the dot again.. this should give you a dropdown menu with all available images in your resources folder..
    hope this helps out if you haven't figured it out by now.

    trujade

    help out microsoft for helping you.. test run 7
  • Wednesday, June 10, 2009 3:43 AMDoug__ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Make sure you close all of these threads (because you multi-posted) when you get a response in any of them that you think answers your question.


    Doug

    Doug, if you happen to have the other links please provide them and I'll clean up the duplicate mess.

    Thanks!
    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    Hi Reed,

    I would have posted the links to the duplicates, but one person (remaining unnamed) has voiced his displeasure with me doing that.  Trujade has given one link in his post, and if I remember correctly, there were a total of 3 posts for this same topic.  I'll look thru the OP's list and see if I can find the other link.

    Should I always post the links to duplicated questions so you guys can clean up?  Dups are inconsiderate and just create more work for you!

    **  EDIT  **
    Found them both:

    http://social.msdn.microsoft.com/Forums/en-US/linqprojectgeneral/thread/28e72d35-ac99-4565-b1c8-4363964bef0f

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2f2cdd99-d00b-4698-aded-fbe2564e147a




    Doug
  • Wednesday, June 10, 2009 3:48 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    doug.. look right under the reply link i posted as a second thread..  you might find the third one and a way to find same posts easier..

    " but one person (remaining unnamed)"
    lol..
    help out microsoft for helping you.. test run 7
  • Wednesday, June 10, 2009 3:55 AMDoug__ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Uh oh, my bad!  I didn't read down that far.  Just saw the one post you made with the dup link.  Oh well, there should be plenty of information for the dups to get dealt with!   LOL


    Doug
  • Wednesday, June 10, 2009 3:56 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    help out microsoft for helping you.. test run 7
  • Wednesday, June 10, 2009 4:00 AMDoug__ Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    At least I credited you with the post that I DID see!   LOL



    Doug
  • Wednesday, June 10, 2009 4:04 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i was hoping for a proposed answer, but that will do.. thanx doug for editing your post.. makes my reply look good..
    help out microsoft for helping you.. test run 7
  • Thursday, June 11, 2009 5:16 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Guys, is there idea how to enhance the images and graphic of my project? How can i do about it?

  • Thursday, June 11, 2009 5:37 AMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Guys, is there idea how to enhance the images and graphic of my project? How can i do about it?


    what do you mean by enhance your images and graphics?  There are lot of links posted for you in this thread about graphics class using GDI+. well, If you want to use picturebox for your graphics, you will have long way to go because picturebox is mainly design to view image, it doesn't have property or method to enhance image.

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
  • Thursday, June 11, 2009 5:45 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    ya i know.. btw, if i wanted to create something like a game ( racing car) , so i can only use solely on GDI+? combination of VB2005 possible?

    And also , i tried clicking on the link, stated as page not found.
  • Thursday, June 11, 2009 6:26 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    if you want 3d images, you need a 3d imager..  Autodesk - Autodesk 3ds Max , a world creator, etc..  just google for 3d stuff.
    there are a few freeware imagers online, but the only thing you get from those, is frustration, if you don't have any ideas on what vertices, for example, means.

    combining the images with code, don't ask me how.. ;o)

    these are a few images from xna for a car game startup kit.  it's designed for c#, which is not much different than vb, but to me, it is.
    their startup kits, usually have one designed level to play, and you can modify the games.   that's about all i can tell you about xna, other than that the games, are to be designed for xbox or such..



    XNA Creators Club Online - home

    i would say "happy gaming", but honestly....

    trujade...

    help out microsoft for helping you.. test run 7
  • Thursday, June 11, 2009 6:38 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    wah.. I guess don't have to be so complicated.. But as least, the image or graphic  have to look presentable  .. Coz after all, i need not use to many buttons to operate... As the main purpose is to use
    SENSOR to test whether the images of the car synchronises with the movement of the sensor.. (eg when i move left,the car move left)

     
  • Thursday, June 11, 2009 6:40 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    and also, something to do with serial port( which I'm lost too)
  • Thursday, June 11, 2009 7:02 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    have you tried drawing a car on paper, then scanning the images, and flipping them in a image editor to get the same result for both sides?

    all that stuff you mentioned about sensoring your game and you didn't know what a event was?
    no hard feelings, but you have a ways to go.  don't start from the finish line and run backwards towards the starting line.. you'll never finish your race..

    trujade.

    help out microsoft for helping you.. test run 7
  • Thursday, June 11, 2009 8:42 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    i ended up putting something together, just for fun..

    start by creating a new project.
    save the images below, and add them to your resources folder..
    http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/carup.png http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/carright.png http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/cardown.png http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/carleft.png

    on your form, add a panel from the toolbox.  resize the panel the size of your form.  the bigger the form, the more driving room. ;o)
    then add the code below:

    Public Class Form1
    
        Dim bmp As Bitmap = New Bitmap(My.Resources.carup)
        Dim offset As Size = New Size(0, 0)
    
        Private Sub panel1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles Panel1.Paint
            Dim g As Graphics = e.Graphics
            Dim destRect As Rectangle = Me.Panel1.ClientRectangle
            Dim srcRect As Rectangle = New Rectangle(offset.Width, offset.Height, destRect.Width, destRect.Height)
            g.DrawImage(bmp, destRect, srcRect, g.PageUnit)
        End Sub
    
    
        Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            Dim bHandled As Boolean = False
            Select Case e.KeyCode
                Case Keys.Right
                    bmp = My.Resources.carright
                    offset.Width = offset.Width - 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Left
                    bmp = My.Resources.carleft
                    offset.Width = offset.Width + 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Up
                    bmp = My.Resources.carup
                    offset.Height = offset.Height + 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Down
                    bmp = My.Resources.cardown
                    offset.Height = offset.Height - 10
                    Panel1.Refresh()
                    e.Handled = True
            End Select
    
        End Sub
    
    
    End Class
    
    hope you like driving your new car..

    i got the image from image googling for 'top view of car'..


    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Thursday, June 11, 2009 9:57 AM
    •  
  • Thursday, June 11, 2009 9:06 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    forgot to mention.. this works with the keyboards arrow keys..
    help out microsoft for helping you.. test run 7
  • Thursday, June 11, 2009 9:46 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    1)regarding the form, only add a panel and nothing else?

    2)For the panel, at the properties window, do i need to set anything? And how to insert the 4 images at the properties window?
  • Thursday, June 11, 2009 9:56 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I got that...Thanks...guess it's much better then previous one i did...
  • Thursday, June 11, 2009 9:59 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    help out microsoft for helping you.. test run 7
  • Friday, June 12, 2009 7:16 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi, sorry to trouble u again..
    Was thinking if i could create something like when press keyboard (keydown) the car reverse, not the car facing front again..
    I think i will need the images of all angles of that car?
    Coz i actually wanted it to be something like the image of the car can move in various directions..(not only left ,right front, back)..
    Once again,Sorry for the trouble...
  • Friday, June 12, 2009 8:50 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    YUp.. Regarding the various direction part any idea?
    Eg when u hold (up key and press right key) the car will move in diagonal direction
    vice versa to (holding and pressing other directional keys)
  • Friday, June 12, 2009 9:09 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    ahhhh.. good one there gene..
    i saved the project so i finally got a chance to take a look at it.. and now i see, it's not as i thought..
    driving forward then putting it in reverse, works fine.. just when you turn a corner and want to drive the other way, it drives backwards..
      can't be driving backwards on a one way street... lol..

    this should not be too difficult.
     it can be done by placing a label somewhere on the form, set to visible=false, so it's not seen, when app runs, then when you press the up key, label1.text="1". when you press the right/left keys, the label's text changes to 0, label1.text="0", and when you press the down key, you'll have to use a if statement. 

     Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
            Dim bHandled As Boolean = False
            Select Case e.KeyCode
                Case Keys.Right
    
                    Label1.Text = "0"
    
                    bmp = My.Resources.carright
                    offset.Width = offset.Width - 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Left
    
                    Label1.Text = "0"
    
                    bmp = My.Resources.carleft
                    offset.Width = offset.Width + 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Up
    
                    Label1.Text = "1"
    
                    bmp = My.Resources.carup
                    offset.Height = offset.Height + 10
                    Panel1.Refresh()
                    e.Handled = True
                Case Keys.Down
    
                    If Label1.Text = "1" Then
    
                        bmp = My.Resources.carup
    
                    Else
    
                        bmp = My.Resources.cardown
    
                    End If
    
                    offset.Height = offset.Height - 10
                    Panel1.Refresh()
                    e.Handled = True
            End Select
    
        End Sub
    

    the car drive's much better now, but it's your car now so if you want the right/left buttons, to respond similarly, to the fwd/reverse, you might need another label, and slight recoding, not too far from the code above.

    trujade..




    help out microsoft for helping you.. test run 7
  • Friday, June 12, 2009 9:25 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    sorry, i did not catch your reply in time, so i delete the first reply before this last one..

    with that label deal, i found my self using it quite a bit, since you can have it do stuff in the label's text changed event..

     Private Sub Label1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.TextChanged
            If Label1.Text = "1" Then
                MsgBox("ok")
            ElseIf Label1.Text = "2" Then
                MsgBox("ok 2")
            ElseIf Label1.Text = "3" Then
                MsgBox("ok 3")
            End If
        End Sub
    
    this is just a helpful tip for once you get started building a busier form, and need room.. has nothing to do with driving the car.. just thought i'd add this little bit of info.

    trujade.



     

    help out microsoft for helping you.. test run 7
  • Friday, June 12, 2009 9:56 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    forgot to mention one thing, if not, you probably got a error..
    rename label1 to 0 or 1 before starting your app. or you can do as so:

      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Label1.Text = "1"
        End Sub
    
    sorry about that..
    trujade

    help out microsoft for helping you.. test run 7
  • Friday, June 12, 2009 3:10 PMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    ok thanks Trujade.. I'll try it out and let you know again as I can only do it in school..I'm really glad and happy there are people like you, so efficient and nice..
    THANKS! :)
  • Friday, June 12, 2009 3:27 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    n/p.. you have a fun project.
    another thing, if not yet done, paintshop,  if nothing else, draw some roads, bushes, houses, people, etc., and then you can run everything over with your shiny new car.. ;o)



    help out microsoft for helping you.. test run 7
  • Friday, June 12, 2009 3:35 PMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    ok thanks for your remind.. :)

  • Monday, June 15, 2009 9:20 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Trujade, I'm quite lost about this label thing. Previously, i did that without label, the car moves the same as though with a label. Coz right now i was thinking if the car can move in diagonal way. With the label, it still can't work.. For the reversing of the car, a label is not needed right? i just need to change the image right?

    And also, if i wan it to move in diagonal way, does that mean that i need to have the Diagonal picture of that particular car so as to achieve the result? 

  • Monday, June 15, 2009 9:26 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    so, without the label you can drive fwd. put the car in reverse and it drives backwards?
    help out microsoft for helping you.. test run 7
  • Monday, June 15, 2009 9:41 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    yup..so far i tried.. if without the label, i just need to change the

    Case

     

    Keys.Down to carup then when key pressed down, it will reverse.. without the need of label..

  • Monday, June 15, 2009 9:44 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    you did not pick up on the reason for the label. let me explain..
    when u drive fwd. and put it in reverse, it goes backwards. 
    when you drive fwd, turn right or left, then press the down key, you should still be able to drive fwd on a 2d screen.. without the label after you turn right/left and press down, the car drives backwards..
    help out microsoft for helping you.. test run 7
  • Monday, June 15, 2009 9:46 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    sorry, it think a mistake.. there's a different when the vehicle is from left or right, then going down.
    The vehicle will turn from front again.. but for just now that one without label i guess the vehicle will face its back even though its moving down..
    However i thought it could move in diagonal ways or any other different angles ..
  • Monday, June 15, 2009 9:49 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    you got the point for that label?
    you can set it to visible=false, like it's not even there, and a label like that can make a form unreal. well, maybe a few more labels...
    help out microsoft for helping you.. test run 7
  • Monday, June 15, 2009 9:56 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yup i got it.. Haha I guess i'll just hand up this piece of work ... Thanks :)
  • Monday, June 15, 2009 9:57 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    n/p.. keep this alert on.. i'm working on my website, so i'll post the link in a week, tops..
    should be full of vb goodies..
    help out microsoft for helping you.. test run 7
  • Monday, June 15, 2009 9:59 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Alright..haha.. Thanks :)
  • Monday, June 15, 2009 10:15 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    i don't know if you noticed or not but i just got my second medal today.. how awesome is that..

    if you have any more questions regarding this game project you can post them here, if any other questions, start a new post..
    till later,
    trujade.

    help out microsoft for helping you.. test run 7
  • Tuesday, June 16, 2009 12:41 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    haha.. of course I noticed that.. Alright.. Congrats.. :D
  • Tuesday, June 16, 2009 3:10 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Trujade, that time u were saying, examples like adding roads and trees..
    How to do that?
  • Tuesday, June 16, 2009 12:50 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    any windows p.c. should have a paintshop program.. you can use that to get started.. i use paint.net, which is free to get from online, just google for paint.net.
    i prefer this over the paintshop, due to the options it offers..

    i put this together, really quick, so don't laugh.. ;o) i have stuff to do also.


    http://trujade.com/TEMP%20LOCATION/!temp/vb%20car%20driving/1.png

    on your panel's properties, click on the backcolor, select the middle option, Web, and select Transparent.. this should allow your form's background image to show thru.. now add the above image to your form's background image, also from properties, and right under it the background image layout, select the stretch option, to resize the image to your entire form..
    then click play and drive your car...
    what i noticed, on my p.c. (though i have a decent video card) is that the form kind of glitches when driving the car with my new background..
    that's not my problem to solve.. ;o)

    i think this project is about done, and you might have to start looking into some of the above links posted by other members in order to get a real car driving form... one when u run into things, it stops, blows up, flies away, etc.

    i don't even know where to start with such..

    hope this gets you started on designing backgrounds, since forms do look much better even with the slightest details.. enjoy driving your squarely driving car on a oval road. lol..
    trujade...


    help out microsoft for helping you.. test run 7
  • Wednesday, June 17, 2009 2:58 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    thanks.. also may i know how to get rid of that black retangular shading of that vehicle? And how to make the vehicle travel within the form and not out of it?
    Sorry i guess im really troubling u.. But really no one to seek help from... :(
  • Wednesday, June 17, 2009 5:36 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    troubling me with vb questions that i actually understand?
    you are funnnnnnny! lol..  i would not be a member of a forum if i did not enjoy helping others or getting help..

    posted above by me:
    "i think this project is about done, and you might have to start looking into some of the above links posted by other members in order to get a real car driving form... one when u run into things, it stops, blows up, flies away, etc.
    "


    that black shading:
    what i noticed, on my p.c. (though i have a decent video card) is that the form kind of glitches when driving the car with my new background..
    that's not my problem to solve.. ;o)


    traveling within the form:
    try this link..
    VB Helper: HowTo: Make a bouncing ball animation in VB .NET

    i know it's not a car driving, but it has code in it to make the ball bounce inside your form and stay inside the form.. you might be able to figure something out.  eventually you will.
    the code on that page works entirely..

    you'll need a timer, and whoever put this code together, has this for the timer:

    Private Sub tmrMoveBall_Tick(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles tmrMoveBall.Tick

    just add the code from that tmrMoveBall_Tick ()event (which is the timer's event, they just renamed it) to your Private Sub Timer1_Tick()..

    you can copy the rest of the code and paste it on your form.. also, set your timer to enabled=true and if you want the ball to bounce faster, change the interval in the properties to 1.

    i'm fairly busy right now, but i figured the above information is better than nothing..

    and no, gene9956, never any trouble asking a question on a forum.  what if i go on vacation? lol..
    trujade.
    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Wednesday, June 17, 2009 5:55 AM
    •  
  • Wednesday, June 17, 2009 5:55 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    ok... I'll try to figure that out.. Thanks :)
  • Thursday, June 18, 2009 3:02 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Trajade... Sorry I need to check with u..

    For the above application that u had created (without the background image) using keyboard directional keys, can u teach me how am I to create the same one ,however using buttons(up,down,left,right)...

    Coz my lecturer has ask me to add in serial port and some buttons, which thus now when I run the program, the car can't move... :(

  • Thursday, June 18, 2009 3:02 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    sure.. give me a sec.

    help out microsoft for helping you.. test run 7
  • Thursday, June 18, 2009 3:40 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    ok.. i'll get you started.. and you know what.. it does not glitch anymore, barely.. that code i first posted with the panel, i got from online, never used code to move images until this project, but thanx to you, now i have an understanding how..

    ok.. start a totally new project..
    place your background on your form, add 4 buttons, 4 timers, and 1 picture box.

    name your buttons up/down/left/right or whatever. now to add images to your resources, right click your application in  solution explorer (top right of vb.net) and select properties. then select resources/add resources and add your 4 car images. ( i think we covered resources somewhere in this post..  ;o)

    add a image to your picturebox as a image , not background, so the car doesn't just appear and drive off, and set the size mode to auto size.. you'll know why that setting after you drive your car around on a different setting. ;o)

    you'll have to work with mouse down and mouse up events for the buttons.
    i'll explain the first button and how to get the car moving, you figure out the rest by looking at your previous code to get the direction of the car to move properly..

    let's say button 1 is to go right..

     Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
            PictureBox1.Image = My.Resources.carright
            Timer1.Enabled = True
        End Sub
    
        Private Sub Button1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseUp
            Timer1.Enabled = False
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            PictureBox1.Left = PictureBox1.Left + 20
        End Sub
    
    
    as you can see, when you first press the button, the image changes, then it starts the timer to keep the image moving, and it stop the timer when you let go.

    should be simple enough for you to finish the rest and even add that label deal where the car can go in reverse if needed..

    if you need any further help with this, do let me know.

    trujade.


    help out microsoft for helping you.. test run 7
  • Thursday, June 18, 2009 3:55 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks alot...
  • Thursday, June 18, 2009 4:03 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    no problem.. i answered your other posts.. if this fixes your shading problem, mark a answer in those posts to close them.. sorry i could not help before with this, but as i mentioned, i never did anything with moving images until now.  you were on the right path with your timers when you first started.. and all that nonsense you got not to use them and do this do that, and look where you are at now?..  

    glad i could help..
    trujade.

    p.s. if they keep giving you a tough time in the forum, do as you've been doing.  i've overlooked some of your posts, and you do keep your chin up.. nice.

    help out microsoft for helping you.. test run 7
  • Thursday, June 18, 2009 4:07 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
      you were on the right path with your timers when you first started.. and all that nonsense you got not to use them and do this do that, and look where you are at now?.
    just try to be more specific with your questions and titles.. you'll get better results alot quicker gene.  just a thought..

    trujade.

    help out microsoft for helping you.. test run 7
  • Thursday, June 18, 2009 5:52 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Trujade,

                   1) For the adding an image to my picturebox as IMAGE, is it any image?(like roads or trees)


                   2) And for adding the images u mentioned (in Bitmap format)..,I right click solution explorer,  
                      
                       and click on properties.Then I select resources..I choose under image ( as there are alot more like strings etc) Then choose the ADD Existing File under the ADD Resource and add in the 4 images (carup,cardown,left and right) correct?

                   3) Is the picturebox meant for the for images of the car (carup,cardown,left and right)
                       or other things else?

     

  • Thursday, June 18, 2009 6:04 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Sorry again.. I add 4 buttons... Which I named as ButtonUp, ButtonDown, ButtonLeft, ButtonRight...

    So the above code is for which of the buttons?
  • Thursday, June 18, 2009 6:05 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i just uninstalled vb2oo8. started having bugs, probably from my programming.. ;o)
    i'm d/ling and installing vb 2o1o beta, as speaking.

    1.you can add the first image from the picturebox's image properties.. then set the size mode from the properties as well..  the picture box does not have to be big, if you select auto size from the size mode, the picturebox will resize to the image. also set the background color of the image to transparent.

    2.about the resources, in the resources section right next to the add resources button, should be a little arrow for a dropdown button, click that. you should be able to import resources from one of those dropdown menu options.. pretty sure it's the first one, can't say though, no vb here to check on.

    3.the picturebox is for your car.. the form's background is your background, like the oval track with the trees and that stick figure i made.
    they should be png format.. like a gif, with a transparent background, so only the car is visible, and not the whole rectangle like a jpg image would show.



    help out microsoft for helping you.. test run 7
  • Thursday, June 18, 2009 6:21 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    what does the picturebox.image from my resources say?

    Private Sub Button1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown
            PictureBox1.Image = My.Resources.carright
            Timer1.Enabled = True
        End Sub
    
    

    do the same for the other buttons and timers, just for button 2, change the resource image to carleft, button 3, carup, button 4 cardown

     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            PictureBox1.Left = PictureBox1.Left + 20
        End Sub
    
    
    and for the timers, have timer1 for button 1, timer2 for button 2, etc.
    just change the left + 20, which is the left side of your screen plus 20 pixels, so it's 20 pixels to the right.
    and for up/down is (ex)picturebox1.top=picturebox1.top -20 to go up towards the top of your current location and + 20 to go down from your current location..

    i'm sorry for the mix, i just looked above at the post the arrow keys, and when i wrote my previous post, i thought this was the code included, but it's actually width/height, and with this code it is left and top.. (gulp) for the mixup... sorry.

    hope this explains how to use the code..

    so basically for every button, you have 2 events to enter code in and 1 timer's event..





    help out microsoft for helping you.. test run 7
    • Edited by•.trujade.• Thursday, June 18, 2009 6:25 AMcoding was all weird spaced
    •  
  • Thursday, June 18, 2009 6:24 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    1) add the the first image  from the picturebox... of the car? example carup?

  • Thursday, June 18, 2009 6:25 AM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    sure.

    help out microsoft for helping you.. test run 7
  • Friday, June 19, 2009 6:38 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello Trujade...Are u familiar with coding for serial port.. As in converting Hexadecimal form to Decimal Form code? I mean for VB 2005
                          
  • Friday, June 19, 2009 12:55 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    not at all, but that would make a good question...

    converting Hexadecimal form to Decimal Form, for serial port..

    and try to be specific about what exactly you need, like , i have 2 textboxes and one button, in textbox 1 i have Hexadecimal and when i press the button, to convert it to the other textbox in Decimal form..

    if it's just simple stuff, like having textbox1 with a font like 'wingdings' you can put this in the button's click event.

    TextBox2.Text = TextBox1.Text
    
    otherwise, i cannot help you with this one.. ;o/

    and all the vb2oo5 stuff should be the same as vb2oo8, i would think.





    help out microsoft for helping you.. test run 7
  • Friday, June 19, 2009 1:28 PMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    ok..Thanks anyway.. :)
  • Friday, June 19, 2009 8:37 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    gene, i don't know if you remeber me saying that i will post my website, but here it is..vb.trujade.com
    and i've been working on this mostly, not driving cars.. ;o)http://mininotes.trujade.com/

    i know the websites are are at the beginning point and that i should update them more, but vb is to much fun to get away from..

    you can check from time to time, the vb.trujade.com link, since i'll be updating whenever possible..

    c.ya.
    trujade.
    help out microsoft for helping you.. test run 7
  • Monday, June 22, 2009 8:43 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Trujade.. 

    During your spare time,Can u explain to me the meaning for these code?Cause I find that i need to understand all these before simulating the image using sensor....I'm sorry as I guess u are the only person who can help me now....:(

     



    Dim

     

    bmp As Bitmap = New Bitmap(My.Resources.carup)

     

    Dim offset As Size = New Size(0, 0)

     

    Private Sub panel1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles panel1.Paint

     

    Dim g As Graphics = e.Graphics

     

    Dim destRect As Rectangle = Me.Panel1.ClientRectangle

     

    Dim srcRect As Rectangle = New Rectangle(offset.Width, offset.Height, destRect.Width, destRect.Height)

    g.DrawImage(bmp, destRect, srcRect, g.PageUnit)

     





    2)    Dim

     

    bHandled As Boolean = False     (The meaning of this line)

     

           Select Case e.KeyCode                         (what's the meaning of e.keycode)

     







  • Monday, June 22, 2009 2:54 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    2)  i'm really not sure about all that stuff on the bHandled As Boolean = False , but this link should help..

    How to detect arrow keys in vb.net?

     just read the green comment code above the bHandled As Boolean = False.

    the e.keycode, to me, it seems like electronic keycode,  just shorter, as to define a keyboard press/mouse click. (might be wrong, but it is only used on keys being pressed mostly (i think), so my thoughts are there)

    i would do some googling on such stuff, although i did and still did not make any sense of it since it is not really defined anywhere, just examples..

    i did mention that i got the code for the panel/image on the net, so it was not mine to start with as the recent code with the timers that i put together, that i can explain. ;o)

    if you want to get into all that technical stuff, books are always good.. just go to a book store and skip thru the pages, maybe you'll find a book written the way you understand for a specific topic..

    i'll be here if you still need other info..
    trujade.

    help out microsoft for helping you.. test run 7
  • Monday, June 22, 2009 3:20 PM•.trujade.• Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    gene, when you do finish your sensor project and is available online for viewing/whatever, post a link here so i can see your work.. if not, you can email me from one of the links i posted with my website stuff.. ;o)

    later,
    trujade.

    help out microsoft for helping you.. test run 7
    • Marked As Answer byGene9956 Wednesday, June 24, 2009 5:46 AM
    •  
  • Tuesday, June 23, 2009 12:51 AMGene9956 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Ok sure :)