Animation not working
Animation not working
Animation not working
Animation not working
Animation not working
Animation not working Animation not working Animation not working Animation not working Animation not working Animation not working Animation not working Animation not working
Animation not working Animation not working
Animation not working
Go Back  Xtreme Visual Basic Talk > > > Animation not working


Reply
 
Thread Tools Display Modes
  #1  
Old 09-02-2012, 11:56 AM
arkain arkain is offline
Newcomer
 
Join Date: Aug 2012
Posts: 2
Default Animation not working


im tryin to make a rpg style game.....the character animation is not working well as its not erasin the prvs images without the completion of the final image....
sorry for the shabby code as im new in VB....Plz help me as soon as possible...
Code:
Private Sub drawall()

        bmpTile.MakeTransparent(Color.White)
        BBG = Me.CreateGraphics

        sRect = New Rectangle(0, 0, 1500, 1500)
        dRect = New Rectangle(0, 0, 1500, 1500)
        G.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

        If d = 1 Then


            If anime = -3 Then

                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(400, 63, 50, 60)
                cy -= 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(400, 63, 50, 60)
                cy -= 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(400, 63, 50, 60)
                cy -= 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(400, 63, 50, 60)
                cy -= 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(400, 63, 50, 60)
                cy -= 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 45, 60)
                dRect = New Rectangle(350, 63, 45, 60)
                cy += 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 45, 60)
                dRect = New Rectangle(350, 63, 45, 60)
                cy += 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 45, 60)
                dRect = New Rectangle(350, 63, 45, 60)
                cy += 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 45, 60)
                dRect = New Rectangle(350, 63, 45, 60)
                cy += 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 45, 60)
                dRect = New Rectangle(350, 63, 45, 60)
                cy += 20
                cx -= 15
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                msRect = New Rectangle(0, 0, 1500, 1500)
                mdRect = New Rectangle(0, 0, 1500, 1500)
                mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)
                anime = 0
            End If

            If (anime = -1) Then


                sRect = New Rectangle(cx, cy, 45, 56)
                dRect = New Rectangle(250, 63, 45, 56)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 45, 56)
                dRect = New Rectangle(300, 63, 45, 56)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)


            End If
            If (anime = -2) Then

                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(145, 63, 50, 60)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)

                sRect = New Rectangle(cx, cy, 40, 60)
                dRect = New Rectangle(100, 63, 40, 60)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)


            End If
            If anime = 5 Then
                System.Threading.Thread.Sleep(51)
                cy += 25
                Me.KeyPreview = False
                sRect = New Rectangle(cx, cy, 50, 60)
                dRect = New Rectangle(200, 63, 50, 60)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)


            End If
            If anime = 0 Then
                sRect = New Rectangle(cx, cy, 45, 56)
                dRect = New Rectangle(540, 63, 45, 56)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
            End If
            If (anime = 1) Then
                sRect = New Rectangle(0, 0, 1500, 1500)
                dRect = New Rectangle(0, 0, 1500, 1500)
                G.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)
                cx -= 25
                sRect = New Rectangle(cx, cy, 45, 56)
                dRect = New Rectangle(500, 63, 45, 56)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
                sRect = New Rectangle(0, 0, 1500, 1500)
                dRect = New Rectangle(0, 0, 1500, 1500)
                G.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)
                cx -= 25
                sRect = New Rectangle(cx, cy, 45, 56)
                dRect = New Rectangle(450, 63, 45, 56)
                G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)

            End If

        End If

        G = Graphics.FromImage(BB)
        BBG = Me.CreateGraphics
        BBG.DrawImage(BB, 0, 0)
    End Sub

Last edited by passel; 09-02-2012 at 08:57 PM. Reason: added [code]..[/code] tags
Reply With Quote
  #2  
Old 09-02-2012, 09:48 PM
passel's Avatar
passelAnimation not working passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

You should at least add some comments so we can have a glimmer of what the logic is trying to do, such as each state of anime.
If anime = -3 you do something. What does the -3 signify.

The first thing you do when you come in is this:
Code:
'
    sRect = New Rectangle(0, 0, 1500, 1500)
    dRect = New Rectangle(0, 0, 1500, 1500)
    G.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)
Which I would assume is filling your 1500x1500 background area with mbmpTile, essentially clearing the field, assuming it doesn't have transparent holes in it.

In your -3 anime, it looks like you're trying to do that again, but then not.
Code:
'
        G.DrawImage(bmpTile, sRect, dRect, GraphicsUnit.Pixel)
        msRect = New Rectangle(0, 0, 1500, 1500)
        mdRect = New Rectangle(0, 0, 1500, 1500)
        mG.DrawImage(mbmpTile, sRect, dRect, GraphicsUnit.Pixel)
You set msRect and mdRect to the full area for something apparently, but then you don't use them.
Also, I would have to assume that G is still set from the previous call to drawall and is drawing on image BB, but what is mG drawing on?

Also, in the anime = -3 block, since you are copying several different source rectangles to the same destination rectangle, you are either layering different images on top of each other, or trying to animate a figure.
I'll assume from your question, that you are not trying to layer the images, but that is what you are getting.
Your intent is to flip through the various images to show animation.
Since you only update the screen once at the end of the draw routine, you will only see the final result.
If you want to have something animate, you need to draw just one of the animation frames each time through so that the user can see each one in turn.

There are a number of ways to go about doing your drawing, and the way you are doing it is not correct. It is a big subject, and since I don't have the resources to go into it, I would suggest reading and working through Bob Powell's GDI+ FAQ.
It should be a good start at learning acceptable methods of using GDI+ in the .Net managed environment.
Once you learn the capabilities, and how to do use the basic drawing capabilities of GDI+, then you continue with your game development.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 09-02-2012, 11:03 PM
arkain arkain is offline
Newcomer
 
Join Date: Aug 2012
Posts: 2
Default

thanx......
Bob Powell's GDI+ FAQ. is very helpful....
Reply With Quote
Reply

Tags
animation, jump, vb.net rpg


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Animation not working
Animation not working
Animation not working Animation not working
Animation not working
Animation not working
Animation not working Animation not working Animation not working Animation not working Animation not working Animation not working Animation not working
Animation not working
Animation not working
 
Animation not working
Animation not working
 
-->