Alien Blitz episode 2 & 3 will be ready soon

I began working on episodes 2 & 3 lately

  • Converted all maps to top view, I now have to check if they actually work, and correct lighting issues
  • Corrected some bugs on monsters from episodes 2 & 3, there were not that much actually, but I think I will get more bugs when I do the testing
  • Changed spirit behavior, in Snorms it was a small monster hard to aim, now I made it very strong as aiming is automatic on Android
  • Added camera button for Rifle & Railgun, when pressing this button you will be able to move freely the camera, and lock a monster far away
  • Created a new sprite for the player in isometric mode, it’s some king of mecha armor, it’s not perfect, but I’m quite happy with it.

I think both episodes will be ready in a few days, then I will have to perform tests, and work on the full android release (payment process and save recovery from the free version).

I also made great progress on the isometric version, it is almost fully corrected now, but I have to finish the Android version first (as the PC version will include both isometric and top view versions).

I’ve also worked on using LibGdx Pixmap more often, problem was pixmap doesn’t allow color effects that I use for lighting effects. So I had to dig in the source code and make the appropriate changes. That’s how I discovered the magic of jnigen (http://www.youtube.com/watch?feature=player_embedded&v=N2EE_jlDfrM), this thing is incredible, you just have to write your C source code directly in your java file, and all translations & ant scripts are automatically built.

As of now I have just modified the blit function, but as I have to rebuild the whole thing myself when releasing, it means I could add more functions, and convert some time critical functions to C.

Long story short, here is the modified blit function I created, basically it just transforms color components when performing blit operations

static inline uint32_t blend_microbasic(uint32_t src, uint32_t dst, float r, float g, float b, float a) { 
    int32_t src_r = (src & 0xff000000) >> 24; 
    int32_t src_g = (src & 0xff0000) >> 16; 
    int32_t src_b = (src & 0xff00) >> 8; 
    int32_t src_a = (src & 0xff); 

    int32_t dst_r = (dst & 0xff000000) >> 24; 
    int32_t dst_g = (dst & 0xff0000) >> 16; 
    int32_t dst_b = (dst & 0xff00) >> 8; 
    int32_t dst_a = (dst & 0xff); 

    src_r *= r; 
    src_g *= g; 
    src_b *= b; 
    src_a *= a; 
    dst_r = dst_r + src_a * (src_r - dst_r) / 255; 
    dst_g = dst_g + src_a * (src_g - dst_g) / 255; 
    dst_b = dst_b + src_a * (src_b - dst_b) / 255; 
    dst_a = (int32_t)((1.0f - (1.0f - src_a / 255.0f) * (1.0f - dst_a / 255.0f)) * 255); 
    return (uint32_t)((dst_r << 24) | (dst_g << 16) | (dst_b << 8) | dst_a); 
}
static inline void blit_same_size_microbasic(const gdx2d_pixmap* src_pixmap, const gdx2d_pixmap* dst_pixmap,  
                                      int32_t src_x, int32_t src_y,  
                                     int32_t dst_x, int32_t dst_y,  
                                     uint32_t width, uint32_t height, 
                                     float r, float g, float b, float a) {     
    set_pixel_func pset = set_pixel_func_ptr(dst_pixmap->format); 
    get_pixel_func pget = get_pixel_func_ptr(src_pixmap->format); 
    get_pixel_func dpget = get_pixel_func_ptr(dst_pixmap->format); 
    uint32_t sbpp = gdx2d_bytes_per_pixel(src_pixmap->format); 
    uint32_t dbpp = gdx2d_bytes_per_pixel(dst_pixmap->format); 
    uint32_t spitch = sbpp * src_pixmap->width; 
    uint32_t dpitch = dbpp * dst_pixmap->width; 

    int sx = src_x; 
    int sy = src_y; 
    int dx = dst_x; 
    int dy = dst_y; 

    for(;sy < src_y + height; sy++, dy++) { 
        if(sy < 0 || dy < 0) continue; 
        if(sy >= src_pixmap->height || dy >= dst_pixmap->height) break; 

        for(sx = src_x, dx = dst_x; sx < src_x + width; sx++, dx++) { 
            if(sx < 0 || dx < 0) continue; 
            if(sx >= src_pixmap->width || dx >= dst_pixmap->width) break; 

            const void* src_ptr = src_pixmap->pixels + sx * sbpp + sy * spitch; 
            const void* dst_ptr = dst_pixmap->pixels + dx * dbpp + dy * dpitch; 
            uint32_t src_col = to_RGBA8888(src_pixmap->format, pget((void*)src_ptr)); 

            uint32_t dst_col = to_RGBA8888(dst_pixmap->format, dpget((void*)dst_ptr)); 
            src_col = to_format(dst_pixmap->format, blend_microbasic(src_col, dst_col,r ,g ,b, a)); 

            pset((void*)dst_ptr, src_col); 
        } 
    } 
}

I will clean this code a bit and give away a full diff of my modifications soon. As this code is very specific to my needs I doubt I shall pull it on LibGdx git.

Comments are closed.