CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 3 123 LastLast
Results 1 to 15 of 35
  1. #1
    Join Date
    Apr 2010
    Posts
    14

    Question Help with Tetris

    i finished part 1 of "Creating your own Tetris game". When i started part 2, i added the label for "Score". i then ran the game and the words that is written on the panel, just give a flicker but doesn't show. when i removed the label, the word shows. i am using WS 2005 on a XP Pro machine.

    Pls help.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Help with Tetris

    Download the code sample, and see what you messed up!

    Or, just remove it, and try again, somewhere else.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Apr 2010
    Posts
    14

    Question Re: Help with Tetris

    Quote Originally Posted by dglienna View Post
    Download the code sample, and see what you messed up!

    Or, just remove it, and try again, somewhere else.
    Thanx, i did do all that, but even the downloaded code does the same!

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Help with Tetris

    I'll let Hannes deal with this, as he is the one that wrote the series. AFAIK, they work...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Help with Tetris

    Welcome to the Fourms Jakoe!

    Thank you for your interest in my article series :

    http://codeguru.com/vb/gen/vb_misc/g...le.php/c16803/

    And

    http://www.codeguru.com//vb/gen/vb_m...cle.php/c17005

    The third part will go live tomorrow

    Can you post your project here, in zipped format ? Please.

    I have gone through my codes for both part 1 and 2, and played around with them, and still cannot reproduce this behaviour you are describing

    Hannes

  6. #6
    Join Date
    Apr 2010
    Posts
    14

    Cool Re: Help with Tetris

    Quote Originally Posted by HanneSThEGreaT View Post
    Welcome to the Fourms Jakoe!

    Thank you for your interest in my article series :

    http://codeguru.com/vb/gen/vb_misc/g...le.php/c16803/

    And

    http://www.codeguru.com//vb/gen/vb_m...cle.php/c17005

    The third part will go live tomorrow

    Can you post your project here, in zipped format ? Please.

    I have gone through my codes for both part 1 and 2, and played around with them, and still cannot reproduce this behaviour you are describing

    Hannes
    Good day Hannes

    Thanx for ur reply.

    if i run ur code, it does the same, maybe something is wrong in my system configuration.

    let me just recap, does the text on the pnel stay until an new game is started or does it display quickly.
    Attached Files Attached Files

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Smile Re: Help with Tetris

    Hello again Jakoe!

    This attached picture is what I get. It stays there the whole time, as it should. Only when Enter gets pressed, the game should start. I see that you haven't included the clsTetDisplay class, or made use of it

    What Operating System are you using ?
    Last edited by HanneSThEGreaT; June 14th, 2010 at 05:46 AM.

  8. #8
    Join Date
    Apr 2010
    Posts
    14

    Question Re: Help with Tetris

    Quote Originally Posted by HanneSThEGreaT View Post
    Hello again Jakoe!

    This attached picture is what I get. It stays there the whole time, as it should. Only when Enter gets pressed, the game should start. I see that you haven't included the clsTetDisplay class, or made use of it

    What Operating System are you using ?
    Hi Hannes, thanx for ur effort.

    it works perfect on ur pc.

    i wanted my form to display properly before i made the clsTetDisplay class, otherwise th debugging can get to heavy.

    i am using Win XP Pro and VS 2005

  9. #9
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Help with Tetris

    OK, I see your point

    Let me try something, then get back to you

  10. #10
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Talking Re: Help with Tetris

    Hello Jakoe!

    OK, I think I have fixed your problem. I did add the clsTetDisplay class, and edited the Splash sub to use the clsTetDisplay class' ClearScreen method. Why?

    Well, we are dealing with more than one Graphics object here, we are dealing with the Preview Window, the Main Game Window, the Splash Screen window, as well as the In memory image - which is buffered. The ClearScreen method ensure that an in meory graphic exists, then "paints it black" - like the Rolling Stones song - Paint It Black

    Here is what it looks like :
    Code:
        ''' <summary>
        ''' Determine Existance Of In Memory Graphic
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function ValidGraphic() As Boolean
    
            If Not (g Is Nothing) And Not (InMemoryGraphics Is Nothing) Then
                Return True 'If There Is A Graphic In Memory 
            Else
                Return False 'If Not
            End If
    
        End Function
    
        ''' <summary>
        ''' Erase Game Screen
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub ClearScreen()
    
            'If No Valid Graphic, Do Nothing
            If Not ValidGraphic() Then
                Return
            End If
    
            'Create A Solid Black Brush
            Dim ClearBrush As New SolidBrush(Color.Black)
    
            'Fill The Rectangle With The Black Colour, Causing The Clearance of The Images
            InMemoryGraphics.FillRectangle(ClearBrush, 0, 0, ScreenWidth, ScreenHeight)
    
        End Sub
    This is necessary, as we clear the in memory graphic at the end of the day.
    I also added the Setup method to frmTet, and called it from the Form's constructor - frmTet.Designer.vb

    The Setup method takes care of loading and initialising all the necessary class objects, for use.

    I decided to take this route with my program, as it is much more organised, and cleaner. Grid code is separate, shape code is separate, Display code is separate, game code is separate.

    I am attching your project here, and please let me know what the results are.

    here is the link to part 3 BTW :

    http://www.codeguru.com/vb/gen/vb_mi...cle.php/c17081
    Last edited by HanneSThEGreaT; April 28th, 2010 at 07:40 AM.

  11. #11
    Join Date
    Apr 2010
    Posts
    14

    Question Re: Help with Tetris

    Quote Originally Posted by HanneSThEGreaT View Post
    Hello Jakoe!

    OK, I think I have fixed your problem. I did add the clsTetDisplay class, and edited the Splash sub to use the clsTetDisplay class' ClearScreen method. Why?

    Well, we are dealing with more than one Graphics object here, we are dealing with the Preview Window, the Main Game Window, the Splash Screen window, as well as the In memory image - which is buffered. The ClearScreen method ensure that an in meory graphic exists, then "paints it black" - like the Rolling Stones song - Paint It Black

    Here is what it looks like :
    Code:
        ''' <summary>
        ''' Determine Existance Of In Memory Graphic
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function ValidGraphic() As Boolean
    
            If Not (g Is Nothing) And Not (InMemoryGraphics Is Nothing) Then
                Return True 'If There Is A Graphic In Memory 
            Else
                Return False 'If Not
            End If
    
        End Function
    
        ''' <summary>
        ''' Erase Game Screen
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub ClearScreen()
    
            'If No Valid Graphic, Do Nothing
            If Not ValidGraphic() Then
                Return
            End If
    
            'Create A Solid Black Brush
            Dim ClearBrush As New SolidBrush(Color.Black)
    
            'Fill The Rectangle With The Black Colour, Causing The Clearance of The Images
            InMemoryGraphics.FillRectangle(ClearBrush, 0, 0, ScreenWidth, ScreenHeight)
    
        End Sub
    This is necessary, as we clear the in memory graphic at the end of the day.
    I also added the Setup method to frmTet, and called it from the Form's constructor - frmTet.Designer.vb

    The Setup method takes care of loading and initialising all the necessary class objects, for use.

    I decided to take this route with my program, as it is much more organised, and cleaner. Grid code is separate, shape code is separate, Display code is separate, game code is separate.

    I am attching your project here, and please let me know what the results are.

    here is the link to part 3 BTW :

    http://www.codeguru.com/vb/gen/vb_mi...cle.php/c17081
    Hi Hannes,

    thank you for all your effort, i really appreciate ur help.

    the game is still doing the same , is there maby any settings that i can change?

    thanx for the link.

    A VERY strange thing is happening, the part 3 still doesn't have the splsh scren but, when i press enter, the game works perfectly...?

    i played part 3 and when i pressed Q, the game stopped and AMAZINGLY the splash showed but, as i stopped the debugging and started it again, there were no splash again.

    Jaco
    Last edited by Jakoe; April 14th, 2010 at 02:27 PM.

  12. #12
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Help with Tetris

    Hello again Jaco!

    Hmm, I'll have to further investigate this on Part 2 - if anyone else can confirm the same results that you have had, I'll have a deeper look. I think it may be the timer causing this issue in part 3.

  13. #13
    Join Date
    Apr 2010
    Posts
    14

    Question Re: Help with Tetris

    Quote Originally Posted by HanneSThEGreaT View Post
    Hello again Jaco!

    Hmm, I'll have to further investigate this on Part 2 - if anyone else can confirm the same results that you have had, I'll have a deeper look. I think it may be the timer causing this issue in part 3.
    Hi Hannes

    Thanx for ur help, meanwhile i will also go on and see what i can do.

    i have tried removing the timer but, nothing.

    i appreciate ur help, thanx.

  14. #14
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Help with Tetris

    Hello Jaco - are your frm South Africa BTW? Jaco is quite a common name here

    I haven't helped much! You have actually helped me by discovering these issues, so I must thank you!

    I'm still investigating this, we'll get it sorted - do not worry

  15. #15
    Join Date
    Apr 2010
    Posts
    14

    Cool Re: Help with Tetris

    Quote Originally Posted by HanneSThEGreaT View Post
    Hello Jaco - are your frm South Africa BTW? Jaco is quite a common name here

    I haven't helped much! You have actually helped me by discovering these issues, so I must thank you!

    I'm still investigating this, we'll get it sorted - do not worry
    Hi Hannes, yes i am from S.A., Pretora. I am also wondering about you, since ur name and surname sounds South African.

    i think something is wrong with my system, i started to debug the game, i left it right after it started, when i came back ater almost 45 min, the game was displaying properly.

    When i stopped it and started it again, same thing again.

    in the setUp method, where did you declare grdGame ...

    i also get this error:

    Value of type 'Jetris.clsTetDisplay' cannot be converted to 'Jetris.clsTetGrid'.

    when i add this code:

    'initialse game object
    scrGame = New clsTetDisplay(pnlTetGame, rctScreen)

    i don't know how to post my cde like u did the ther day

    Enjoy ur day
    Last edited by Jakoe; April 16th, 2010 at 02:56 AM.

Page 1 of 3 123 LastLast

Tags for this Thread

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

Featured