本文整理汇总了C#中SFML类的典型用法代码示例。如果您正苦于以下问题:C# SFML类的具体用法?C# SFML怎么用?C# SFML使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SFML类属于命名空间,在下文中一共展示了SFML类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: update
public void update(SFML.Graphics.RenderWindow window, orientation orientation, List<IObject> list, Stopwatch touch, Stopwatch shot)
{
if (orientation == orientation.vertical)
_sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X, _sprite.Position.Y + 0.05f + (_fireRate / 10));
else if (orientation == orientation.horizontal)
_sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.05f + (_fireRate / 10), _sprite.Position.Y);
for (var x = 0; x < list.Count; x++)
{
if (list[x].isEnemy())
{
if ((orientation == orientation.vertical
&& (list[x]._sprite.Position.X <= _sprite.Position.X
&& _sprite.Position.X <= list[x]._sprite.Position.X + 32)
&& list[x]._sprite.Position.Y > _sprite.Position.Y)
|| (orientation == orientation.horizontal
&& (list[x]._sprite.Position.Y <= _sprite.Position.Y
&& _sprite.Position.Y <= list[x]._sprite.Position.Y + 32)
&& list[x]._sprite.Position.X < _sprite.Position.X))
{
list.RemoveAt(x);
list.Remove(this);
}
}
}
}
示例2: update
public override bool update(SFML.Time.Time dt)
{
mWorld.update(dt);
CommandQueue commands = mWorld.getCommandQueue();
mPlayer.handleRealtimeInput(commands);
return true;
}
示例3: DistanceBetweenTwoPoints
public static float DistanceBetweenTwoPoints(SFML.Window.Vector2f a, SFML.Window.Vector2f b)
{
float distanceX = b.X - a.X;
float distanceY = b.Y - a.Y;
return (float)Math.Sqrt((Double)(distanceX * distanceX) + (Double)(distanceY * distanceY));
}
示例4: RenderWindow_KeyPressed
private void RenderWindow_KeyPressed(object sender, SFML.Window.KeyEventArgs e)
{
Vector2D copy = position;
if (e.Code == Keyboard.Key.Left)
{
position.X -= speed.X;
animation.SetCurrentAnimation("player_left");
}
if (e.Code == Keyboard.Key.Right)
{
position.X += speed.X;
animation.SetCurrentAnimation("player_right");
}
if (e.Code == Keyboard.Key.Up)
{
position.Y -= speed.Y;
animation.SetCurrentAnimation("player_up");
}
if (e.Code == Keyboard.Key.Down)
{
position.Y += speed.Y;
animation.SetCurrentAnimation("player_down");
}
animation.Update(deltaTime);
}
示例5: Keyboard
public override void Keyboard(SFML.Window.KeyCode key)
{
switch (char.ToLower((char)key))
{
case 'c':
if (m_fixture2 == null)
{
CircleShape shape = new CircleShape();
shape.Radius = 3.0f;
shape.Position = new Vec2(0.5f, -4.0f);
m_fixture2 = m_body.CreateFixture(shape, 10.0f);
m_body.IsAwake = true;
}
break;
case 'd':
if (m_fixture2 != null)
{
m_body.DestroyFixture(m_fixture2.Value);
m_fixture2 = null;
m_body.IsAwake = true;
}
break;
}
}
示例6: PrepareDrawToTargetSprite
/// <summary>
/// Prepares the <see cref="SFML.Graphics.Sprite"/> used to draw to a <see cref="RenderTarget"/>.
/// </summary>
/// <param name="sprite">The <see cref="SFML.Graphics.Sprite"/> to prepare.</param>
/// <param name="target">The <see cref="RenderTarget"/> begin drawn to.</param>
protected override void PrepareDrawToTargetSprite(SFML.Graphics.Sprite sprite, RenderTarget target)
{
base.PrepareDrawToTargetSprite(sprite, target);
// Always use alpha blending
sprite.BlendMode = BlendMode.Multiply;
}
示例7: Draw
public void Draw(SFML.Graphics.RenderWindow window)
{
/*foreach (SFML.Graphics.Sprite spr in path)
{
window.Draw(spr);
}*/
}
示例8: Draw
public void Draw(SFML.Graphics.RenderWindow window)
{
if (CurrentMap == null)
return;
CurrentMap.Draw(window);
}
示例9: OnKeyDown
protected override void OnKeyDown(SFML.Window.KeyEventArgs key)
{
if(key.Code == SFML.Window.Keyboard.Key.T)
{
}
}
示例10: CollideFrom
/// <summary>
/// Handles when another Entity collides into us. Not synonymous CollideInto since the
/// <paramref name="collider"/> Entity is the one who collided into us. For example, if the
/// two entities in question were a moving Character and a stationary wall, this Entity would be
/// the Wall and <paramref name="collider"/> would be the Character.
/// </summary>
/// <param name="collider">Entity that collided into us.</param>
/// <param name="displacement">Displacement between the two Entities.</param>
public override void CollideFrom(Entity collider, SFML.Graphics.Vector2 displacement)
{
// When a character touches this, teleport the character to the destination
Character character = collider as Character;
if (character == null)
return;
// Only let users use teleports
if (character is NPC)
return;
// Teleport to a new map
if (DestinationMap > 0)
{
if (character.Map.ID != DestinationMap)
{
var newMap = character.World.GetMap(DestinationMap);
if (newMap == null)
{
const string errmsg = "Failed to teleport Character `{0}` - Invalid DestMap `{1}`.";
Debug.Fail(string.Format(errmsg, character, this));
if (log.IsErrorEnabled)
log.ErrorFormat(errmsg, character, this);
return;
}
character.Teleport(newMap, Destination);
}
}
// Teleport the CharacterEntity to our predefined location
character.Position = Destination;
}
示例11: Window_KeyPressed
void Window_KeyPressed(object sender, SFML.Window.KeyEventArgs e)
{
if (e.Code == SFML.Window.Keyboard.Key.Num1)
{
_game.PushState((IGameState)(_prototypeStates[1].GetConstructor(new Type[] { }).Invoke(new Object[] { })));
}
}
示例12: RenderTarget
public RenderTarget(SFML.Graphics.RenderTarget renderTarget)
{
this.renderTarget = renderTarget;
m_VertexCache = new Vertex[CacheSize];
m_RenderState = RenderStates.Default;
}
示例13: OnKeyPressed
/// <summary>
/// Function called when a key is pressed
/// </summary>
static void OnKeyPressed(object sender, SFML.Window.KeyEventArgs e)
{
Window window = (Window)sender;
if (e.Code == Keyboard.Key.Escape)
window.Close();
game.OnKeyPressed(sender, e);
}
示例14: AABB
public AABB(SFML.Window.Vector2f position, float width, float height, SFML.Graphics.Color color)
{
Position = position;
Extents = new SFML.Window.Vector2f(width, height);
this.color = color;
Configure();
}
示例15: Shot
public Shot(SFML.Window.Vector2f pos, string sprite, int dmg, int fireRate)
{
_damage = dmg;
_fireRate = fireRate;
_sprite = new SFML.Graphics.Sprite();
_sprite.Texture = new SFML.Graphics.Texture(sprite, new SFML.Graphics.IntRect(10, 10, 5, 5));
_sprite.Position = new SFML.Window.Vector2f(pos.X + 15, pos.Y + 32);
}