Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.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 03-22-2011, 05:45 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 5
dacrinus is on a distinguished road
Angry IVbricker game problems

Hello. This is the first game I do, but I have a problem with the bricks. I posted a video on youtube with the game. Please help me. Thanks.....YouTube - Xcode
dacrinus is offline   Reply With Quote
Old 03-22-2011, 06:05 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

ehm....the problem is that the brick doesn't disappear on collision?.

You need to write the code to do that, is not something automatic
__________________
dany_dev is offline   Reply With Quote
Old 03-22-2011, 08:22 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 5
dacrinus is on a distinguished road
Default

Quote:
Originally Posted by dany_dev View Post
ehm....the problem is that the brick doesn't disappear on collision?.

You need to write the code to do that, is not something automatic
And you have any ideea what is the code?
dacrinus is offline   Reply With Quote
Old 03-22-2011, 08:26 AM   #4 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

yes, it is similar to the code that you "wrote" for wall collision.
__________________
dany_dev is offline   Reply With Quote
Old 03-22-2011, 08:38 AM   #5 (permalink)
Registered Member
 
Join Date: Oct 2010
Location: delhi india
Age: 24
Posts: 120
vijay.adhikari is on a distinguished road
Send a message via Skype™ to vijay.adhikari
Default

int outer = 32/4;
int inner=4;
outer=(32/4 -outer)>0? outer uter+1;
NSLog(@"outer is as following %d",outer);
for (int i=0,k=0,t=0;i<outer;i++)
{

if (i == outer-1) {
inner=32%4;
}
for (int j=0; j<inner; j++) {

boximage = [[Box alloc] initWithImage:[UIImage imageNamed:@"bluebox.png"]];
boximage.frame = CGRectMake(i*40,j*40,40,40);
boximage.tag = t;
[self.view addSubview:boximage];

NSLog(@"tag images %d",boximage.tag);
//[boximage release];

k++;
t++;
}

}



u see the [box alloc]....make a class box:uiimageview ok
vijay.adhikari is offline   Reply With Quote
Old 03-24-2011, 01:39 PM   #6 (permalink)
Win
iOS dev
 
Join Date: Jan 2011
Location: Philadelphia
Posts: 11
Win is on a distinguished road
Post

Go to aPress and download the source code for the book - it's free.


Code:
BOOL there_are_solid_bricks = NO;
	
	for (int y = 0; y < BRICKS_HEIGHT; y++)
	{
		for (int x = 0; x < BRICKS_WIDTH; x++)
		{
			if (1.0 == bricks[x][y].alpha) 
			{
				there_are_solid_bricks = YES;
				if ( CGRectIntersectsRect(ball.frame, bricks[x][y].frame) )
				{
					[self processCollision:bricks[x][y]];
				}
			} 
			else 
			{
				if (bricks[x][y].alpha > 0)
					bricks[x][y].alpha -= 0.1;
			}
		}
	}
	
	if (!there_are_solid_bricks) {
		[self pauseGame];
		isPlaying = NO;
		lives = 0;
		[self saveGameState];
		
		messageLabel.text = @"You Win!";
		messageLabel.hidden = NO;
	}


Code:
- (void)processCollision:(UIImageView *)brick 
{
	score += 10;
	scoreLabel.text = [NSString stringWithFormat:@"%d", score];

	if (ballMovement.x > 0 && brick.frame.origin.x - ball.center.x <= 4) 
		ballMovement.x = -ballMovement.x;
	else if (ballMovement.x < 0 && ball.center.x - (brick.frame.origin.x + brick.frame.size.width) <= 4) 
		ballMovement.x = -ballMovement.x;

	if (ballMovement.y > 0 && brick.frame.origin.y - ball.center.y <= 4) 
		ballMovement.y = -ballMovement.y;
	else if (ballMovement.y < 0 && ball.center.y - (brick.frame.origin.y + brick.frame.size.height) <= 4) 
		ballMovement.y = -ballMovement.y;

	brick.alpha -= 0.1;
}
Win is offline   Reply With Quote
Old 03-24-2011, 06:49 PM   #7 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 8
Sbasham is on a distinguished road
Default

I havent gotten to that step yet because when i coded the paddle so the ball will bounce off of it. the ball no longer has screen boundries. It will just go off the screen forever until i re simulate the game.

Any ideas why?
Sbasham 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



» Advertisements
» Online Users: 426
6 members and 420 guests
chemistry, Emy, hussain1982, Retouchable, skrew88, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,922
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:15 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0