[Obj-C] Paddle for the game "Pong"

Discussion in 'iOS Development' started by H4CK!NT0SH, Jul 9, 2009.

  1. H4CK!NT0SH

    H4CK!NT0SH Banned

    Joined:
    Jun 28, 2009
    Messages:
    159
    Likes Received:
    0
    Device:
    2G iPod touch
    Hey all. I'm currently writing a "Pong" application for the App Store, and I'm having some _minor_ problems with the paddles.

    Here is what I have so far:

    Code:
    -(void) onTimer {
    	paddle.left = CGPointMake(paddle.left.x+pos.x,ball.center.y+pos.y);
    	
    	if(paddle.left.x > 320 || paddle.left.x < 0)
    		pos.x = -pos.x;
    	if(paddle.left.y > 460 || paddle.left.y < 0)
    		pos.y = -pos.y;
    }
    I need to know how to make the paddle respond to when the screen is touched...Does anyone know the code for that? Thanks guys.
  2. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
  3. H4CK!NT0SH

    H4CK!NT0SH Banned

    Joined:
    Jun 28, 2009
    Messages:
    159
    Likes Received:
    0
    Device:
    2G iPod touch

    Thanks Skylar

    Please Register or Log in to view images


    ------------------double post merged------------------
    Hmm. Skylar I'm having a small amount of trouble trying to follow those guides. Could you maybe apply the necessary guide to this code below? If not, that's totally fine.

    Code:
    //
    //  BallViewController.h
    //  Ball
    //
    //  Created by _ on 7/9/09
    //  Copyright __MyCompanyName__ 2009. All rights reserved.
    //
    
    #import <UIKit/UIKit.h>
    
    @interface BallViewController : UIViewController {
    	IBOutlet UIImageView *ball;
    	CGPoint pos;
    }
    
    @property(nonatomic,retain) IBOutlet UIImageView *ball;
    
    @end
    
    
    Notice: The paddle code hasn't been applied, which is what I'm having trouble with. Sorry for throwing all this at you, I just need some help as I just spent the last 8 hours learning Obj-C and I'm attempting to write my first program. Heh. Thanks.
  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Your starting with too much if your just learning.
    Try making some Hello World applications, then play around with the UIKit elements. It really makes things easier.
    Because so far, you've done nothing as that code is from iCodeBlog, and was just ripped the other day and placed on the App Store without permission.
  5. H4CK!NT0SH

    H4CK!NT0SH Banned

    Joined:
    Jun 28, 2009
    Messages:
    159
    Likes Received:
    0
    Device:
    2G iPod touch
    Yes, it's from iCodeBlog, but you're allowed to build off of it. I saw that article about the guy who got busted for it. He completely stole all their code, but what I'm doing is taking some of that code and building of it. The paddle code is not from iCodeBlog, I am attempting to create it myself. Also, I would be giving credit to them.
  6. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    On an unrelated topic, I was the guy who notified Brandon about the stolen code.
  7. H4CK!NT0SH

    H4CK!NT0SH Banned

    Joined:
    Jun 28, 2009
    Messages:
    159
    Likes Received:
    0
    Device:
    2G iPod touch
    Well good job, I'm glad you reported that. Just wondering, was that a threat? Haha. I'm not stealing anything, but if it seems as though I am, I won't submit it to Apple.
  8. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Alright, no worries.
    I was just saying how I started out

    Please Register or Log in to view images

    .
    Good luck.

    No it was not, he's just proud of himself

    Please Register or Log in to view images

    .

Share This Page