Small game, encountering errors...

Apprentice
Posts: 7
Joined: 2008.12
Post: #1
Hey guys

I finally found a pretty good game programming tutorial that's relatively new.

I was able to use his template to begin my own game, which is a port of this. Sorry for the bad quality, it wasn't me who originally recorded it.

Basically, if you know the Playstation consoles, the green smilie (if you can see it) is the player's character, which is controlled by an analog nub.

I was thinking of creating buttons on the screen to make up for having no physical buttons on the iPhone, but just in IB, it looked like it wouldn't work.

So I have a few questions that I would be very thankful if you could answer:

  1. What would be the best way to control the player?
  2. I have code that can cause the 'enemies' to follow the player, but can't decide on how to implement it, would it work (see below)?
  3. I've been looking through Apple's documentation, but can't figure out how to set up a background MP3 to play looped. What is the best way to set this up?
  4. I set the orientation to landscape programmatically, but when I simulate the game after building, all of the borders are there except for the bottom. Could it be that IB is the cause? I'm using a view, but it won't allow me to edit it's size/boundaries in IB for some reason.


Code:
// Vector.h
@interface Vector : NSObject {
    double _x;
    double _y;
}
- (id)initWithVectorVector *)vector;
- (id)initWithXdouble)x ydouble)y;
- (Vector *)addVector *)vector;
- (Vector *)subtractVector *)vector;
- (Vector *)negate;
- (Vector *)multiplydouble)scalar;
- (double)magnitude;
@property (nonatomic,assign) double x;
@property (nonatomic,assign) double y;
@end



// Vector.m
@implementation
@synthesize x = _x, y = _y;
- (id)initWithVectorVector *)vector {
    if(self = [super init]) {
        _x = vector.x;
        _y = vector.y;
    }
    return self;
}
- (id)initWithXdouble)x ydouble)y {
    if(self = [super init]) {
        _x = x;
        _y = y;
    }
}
- (Vector *)addVector *)vector {
    Vector *result = [[Vector alloc] initWithX:self.x + vector.x y:self.y + vector.y];
    return [result autorelease];
}
- (Vector *)subtractVector *)vector {
    Vector *result = [[Vector alloc] initWithX:self.x - vector.x y:self.y - vector.y];
    return [result autorelease];
}
- (Vector *)negate {
    Vector *result = [[Vector alloc] initWithX:-self.x y:-self.y];
    return [result autorelease];
}
- (Vector *)multiplydouble)scalar {
    Vector *result = [[Vector alloc] initWithX:self.x * scalar y:self.y * scalar];
    return [result autorelease];
}
- (double)magnitude {
    return sqrt(self.x*self.x + self.y*self.y);
}
@end

Thanks guys for the help Wink You are one of my only resources. I can submit more info if needed.
Quote this message in a reply
Apprentice
Posts: 7
Joined: 2008.12
Post: #2
Can anyone help?

I just need to find a way to attach a line to a UIImage and apply physics effects to the line to make it move in 360 degrees.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Where should I present a small game in this forum? riruilo 1 1,955 Oct 5, 2009 07:15 PM
Last Post: AnotherJake