Beispiel #1
0
/***
Set the color of a pixel.
@function :setPixel
@tparam number x X position of the pixel
@tparam number y Y position of the pixel
@tparam number color New color of the pixel
*/
static int texture_setPixel(lua_State *L) {
	texture_userdata *texture = luaL_checkudata(L, 1, "LTexture");
	int x = luaL_checkinteger(L, 2);
	int y = luaL_checkinteger(L, 3);
	u32 color = luaL_checkinteger(L, 4);

	sf2d_set_pixel(texture->texture, x, y, color);

	return 0;
}
Beispiel #2
0
void initMiniMap(bool loadUpWorld) {
	int i, x, y;
	for (i = 0; i < 5; ++i) {
		for (x = 0; x < 128; ++x) {
			for (y = 0; y < 128; ++y) {

				if (!loadUpWorld) { // generate stairs up when making a new world.
					switch (map[i][x + y * 128]) {
					case TILE_STAIRS_DOWN:
						map[i + 1][x + y * 128] = TILE_STAIRS_UP;
						if (i == 0) {
							map[i + 1][(x + 1) + y * 128] = TILE_HARDROCK;
							map[i + 1][x + (y + 1) * 128] = TILE_HARDROCK;
							map[i + 1][(x - 1) + y * 128] = TILE_HARDROCK;
							map[i + 1][x + (y - 1) * 128] = TILE_HARDROCK;
							map[i + 1][(x + 1) + (y + 1) * 128] = TILE_HARDROCK;
							map[i + 1][(x - 1) + (y - 1) * 128] = TILE_HARDROCK;
							map[i + 1][(x - 1) + (y + 1) * 128] = TILE_HARDROCK;
							map[i + 1][(x + 1) + (y - 1) * 128] = TILE_HARDROCK;
						} else {
							map[i + 1][(x + 1) + y * 128] = TILE_DIRT;
							map[i + 1][x + (y + 1) * 128] = TILE_DIRT;
							map[i + 1][(x - 1) + y * 128] = TILE_DIRT;
							map[i + 1][x + (y - 1) * 128] = TILE_DIRT;
							map[i + 1][(x + 1) + (y + 1) * 128] = TILE_DIRT;
							map[i + 1][(x - 1) + (y - 1) * 128] = TILE_DIRT;
							map[i + 1][(x - 1) + (y + 1) * 128] = TILE_DIRT;
							map[i + 1][(x + 1) + (y - 1) * 128] = TILE_DIRT;
						}
					}
				}

				/* Minimaps */
				sf2d_set_pixel(minimap[i], x, y, getTileColor(map[i][x + y * 128]));
			}
		}
	}
}
Beispiel #3
0
void initMiniMap(bool loadUpWorld){
    int i,x,y;
    for(i=0;i<5;++i){
        for(x=0;x < 128;++x){
            for(y=0;y < 128;++y){
                
                if(!loadUpWorld){ // generate stairs up when making a new world.
                    switch(map[i][x+y*128]){
                        case TILE_STAIRS_DOWN:
                            map[i+1][x+y*128] = TILE_STAIRS_UP;
                            if(i == 0){
                                map[i+1][(x+1)+y*128] = TILE_HARDROCK;
                                map[i+1][x+(y+1)*128] = TILE_HARDROCK;
                                map[i+1][(x-1)+y*128] = TILE_HARDROCK;
                                map[i+1][x+(y-1)*128] = TILE_HARDROCK;
                                map[i+1][(x+1)+(y+1)*128] = TILE_HARDROCK;
                                map[i+1][(x-1)+(y-1)*128] = TILE_HARDROCK;
                                map[i+1][(x-1)+(y+1)*128] = TILE_HARDROCK;
                                map[i+1][(x+1)+(y-1)*128] = TILE_HARDROCK;
                            } else {
                                map[i+1][(x+1)+y*128] = TILE_DIRT;
                                map[i+1][x+(y+1)*128] = TILE_DIRT;
                                map[i+1][(x-1)+y*128] = TILE_DIRT;
                                map[i+1][x+(y-1)*128] = TILE_DIRT;
                                map[i+1][(x+1)+(y+1)*128] = TILE_DIRT;
                                map[i+1][(x-1)+(y-1)*128] = TILE_DIRT;
                                map[i+1][(x-1)+(y+1)*128] = TILE_DIRT;
                                map[i+1][(x+1)+(y-1)*128] = TILE_DIRT;
                            }
                    }
                }
                
                /* Minimaps */
                switch(map[i][x+y*128]){
                    case TILE_WATER: sf2d_set_pixel (minimap[i], x, y, 0xFFFF0000); break;
                    case TILE_LAVA: sf2d_set_pixel (minimap[i], x, y, 0xFF0000FF); break;
                    case TILE_DIRT: sf2d_set_pixel (minimap[i], x, y, 0xFF6C6D82); break;
                    case TILE_ROCK: sf2d_set_pixel (minimap[i], x, y, 0xFF7F7F7F); break;
                    case TILE_HARDROCK: sf2d_set_pixel (minimap[i], x, y, 0xFF7F5F5F); break;
                    case TILE_GRASS: sf2d_set_pixel (minimap[i], x, y, 0xFF00FF00); break;
                    case TILE_TREE: sf2d_set_pixel (minimap[i], x, y, 0xFF007F00); break;
                    case TILE_SAND: sf2d_set_pixel (minimap[i], x, y, 0xFF00FFFF); break;
                    case TILE_CACTUS: sf2d_set_pixel (minimap[i], x, y, 0xFF009F00); break;
                    case TILE_FLOWER: sf2d_set_pixel (minimap[i], x, y, 0xFF00FF3F); break;
                    case TILE_IRONORE: sf2d_set_pixel (minimap[i], x, y, 0xFF9696DC); break;
                    case TILE_GOLDORE: sf2d_set_pixel (minimap[i], x, y, 0xFF9AE8E5); break;
                    case TILE_GEMORE: sf2d_set_pixel (minimap[i], x, y, 0xFFDE98DF); break;
                    case TILE_CLOUD: sf2d_set_pixel (minimap[i], x, y, 0xFFFFFFFF); break;
                    case TILE_CLOUDCACTUS: sf2d_set_pixel (minimap[i], x, y, 0xFFAFAFAF); break;
                    case TILE_STAIRS_DOWN: sf2d_set_pixel (minimap[i], x, y, 0xFF9F9F9F); break;
                    case TILE_STAIRS_UP: sf2d_set_pixel (minimap[i], x, y, 0xFF9F9F9F); break;
                    default: sf2d_set_pixel (minimap[i], x, y, 0xFF111111); break;
                }
            }
        }
    }
}