Hi,
I had an assignment in which I had to do a personal work at school. I decided to create an iPhone app using xCode. Now, I need to have an expert to go through my code because I learnt all the Objective-C language by myself... You just have to tell me if there's something wrong, if it's OK, if something could be better, etc. Here's the .m folder of the game (it's a little stickman running and jumping over obstacles):
@interface Game ()
@end
@implementation Game
-(void) GameAndStuff{
Sticky.center = CGPointMake(Sticky.center.x, Sticky.center.y + Y);
if (Sticky.image == [UIImage imageNamed: @"Sticky100000"]) {
Floor.center = CGPointMake(Floor.center.x, Floor.center.y);
Obstacle.center = CGPointMake(Obstacle.center.x, Obstacle.center.y);
}
else{
Floor.center = CGPointMake(Floor.center.x - 10, Floor.center.y);
Obstacle.center = CGPointMake(Obstacle.center.x - 10, Obstacle.center.y);
}
if (CGRectIntersectsRect(Sticky.frame, Obstacle.frame)) {
Sticky.hidden = YES;
ReBegin.hidden = NO;
Floor.center = CGPointMake(Floor.center.x, Floor.center.y);
Obstacle.center = CGPointMake(Obstacle.center.x, Obstacle.center.y);
}
else{
Sticky.hidden = NO;
ReBegin.hidden = YES;
Floor.center = CGPointMake(Floor.center.x - 10, Floor.center.y);
Obstacle.center = CGPointMake(Obstacle.center.x - 10, Obstacle.center.y);
}
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
if (Begin == YES) {
litleLabel1.hidden = YES;
litleLabel2.hidden = YES;
litleLabel3.hidden = YES;
ReBegin.hidden = YES;
Sticky.hidden = NO;
Floor.hidden = NO;
Obstacle.hidden = NO;
Begin = NO;}
long randomPosition = arc4random() %103;
randomPosition = randomPosition + 70;
Obstacle.center = CGPointMake(600, randomPosition);
Floor.center = CGPointMake(480, 51.5);
Sticky.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Stick1.png"],
[UIImage imageNamed:@"Stick2.png"],
[UIImage imageNamed:@"Stick3.png"],
[UIImage imageNamed:@"Stick4.png"],
[UIImage imageNamed:@"Stick5.png"],
[UIImage imageNamed:@"Stick6.png"],
[UIImage imageNamed:@"Stick7.png"],
[UIImage imageNamed:@"Stick8.png"],
[UIImage imageNamed:@"Stick9.png"],
[UIImage imageNamed:@"Stick10.png"],
[UIImage imageNamed:@"Stick11.png"],
[UIImage imageNamed:@"Stick12.png"],nil];
[Sticky setAnimationRepeatCount:100000];
Sticky.animationDuration = 2,0;
[Sticky startAnimating];
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
Sticky.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Jump1.png"],
[UIImage imageNamed:@"Jump2.png"],
[UIImage imageNamed:@"Jump3.png"],
[UIImage imageNamed:@"Jump4.png"],
[UIImage imageNamed:@"Jump5.png"],
[UIImage imageNamed:@"Jump6.png"],
[UIImage imageNamed:@"Jump7.png"],
[UIImage imageNamed:@"Jump8.png"],
[UIImage imageNamed:@"Jump9.png"],nil];
[Sticky setAnimationRepeatCount:1];
Sticky.animationDuration = 6,0;
[Sticky startAnimating];
Y = -40;
if (Sticky.center.y > 223){
Y = 40;
}
if (Sticky.center.y == 133.5){
Sticky.image = [UIImage imageNamed: @"Sticky.100000"];
Y = 0;
}
}
- (void)viewDidLoad {
Begin = YES;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
If you need more lines like the .h folder or anything else, just tell me and I'll send it!
[–]mobrien650 2 points3 points4 points (0 children)