Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB Expert!

Join 244,284 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,030 people online right now. Registration is fast and FREE... Join Now!




memory game array

 
Reply to this topicStart new topic

memory game array, help with a memory game array

parrich
2 Dec, 2008 - 02:05 PM
Post #1

New D.I.C Head
*

Joined: 2 Dec, 2008
Posts: 4

hi guys im new to this whole programming thing. i have recently got a homework assignment for a simple 2 player memory/matching game, i am having trouble getting this aray right, what am i dong wrong? there are 20 blank boxes to match, giving a total of 10 matches, the array i have so far is as follows

CODE


Private sub drawboard
dim gamePositionpicturebox as picturebox
for rowinteger as integer = 0 to 3 step 1
for columninteger as integer = 0 to 4 step 1
gamepostionpicturebox = CType ((me.Controls ("PictrueBox" & rowinteger & columninteger)), Picturebox)
gamepostionpicturebox.Image = ImageList.Images (gamePlayInteger (rowInteger, columnInteger))



I hope that someone can help me, this is my final for the class and its due in 9 days. note this project has alot of work to be done, i am so lost in this class plz someone help me!!! I went ahead and attached what i have done so far.
any comments or suggestions will help greatly. Thank you in advance.


Attached File(s)
Attached File  MemoryGame.zip ( 228.43k ) Number of downloads: 45

User is offlineProfile CardPM
+Quote Post


Martyr2
RE: Memory Game Array
2 Dec, 2008 - 03:13 PM
Post #2

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 6,656



Thanked: 613 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
A few problems here... first of all you only have images from 00-04, 10-14,20-24,30-34. Notice anything here? None of them include 4 at the beginning and none of them include 5 at the end. So your for loops will have to be incrementing from 0-3 and 0-4 respectively.

I also notice you don't have an Imagelist included in your project. You have to draw one onto your gameForm and then access it through its name "Imagelist1". Right now what you are seeing is the ImageList object, not an instance of it on your project. You have to add it to the project and load it up with images. You can load it with images through its Image collection property in the property window or by specifying its name along with its images collection imagelist1.images.add(iconorimageobjecthere).

Next I notice that you don't load up the array gamePlayInteger. You are going to have to put some values into that array if you wish to get values back out of it.

I also notice you don't have a winnerLabel on your summaryForm but then you reference it in code. So make sure you change that by adding the label or removing the code referring to the label.

Here is something I was tinkering with that may help you get on the right path. I added an Imagelist icon to the form and then loaded it with 20 images. I moved some looping code to the form_load event to load up the pictureboxes with images. This shows you how to go about pulling images out of the imagelist and put into pictureboxes.

vb

Private Sub gameForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
startGame()
Dim gamePositionPictureBox As PictureBox
For rowInteger As Integer = 0 To 3
For columnInteger As Integer = 0 To 4

gamePositionPictureBox = CType((Me.Controls("PictureBox" & rowInteger & columnInteger)), PictureBox)
gamePositionPictureBox.Image = ImageList1.Images.Item(rowInteger + columnInteger)
Next
Next
End Sub


You of course will need to change this around but you will get t he idea of how things are put together and how to go about setting some of these pictureboxes you have made.

So play around with it and see if you can get the pictures loading into your pictureboxes at first and that your project compiles.

smile.gif


User is offlineProfile CardPM
+Quote Post

parrich
RE: Memory Game Array
2 Dec, 2008 - 06:17 PM
Post #3

New D.I.C Head
*

Joined: 2 Dec, 2008
Posts: 4

Thank you so much for your help. I will have time tomorrow to play around and see if I can get this stuff to work.
User is offlineProfile CardPM
+Quote Post

parrich
RE: Memory Game Array
6 Dec, 2008 - 09:58 AM
Post #4

New D.I.C Head
*

Joined: 2 Dec, 2008
Posts: 4

ok i have got the images to load to the form, first of all i have some questions, 1.how do i get it to load only 2 of the same pic? 2. how can i get it to randomize pics? 3.how do i hide pics, so when someone clicks on the blank space the pic then shows? once again i am a newbie when it comes to this stuff so i basically have no idea what im doing tongue.gif is there anywhere you can reccomend that will help me? Thanks in advance

CODE

  Private Sub DrawBoard()
        ImageList1 = New ImageList
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\Yinyang.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\Ball.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\dice.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\dollars.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\Earth3.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\info1.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\Ovni.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\Peace.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\UFO.gif"))
        ImageList1.Images.Add(Image.FromFile("D:\VB\MemoryGame\MemoryGame\X.gif"))

        Dim gamePositionPictureBox As PictureBox
        For rowInteger As Integer = 0 To 3
            For columnInteger As Integer = 0 To 4

                gamePositionPictureBox = CType((Me.Controls("PictureBox" & rowInteger & columnInteger)), PictureBox)
                gamePositionPictureBox.Image = ImageList1.Images.Item(rowInteger + columnInteger)
            Next
        Next
    End Sub


i have uploaded what i have so far again, this project isnt going as well as i had hoped, it is due on dec. 11th, hope i can get this stuff and get it to work by then! thanks again


Attached File(s)
Attached File  MemoryGame.zip ( 232.09k ) Number of downloads: 19
User is offlineProfile CardPM
+Quote Post

oasisjoel
RE: Memory Game Array
6 Dec, 2008 - 07:23 PM
Post #5

D.I.C Head
**

Joined: 11 Sep, 2008
Posts: 232



Thanked: 3 times
My Contributions
If your planning to this game I got a suggestion why not make multiple array for the coordinates of the picture dim picture[8][8] as string
User is offlineProfile CardPM
+Quote Post

parrich
RE: Memory Game Array
7 Dec, 2008 - 09:49 AM
Post #6

New D.I.C Head
*

Joined: 2 Dec, 2008
Posts: 4

QUOTE(oasisjoel @ 6 Dec, 2008 - 07:23 PM) *

If your planning to this game I got a suggestion why not make multiple array for the coordinates of the picture dim picture[8][8] as string



huh? exactly what do ya mean by this? As I've mentioned three times before im new to this stuff and have no idea what im doing!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 02:53PM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month