コード例 #1
0
ファイル: u_magic.c プロジェクト: marrub--/Lithium
stkcall
void Upgr_Magic_Render(struct player *p, struct upgrade *upgr)
{
   if(!p->hudenabled || p->indialogue) return;

   i32 hprc = ceilk(min(UData.manaperc,       0.5) * 2 * 62);
   i32 fprc = ceilk(max(UData.manaperc - 0.5, 0.0) * 2 * 62);

   PrintSprite(sp_HUD_C_MagicIcon, 1,1, 213,2);
   PrintSprite(sp_HUD_C_BarSmall2, 1,1, 220,2);

   SetClip(2, 219-5, hprc, 5);
   PrintSprite(sp_HUD_C_ManaBar1, 2,1, 219,2);
   ClearClip();

   SetClip(2, 219-5, fprc, 5);
   PrintSprite(sp_HUD_C_ManaBar2, 2,1, 219,2);
   ClearClip();
}
コード例 #2
0
ファイル: u_magic.c プロジェクト: marrub--/Lithium
script
static void UpdateMagicUI(struct player *p, struct upgrade *upgr)
{
   struct gui_state *g = &UData.gst;

   G_Begin(g, 320, 240);
   G_UpdateState(g, p);

   PrintSprite(sp_UI_MagicSelectBack, 0,1, 0,1);

   bool any = false;

   for(i32 i = 0; i < countof(minf); i++)
   {
      struct magic_info const *m = &minf[i];

      if(m->st != -1 && !world.cbiupgr[m->st]) continue;

      char gfx[32] = ":UI:"; strcat(gfx, m->name);
      char hot[32] = ":UI:"; strcat(hot, m->name); strcat(hot, "Sel");

      struct gui_pre_btn pre = {
         .gfx      = gfx,
         .hot      = hot,
         .cdef     = "d",
         .cact     = "r",
         .chot     = "k",
         .cdis     = "m",
         .font     = s"cbifont",
         .snd      = s"player/cbi/buttonpress",
         .external = true,
         .w        = 64,
         .h        = 64
      };

      char name[128]; LanguageCV(name, LANG "INFO_SHORT_%s", m->name);

      if(G_Button_FId(g, i + 1, name, m->x, m->y, .preset = &pre))
         GiveMagic(m);
   }

   G_End(g, gui_curs_outline);
}

script
static void GivePlayerZ(i32 tid, struct player *p)
{
   while(ACS_ThingCount(T_NONE, tid)) {
      SetMembI(tid, sm_UserZ, p->z);
      ACS_Delay(1);
   }
}

static void SetMagicUI(struct player *p, bool on)
{
   if(p->dead) return;

   struct upgrade *upgr = p->getUpgr(UPGR_Magic);

   if(on)
   {
      UData.ui = true;
      p->semifrozen++;

      UData.gst.gfxprefix = ":UI:";
      UData.gst.cx = 320/2;
      UData.gst.cy = 240/2;

      G_Init(&UData.gst);
   }
   else if(!on && UData.ui)
   {
      if(UData.gst.hot) GiveMagic(&minf[UData.gst.hot - 1]);

      UData.ui = false;
      p->semifrozen--;

      memset(&UData.gst, 0, sizeof UData.gst);
   }
}

// Extern Functions ----------------------------------------------------------|

script
void Upgr_Magic_Update(struct player *p, struct upgrade *upgr)
{
   StrEntON
   k32 manaperc = p->mana / (k32)p->manamax;

   if(UData.manaperc < 1 && manaperc == 1)
      ACS_LocalAmbientSound(ss_player_manafull, 127);

   UData.manaperc = manaperc;

   if(p->buttons & BT_USER4 && !(p->old.buttons & BT_USER4))
      SetMagicUI(p, true);
   else if(!(p->buttons & BT_USER4) && p->old.buttons & BT_USER4)
      SetMagicUI(p, false);

   if(UData.ui)
      UpdateMagicUI(p, upgr);

   if(manaperc >= 0.7)
      for(i32 i = 0; i < 5 * manaperc; i++)
   {
      k32 dst = ACS_RandomFixed(32, 56);
      k32 ang = ACS_RandomFixed(0, 1);
      i32 tid = ACS_UniqueTID();
      i32 x   = ACS_Cos(ang) * dst;
      i32 y   = ACS_Sin(ang) * dst;
      i32 z   = ACS_Random(8, 48);
      ACS_Spawn(so_ManaLeak, p->x + x, p->y + y, p->z + z, tid);
      SetMembI(tid, sm_UserX, x);
      SetMembI(tid, sm_UserY, y);
      SetPropK(tid, APROP_Alpha, manaperc / 2);
      PtrSet(tid, AAPTR_DEFAULT, AAPTR_MASTER, p->tid);
      GivePlayerZ(tid, p);
   }
}
コード例 #3
0
ファイル: encoder.cpp プロジェクト: cubemoon/game-editor
bool KrEncoder::EncodeSprite( SDL_Surface* surface, const AllInfo& allInfo, KrConsole* console )
{
//	gedString spriteName, actionName;
//	TiXmlElement* action;
//	TiXmlElement* frame;
//
//	spriteName = "no_sprite_name";
//	if ( sprite->Attribute( "name" ) )
//	{
//		spriteName = *(sprite->Attribute( "name" ));
//	}

	// Create or locate the sprite.
	if ( !vault.GetSpriteResource( allInfo.name ) )
	{
		vault.AddResource( new KrSpriteResource( allInfo.name ) );
	}
	KrSpriteResource* spriteResource = vault.GetSpriteResource( allInfo.name );
	GLASSERT( spriteResource );

	GlDynArray< int > rotation;
	if ( allInfo.rotation.Count() )
		rotation = allInfo.rotation;
	else
		rotation.PushBack( 0 );

	for( int i=0; i<(int) rotation.Count(); ++i )
	{
		// Get or create the action.
		// If using rotation, append to the name.
		gedString action = allInfo.action;
		if ( rotation.Count() > 1 )
		{
			char buf[16];
			sprintf( buf, ".ROT%03d", rotation[i] );
			action += buf;
		}

		if ( !spriteResource->GetAction( action ) )
		{
			spriteResource->AddAction( new KrAction( action ) );
		}
		KrAction* actionRes = spriteResource->GetAction( action );
		GLASSERT( actionRes );

		int index = actionRes->NumFrames();
		actionRes->AddFrame();

		KrPaintInfo info( surface );
		KrRle* rle = actionRes->GetFrame( index );

		if ( allInfo.isoTargetWidth > 0 )
		{
			CreateIsoTile(  &info, console, 
							allInfo.x, allInfo.y, allInfo.width, allInfo.height,
							rle, allInfo.isoTargetWidth,
							rotation[i] );
		}
		else
		{
			rle->Create( &info, allInfo.x, allInfo.y, allInfo.width, allInfo.height, allInfo.hotx, allInfo.hoty, allInfo.deltax, allInfo.deltay );
		}
		PrintSprite( console, allInfo.name, action, index, actionRes->GetFrame( index ) );
	}

	return true;
}