internal SfmlText ConstructText(string text) { var txt = new SfmlText(text, SfmlFont, CharacterSize) { LetterSpacing = CharacterSpacing, LineSpacing = LineSpacing, OutlineThickness = OutlineThickness }; if (Bold) { txt.Style |= SfmlText.Styles.Bold; } if (Italic) { txt.Style |= SfmlText.Styles.Italic; } if (Underline) { txt.Style |= SfmlText.Styles.Underlined; } if (Strikethrough) { txt.Style |= SfmlText.Styles.StrikeThrough; } return(txt); }
void Initialize(string str, object font, int size) { if (size < 0) { throw new ArgumentException("Font size must be greater than 0."); } if (font is string) { this.font = (string)font == "" ? Fonts.DefaultFont : Fonts.Load((string)font); } else if (font is Font) { this.font = ((Font)font).font; } else if (font is SFML.Graphics.Font) { this.font = (SFML.Graphics.Font)font; } else { this.font = Fonts.Load((Stream)font); } text = new SFML.Graphics.Text(str, this.font, (uint)size); String = str; Name = "Text"; SFMLDrawable = text; }
public override void Init(GameEngine game) { base.Init(game); List<SFML.Graphics.Text> protptypeLabel = new List<SFML.Graphics.Text>(); List<Type> prototypeStates = new List<Type>(); Assembly assembly = Assembly.GetExecutingAssembly(); Type[] classes = assembly.GetTypes(); int i =0; foreach (Type t in classes) { if (t.BaseType.Name.Equals("IPrototype")) { SFML.Graphics.Text text = new SFML.Graphics.Text(i+". :"+t.Name); text.Position = new SFML.Window.Vector2f(50, 20 + i * 30); protptypeLabel.Add(text); prototypeStates.Add(t); i++; } } _prototypeLabels = protptypeLabel.ToArray<SFML.Graphics.Text>(); _prototypeStates = prototypeStates.ToArray<Type>(); }
public MenuScene(Scene.Context context, SceneManager scnManager) : base (context, scnManager) { _logger.Log(LogLevel.Info, " >>> Configurando escena del Menú"); _optionIndex = (int)MenuOptions.PLAY; ; _options = new List<SFML.Graphics.Text>(); // opcion jugar SFML.Graphics.Text textPlay = new SFML.Graphics.Text(); textPlay.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"]; textPlay.DisplayedString = "Jugar"; textPlay.Position = new SFML.System.Vector2f((context.Window.Size.X - textPlay.GetLocalBounds().Width) * 0.5f, (context.Window.Size.Y - 2 * textPlay.CharacterSize - OPTION_SEPARATION) *0.5f); _options.Add(textPlay); // opción salir SFML.Graphics.Text textExit = new SFML.Graphics.Text(); textExit.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"]; textExit.DisplayedString = "Salir"; textExit.Position = new SFML.System.Vector2f((context.Window.Size.X - textExit.GetLocalBounds().Width) * 0.5f, textPlay.Position.Y + textPlay.CharacterSize + OPTION_SEPARATION); _options.Add(textExit); UpdateOptionText(); }
public ConsoleInfoEntity(Activity activity) : base(activity) { this.fontSize = 18; this.text = new SFML.Graphics.Text("", new SFML.Graphics.Font("ARCADECLASSIC.TTF"), this.fontSize); this.text.FillColor = SFML.Graphics.Color.Green; var drawable = new RawSFMLDrawable(this, this.text); drawable.Layer = int.MaxValue; this.AddComponent(drawable); }
public Button(string textToShow, SFML.Graphics.Font font, SFML.System.Vector2f position, SFML.Graphics.Texture normal, SFML.Graphics.Texture highlighted, SFML.Graphics.Texture pressed) { text = textToShow; sfmlText = new SFML.Graphics.Text(text, font); sfmlText.OutlineThickness = 1; sfmlText.OutlineColor = SFML.Graphics.Color.Black; normalTXT = normal; highlightedTXT = highlighted; pressedTXT = pressed; sprite = new SFML.Graphics.Sprite(normalTXT); sprite.Position = position; }
public Font(Font font) { font.EnsureNotDisposed(); SfmlFont = new SfmlFont(font.SfmlFont); MeasureContainer = new SfmlText(); CharacterSize = font.CharacterSize; CharacterSpacing = font.CharacterSpacing; LineSpacing = font.LineSpacing; OutlineThickness = font.OutlineThickness; Bold = font.Bold; Italic = font.Italic; Underline = font.Underline; Strikethrough = font.Strikethrough; }
public void Run() { var window = new SFML.Graphics.RenderWindow(new SFML.Window.VideoMode(800, 1000), "SFML!"); window.KeyPressed += Window_KeyPressed; player = new Airship.Player(40, 3); player.Position = new SFML.System.Vector2f(window.Size.X / 2 - 40, 900); enemyList = new List <Airship.EnemyAirships>(); bulletList = new List <Airship.Blueprint.Bullets>(); enemyBullets = new List <Airship.Blueprint.Bullets>(); for (int i = 0; i < 50; i++) { bulletList.Add(new Airship.Blueprint.Bullets(player.Position)); } enemyList.Add(new Airship.EnemyAirships()); enemyList.Add(new Airship.EnemyAirships()); enemyList.Add(new Airship.EnemyAirships()); enemyList.Add(new Airship.EnemyAirships()); for (int i = 0; i < 200; i++) { enemyBullets.Add(new Airship.Blueprint.Bullets(enemyList[0].Position)); } var scoreText = new SFML.Graphics.Text($"Score: {player.Score}", new SFML.Graphics.Font("myfont.ttf")); while (window.IsOpen) { window.Clear(); count += 1; render(window, scoreText); window.DispatchEvents(); window.Display(); } }
public PauseScene(Scene.Context context, SceneManager scnManager) : base (context, scnManager) { _logger.Log(LogLevel.Info, " >>> Configurando escena de Pausa"); _mainText = new SFML.Graphics.Text(); _infoText = new SFML.Graphics.Text(); // opcion jugar _mainText.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"]; _mainText.DisplayedString = "Pausa"; _mainText.Position = new SFML.System.Vector2f((context.Window.Size.X - _mainText.GetLocalBounds().Width) * 0.5f, (context.Window.Size.Y - 2 * _mainText.CharacterSize - OPTION_SEPARATION) * 0.5f); // opción salir _infoText.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"]; _infoText.DisplayedString = "Pulsa espacio para ir al menú principal"; _infoText.CharacterSize = (UInt32)(_infoText.CharacterSize * 0.8f); _infoText.Position = new SFML.System.Vector2f((context.Window.Size.X - _infoText.GetLocalBounds().Width) * 0.5f, _mainText.Position.Y + _mainText.CharacterSize + OPTION_SEPARATION); }
public SFMLTextComp() : base() { SFMLText = new SFML.Graphics.Text("", new SFML.Graphics.Font(FontLocation)); }
public Font(string filePath) { SfmlFont = new SfmlFont(filePath); MeasureContainer = new SfmlText(); }
void Initialize(string str, object font, int size) { if (size < 0) throw new ArgumentException("Font size must be greater than 0."); if (font is string) { this.font = (string)font == "" ? Fonts.DefaultFont : Fonts.Load((string)font); } else if (font is Font) { this.font = ((Font) font).font; } else if (font is SFML.Graphics.Font) { this.font = (SFML.Graphics.Font)font; } else { this.font = Fonts.Load((Stream) font); } text = new SFML.Graphics.Text(str, this.font, (uint)size); String = str; Name = "Text"; SFMLDrawable = text; }
public void render(SFML.Graphics.RenderWindow window, SFML.Graphics.Text scoreText) { player.update(player.Position, window); scoreText.DisplayedString = $"Score: {player.Score}"; window.Draw(player.airshipShape); foreach (Airship.EnemyAirships element in enemyList) { window.Draw(element.airshipShape); for (int j = 0; j < enemyBullets.Count; j += 4) { for (int indexOfBullet = 0; indexOfBullet < enemyList.Count; indexOfBullet++) { if (enemyBullets[indexOfBullet + j].thrown != true) { enemyBullets[indexOfBullet + j].Position = enemyList[indexOfBullet].Position; } enemyBullets[indexOfBullet + j].thrown = true; } } if (count == 150) { element.update(window); if (enemyList.IndexOf(element) == enemyList.Count - 1) { count = 0; } } } ThreadPool.QueueUserWorkItem(o => changeBullet(enemyBullets)); for (int v = 0; v < enemyBullets.Count; v++) { if (enemyBullets[v].thrown == true) { window.Draw(enemyBullets[v].bulletShape); } } for (int i = 0; i < bulletList.Count; i++) { if (bulletList[i].thrown == true) { window.Draw(bulletList[i].bulletShape); bulletList[i].update(player.Position); } for (int j = enemyList.Count - 1; j > -1; j--) { if (bulletList[i].Position.X + 50 >= enemyList[j].Position.X && bulletList[i].Position.X - 50 <= enemyList[j].Position.X && bulletList[i].Position.Y == enemyList[j].Position.Y) { enemyList[j].Health = 20; if (enemyList[j].Health <= 0) { player.Score++; enemyList.RemoveAt(j); } bulletList[i].update(player.Position); bulletList[i].thrown = false; } if (enemyList.Count == 0) { enemyList.Add(new Airship.EnemyAirships()); enemyList.Add(new Airship.EnemyAirships()); enemyList.Add(new Airship.EnemyAirships()); enemyList.Add(new Airship.EnemyAirships()); } } } for (int j = 0; j < enemyBullets.Count; j++) { if (player.Health <= 0) { window.Close(); break; } if (enemyBullets[j].Position.Y < 800) { continue; } if (enemyBullets[j].Position.X + 30 >= player.Position.X && enemyBullets[j].Position.X - 30 <= player.Position.X && enemyBullets[j].Position.Y + 10 >= player.Position.Y && enemyBullets[j].Position.Y - 10 <= player.Position.Y) { player.Health = 10; enemyBullets[j].update(enemyList[0].Position); enemyBullets[j].thrown = false; Console.WriteLine(player.Health); } } window.Draw(scoreText); }