Jump to content

  • Log In with Google      Sign In   
  • Create Account

nick5454

Member Since 06 May 2003
Offline Last Active Jul 10 2014 03:44 PM

Topics I've Started

Looking for source code for a tiled 2d scroller

10 July 2014 - 08:13 AM

Hi,

 

I'm looking for source code for a simple 2d scroller like mario brothers. Does anyone know of link where I can purchase the code? I don't need a complete game, just the basic engine to side scroll. I checked code canyon, but all they have is UIKit scrollers.

 

I want to use it on iOS iPhone and would rather purchase source code to move fast. I understand opengl for the most part, but am not sure how to draw tile maps in opengl. Just looking for starter code and I am willing to buy the source.

 

Thanks,

Nick


help with quads for sprites in TextureAtlas

17 October 2013 - 12:20 PM

I have a texture atlas with 3 sprite images horizontally.
 
What I am trying to do is only display the first sprite ( 1/3 of the x axis )
 
I assume that when I load the texture I specify the quad for the entire and then I can define an additional quad that is 1/3. I am guessing that is wrong and I just load the texture and specify the quad at 1/3.

 

I am using GHLKit for iphone ( wrapper for openGL ). Can anyone tell me why I can't just show the first sprite and it always shows my entire atlas?

 

Here is my quad defined:

    TexturedQuad newQuad;
    newQuad.bl.geometryVertex = CGPointMake(0, 0);
    newQuad.br.geometryVertex = CGPointMake(self.textureInfo.width, 0);
    newQuad.tl.geometryVertex = CGPointMake(0, self.textureInfo.height);
    newQuad.tr.geometryVertex = CGPointMake(self.textureInfo.width, self.textureInfo.height);

    newQuad.bl.textureVertex = CGPointMake(0, 1);
    newQuad.br.textureVertex = CGPointMake(.3, 1);
    newQuad.tl.textureVertex = CGPointMake(0, 0);
    newQuad.tr.textureVertex = CGPointMake(.3, 0);
    
    self.quad = newQuad;

 

The problem is this just shows the image stretched and not cropped

 

Here is the sprite code:

- (void)setSprite:(NSString *)fileName effect:(GLKBaseEffect *)newEffect {

    // 1
    self.effect = newEffect;
        
    // 2
    NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
                                  [NSNumber numberWithBool:YES],
                                  GLKTextureLoaderOriginBottomLeft,
                                  nil];
        
    // 3
    NSError * error;
    NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:nil];
    
    // 4
    self.textureInfo = [GLKTextureLoader textureWithContentsOfFile:path options:options error:&error];
    if (self.textureInfo == nil) {
        NSLog(@"Error loading file: %@", [error localizedDescription]);
            return ;
    }

    TexturedQuad newQuad;
    newQuad.bl.geometryVertex = CGPointMake(0, 0);
    newQuad.br.geometryVertex = CGPointMake(self.textureInfo.width/3, 0);
    newQuad.tl.geometryVertex = CGPointMake(0, self.textureInfo.height);
    newQuad.tr.geometryVertex = CGPointMake(self.textureInfo.width/3, self.textureInfo.height);

    newQuad.bl.textureVertex = CGPointMake(0, 1);
    newQuad.br.textureVertex = CGPointMake(.3, 1);
    newQuad.tl.textureVertex = CGPointMake(0, 0);
    newQuad.tr.textureVertex = CGPointMake(.3, 0);
    
    self.quad = newQuad;

}

 

the render method:

- (void)render {
    
    // 1
    self.effect.texture2d0.name = self.textureInfo.name;
    self.effect.texture2d0.enabled = YES;
    
    // 2
    y++;
    self.effect.transform.modelviewMatrix = self.modelMatrix;
    [self.effect prepareToDraw];
    
    // 3
    glEnableVertexAttribArray(GLKVertexAttribPosition);
    glEnableVertexAttribArray(GLKVertexAttribTexCoord0);
    

    // 4
    long offset = (long)&_quad;
    glVertexAttribPointer(GLKVertexAttribPosition, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, geometryVertex)));
    glVertexAttribPointer(GLKVertexAttribTexCoord0, 2, GL_FLOAT, GL_FALSE, sizeof(TexturedVertex), (void *) (offset + offsetof(TexturedVertex, textureVertex)));
    
    // 5
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
}
 

setup projection

- (void)setupGL
{
    [EAGLContext setCurrentContext:self.context];
    
    self.effect = [[GLKBaseEffect alloc] init];
    
    GLKMatrix4 projectionMatrix = GLKMatrix4MakeOrtho(0, 480, 320, 0, -1, 1);
    self.effect.transform.projectionMatrix = projectionMatrix;
    
    [self setSprite:@"NinjaSpriteSheet.png" effect:self.effect ];

}


Sprite Sheet maker

12 August 2013 - 02:48 PM

I have a project called iSprite at http://iSprite.codeplex.com

 

In a jist it allows you to create a grid and place images in that grid through drag&drop, or inserting multiple files. When you click save it produces a sheet with all drawings centered exactly based on the original size image. Each square has attributes that can be modified

 

I'm working on adding save folders, so multiple sheets can be stored with an xml definition file.

 

If anyone wants to use it, help code it, etc..., I would greatly appreciate it. Currently I make improvements as I need them. After all the features are flashed out I plan on adding a multi layer level editor.

 

The app is developed in .net (PC).

 

Thanks,

Nick


Creating 2d chars with photoshop vs illustrator

20 March 2013 - 10:15 AM

Would anyone recommend making 2d chars for my game Photoshop over Illustrator or vice versa.

 

I read that Illustrator does vector graphics which I assume is better for rendering, but I also read that Photoshop is pixel based which is what a 2d character will render as.

 

These are 2d characters with detailed drawings and have accessories like guns and clothes.

 

Any advice is appreciated.

Nick


Using Sonic pictures

12 March 2013 - 11:44 AM

An independent artist created a sonic the hedgehog sprite sheet and as long as I give him credit, I can use it. My questions is: Is there a legal disclaimer I can put on the screen that says this is not made by sega...etc to avoid being sued. I simply want to make a sonic game for fun on the iphone and provide it free of charge to anyone. Will I get sued for doing that or is there a way I can state this is for fun and the graphics were independently. Or is this a shady idea?

PARTNERS