void Draw_Map(int map_array[12][20], POSITION pos, POSITION laserPos, int laser, POSITION missilePos, int missile) { //int x = map_x_location; int x = 0; int y = 0; SetPlane (LIGHT_PLANE); ClrScr (); SetPlane (DARK_PLANE); ClrScr (); drawRType(pos); if (laser) drawLaser(laserPos); if (missile) drawMissile(missilePos); // Well.. the map_x_location will keep track of where we are on the X-plane on the map array // This way we mask out the stuff in the array that we use.. So we will only read 30x8 elements of the // array (instead of 60x8 which it is at the moment.. ).. This might sound unuseful, and it sort of is // with a small array as this one.. but i'm guessing you will create worlds that are much much bigger.. // so.. to gain more speed.. we mask it out ;) /*while (x<20) {// Again, we can't view more than 30 blocks.. so.. don't calculate more than 30 blocks if ((map_array[y][x]==7)) { // If the array at this location is equal to 1, place a ground piece Sprite8(x*8, y*8, 8, ground_down, GetPlane (DARK_PLANE), SPRT_XOR); Sprite8(x*8, y*8, 8, ground_down, GetPlane (LIGHT_PLANE), SPRT_XOR); } if ((map_array[y][x]==8)) { // .. and if it's 2, place block1 Sprite8(x*8, y*8, 8, ground_flat, GetPlane (DARK_PLANE), SPRT_XOR); Sprite8(x*8, y*8, 8, ground_flat, GetPlane (LIGHT_PLANE), SPRT_XOR); } if (map_array[y][x]==9) { Sprite8(x*8, y+8, 8, ground_up, GrayGetPlane(LIGHT_PLANE), SPRT_XOR); Sprite8(x*8, y+8, 8, ground_up, GrayGetPlane(DARK_PLANE), SPRT_XOR); } y++; // Now.. we're increasing the Y value.. note that i'm drawing the world from LEFT to RIGHT // I've seen people who draw their world TOP to DOWN or otherwise, but i found LEFT to RIGHT // is the best way to draw the world.. if (y>11) { // We've reached the limit.. restore the Y value, and move 1 block row forward.. y=0; x++; } }*/ for (x = 0; x <= 19; x++) { for (y = 0; y <= 11; y++) { if (map_array[y][x] == 7) { Sprite8(x*8, y*8, 8, ground_down, GrayGetPlane(DARK_PLANE), SPRT_XOR); Sprite8(x*8, y*8, 8, ground_down, GrayGetPlane(LIGHT_PLANE), SPRT_XOR); } else if (map_array[y][x] == 8) { Sprite8(x*8, y*8, 8, ground_flat, GrayGetPlane(DARK_PLANE), SPRT_XOR); Sprite8(x*8, y*8, 8, ground_flat, GrayGetPlane(LIGHT_PLANE), SPRT_XOR); } else if (map_array[y][x] == 9) { Sprite8(x*8, y*8, 8, ground_up, GrayGetPlane(DARK_PLANE), SPRT_XOR); Sprite8(x*8, y*8, 8, ground_up, GrayGetPlane(LIGHT_PLANE), SPRT_XOR); } } } }
// function that draws the screen void Draw_Map(int map_x_location, char map_array[12][MAP_SIZE], POSITION pos, POSITION laserPos, int laser, POSITION missilePos, int missile) { int x = map_x_location; int y = 0; // clear both planes SetPlane (LIGHT_PLANE); ClrScr(); SetPlane (DARK_PLANE); ClrScr(); // draw ship, and missiles and cannons if they exist drawShip(pos, map_x_location); if (laser) drawLaser(laserPos, map_x_location); if (missile == 1) drawMissile(missilePos, map_x_location); if (missile == -1) drawUpMissile(missilePos, map_x_location); // Well.. the map_x_location will keep track of where we are on the X-plane on the map array // This way we mask out the stuff in the array that we use.. So we will only read 20x12 elements of the // array (instead of MAP_SIZEx12 which it is at the moment.. ) while (x < (map_x_location + 20)) {// Again, we can't view more than 20 blocks.. so.. don't calculate more than 20 blocks if ((map_array[y][x] == 1)) { // If the array at this location is equal to 1, place a broken piece Sprite8((x - map_x_location) * 8, y * 8, 8, broken2_dark, GetPlane (DARK_PLANE), SPRT_XOR); Sprite8((x - map_x_location) * 8, y * 8, 8, broken2_light, GetPlane (LIGHT_PLANE), SPRT_XOR); } if ((map_array[y][x] == 2)) { // If the array at this location is equal to 1, place a broken piece Sprite8((x - map_x_location) * 8, y * 8, 8, broken1_dark, GetPlane (DARK_PLANE), SPRT_XOR); Sprite8((x - map_x_location) * 8, y * 8, 8, broken1_light, GetPlane (LIGHT_PLANE), SPRT_XOR); } if ((map_array[y][x] == 3)) { // .. and if it's 2, place block1 Sprite8((x - map_x_location) * 8, y * 8, 8, block1_dark, GetPlane (DARK_PLANE), SPRT_XOR); Sprite8((x - map_x_location) * 8, y * 8, 8, block1_light, GetPlane (LIGHT_PLANE), SPRT_XOR); } if ((map_array[y][x] == 4)) { // a 3 means the indestructible block Sprite8((x - map_x_location) * 8, y * 8, 8, solid1_light, GrayGetPlane(LIGHT_PLANE), SPRT_XOR); Sprite8((x - map_x_location) * 8, y * 8, 8, solid1_dark, GrayGetPlane(LIGHT_PLANE), SPRT_XOR); Sprite8((x - map_x_location) * 8, y * 8, 8, solid1_mid, GrayGetPlane(DARK_PLANE), SPRT_XOR); Sprite8((x - map_x_location) * 8, y * 8, 8, solid1_dark, GrayGetPlane(DARK_PLANE), SPRT_XOR); } y++; // Now.. we're increasing the Y value.. note that i'm drawing the world from LEFT to RIGHT // I've seen people who draw their world TOP to DOWN or otherwise, but i found LEFT to RIGHT // is the best way to draw the world.. if (y > 11) { // We've reached the limit.. restore the Y value, and move 1 block row forward.. y = 0; x++; } } }
bool ON_Hatch::Create( const ON_Plane& plane, const ON_SimpleArray<const ON_Curve*> loops, int pattern_index, double pattern_rotation, double pattern_scale) { if( loops.Count() < 1) return false; if( pattern_index < 0) return false; SetPlane( plane); for( int i = 0; i < loops.Count(); i++) { ON_HatchLoop* pLoop = new ON_HatchLoop; pLoop->SetCurve( *loops[i]); pLoop->SetType( i?ON_HatchLoop::ltInner:ON_HatchLoop::ltOuter); AddLoop( pLoop); } SetPatternIndex( pattern_index); SetPatternRotation( pattern_rotation); SetPatternScale( pattern_scale); return true; }
void YARPImageUtils::SetBlue (const YARPImageOf<YarpPixelMono>& in, YARPImageOf<YarpPixelBGR>& out) { SetPlane (in, out, 0); }
void YARPImageUtils::SetGreen (const YARPImageOf<YarpPixelMono>& in, YARPImageOf<YarpPixelBGR>& out) { SetPlane (in, out, 1); }
void YARPImageUtils::SetRed (const YARPImageOf<YarpPixelMono>& in, YARPImageOf<YarpPixelRGB>& out) { SetPlane (in, out, 0); }