本文整理汇总了C++中LoadSprite函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadSprite函数的具体用法?C++ LoadSprite怎么用?C++ LoadSprite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadSprite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitEnt
Entity* InitEnt(Entity *ent, int x, int y, int vy, int onGround, char* imagel, char* imager, int xframe, int yframe)
{
ent = (Entity*)malloc(sizeof(Entity));
ent->x = x;
ent->y = y;
ent->vy = vy;
ent->flag = IDLE;
ent->sprl = LoadSprite(imagel, xframe, yframe);
ent->sprr = LoadSprite(imager, xframe, yframe);
ent->spr = ent->sprl;
ent->frame = 0;
ent->used = 1;
ent->onGround = 0;
ent->hurtbox.x = 0;
ent->hurtbox.y = 0;
ent->hurtbox.w = 320;
ent->hurtbox.h = 240;
ent->hitboxR.x = 160;
ent->hitboxR.y = 110;
ent->hitboxR.w = 160;
ent->hitboxR.h = 20;
ent->hitboxL.x = 160;
ent->hitboxL.y = 110;
ent->hitboxL.w = -160;
ent->hitboxL.h = 20;
return ent;
}
示例2: SetUpTitle
void SetUpTitle()
{
Button* NewGame, *Continue,*Editor;
Editor_Panel* panel;
Label* Title;
NewGame = CreateEditorButton(NULL,CreateSDL_Rect(100,200,255,100));
Continue = CreateEditorButton(NULL,CreateSDL_Rect(300,330,255,100));
Editor = CreateEditorButton(NULL,CreateSDL_Rect(500,460,255,100));
NewGame->sprite = LoadSprite("images/New_Game_Button.png",255,100);
NewGame->sprite->fpl = 1;
strcpy(NewGame->name,"NewGame");
Continue->sprite = LoadSprite("images/Continue_Button.png",255,100);
Continue->sprite->fpl = 1;
strcpy(Continue->name,"Continue");
Editor->sprite = LoadSprite("images/Level_Editor_Button.png",255,100);
Editor->sprite->fpl = 1;
strcpy(Editor->name,"Editor");
Title = CreateEditorLabel(NULL,CreateSDL_Rect(0,0,350,200));
Title->sprite = LoadSprite("images/Aard_Title.png",350,200);
panel = CreateEditorPanel(CreateSDL_Rect(0,0,800,600));
panel->buttons = g_list_append(panel->buttons,NewGame);
panel->buttons = g_list_append(panel->buttons,Continue);
panel->buttons = g_list_append(panel->buttons,Editor);
panel->labels = g_list_append(panel->labels,Title);
MainEditorPanels = g_list_append(MainEditorPanels,panel);
atexit(FreeEveryThing);
}
示例3: CreateCombination
// This is where the bones of the project are forged
// (loading sprites, for example)
BOOL CGameLogic::Init(CGame *game)
{
// Initialize the combination
m_combo = CreateCombination();
m_nodes = m_combo;
for (unsigned i = 0; i < m_nodes.size(); i++)
m_nodes[i] = i;
// Load sprites
auto path = game->GetExecutablePath();
// Slider (Mid-section)
CSprite *spr = nullptr;
if (!LoadSprite(path, L"sliderMid.png", game->GetRenderer(), &spr))
return FALSE;
m_sprites.push_back(spr);
spr->SetPosition(0, 0);
// Slider (nodes)
for (auto i = 0; i < 5; i++) {
spr = nullptr;
if (!LoadSprite(path, L"sliderNode.png", game->GetRenderer(), &spr))
return FALSE;
m_sprites.push_back(spr);
}
return TRUE;
}
示例4: LoadReferencedSprites
void __cdecl LoadReferencedSprites() { // replaces sub_42B510
memset( Loaded_Sprite_Array, 0, sizeof( Loaded_Sprite_Array ) );
int loaded_count = 0;
for( int i = SPRITE_FIRST; i <= SPRITE_LAST; i++ ){
if( SpriteTable[i].ref_count != 0 ){ // load sprite if used
char szPath[MAX_PATH];
wsprintfA( szPath, GetGameDirStr( "[SPRITES]\\%s.spr" ), SpriteTable[i].name );
LoadSprite( *((DWORD*)0x005014BC), 0, szPath, &(Loaded_Sprite_Array[loaded_count]) );
if( Loaded_Sprite_Array[loaded_count] != 0 ){
SpriteTable[i].loaded_index_sprites = (WORD) loaded_count;
loaded_count++;
}
}
}
for( int i = X_SPRITE_FIRST; i <= X_SPRITE_LAST; i++ ){
if( SpriteTable[i].ref_count != 0 ){ // load sprite if used
char szPath[MAX_PATH];
wsprintfA( szPath, GetGameDirStr( "[SPRITES]\\%s.spr" ), SpriteTable[i].name );
LoadSprite( *((DWORD*)0x005014BC), 0, szPath, &(Loaded_Sprite_Array[loaded_count]) );
if( Loaded_Sprite_Array[loaded_count] != 0 ){
SpriteTable[i].loaded_index_sprites = (WORD) loaded_count;
loaded_count++;
}
}
}
*((DWORD*)0x00502AF4) = 0x0042B430; // as per original, set function pointer
}
示例5: InitVersus
void InitVersus(){
LoadStage(stage);
InitFighters(c1,c2);
DrawBG(HUDBG);
pausescr = LoadSprite("images/pause.png",1024,768,1);
p1vic = LoadSprite("images/p1win.png",1024,768,1);
p2vic = LoadSprite("images/p2win.png",1024,768,1);
drawvic = LoadSprite("images/draw.png",1024,768,1);
}
示例6: Assert
SpriteGroup *SpriteGroupList::GetSprite(uint32 index, GROUPTYPE type, LOADTYPE loadType,GAME_ACTION action)
{
Assert(index >= 0);
Assert(index < k_MAX_SPRITES);
if((index < 0) || (index >= k_MAX_SPRITES))
index = 0;
SpriteGroup *group = m_spriteList[index];
if (group)
{
if (loadType != group->GetLoadType())
{
if ((loadType==LOADTYPE_FULL)||(loadType==LOADTYPE_INDEXED))
{
group->DeallocateStorage();
(void) LoadSprite(index, type, loadType, action);
}
}
}
else
{
if (SPRITELISTERR_OK == LoadSprite(index, type, loadType, action))
{
// No action: m_spriteList[index] initialised with data from file
}
else
{
return NULL;
}
}
switch (loadType)
{
case LOADTYPE_BASIC:
m_spriteList[index]->AddRef();
break;
case LOADTYPE_FULL:
case LOADTYPE_INDEXED:
m_spriteList[index]->AddFullLoadRef();
break;
default:
Assert(loadType == LOADTYPE_BASIC || loadType == LOADTYPE_FULL);
break;
}
return m_spriteList[index];
}
示例7: RenderCb
static void RenderCb (Entity *ent, Camera &cam)
{
//TurtleShell *self = TURTLE_SHELL (ent);
Vec3f r,p;
r = ent->bounds.half;
p = ent->pos;
if (DRAW_BOUNDS)
{
// draw bounds
glDisable (GL_TEXTURE_2D);
glColor3f (1.0,0.0,0.0);
glBegin (GL_QUADS);
glVertex3f (p.x-r.x, p.y+r.y, p.z);
glVertex3f (p.x-r.x, p.y-r.y, p.z);
glVertex3f (p.x+r.x, p.y-r.y, p.z);
glVertex3f (p.x+r.x, p.y+r.y, p.z);
glEnd ();
glEnable (GL_TEXTURE_2D);
}
if (!g_sprites[TURTLE_SHELL].shader)
LoadSprite (g_sprites+TURTLE_SHELL, "sprites/turtle_shell.sprt");
Sprite *s;
SpriteFrame *f;
int anim;
s = g_sprites + TURTLE_SHELL;
anim = GetAnimFrame(TURTLE_SHELL (ent), s->fps)%s->numFrames;
f = s->frames + anim;
glColor3f (1.,1.,1.);
glBindTexture (GL_TEXTURE_2D, s->shader->tex);
float x1,x2,y1,y2;
float w = s->w/2,
h = s->h/2;
x1 = p.x-w + s->pos.x;
y1 = p.y+h + s->pos.y;
x2 = p.x+w + s->pos.x;
y2 = p.y-h + s->pos.y;
//glColor3f (1.0,0.0,0.0);
//glDisable (GL_CULL_FACE);
//glBlendFunc (GL_DST_COLOR, GL_ONE);
glBegin (GL_QUADS);
glTexCoord2f (f->p1.x,f->p2.y);glVertex3f (x1, y1, p.z);
glTexCoord2f (f->p1.x,f->p1.y);glVertex3f (x1, y2, p.z);
glTexCoord2f (f->p2.x,f->p1.y);glVertex3f (x2, y2, p.z);
glTexCoord2f (f->p2.x,f->p2.y);glVertex3f (x2, y1, p.z);
glEnd ();
//glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
示例8: LoadSprite
bool CannonType::InitCannonType (PipeType* pipe, int startingx, int width, int height, int spacing, const char * CannonSprite)
{
mPipe = pipe;
mCannonBG = LoadSprite(CannonSprite);
//set the cannons up
//start with the first cannon
mCannons[0].x = startingx;
mCannons[0].y = pipe->y + 30;
mCannons[0].mCannonWidth = width;
mCannons[0].mCannonHeight = height;
mCannons[0].Loaded = 0;
//setup the second cannon;
mCannons[1].x = startingx + width + spacing;
mCannons[1].y = pipe->y + 30;
mCannons[1].mCannonWidth = width;
mCannons[1].mCannonHeight = height;
mCannons[1].Loaded = 0;
//setup the last cannon;
mCannons[2].x = startingx + width + spacing + width + spacing;
mCannons[2].y = pipe->y + 30;
mCannons[2].mCannonWidth = width;
mCannons[2].mCannonHeight = height;
mCannons[2].Loaded = 0;
return true;
}
示例9: sprintf
void SpriteGroupList::RefreshBasicLoads(GROUPTYPE groupType)
{
ProgressWindow::BeginProgress(
g_theProgressWindow,
"InitProgressWindow",
k_MAX_SPRITES-1 );
MBCHAR s[_MAX_PATH];
sprintf( s, g_theStringDB->GetNameStr("LOADING") );
for (sint32 i=0; i<k_MAX_SPRITES; i++)
{
UnitSpriteGroup *usg = (UnitSpriteGroup *)m_spriteList[i];
if (usg && (usg->GetLoadType() == LOADTYPE_BASIC))
{
usg->DeallocateStorage();
(void) LoadSprite(i, groupType, LOADTYPE_BASIC,(GAME_ACTION)0);
}
g_theProgressWindow->StartCountingTo( i, s );
}
ProgressWindow::EndProgress( g_theProgressWindow );
}
示例10: LoadSprite
Window *NewWindow(char *title,char *spritename,int x,int y, int w,int h,int c1,int c2,int layer,void (*drawwindow)(Window *self),void (*updatewindow)(Window *self))
{
int i;
for(i = 0;i < MAXWINDOWS;i++)
{
if(!WindowList[i].inuse)
{
WindowList[i].inuse = 1;
if(spritename != NULL)
{
WindowList[i].sprite = LoadSprite(spritename,w,h);
if(WindowList[i].sprite != NULL)WindowList[i].usesprite = 1;
else WindowList[i].usesprite = 0;
}
else WindowList[i].usesprite = 0;
if(title != NULL)
{
strcpy(WindowList[i].title,title);
}
WindowList[i].rect.x = x;
WindowList[i].rect.y = y;
WindowList[i].rect.w = w;
WindowList[i].rect.h = h;
WindowList[i].layer = layer;
WindowList[i].fg = c1;
WindowList[i].bg = c2;
WindowList[i].drawwindow = drawwindow;
WindowList[i].updatewindow = updatewindow;
return &WindowList[i];
}
}
return NULL;
}
示例11: entity_new
Entity *newCube(Vec3D position,const char *name)
{
Entity * ent;
char buffer[255];
int i;
ent = entity_new();
if (!ent)
{
return NULL;
}
/*for (i = 0; i < 24;i++)
{
//sprintf(buffer,"models/robot/walk_bot_%06i.obj",i + 1);
ent->objAnimation[i] = obj_load(buffer);
}*/
ent->objModel = obj_load("models/cube.obj");//ent->objAnimation[0];
if( !ent->objModel )
slog( "test" );
ent->texture = LoadSprite("models/cube_text.png",1024,1024); //LoadSprite("models/robot/robot.png",1024,1024);
vec3d_cpy(ent->body.position,position);
vec3d_set(ent->scale,1,1,1);
vec3d_set(ent->rotation,0,0,0);
vec4d_set(ent->color,1,1,1,1);
cube_set(ent->body.bounds,-1,-1,-1,2,2,2);
ent->rotation.x = 90;
sprintf(ent->name,"%s",name);
ent->think = think;
ent->state = 0;
mgl_callback_set(&ent->body.touch,touch_callback,ent);
return ent;
}
示例12: LoadSprite
bool Sample::Init()
{
LoadSprite(L"Sprite.txt");
int iIndex = I_Sprite.Load(L"TypeA",
L"../../data/bitmap1.bmp",
L"../../data/bitmap2.bmp");
KSprite* pSprite = I_Sprite.Find(iIndex);
pSprite->SetRectArray(m_SpriteList[0], 2.0f);
iIndex = I_Sprite.Load(L"TypeB",
L"../../data/bitmap1.bmp",
L"../../data/bitmap2.bmp");
pSprite = I_Sprite.Find(iIndex);
pSprite->SetRectArray(m_SpriteList[1], 1.0f);
iIndex = I_Sprite.Load(L"TypeC",
L"../../data/bitmap1.bmp",
L"../../data/bitmap2.bmp");
pSprite = I_Sprite.Find(iIndex);
pSprite->SetRectArray(m_SpriteList[2], 1.0f);
m_Hero.Load(L"../../data/bitmap.bmp",
L"../../data/bitmap.bmp");
m_Effect.SetSprite(0);
return true;
}
示例13: InitMouse
/*this only handles the drawing and animation of. Assuming you have a 16 by 16 tiled sprite sheet. This will not handle input*/
void InitMouse()
{
Msprite = LoadSprite("images/mouse.png",16, 16);
if(Msprite == NULL)fprintf(stdout,"mouse didn't load\n");
Mouse.state = 0;
Mouse.shown = 0;
Mouse.frame = 0;
}
示例14: LoadSprite
int CHudHealth::Draw(float flTime)
{
int r, g, b;
int a = 0, x, y;
int HealthWidth;
if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
return 1;
if ( !m_HSPRITE )
m_HSPRITE = LoadSprite(PAIN_NAME);
// Has health changed? Flash the health #
if (m_fFade)
{
m_fFade -= (gHUD.m_flTimeDelta * 20);
if (m_fFade <= 0)
{
a = MIN_ALPHA;
m_fFade = 0;
}
// Fade the health number back to dim
a = MIN_ALPHA + (m_fFade/FADE_TIME) * 128;
}
else
a = MIN_ALPHA;
// If health is getting low, make it bright red
if (m_iHealth <= 15)
a = 255;
GetPainColor( r, g, b );
ScaleColors(r, g, b, a );
// Only draw health if we have the suit.
if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
{
HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = CrossWidth /2;
SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
x = CrossWidth + HealthWidth / 2;
//x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
gHUD.DrawHudNumber2( x, y, false, 3, m_iHealth, r, g, b);
}
DrawDamage(flTime);
return DrawPain(flTime);
}
示例15: LoadFonts
/**
** Load all fonts.
*/
global void LoadFonts(void)
{
unsigned i;
for( i=0; i<sizeof(Fonts)/sizeof(*Fonts); ++i ) {
ShowLoadProgress("\tFonts %s\n",Fonts[i].File);
LoadSprite(Fonts[i].File,&Fonts[i].Sprite);
}
}