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); } } } }
public override bool update(SFML.Time.Time dt) { mWorld.update(dt); CommandQueue commands = mWorld.getCommandQueue(); mPlayer.handleRealtimeInput(commands); return true; }
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)); }
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); }
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; } }
/// <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; }
public void Draw(SFML.Graphics.RenderWindow window) { /*foreach (SFML.Graphics.Sprite spr in path) { window.Draw(spr); }*/ }
public void Draw(SFML.Graphics.RenderWindow window) { if (CurrentMap == null) return; CurrentMap.Draw(window); }
protected override void OnKeyDown(SFML.Window.KeyEventArgs key) { if(key.Code == SFML.Window.Keyboard.Key.T) { } }
/// <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; }
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[] { }))); } }
public RenderTarget(SFML.Graphics.RenderTarget renderTarget) { this.renderTarget = renderTarget; m_VertexCache = new Vertex[CacheSize]; m_RenderState = RenderStates.Default; }
/// <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); }
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(); }
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); }
public override void Keyboard(SFML.Window.KeyCode key) { switch (char.ToLower((char)key)) { case 'c': CreateCircle(); break; } }
public LineSegment(SFML.Window.Vector2f start, SFML.Window.Vector2f end) { Start = start; End = end; linePoints = new VertexArray(PrimitiveType.Lines); linePoints.Append(new Vertex(start)); linePoints.Append(new Vertex(end)); }
public static Color SFML2WPF(SFML.Graphics.Color sf) { return new Color { R = sf.R, G = sf.G, B = sf.B, A = sf.A }; }
public AABB(SFML.Window.Vector2f position, Vector2f extents, Color color) { Position = position; Extents = extents; this.color = color; Configure(); }
public AABB(SFML.Window.Vector2f position, Vector2f extents) { Position = position; Extents = extents; this.color = Color.White; Configure(); }
public AABB(SFML.Window.Vector2f position, float width, float height) { Position = position; Extents = new SFML.Window.Vector2f(width, height); this.color = Color.White; Configure(); }
public override void Draw(SFML.Graphics.RenderTarget window) { SFML.Graphics.View currentView = window.GetView(); window.SetView(GetRoot().MapView); base.Draw(window); window.SetView(currentView); }
public LineSegment(SFML.Window.Vector2f start, SFML.Window.Vector2f end, SFML.Graphics.Color color) { Start = start; End = end; linePoints = new VertexArray(PrimitiveType.Lines); linePoints.Append(new Vertex(start) { Color = color }); linePoints.Append(new Vertex(end) { Color = color }); }
//////////////////////// // Métodos //////////////////////// /// <summary> /// Actualiza el estado de la escena en función del tiempo transcurrido desde la última actualización /// </summary> /// <param name="time">tiempo transcurrido desde la última actualización </param> /// <returns>true: siempre deja que las escenas inferiores se actualicen</returns> public override bool Update(SFML.System.Time time) { // calculamos las nuevas posiciones de los elementos del mundo _world.Update(time); _player.HandleRealtimeInput(_world.CommandQueue); return true; }
public void AddLine(string text, SFML.Graphics.Color color) { Label newLabel = new Label(text, "MICROGBE", this._resourceManager); newLabel.Position = new Vector2i(5, last_y); newLabel.TextColor = color; newLabel.Update(0); last_y = newLabel.ClientArea.Bottom(); components.Add(newLabel); }
public AABBProjection(AABB start, SFML.Window.Vector2f movement, SFML.Graphics.Color color) { Start = start; End = new AABB(new SFML.Window.Vector2f(start.Position.X + movement.X, start.Position.Y + movement.Y), start.Extents.X, start.Extents.Y, Start.Color); this.color = color; InitializeSegments(); }
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.03f); else if (orientation == orientation.horizontal) _sprite.Position = new SFML.Window.Vector2f(_sprite.Position.X + 0.03f, _sprite.Position.Y); if (_sprite.Position.X > window.Size.X || _sprite.Position.Y > window.Size.Y) list.Remove(this); }
public override bool update(SFML.Time.Time dt) { mTextEffectTime += dt; if (mTextEffectTime >= Time.FromSeconds(0.5)) { mShowText = !mShowText; mTextEffectTime = Time.Zero; } return true; }
/// <summary> /// creates a game /// </summary> /// <param name="width">width of the window</param> /// <param name="height">height of the window</param> /// <param name="title">titel of the window</param> /// <param name="screen">style of the window</param> public AbstractGame(uint width, uint height, string title, SFML.Window.Styles screen) { win = new RenderWindow(new SFML.Window.VideoMode(width, height), title, screen); win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); }; gameTime = new GameTime(); MouseControler.Initialize(win); KeyboardControler.Initialize(); }
void Drawable.Draw(SFML.Graphics.RenderTarget target, SFML.Graphics.RenderStates states) { // apply the transform states.Transform *= Transform.Identity; // apply the tileset texture states.Texture = m_tileset; // draw the vertex array target.Draw(m_vertices, states); }