Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

iVidCam Free
(free)

Kid Art
($0.99)

iPUBQUIZ
(£1.19)

ArtStudio
($3.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-22-2009, 12:16 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 10
Default Photo hunt game: high level design help

I'm in the beginning stages of creating a photo hunt/spot the difference game. The type where players must pick out differences between two similar photographs.

As a proof of concept, I created an incredibly crude prototype using almost entirely interface builder. I have 2 images on screen, with a bunch of nearly invisible buttons placed over differences in the pictures. When one of the invisible buttons is pressed, an alert pops up saying "You found a difference."

My question is from a design perspective, is there a better method of implementing this game programmatically? There must be a better way than littering the screen with invisible buttons and having 20 nibs for 20 pictures.

Since these photo hunt games are so popular, there must be some "standard" method of design/implementation i don't know of.
tarenar is offline   Reply With Quote
Old 04-22-2009, 01:03 AM   #2 (permalink)
ftm
FasterThanMonkeys.com
iPhone Dev SDK Supporter
 
Join Date: Mar 2009
Location: Southern California
Posts: 521
Send a message via AIM to ftm
Default

Probably just using a single NIB with an image, and using touch events to capture x/y coordinates would be the simplest design. Each image would have rectangles associated with it that represent the differences. Each time a user touches the screen, the x/y location would be compared to the list of rectangles.

Just out of curiosity... is there something that is going to make your photo hunt unique? Or is it just a learning experience for you?
__________________


Website: http://fasterthanmonkeys.com

iScore Baseball Scorekeeper Top baseball scorekeeping app for iPhone
Bug Squash Reached #1 kids game in 15+ countries including USA, now with OpenFeint
Jam Packed! Fun puzzle game for all ages
Jam Packed Christmas Holiday puzzle game!
iScore Basketball Scorekeeper Best basketball scorekeeping application

Last edited by ftm; 04-22-2009 at 03:13 AM.
ftm is offline   Reply With Quote
Old 04-22-2009, 01:15 AM   #3 (permalink)
Pro. Game Developer
iPhone Dev SDK Supporter
 
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 1,415
Default

Quote:
Originally Posted by ftm View Post
Probably just using a single NIB with an image, and using touch events to capture x/y coordinates would be the simplest design. Each image would have rectangles associated with it that represent the differences. Each time a user touches the screen, the x/y location would be compared to the list of images.

Just out of curiosity... is there something that is going to make your photo hunt unique? Or is it just a learning experience for you?
I (not the OP) was thinking of doing one of these as a starter project just to get something onto the App Store, but eventually decided against it and started focusing on my "real" project. Anyways, the architecture you describe is essentially what I was thinking -- I think. Each "puzzle" would have a dataset consisting of an image (prebuilt with the different left and right side images) and a number of (x,y) positions. During game play, any touch position would be compared against all of the positions (adjusted for both the left and right panes). Any touch within a predefined radius of any of the positions would register as a correct guess, and that position would be marked as such, etc. etc. Pretty simple and straightforward implementation.
Kalimba is offline   Reply With Quote
Old 04-22-2009, 04:30 PM   #4 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 10
Default

Thanks for the quick response.

I'm using it primarily as a learning experience. Thus far the only saving/loading of information I've dealt with is using NSUserDefaults to keep track of high score data.

So if I understand both of your implementation suggestions correctly, I should have all my static images (ie: jpgs) stored in my project resources folder, as well as a text file of some sort (plist?) to save the x,y coordinates of the difference points.

Then I associate each picture to an entry in my text file.
ie: associate "1.jpg" to "entry 1" in the text file. With each entry formatted something like "[entry number:(x1 coordinate, y1 coordinate), ... (xN coordinate, yN coordinate)]"
tarenar is offline   Reply With Quote
Old 04-22-2009, 05:56 PM   #5 (permalink)
smithdale87's boss.
 
Magic Hands's Avatar
 
Join Date: Nov 2008
Location: Memphis, TN
Posts: 267
Default

Quote:
Originally Posted by tarenar View Post
Thanks for the quick response.

I'm using it primarily as a learning experience. Thus far the only saving/loading of information I've dealt with is using NSUserDefaults to keep track of high score data.

So if I understand both of your implementation suggestions correctly, I should have all my static images (ie: jpgs) stored in my project resources folder, as well as a text file of some sort (plist?) to save the x,y coordinates of the difference points.

Then I associate each picture to an entry in my text file.
ie: associate "1.jpg" to "entry 1" in the text file. With each entry formatted something like "[entry numberx1 coordinate, y1 coordinate), ... (xN coordinate, yN coordinate)]"
You got it!! Let us know how it turns out.
__________________
Elvis Mobile v1.0 - New! Keep track of Elvis news from Graceland.
Segment v1.1
ThumStruck (v1.1) - includes 10 songs
ThumStruck Free (v1.3) - includes 2 songs
Magic Hands is offline   Reply With Quote
Old 04-23-2009, 04:38 AM   #6 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 10
Default

I've structured my plist as follows

Code:
Array (represents all pictures)
   Array1 (represents picture)
      Dictionary1 (2 coordinates for difference in image)
         Number1 (x1 coordinate)
         Number2 (y1 coordinate)
         Number3 (x2 coordinate)
         Number4 (y2 coordinate)
         Number5 (found variable set to 1 if this difference found)
   ...
   ArrayN 
      Dictionary1 
         Number1 
         Number2 
         Number3 
         Number4 
         Number5
An outer array represents all of my pictures, while the inner array represents an individual picture. Each of the 5 dictionaries in the inner array holds coordinates for differences in the pictures. The found variable is set to 1 when a difference for this image is found.

I detect when the user touches each point with the following code, shortened for brevity:
Code:
//pseudo code for brevity
-(void)touchesEnded:

  get touch location
  for (each dictionary in the picture array) {

   if (player touches one of the points) {
   set the found variable for this point to 1/YES
   }
    
}
In the if statement, when a difference is successfully found, I set the "found" variable in my dictionary to "1" to indicate that I found a difference.

In the simulator everything works fine. But when I load the app onto my phone, and tap a difference point, the screen freezes. The only way to quit is to stop it within Xcode. Using the debugger, I pinpointed the crash to the line of code "[currentDiff setObject:tempBool forKey:@"found"];" below. Specifically the tempBool variable.

Code:
//2 rects always point to 1 difference. if finger in one of the two rects, found a difference
if (((CGRectContainsPoint(leftRect, location)) || CGRectContainsPoint(rightRect, location)) && (found == 0))
{
//now that we've found a difference, update local copy of the picture data and set its found flag to 1(true)
NSNumber *tempFound = [[NSNumber alloc] initWithInt:1];
				
[currentDiff setObject:tempFound forKey:@"found"]; //crashing game on iphone
				
[tempFound release];
[localCopyPic replaceObjectAtIndex:i withObject:currentDiff];

}
Why does this code work in the simulator but not on my phone?
tarenar is offline   Reply With Quote
Old 04-23-2009, 04:10 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2009
Posts: 10
Default

To avoid replacing the "found" variable in my dictionary, I simply deleted the dictionary once a difference was found. This approach appears to work.

Still, it's odd how the previous implementation worked in the simulator but not the phone.
tarenar is offline   Reply With Quote
Reply

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 24,074
Threads: 38,856
Posts: 170,469
Top Poster: smasher (2,563)
Welcome to our newest member, panpan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:30 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0