void Overlay::render() { copy_to_inner(); al_lock_mutex(front_mutex); CheckViewscreen(); ReadTileLocations(); if(good_viewscreen){ if(front_data != NULL && front_updated){ //allegro sometimes gives a negative pitch, which SDL doesn't understand, so take care of that case int neg = 1; int dataoffset = 0; if(front_data->pitch < 0){ neg = -1; dataoffset = (al_get_bitmap_height(front) - 1)*front_data->pitch; } //get the SDL surface information so we can do a blit DFHack::DFSDL_Surface * dfsurf = (DFHack::DFSDL_Surface *) SDL_GetVideoSurface(); DFHack::DFSDL_Surface * sssurf = (DFHack::DFSDL_Surface *) SDL_CreateRGBSurfaceFrom( ((char*) front_data->data) + dataoffset, al_get_bitmap_width(front), al_get_bitmap_height(front), 8*front_data->pixel_size, neg*front_data->pitch, 0, 0, 0, 0); DFSDL_Rect src; src.x = 0; src.y = 0; src.w = ssState.ScreenW; src.h = ssState.ScreenH; DFSDL_Rect pos; pos.x = offsetx; pos.y = offsety; pos.w = 0; pos.h = 0; //do the blit SDL_UpperBlit(sssurf, &src, dfsurf, &pos); SDL_FreeSurface(sssurf); } front_updated = false; } else { width = 0; height = 0; } al_unlock_mutex(front_mutex); parent->render(); }
void cKillerBlume::update() { if(dead)return; rect.x = x - cam_x; rect.y = y - cam_y; rect.w = 40; rect.h = 40; if(!collision(&rect,&LEVEL->SCREEN_RECT)) return; if(count>0) { timer+=0.05f; count++; y-= (count>=46) ? ((count>=200) ? -1 : 0) : 1; if(count >= 243) count = -150; SDL_UpperBlit(KBLUM_SURFACE[(int)timer%2],0,screen,&rect); if(collision(&rect,&PLAYER->rect)) if(!PLAYER->stat) PLAYER->die(); else PLAYER->changeStat(0); } else { if(count<0) count++; else { rect.x -=40; rect.y -= 80; rect.w += 80; rect.h += 200; if(!collision(&rect,&PLAYER->rect)) { count = 1; timer = 0; } } rect.x = 900; } }
int Surface::upperBlit(State & state, SDL_Surface * surface){ Stack * stack = state.stack; Surface * interfaceSurface = state.getInterface<Surface>("LuaSDL_Surface"); Rect * interfaceRect = state.getInterface<Rect>("LuaSDL_Rect"); SDL_Rect * r1 = interfaceRect->get(1); SDL_Rect * r2 = interfaceRect->get(3); SDL_Surface * destSurface = interfaceSurface->get(2); if (destSurface){ stack->push<bool>( SDL_UpperBlit( surface, (r1) ? r1 : NULL, destSurface, (r2) ? r2 : NULL) == 0); return 1; } else{ return 0; } }
void cBrett::update() { if(count >= 100&&dir) // dir为0就是向左走 dir = 0; else if(count <= 0&&!dir) // dir为1就是向右走 dir = 1; if(dir) { y+=BRETTSPEED; count++; } else { y-=BRETTSPEED; count--; } tmp_rect.x = x - cam_x; tmp_rect.y = y - cam_y; SDL_UpperBlit(BRETT_SURFACE,0,screen,&tmp_rect); if(PLAYER->JUMPcount==400) if(pointCollision(&tmp_rect,PLAYER->x+20-cam_x,PLAYER->y+PLAYER->H-cam_y)) { PLAYER->y = y - PLAYER->H; PLAYER->touch_now = 1; PLAYER->y_speed = -1; if(dir) PLAYER->y+=10; } }