예제 #1
0
파일: entity.c 프로젝트: Darksim150/276
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
0
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
0
// 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
0
	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
0
파일: game.c 프로젝트: jc429/276game
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
0
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
0
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);

}
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
0
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
0
파일: window.c 프로젝트: FratStar/AlienRush
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
0
파일: window.c 프로젝트: FratStar/AlienRush
Button *NewButton(char *spritename,char *text,int x, int y, int w, int h,Uint8 hotkey,int layer,int c1,int c2)
{
  int i;
  for(i = 0;i < MAXBUTTONS;i++)
  {
    if(!ButtonList[i].inuse)
    {
      ButtonList[i].inuse = 1;
      if(spritename != NULL)
      {
        ButtonList[i].sprite = LoadSprite(spritename,w,h);
        if(ButtonList[i].sprite != NULL)ButtonList[i].usesprite = 1;
        else ButtonList[i].usesprite = 0;
      }
      else ButtonList[i].usesprite = 0;
      if(text != NULL)
      {
        strcpy(ButtonList[i].text,text);
      }
      ButtonList[i].rect.x = x;
      ButtonList[i].rect.y = y;
      ButtonList[i].rect.w = w;
      ButtonList[i].rect.h = h;
      ButtonList[i].Hotkey = hotkey;
      ButtonList[i].layer = layer;
      ButtonList[i].fg = c1;
      ButtonList[i].bg = c2;
      return &ButtonList[i];
    }
  }
  return NULL;
}
예제 #12
0
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;
}
예제 #13
0
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;
}
예제 #14
0
파일: mouse.c 프로젝트: cjm43/GameTest
/*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;
}
예제 #15
0
파일: health.cpp 프로젝트: mittorn/csdm
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);
}
예제 #16
0
/**
**	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);
    }
}
예제 #17
0
SFBoss::SFBoss(shared_ptr<SFWindow> window,shared_ptr<SFPattern> pattern_get, shared_ptr<SFPlayer> player_get, int h) :
                    SFAsset(window), w_height(h), pattern(pattern_get), player(player_get),
                    phase(0), sub_phase(0), p_dir(0){
  health = 100;
  move_speed = 1.0f;
  sprite = IMG_LoadTexture(sf_window->getRenderer(), "assets/alien_boss.png");
  LoadSprite();

}
예제 #18
0
// Redraw
// step through the local data,  placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission )
{
	m_fOldTime = m_flTime;	// save time of previous redraw
	m_flTime = flTime;
	m_flTimeDelta = (double)m_flTime - m_fOldTime;
	
	// Clock was reset, reset delta
	if ( m_flTimeDelta < 0 )
		m_flTimeDelta = 0;

	m_iIntermission = intermission;

	// if no redrawing is necessary
	// return 0;
	
	HUDLIST *pList = m_pHudList;

	while (pList)
	{
		if ( !intermission )
		{
			if ((pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL))
				pList->p->Draw(flTime);
		}
		else
		{  // it's an intermission,  so only draw hud elements that are set to draw during intermissions
			if ( pList->p->m_iFlags & HUD_INTERMISSION )
				pList->p->Draw( flTime );
		}

		pList = pList->pNext;
	}

	// are we in demo mode? do we need to draw the logo in the top corner?
	if (m_iLogo)
	{
		int x, y, i;

		if (m_hsprLogo == 0)
			m_hsprLogo = LoadSprite("sprites/%d_logo.spr");

		SPR_Set(m_hsprLogo, 250, 250, 250 );
		
		x = SPR_Width(m_hsprLogo, 0);
		x = ScreenWidth - x;
		y = SPR_Height(m_hsprLogo, 0)/2;

		// Draw the logo at 20 fps
		int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
		i = grgLogoFrame[iFrame] - 1;

		SPR_DrawAdditive(i, x, y, NULL);
	}

	return 1;
}
예제 #19
0
GameObject::GameObject(char *filename, D3DCOLOR transCol) 
{
	isSprite = true;
	m_pShape = NULL;
	m_color = btVector3(1,1,1);
	m_mesh = false;
	m_sprite = NULL;
	LoadSprite(filename, transCol);

}
예제 #20
0
void Init(HWND hwnd)
{	
	// Hide the Cursor
	ShowCursor(FALSE);

	// Load and init the sprite
	LoadSprite(&gSprite, "caust", 32);
	SetSpritePosition(&gSprite, 200, 200);

	// Load and init the second sprite
	LoadSprite(&gSprite2, "caust", 32);
	SetSpritePosition(&gSprite2, 300, 100);

	// Create our double buffering
	CreateDoubleBuffering(&gBuffer, hwnd);					
															
	// Set the backbuffer to white first (This clears the backbuffer)
	ClearScreen(gBuffer.hdcBack, gBuffer.scrnRect, WHITE_BRUSH);			
}
예제 #21
0
파일: health.cpp 프로젝트: ET-NiK/amxxgroup
int CHudHealth::Draw(float flTime)
{
	// No Health in Discwar
	if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
		return 1;

	if ( !m_hSprite )
		m_hSprite = LoadSprite(PAIN_NAME);

	return DrawDamage(flTime);
}
SpriteInstance* GraphicsController::CreateSprite(std::string filename) {
	//TODO: MC to write a file-loader
	int hashedFilename = GetStringHashcode(filename);

	if(m_LoadedSpriteTemplates.find(hashedFilename) == m_LoadedSpriteTemplates.end()) {
		LoadSprite(filename);
	}

	m_SpritesInPlay.push_back(m_LoadedSpriteTemplates[hashedFilename].CreateSprite());
	return &m_SpritesInPlay.back();
}
예제 #23
0
파일: Buttons.hpp 프로젝트: 0mN1/MultiVerse
    Button(Vector2f _pos, string _fileName1, string _fileName2)
    {
        Position = _pos;
        index = 0;

        for(int i = 0; i < 2; i++)
        {
            sprite[i] = LoadSprite(image[i], (!i)?_fileName1:_fileName2);
            sprite[i].SetPosition(Position);
        }
    }
예제 #24
0
void Animator::ImportSheet(const char* a_pSpriteSheet)
{
	LoadSprite(a_pSpriteSheet);
	LoadAnimations(atlas.sAnimations.c_str());

	m_dFrames = (1.0 / 15.0);
	currentAnimation = "";
	currentSprite = "idle";
	currentFrame = 0;
	currentPlayType = SINGLE;
	SetSprite();
}
예제 #25
0
void InitCharacter(character *sprite)
{
	sprite->x = 496;
	sprite->y = 588;
	sprite->csprite = LoadSprite("images/cyan.png",36, 48);
	sprite->flag = 0;
	sprite->frame = 0;
	sprite->collision.h = 48;
	sprite->collision.w = 36;
	sprite->collision.x = 496;
	sprite->collision.y = 588;
}
예제 #26
0
파일: button.c 프로젝트: cpg6/2D-SDL-JRPG
void InitAttackButton(attackButton *sprite)																	/** Init the attack button */
{

	sprite->cx = 300;
	sprite->cy = 300;
	sprite->sprite_c = LoadSprite("images/attackbutton.png",128,96);
	sprite->frame = 0;
	sprite->collision.h = 96;
	sprite->collision.w = 128;
	sprite->collision.x = 768;					//offsets
	sprite->collision.y = 638;					
}
예제 #27
0
int main(int argc, char *argv[]) {
    SDL_Window *window;
    SDL_Renderer *renderer;
    SDL_Event event;
    Uint8 done = 0;

    if (SDL_CreateWindowAndRenderer(0, 0, 0, &window, &renderer) < 0)
        exit(1);

	Sprite sprite = LoadSprite ("image.png", renderer);
    if (sprite.texture == NULL)
		exit(2);

	SDL_InitSubSystem (SDL_INIT_AUDIO);
	if (Mix_OpenAudio (22050, AUDIO_S16SYS, 2, 2048))
		exit(3);
	Mix_Music *music;
	music = Mix_LoadMUS ("demo.ogg");
	if (!Mix_PlayingMusic ())
		Mix_PlayMusic (music, -1);

	TTF_Font *font;
	SDL_Color colour = { 255, 255, 255 };
	SDL_Surface *text;

	TTF_Init ();

	font = TTF_OpenFont ("arial.ttf", 24);
	if (!font)
		exit (4);

	text = TTF_RenderText_Solid (font, "Hello, World!", colour);

    while (!done) {
        while (SDL_PollEvent (&event)) {
            if (event.type == SDL_QUIT || event.type == SDL_KEYDOWN || event.type == SDL_FINGERDOWN) {
				done = 1;
            }
        }

		SDL_SetRenderDrawColor (renderer, 0xA0, 0xA0, 0xA0, 0xFF);
		SDL_RenderClear (renderer);

		draw (window, renderer, sprite);
		SDL_RenderCopy (renderer, text, NULL, NULL);
	
		SDL_RenderPresent (renderer);
		
		SDL_Delay (10);
    }

    exit (0);
}
예제 #28
0
bool SpriteGroupList::ReleaseSprite(uint32 index, LOADTYPE loadType)
{
	Assert(index >= 0);
	Assert(index < k_MAX_SPRITES);

	if (index < 0 || index >= k_MAX_SPRITES)
		return true; // Old behaviour

	if (m_spriteList[index] == NULL)
		return true; // Old behaviour

	LOADTYPE	groupLoadType = m_spriteList[index]->GetLoadType();

	if (loadType == LOADTYPE_FULL) 
    {
		if (groupLoadType == LOADTYPE_FULL) 
		{
			m_spriteList[index]->ReleaseFullLoad();
		}
	} 
    else 
    {
		m_spriteList[index]->Release();
	}

    if (0 == m_spriteList[index]->GetFullLoadRefCount())
    {
	    sint32	basicRefs   = m_spriteList[index]->GetRefCount(); 

        if (basicRefs == 0)
        {
		    delete m_spriteList[index];
            m_spriteList[index] = NULL;
		    return true;
	    }
        else if (basicRefs > 0)
	    {
		    if (groupLoadType == LOADTYPE_FULL) 
		    {
			    m_spriteList[index]->DeallocateStorage();
			    m_spriteList[index]->DeallocateFullLoadAnims();

			    (void) LoadSprite(index, 
                                  m_spriteList[index]->GetType(), 
                                  LOADTYPE_BASIC, 
                                  (GAME_ACTION) 0
                                 );
		    }
        }
	}

	return false;
}
예제 #29
0
int main(int argc, char *argv[])
{
	RosalilaGraphics* graphics = new RosalilaGraphics();
    SDL_Window *window = graphics->window;
    SDL_Renderer *renderer = graphics->renderer;

	Image*image=graphics->getTexture("image.png");

	Sprite sprite = LoadSprite("image2.bmp", renderer,graphics);
    if(sprite.texture == NULL)
        exit(2);

    /* Main render loop */
    Uint8 done = 0;
    SDL_Event event;
    while(!done)
	{
        /* Check for events */
        while(SDL_PollEvent(&event))
		{
            if(event.type == SDL_QUIT || event.type == SDL_KEYDOWN || event.type == SDL_FINGERDOWN)
			{
                done = 1;
            }
        }
		
		
		/* Draw a gray background */
//		SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
//		SDL_RenderClear(renderer);
		
		//draw(window, renderer, sprite);
		graphics->draw2DImage	(
             image,
             image->getWidth(),image->getHeight(),
             0,0,
             1,
             0,
             false,
             1,
             1,
             Color(1,1,1,1),
             false);
	graphics->updateScreen();
		/* Update the screen! */
//		SDL_RenderPresent(renderer);
		
//		SDL_Delay(10);
    }

    exit(0);
}
예제 #30
0
void Sprite::LoadAnimatedSprite( Animated_Sprite_Template* templat, 
            const char* base_name,int width, int height, D3DCOLOR key, int n_frames, int frame_duration)
{
    templat->frames = (Sprite*)malloc( sizeof( Sprite ) * n_frames );

    for( int index = 0; index < n_frames; index++ )
    {
        char file_name_buffer[ 64 ];
        sprintf( file_name_buffer,"%s%.2d.bmp",base_name,index );
        LoadSprite( &templat->frames[ index ],file_name_buffer,width,height,key );
    }
    templat->n_frames = n_frames;
    templat->frame_duration = frame_duration;
}