Click to See Complete Forum and Search --> : Help with Tetris


Jakoe
April 11th, 2010, 10:43 AM
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.

dglienna
April 12th, 2010, 01:09 AM
Download the code sample, and see what you messed up!

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

Jakoe
April 12th, 2010, 01:55 AM
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!

dglienna
April 12th, 2010, 03:16 AM
I'll let Hannes deal with this, as he is the one that wrote the series. AFAIK, they work...

HanneSThEGreaT
April 13th, 2010, 09:28 AM
Welcome to the Fourms Jakoe! :wave:

Thank you for your interest in my article series :

http://codeguru.com/vb/gen/vb_misc/gamesandfun/article.php/c16803/

And

http://www.codeguru.com//vb/gen/vb_misc/gamesandfun/article.php/c17005

The third part will go live tomorrow :D

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

Jakoe
April 14th, 2010, 03:13 AM
Welcome to the Fourms Jakoe! :wave:

Thank you for your interest in my article series :

http://codeguru.com/vb/gen/vb_misc/gamesandfun/article.php/c16803/

And

http://www.codeguru.com//vb/gen/vb_misc/gamesandfun/article.php/c17005

The third part will go live tomorrow :D

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.

HanneSThEGreaT
April 14th, 2010, 03:36 AM
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 ?

Jakoe
April 14th, 2010, 06:46 AM
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

HanneSThEGreaT
April 14th, 2010, 07:06 AM
OK, I see your point :)

Let me try something, then get back to you :)

HanneSThEGreaT
April 14th, 2010, 08:13 AM
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 :
''' <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_misc/gamesandfun/article.php/c17081

Jakoe
April 14th, 2010, 01:41 PM
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 :
''' <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_misc/gamesandfun/article.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

HanneSThEGreaT
April 15th, 2010, 07:19 AM
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.

Jakoe
April 15th, 2010, 12:16 PM
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.

HanneSThEGreaT
April 15th, 2010, 01:49 PM
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 :)

Jakoe
April 16th, 2010, 01:11 AM
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 :)

HanneSThEGreaT
April 16th, 2010, 03:19 AM
Hello again Jaco!

I'm from Vereeniging, quite close to Sasolburg etc. :)

I am stumped, honestly, truly stumped :blush:

Only thing I can think of is your ( I shudder to say ) Graphics card, perhaps??

Join a Discussion on Multithreaded Programming (http://blog.codeguru.com/blog/2010/04/join-a-discussion-on-multithre-1.html)

Jakoe
April 16th, 2010, 04:37 AM
Hello again Jaco!

I'm from Vereeniging, quite close to Sasolburg etc. :)

I am stumped, honestly, truly stumped :blush:

Only thing I can think of is your ( I shudder to say ) Graphics card, perhaps??

Join a Discussion on Multithreaded Programming (http://blog.codeguru.com/blog/2010/04/join-a-discussion-on-multithre-1.html)

Eish...:(

Cimperiali
April 16th, 2010, 06:29 PM
vs 2008 and windows 7. Seems as if fixedTetris, after vs2008 conversion behave the same as for Jakoe.
''''''''''''''''''''''''''''''''''''''EDIT''''''''''''''''''''''''
I admit I did not read the articles, just take the fixed code an tried. As it did nothing, I entered code.
Saw a timer named "tmrTet" not enabled (and no code for it)
Saw the paint event, with a call to a splash routine. It seemed that first run actually noved something, then everithing stppped and there was no way to made it move again.
''''''''''''''''EDit II '''''''''''''''''''''''
rebuilt as release, launced, and the Jetris appeared for a small fraction of second on monitor, then disappeared and there has been no way to get it back. I am quite sure that if I restart the machine I could see it again.

Jakoe
April 17th, 2010, 01:57 AM
vs 2008 and windows 7. Seems as if fixedTetris, after vs2008 conversion behave the same as for Jakoe.
''''''''''''''''''''''''''''''''''''''EDIT''''''''''''''''''''''''
I admit I did not read the articles, just take the fixed code an tried. As it did nothing, I entered code.
Saw a timer named "tmrTet" not enabled (and no code for it)
Saw the paint event, with a call to a splash routine. It seemed that first run actually noved something, then everithing stppped and there was no way to made it move again.
''''''''''''''''EDit II '''''''''''''''''''''''
rebuilt as release, launced, and the Jetris appeared for a small fraction of second on monitor, then disappeared and there has been no way to get it back. I am quite sure that if I restart the machine I could see it again.

i see that if i leave the game running for a few minutes, the Jetris does evnntualy apper.

Jakoe
April 17th, 2010, 02:14 AM
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

Me again :)

don't worry about the other problems i wrote abut, i got them, ha ha

i see now that if i can run the game and i minimize it and then resore it, the word appears.

just thought i'd let u know :)

Have a gr8 day

Jakoe
April 22nd, 2010, 07:47 AM
Hi Hannes

Me again :)

don't worry about the other problems i wrote abut, i got them, ha ha

i see now that if i can run the game and i minimize it and then resore it, the word appears.

just thought i'd let u know :)

Have a gr8 day

Good day Hannes

Afrikaans.

Sorry to hear about the hand, I hope it doesn’t hurt too much, and thanx for your reply.

Can you maybe find my problem, I struggle to figure out why he blocks move if I click my mouse.

My blocks just flips in one direction but, that is how it should be.

And I want to do something that make the blocks move with the mouse cursor, better than now.

I also saw that with your and my game, the row doesn’t get cleared when it’s full.

Do you have any ideas for me, pls.

Jaco

HanneSThEGreaT
April 22nd, 2010, 08:30 AM
Hello Jaco!

Afrikaans.

Jip, my hand is vrek seer! :lol:

That will teach me to think I'm still 18! LOL!

Anyways, I know about the rows not clearing part - that will be addressed in the 4th part - which will now take a little longer to complete because of my hand.

I have downloaded your version, and I'll check it out :)

Thanx for your continued interest! :thumb:

Hannes

Jakoe
April 22nd, 2010, 09:49 AM
Hello Jaco!

Afrikaans.

Jip, my hand is vrek seer! :lol:

That will teach me to think I'm still 18! LOL!

Anyways, I know about the rows not clearing part - that will be addressed in the 4th part - which will now take a little longer to complete because of my hand.

I have downloaded your version, and I'll check it out :)

Thanx for your continued interest! :thumb:

Hannes

Thank you Hannes

I'm enjoying the project very much. :thumb:

Jaco

HanneSThEGreaT
April 26th, 2010, 05:00 AM
Hello Jaco.

It seems as if one of my display objects that I created got a bit confused. The only way I could get the issue concerning the SplashScreen fixed was to add another panel on top of the Game panel. Then I had to do the following in the code :

Declare a Splash rectangle :

Private rctSplash As Rectangle

In the Setup function edit the necessary line to look like :

scrSplash = New clsTetDisplay(pnlSplash, rctSplash)

In the form's KeyDown event, change the "Q" case to :

Case "Q" 'Stop, Reset Everything
tmrTet.Stop()
SetUp()
Splash()
pnlSplash.Visible = True

And edit the "RETURN" case to include the following :

pnlSplash.Visible = False

That's it.

I am including a revised version of my Tetris here. There are other issues as we know, but let us take it one at time, after this we do the next issue :)

Lekker dag!

Hannes

Jakoe
April 26th, 2010, 09:22 AM
Hello Jaco.

It seems as if one of my display objects that I created got a bit confused. The only way I could get the issue concerning the SplashScreen fixed was to add another panel on top of the Game panel. Then I had to do the following in the code :

Declare a Splash rectangle :

Private rctSplash As Rectangle

In the Setup function edit the necessary line to look like :

scrSplash = New clsTetDisplay(pnlSplash, rctSplash)

In the form's KeyDown event, change the "Q" case to :

Case "Q" 'Stop, Reset Everything
tmrTet.Stop()
SetUp()
Splash()
pnlSplash.Visible = True

And edit the "RETURN" case to include the following :

pnlSplash.Visible = False

That's it.

I am including a revised version of my Tetris here. There are other issues as we know, but let us take it one at time, after this we do the next issue :)

Lekker dag!

Hannes

Hi Hannes,

Hope your weekend was lekke.

Thanx for the code,

Unfortunately it doesn't help, but i had this feeling just now, and added the setUp sub to the frmTet load event.

And there it was. Amazingly :)

I guess that's fixed huh

Enjoy your day
Jaco

HanneSThEGreaT
April 26th, 2010, 09:49 AM
Hi Jaco!

Yep, it was, hope yours was good too.

Strange, on my machine it didn't want to work, even when I added Setup to Load...

My last resort was to basically add another panel. there is just something small giving issues, but it's OK, if it is fixed. I should say that I have tested this on Windows 7, so Windows 7 might have been the whole problam afterall, hmm..

Working on the other issues

Have a great evening

HanneSThEGreaT
April 26th, 2010, 10:00 AM
Ah hah! Windows 7 is the culprit!! I have always loved Windows 7, but now this love for Windows 7 is starting to fade away - it is giving us too many unecessary unexpected behaviours! :mad:

I did a small test, with adding the call tro Setup inside load on my XP machine ( at work ) and voila!

It is very disappointing from Windows 7 to say the least, really :cry: I expected better ( with all the improvements in Graphics etc. ) It is as if it concentrates more on newer .NET Frameworks ( 2008, 2010 ), than the older ones - bad Windows 7, bad! :sick:

Anyways, the splash screen issue has literally taken my whole weekend, and it was even more difficult with my broken hand!

Thanx Jaco, for all your feedback, I'll buy you a six pack Castles one day when this nightmare of a project, has been completed :)

Now, off to the next victim on my list for Tetris... :wave:

Jakoe
April 26th, 2010, 02:55 PM
Ah hah! Windows 7 is the culprit!! I have always loved Windows 7, but now this love for Windows 7 is starting to fade away - it is giving us too many unecessary unexpected behaviours! :mad:

I did a small test, with adding the call tro Setup inside load on my XP machine ( at work ) and voila!

It is very disappointing from Windows 7 to say the least, really :cry: I expected better ( with all the improvements in Graphics etc. ) It is as if it concentrates more on newer .NET Frameworks ( 2008, 2010 ), than the older ones - bad Windows 7, bad! :sick:

Anyways, the splash screen issue has literally taken my whole weekend, and it was even more difficult with my broken hand!

Thanx Jaco, for all your feedback, I'll buy you a six pack Castles one day when this nightmare of a project, has been completed :)

Now, off to the next victim on my list for Tetris... :wave:

**** Windows 7 :)

thanks to you, i would like it if you can guide me through the process of completing my Jetris. Anyway, i'll hold you to the six pack :)

Speak to you soon.

Jaco

dglienna
April 26th, 2010, 03:05 PM
Hannes, nothing but the blank form appears on Win7/VS2010. It upgrades successfully, but complains about no Form1. I changed the form to frmTet to get it to show up.

HanneSThEGreaT
April 28th, 2010, 07:37 AM
Hello Jaco!

Well tis public holiday we had yesterday turned out to be fruitful :)

I have fixed the issue of the rows ( when full ) not updating the scores, levels and to disappear to let the other rows drop down.

:D :D :D

Amazing what rest can do....

I am attaching the latest version here, just have a look at the DropDown and IsLocEmpty functions inside clsTetGrid.

Off to the next issue :D

Lekker dag!

dglienna
April 28th, 2010, 10:33 AM
Hannes, nothing but the blank form appears on Win7/VS2010. It upgrades successfully, but complains about no Form1. I changed the form to frmTet to get it to show up.



Miss this one?

HanneSThEGreaT
April 28th, 2010, 10:39 AM
Miss this one?

So it seems :)

I haven't yet received VS 2010 :(, so I can not make a statement as to what happens in it :)

I did notice though that it has given me that error before ( in VS 2005 ), I guess I should make a new project and copy these things in there and see if that would resolve that issue, hopefully :)

Thanx for your valuable input David - I'll buy you a sixpack Buddweisers one day :D LOL!

dglienna
April 28th, 2010, 12:43 PM
I'd like the FULL code, not just the fix. I only had Part III

Marraco
April 29th, 2010, 01:58 PM
I have not read the entire thread, but could not resist to suggest replacing this:
...
''' <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
...

with:
''' <summary>
''' Determine Existance Of In Memory Graphic
''' </summary>
''' <returns>Return True 'If There Is A Graphic In Memory; Return False 'If Not
''' </returns>
''' <remarks></remarks>
Public Function ValidGraphic() As Boolean

Return (g IsNot Nothing) AndAlso (InMemoryGraphics IsNot Nothing)

End Function

HanneSThEGreaT
August 30th, 2010, 06:12 AM
OK, before you shoot me down... I know I should practise what I preach...

I think this is the final version of my Tetris game. Anyone willing to help identify more issues are more than welcome. I have forgotten this thread until recently, and I'd like to get my final version of Tetris up and running and get the last part of this article series published.

If you have any hints, suggestions, fixes let me know and I will obviously credit you in my article as well :D

Hannes