Sha256: e69452be011d87088cf03c0ecfd8b5a0a1c19c9be3748a2197df5233e9fe097d

Contents?: true

Size: 1.79 KB

Versions: 3

Compression:

Stored size: 1.79 KB

Contents

#import "ObjGosuImage.h"
#import "ObjGosuWindow.h"
#import <Gosu/Image.hpp>
#import <Gosu/Utility.hpp>
#import <Gosu/Window.hpp>
#import <vector>

@implementation ObjGosuImage
- (int)width
{
    return _image->width();
}

- (int)height
{
    return _image->height();
}

- (id)initWithWindow:(id)window filename:(NSString*)filename tileable:(BOOL)tileable
{
    if (not (self = [super init]))
        return NULL;
    
    _image = new Gosu::Image(((Gosu::Window*)[[window _objcObject] _cppObject])->graphics(),
        Gosu::widen([filename UTF8String]), tileable);
    
    return self;
}

- (id)initWithCPPObject:(Gosu::Image*)image
{
    if (not (self = [super init]))
        return NULL;
    
    _image = image;
    
    return self;
}

+ (NSMutableArray*)loadTilesWithWindow:(id)window filename:(NSString*)filename
    tileWidth:(int)tileWidth tileHeight:(int)tileHeight tileable:(BOOL)tileable
{
    std::vector<Gosu::Image*> images;
    imagesFromTiledBitmap(((Gosu::Window*)[[window _objcObject] _cppObject])->graphics(),
        Gosu::utf8ToWstring([filename UTF8String]), tileWidth, tileHeight, tileable, images);

    NSMutableArray* array = [NSMutableArray arrayWithCapacity:images.size()];
    for (int i = 0; i < images.size(); ++i)
        [array insertObject:[[ObjGosuImage alloc] initWithCPPObject:images[i]] atIndex:i];
    return array;
}

- (void)drawWithX: (float)x y:(float)y z:(float)z
    factorX:(float)factorX factorY:(float)factorY color:(unsigned long)color
{
    _image->draw(x, y, z, factorX, factorY, color);
}

- (void)drawRotWithX: (float)x y:(float)y z:(float)z angle:(float)angle
    centerX:(float)centerX centerY:(float)centerY
    factorX:(float)factorX factorY:(float)factorY color:(unsigned long)color
{
    _image->drawRot(x, y, z, angle, centerX, centerY, factorX, factorY, color);
}
@end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gosu-0.7.18 GosuImpl/ObjGosu/ObjGosuImage.mm
gosu-0.7.17 GosuImpl/ObjGosu/ObjGosuImage.mm
gosu-0.7.16 GosuImpl/ObjGosu/ObjGosuImage.mm