Monday 15 March 2010

java - understanding cuboc libgdx example -



java - understanding cuboc libgdx example -

i have cloned , able produce functional application cuboc libgdx demo got here: https://github.com/libgdx/libgdx-demo-cuboc

i trying understand bit of code in cuboc libgdx demo. add together questions comments in code below:

package com.badlogic.cubocy; import com.badlogic.gdx.gdx; import com.badlogic.gdx.graphics.pixmap; import com.badlogic.gdx.utils.array; public class map { static int empty = 0; /*** *** why these ints have in hex ? ***/ static int tile = 0xffffff; static int start = 0xff0000; static int end = 0xff00ff; static int dispenser = 0xff0100; static int spikes = 0x00ff00; static int rocket = 0x0000ff; ... private void loadbinary () { /*** *** how did file "levels.png" created ? ***/ pixmap pixmap = new pixmap(gdx.files.internal("data/levels.png")); tiles = new int[pixmap.getwidth()][pixmap.getheight()]; (int y = 0; y < 35; y++) { (int x = 0; x < 150; x++) { /*** *** what's bitwise operations? ***/ int pix = (pixmap.getpixel(x, y) >>> 8) & 0xffffff; if (match(pix, start)) { ... } else if (match(pix, dispenser)) { ... } else if (match(pix, rocket)) { ... } else { tiles[x][y] = pix; } } } ...

thanks!

they don't have in hex, it's convenient way see colors correspond in image file that's beingness used map.

the map editor game mspaint. drew png file in fine art program. each color in image file matches 1 of constant ints @ top of class.

pixmap ints in rgba, apparently rgb values used. if @ constant ints @ top, none of them utilize first 8 bits of 32-bit integer. bitwise operations on line drop part of image's pixel (>>>8) , gives rgb int. not super-familiar bit shifts. seems redundant me mask & 0xffffff after using unsigned shift >>> instead of signed shift >>, maybe i'm missing something.

java android libgdx

No comments:

Post a Comment