Click here to Skip to main content
Click here to Skip to main content
Go to top

Campaign Button Memory Game

, 24 Feb 2004
Rate this:
Please Sign up or sign in to vote.
This intermediate tutorial describes how to play campaign button memory and how to customize the game. The game is data driven so you can change the images, difficulty, etc. without changing the VB code.

Introduction

This campaign button memory game was brought to you by www.pcbutton.com - (2004 campaign buttons, political buttons and memorabilia buttons).

This intermediate tutorial describes how to play campaign button memory and how to customize the game. The game is data driven so you can change the images, difficulty, etc. without changing the VB code.

How is Campaign Button Memory Played?

First the user starts the game by clicking on “Start Game”:

Sample image

Then the user clicks two images to uncover them (In this example, two Jimmy Carter images):

Sample image

Then the user clicks “Continue”. If the images match, they will stay uncovered. Once users uncover all images and clicks “Continue”, they wins the game and their score (number of turns) is displayed. The lower the score, the better the player did.

There is no time limit and users have as many chances as they need to match all the images.

Sample image

How Can I Substitute in my Own Images?

Simply update the data.xml to point to images of your choosing. There must be 12 or less image tags and an even number of them. Also, there must be two of each image. The order determines how the images are displayed. Be sure to leave the visible attribute set to “FALSE”:

.
.
.
<images>
 <image>
  <file>CARTERGOLD.jpg</file>
  <visible>FALSE</visible>
 </image>
 <image>
  <file>CARTERGOLD1.jpg</file>
  <visible>FALSE</visible>
 </image>
.
.
.

Why is There a “visible” Child Tag of “image”?

Putting the visible state in the data was more of a stylistic choice as it could have been entirely memory resident. The visible tag is used to store the display state of the image when a match is made. This way you can modify the code to have a “Save Game” feature, which simply saves the modified data.xml rather than having to make a new mechanism for storing and loading saved games.

Can I Use Images of a Different Size?

Yes. However the first image must be the largest and they must share similar aspect ratios as the first image determines the spacing for the rest of the images:

.
.
.
Function realignimages()
    Dim imagesize As Double

Get size of first image:

    imagesize = picImage(0).Picture.Width * 0.6

Display first row:

    picImage(1).Left = picImage(0).Left + imagesize
    picImage(2).Left = picImage(1).Left + imagesize
    picImage(3).Left = picImage(2).Left + imagesize
    picImage(1).Top = picImage(0).Top
    picImage(2).Top = picImage(0).Top
    picImage(3).Top = picImage(0).Top

Display second row:

    picImage(4).Top = picImage(0).Top + imagesize
    picImage(5).Left = picImage(4).Left + imagesize
    picImage(6).Left = picImage(5).Left + imagesize
    picImage(7).Left = picImage(6).Left + imagesize
    picImage(5).Top = picImage(4).Top
    picImage(6).Top = picImage(4).Top
    picImage(7).Top = picImage(4).Top

Display third row:

    picImage(8).Top = picImage(4).Top + imagesize
    picImage(9).Left = picImage(8).Left + imagesize
    picImage(10).Left = picImage(9).Left + imagesize
    picImage(11).Left = picImage(10).Left + imagesize
    picImage(9).Top = picImage(8).Top
    picImage(10).Top = picImage(8).Top
    picImage(11).Top = picImage(8).Top
End Function
.
.
.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

dzzxyz
Web Developer
United States United States
Keep on coding!

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 25 Feb 2004
Article Copyright 2004 by dzzxyz
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid