本文整理汇总了C++中SpriteCache类的典型用法代码示例。如果您正苦于以下问题:C++ SpriteCache类的具体用法?C++ SpriteCache怎么用?C++ SpriteCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SpriteCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DynamicSprite_CreateFromDrawingSurface
ScriptDynamicSprite* DynamicSprite_CreateFromDrawingSurface(ScriptDrawingSurface *sds, int x, int y, int width, int height)
{
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
// use DrawingSurface resolution
sds->MultiplyCoordinates(&x, &y);
sds->MultiplyCoordinates(&width, &height);
Bitmap *ds = sds->StartDrawing();
if ((x < 0) || (y < 0) || (x + width > ds->GetWidth()) || (y + height > ds->GetHeight()))
quit("!DynamicSprite.CreateFromDrawingSurface: requested area is outside the surface");
int colDepth = ds->GetColorDepth();
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, colDepth);
if (newPic == NULL)
return NULL;
newPic->Blit(ds, x, y, 0, 0, width, height);
sds->FinishedDrawingReadOnly();
add_dynamic_sprite(gotSlot, newPic, (sds->hasAlphaChannel != 0));
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
return new_spr;
}
示例2: precache_view
void precache_view(int view)
{
if (view < 0)
return;
for (int i = 0; i < views[view].numLoops; i++) {
for (int j = 0; j < views[view].loops[i].numFrames; j++)
spriteset.precache (views[view].loops[i].frames[j].pic);
}
}
示例3: new_room
// new_room: changes the current room number, and loads the new room from disk
void new_room(int newnum,CharacterInfo*forchar) {
EndSkippingUntilCharStops();
Out::FPrint("Room change requested to room %d", newnum);
update_polled_stuff_if_runtime();
// we are currently running Leaves Screen scripts
in_leaves_screen = newnum;
// player leaves screen event
run_room_event(8);
// Run the global OnRoomLeave event
run_on_event (GE_LEAVE_ROOM, RuntimeScriptValue().SetInt32(displayed_room));
platform->RunPluginHooks(AGSE_LEAVEROOM, displayed_room);
// update the new room number if it has been altered by OnLeave scripts
newnum = in_leaves_screen;
in_leaves_screen = -1;
if ((playerchar->following >= 0) &&
(game.chars[playerchar->following].room != newnum)) {
// the player character is following another character,
// who is not in the new room. therefore, abort the follow
playerchar->following = -1;
}
update_polled_stuff_if_runtime();
// change rooms
unload_old_room();
if (psp_clear_cache_on_room_change)
{
// Delete all cached sprites
spriteset.removeAll();
// Delete all gui background images
for (int i = 0; i < game.numgui; i++)
{
delete guibg[i];
guibg[i] = NULL;
if (guibgbmp[i])
gfxDriver->DestroyDDB(guibgbmp[i]);
guibgbmp[i] = NULL;
}
guis_need_update = 1;
}
update_polled_stuff_if_runtime();
load_new_room(newnum,forchar);
}
示例4: DynamicSprite_CreateFromScreenShot
ScriptDynamicSprite* DynamicSprite_CreateFromScreenShot(int width, int height) {
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
if (width <= 0)
width = virtual_screen->GetWidth();
else
width = multiply_up_coordinate(width);
if (height <= 0)
height = virtual_screen->GetHeight();
else
height = multiply_up_coordinate(height);
Bitmap *newPic;
if (!gfxDriver->UsesMemoryBackBuffer())
{
// D3D driver
Bitmap *scrndump = BitmapHelper::CreateBitmap(scrnwid, scrnhit, final_col_dep);
gfxDriver->GetCopyOfScreenIntoBitmap(scrndump);
update_polled_stuff_if_runtime();
if ((scrnwid != width) || (scrnhit != height))
{
newPic = BitmapHelper::CreateBitmap(width, height, final_col_dep);
newPic->StretchBlt(scrndump,
RectWH(0, 0, scrndump->GetWidth(), scrndump->GetHeight()),
RectWH(0, 0, width, height));
delete scrndump;
}
else
{
newPic = scrndump;
}
}
else
{
// resize the sprite to the requested size
newPic = BitmapHelper::CreateBitmap(width, height, virtual_screen->GetColorDepth());
newPic->StretchBlt(virtual_screen,
RectWH(0, 0, virtual_screen->GetWidth(), virtual_screen->GetHeight()),
RectWH(0, 0, width, height));
}
// replace the bitmap in the sprite set
add_dynamic_sprite(gotSlot, gfxDriver->ConvertBitmapToSupportedColourDepth(newPic));
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
return new_spr;
}
示例5: DynamicSprite_CreateFromExistingSprite
ScriptDynamicSprite* DynamicSprite_CreateFromExistingSprite(int slot, int preserveAlphaChannel) {
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
if (!spriteset.doesSpriteExist(slot))
quitprintf("DynamicSprite.CreateFromExistingSprite: sprite %d does not exist", slot);
// create a new sprite as a copy of the existing one
Bitmap *newPic = BitmapHelper::CreateBitmapCopy(spriteset[slot]);
if (newPic == NULL)
return NULL;
bool hasAlpha = (preserveAlphaChannel) && ((game.spriteflags[slot] & SPF_ALPHACHANNEL) != 0);
// replace the bitmap in the sprite set
add_dynamic_sprite(gotSlot, newPic, hasAlpha);
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
return new_spr;
}
示例6: DynamicSprite_CreateFromExistingSprite
ScriptDynamicSprite* DynamicSprite_CreateFromExistingSprite(int slot, int preserveAlphaChannel) {
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
if (!spriteset.doesSpriteExist(slot))
quitprintf("DynamicSprite.CreateFromExistingSprite: sprite %d does not exist", slot);
// create a new sprite as a copy of the existing one
Bitmap *newPic = BitmapHelper::CreateBitmap(spritewidth[slot], spriteheight[slot], spriteset[slot]->GetColorDepth());
if (newPic == NULL)
return NULL;
newPic->Blit(spriteset[slot], 0, 0, 0, 0, spritewidth[slot], spriteheight[slot]);
bool hasAlpha = (preserveAlphaChannel) && ((game.spriteflags[slot] & SPF_ALPHACHANNEL) != 0);
// replace the bitmap in the sprite set
add_dynamic_sprite(gotSlot, newPic, hasAlpha);
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
return new_spr;
}
示例7: add_dynamic_sprite
void add_dynamic_sprite(int gotSlot, Bitmap *redin, bool hasAlpha) {
spriteset.set(gotSlot, redin);
game.spriteflags[gotSlot] = SPF_DYNAMICALLOC;
if (redin->GetColorDepth() > 8)
game.spriteflags[gotSlot] |= SPF_HICOLOR;
if (redin->GetColorDepth() > 16)
game.spriteflags[gotSlot] |= SPF_TRUECOLOR;
if (hasAlpha)
game.spriteflags[gotSlot] |= SPF_ALPHACHANNEL;
spritewidth[gotSlot] = redin->GetWidth();
spriteheight[gotSlot] = redin->GetHeight();
}
示例8: engine_init_sprites
int engine_init_sprites()
{
Out::FPrint("Initialize sprites");
if (spriteset.initFile ("acsprset.spr"))
{
platform->FinishedUsingGraphicsMode();
allegro_exit();
proper_exit=1;
platform->DisplayAlert("Could not load sprite set file ACSPRSET.SPR\n"
"This means that the file is missing or there is not enough free\n"
"system memory to load the file.\n");
return EXIT_NORMAL;
}
return RETURN_CONTINUE;
}
示例9: free_dynamic_sprite
void free_dynamic_sprite (int gotSlot) {
int tt;
if ((gotSlot < 0) || (gotSlot >= spriteset.elements))
quit("!FreeDynamicSprite: invalid slot number");
if ((game.spriteflags[gotSlot] & SPF_DYNAMICALLOC) == 0)
quitprintf("!DeleteSprite: Attempted to free static sprite %d that was not loaded by the script", gotSlot);
delete spriteset[gotSlot];
spriteset.set(gotSlot, NULL);
game.spriteflags[gotSlot] = 0;
spritewidth[gotSlot] = 0;
spriteheight[gotSlot] = 0;
// ensure it isn't still on any GUI buttons
for (tt = 0; tt < numguibuts; tt++) {
if (guibuts[tt].IsDeleted())
continue;
if (guibuts[tt].Image == gotSlot)
guibuts[tt].Image = 0;
if (guibuts[tt].CurrentImage == gotSlot)
guibuts[tt].CurrentImage = 0;
if (guibuts[tt].MouseOverImage == gotSlot)
guibuts[tt].MouseOverImage = 0;
if (guibuts[tt].PushedImage == gotSlot)
guibuts[tt].PushedImage = 0;
}
// force refresh of any object caches using the sprite
if (croom != NULL)
{
for (tt = 0; tt < croom->numobj; tt++)
{
if (objs[tt].num == gotSlot)
{
objs[tt].num = 0;
objcache[tt].sppic = -1;
}
else if (objcache[tt].sppic == gotSlot)
objcache[tt].sppic = -1;
}
}
}
示例10: CreateDynamicSprite
int IAGSEngine::CreateDynamicSprite(int32 coldepth, int32 width, int32 height) {
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return 0;
if ((width < 1) || (height < 1))
quit("!IAGSEngine::CreateDynamicSprite: invalid width/height requested by plugin");
// resize the sprite to the requested size
Bitmap *newPic = BitmapHelper::CreateTransparentBitmap(width, height, coldepth);
if (newPic == NULL)
return 0;
// add it into the sprite set
add_dynamic_sprite(gotSlot, newPic);
return gotSlot;
}
示例11: DynamicSprite_Create
ScriptDynamicSprite* DynamicSprite_Create(int width, int height, int alphaChannel)
{
multiply_up_coordinates(&width, &height);
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
Bitmap *newPic = BitmapHelper::CreateTransparentBitmap(width, height, System_GetColorDepth());
if (newPic == NULL)
return NULL;
if ((alphaChannel) && (System_GetColorDepth() < 32))
alphaChannel = false;
add_dynamic_sprite(gotSlot, ReplaceBitmapWithSupportedFormat(newPic), alphaChannel != 0);
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
return new_spr;
}
示例12: DynamicSprite_Create
ScriptDynamicSprite* DynamicSprite_Create(int width, int height, int alphaChannel)
{
multiply_up_coordinates(&width, &height);
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, final_col_dep);
if (newPic == NULL)
return NULL;
newPic->Clear(newPic->GetMaskColor());
if ((alphaChannel) && (final_col_dep < 32))
alphaChannel = false;
add_dynamic_sprite(gotSlot, gfxDriver->ConvertBitmapToSupportedColourDepth(newPic), alphaChannel != 0);
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
return new_spr;
}
示例13: DynamicSprite_CreateFromBackground
ScriptDynamicSprite* DynamicSprite_CreateFromBackground(int frame, int x1, int y1, int width, int height) {
if (frame == SCR_NO_VALUE) {
frame = play.bg_frame;
}
else if ((frame < 0) || (frame >= thisroom.num_bscenes))
quit("!DynamicSprite.CreateFromBackground: invalid frame specified");
if (x1 == SCR_NO_VALUE) {
x1 = 0;
y1 = 0;
width = play.room_width;
height = play.room_height;
}
else if ((x1 < 0) || (y1 < 0) || (width < 1) || (height < 1) ||
(x1 + width > play.room_width) || (y1 + height > play.room_height))
quit("!DynamicSprite.CreateFromBackground: invalid co-ordinates specified");
multiply_up_coordinates(&x1, &y1);
multiply_up_coordinates(&width, &height);
int gotSlot = spriteset.findFreeSlot();
if (gotSlot <= 0)
return NULL;
// create a new sprite as a copy of the existing one
Bitmap *newPic = BitmapHelper::CreateBitmap(width, height, thisroom.ebscene[frame]->GetColorDepth());
if (newPic == NULL)
return NULL;
newPic->Blit(thisroom.ebscene[frame], x1, y1, 0, 0, width, height);
// replace the bitmap in the sprite set
add_dynamic_sprite(gotSlot, newPic);
ScriptDynamicSprite *new_spr = new ScriptDynamicSprite(gotSlot);
GlobalReturnValue.SetDynamicObject(new_spr, new_spr);
return new_spr;
}
示例14: init_game_settings
void init_game_settings() {
int ee;
for (ee=0;ee<256;ee++) {
if (game.paluses[ee]!=PAL_BACKGROUND)
palette[ee]=game.defpal[ee];
}
if (game.options[OPT_NOSCALEFNT]) wtext_multiply=1;
for (ee = 0; ee < game.numcursors; ee++)
{
// The cursor graphics are assigned to mousecurs[] and so cannot
// be removed from memory
if (game.mcurs[ee].pic >= 0)
spriteset.precache (game.mcurs[ee].pic);
// just in case they typed an invalid view number in the editor
if (game.mcurs[ee].view >= game.numviews)
game.mcurs[ee].view = -1;
if (game.mcurs[ee].view >= 0)
precache_view (game.mcurs[ee].view);
}
// may as well preload the character gfx
if (playerchar->view >= 0)
precache_view (playerchar->view);
for (ee = 0; ee < MAX_INIT_SPR; ee++)
objcache[ee].image = NULL;
/* dummygui.guiId = -1;
dummyguicontrol.guin = -1;
dummyguicontrol.objn = -1;*/
our_eip=-6;
// game.chars[0].talkview=4;
//init_language_text(game.langcodes[0]);
for (ee = 0; ee < MAX_INIT_SPR; ee++) {
scrObj[ee].id = ee;
// 64 bit: Using the id instead
// scrObj[ee].obj = NULL;
}
for (ee=0;ee<game.numcharacters;ee++) {
memset(&game.chars[ee].inv[0],0,MAX_INV*sizeof(short));
game.chars[ee].activeinv=-1;
game.chars[ee].following=-1;
game.chars[ee].followinfo=97 | (10 << 8);
game.chars[ee].idletime=20; // can be overridden later with SetIdle or summink
game.chars[ee].idleleft=game.chars[ee].idletime;
game.chars[ee].transparency = 0;
game.chars[ee].baseline = -1;
game.chars[ee].walkwaitcounter = 0;
game.chars[ee].z = 0;
charextra[ee].xwas = INVALID_X;
charextra[ee].zoom = 100;
if (game.chars[ee].view >= 0) {
// set initial loop to 0
game.chars[ee].loop = 0;
// or to 1 if they don't have up/down frames
if (views[game.chars[ee].view].loops[0].numFrames < 1)
game.chars[ee].loop = 1;
}
charextra[ee].process_idle_this_time = 0;
charextra[ee].invorder_count = 0;
charextra[ee].slow_move_counter = 0;
charextra[ee].animwait = 0;
}
// multiply up gui positions
guibg = (Bitmap **)malloc(sizeof(Bitmap *) * game.numgui);
guibgbmp = (IDriverDependantBitmap**)malloc(sizeof(IDriverDependantBitmap*) * game.numgui);
for (ee=0;ee<game.numgui;ee++) {
guibg[ee] = NULL;
guibgbmp[ee] = NULL;
}
our_eip=-5;
for (ee=0;ee<game.numinvitems;ee++) {
if (game.invinfo[ee].flags & IFLG_STARTWITH) playerchar->inv[ee]=1;
else playerchar->inv[ee]=0;
}
play.score=0;
play.sierra_inv_color=7;
play.talkanim_speed = 5;
play.inv_item_wid = 40;
play.inv_item_hit = 22;
play.messagetime=-1;
play.disabled_user_interface=0;
play.gscript_timer=-1;
play.debug_mode=game.options[OPT_DEBUGMODE];
play.inv_top=0;
play.inv_numdisp=0;
play.obsolete_inv_numorder=0;
play.text_speed=15;
play.text_min_display_time_ms = 1000;
play.ignore_user_input_after_text_timeout_ms = 500;
play.ignore_user_input_until_time = 0;
play.lipsync_speed = 15;
//.........这里部分代码省略.........
示例15: apply_config
void apply_config(const ConfigTree &cfg)
{
{
#ifndef WINDOWS_VERSION
usetup.digicard=INIreadint(cfg, "sound","digiid", DIGI_AUTODETECT);
usetup.midicard=INIreadint(cfg, "sound","midiid", MIDI_AUTODETECT);
#else
int idx = INIreadint(cfg, "sound","digiwinindx", -1);
if (idx == 0)
idx = DIGI_DIRECTAMX(0);
else if (idx == 1)
idx = DIGI_WAVOUTID(0);
else if (idx == 2)
idx = DIGI_NONE;
else if (idx == 3)
idx = DIGI_DIRECTX(0);
else
idx = DIGI_AUTODETECT;
usetup.digicard = idx;
idx = INIreadint(cfg, "sound","midiwinindx", -1);
if (idx == 1)
idx = MIDI_NONE;
else if (idx == 2)
idx = MIDI_WIN32MAPPER;
else
idx = MIDI_AUTODETECT;
usetup.midicard = idx;
#endif
psp_audio_multithreaded = INIreadint(cfg, "sound", "threaded", psp_audio_multithreaded);
// Filter can also be set by command line
// TODO: apply command line arguments to ConfigTree instead to override options read from config file
const bool should_read_filter = usetup.Screen.Filter.ID.IsEmpty();
// Legacy graphics settings has to be translated into new options;
// they must be read first, to let newer options override them, if ones are present
read_legacy_graphics_config(cfg, should_read_filter);
// Graphics mode
usetup.Screen.DriverID = INIreadstring(cfg, "graphics", "driver");
usetup.Screen.DisplayMode.Windowed = INIreadint(cfg, "graphics", "windowed") > 0;
const char *screen_sz_def_options[kNumScreenDef] = { "explicit", "scaling", "max" };
usetup.Screen.DisplayMode.ScreenSize.SizeDef = usetup.Screen.DisplayMode.Windowed ? kScreenDef_ByGameScaling : kScreenDef_MaxDisplay;
String screen_sz_def_str = INIreadstring(cfg, "graphics", "screen_def");
for (int i = 0; i < kNumScreenDef; ++i)
{
if (screen_sz_def_str.CompareNoCase(screen_sz_def_options[i]) == 0)
{
usetup.Screen.DisplayMode.ScreenSize.SizeDef = (ScreenSizeDefinition)i;
break;
}
}
usetup.Screen.DisplayMode.ScreenSize.Size = Size(INIreadint(cfg, "graphics", "screen_width"),
INIreadint(cfg, "graphics", "screen_height"));
usetup.Screen.DisplayMode.ScreenSize.MatchDeviceRatio = INIreadint(cfg, "graphics", "match_device_ratio", 1) != 0;
// TODO: move to config overrides (replace values during config load)
#if defined(MAC_VERSION)
usetup.Screen.Filter.ID = "none";
#else
if (should_read_filter)
usetup.Screen.Filter.ID = INIreadstring(cfg, "graphics", "filter", "StdScale");
parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_fs", "proportional"), usetup.Screen.FsGameFrame);
if (should_read_filter)
parse_scaling_option(INIreadstring(cfg, "graphics", "game_scale_win", "max_round"), usetup.Screen.WinGameFrame);
#endif
usetup.Screen.DisplayMode.RefreshRate = INIreadint(cfg, "graphics", "refresh");
usetup.Screen.DisplayMode.VSync = INIreadint(cfg, "graphics", "vsync") > 0;
usetup.RenderAtScreenRes = INIreadint(cfg, "graphics", "render_at_screenres") > 0;
usetup.Supersampling = INIreadint(cfg, "graphics", "supersampling", 1);
usetup.enable_antialiasing = INIreadint(cfg, "misc", "antialias") > 0;
// This option is backwards (usevox is 0 if no_speech_pack)
usetup.no_speech_pack = INIreadint(cfg, "sound", "usespeech", 1) == 0;
usetup.user_data_dir = INIreadstring(cfg, "misc", "user_data_dir");
usetup.shared_data_dir = INIreadstring(cfg, "misc", "shared_data_dir");
usetup.translation = INIreadstring(cfg, "language", "translation");
// TODO: move to config overrides (replace values during config load)
// PSP: Don't let the setup determine the cache size as it is always too big.
#if !defined(PSP_VERSION)
// the config file specifies cache size in KB, here we convert it to bytes
spriteset.SetMaxCacheSize(INIreadint (cfg, "misc", "cachemax", DEFAULTCACHESIZE / 1024) * 1024);
#endif
usetup.mouse_auto_lock = INIreadint(cfg, "mouse", "auto_lock") > 0;
usetup.mouse_speed = INIreadfloat(cfg, "mouse", "speed", 1.f);
if (usetup.mouse_speed <= 0.f)
usetup.mouse_speed = 1.f;
const char *mouse_ctrl_options[kNumMouseCtrlOptions] = { "never", "fullscreen", "always" };
String mouse_str = INIreadstring(cfg, "mouse", "control", "fullscreen");
for (int i = 0; i < kNumMouseCtrlOptions; ++i)
{
if (mouse_str.CompareNoCase(mouse_ctrl_options[i]) == 0)
//.........这里部分代码省略.........