本文整理汇总了C#中SFML.Graphics.RenderWindow.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.Clear方法的具体用法?C# RenderWindow.Clear怎么用?C# RenderWindow.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// initialize window and view
win = new RenderWindow(new VideoMode(1000, 700), "Hadoken!!!");
view = new View();
resetView();
gui = new GUI(win, view);
// exit Program, when window is being closed
//win.Closed += new EventHandler(closeWindow);
win.Closed += (sender, e) => { (sender as Window).Close(); };
// initialize GameState
handleNewGameState();
// initialize GameTime
GameTime gameTime = new GameTime();
gameTime.Start();
// debug Text
Text debugText = new Text("debug Text", new Font("Fonts/calibri.ttf"));
while (running && win.IsOpen())
{
KeyboardInputManager.update();
currentGameState = state.update();
// gather draw-stuff
win.Clear(new Color(100, 149, 237)); //cornflowerblue ftw!!! 1337
state.draw(win, view);
state.drawGUI(gui);
// first the state must be drawn, before I can change the currentState
if (currentGameState != prevGameState)
{
handleNewGameState();
}
// do the actual drawing
win.SetView(view);
win.Display();
// check for window-events. e.g. window closed
win.DispatchEvents();
// update GameTime
gameTime.Update();
float deltaTime = (float)gameTime.EllapsedTime.TotalSeconds;
// idleLoop for fixed FrameRate
float deltaPlusIdleTime = deltaTime;
while (deltaPlusIdleTime < (1F / fixedFps))
{
gameTime.Update();
deltaPlusIdleTime += (float)gameTime.EllapsedTime.TotalSeconds;
}
Console.WriteLine("real fps: " + (int)(1F / deltaPlusIdleTime) + ", theo fps: " + (int)(1F / deltaTime));
}
}
示例2: draw
public override void draw(GameTime time, RenderWindow window)
{
window.Clear(Color.Black);
ScreenManager.draw(time, window);
Log.draw(window);
window.Display();
}
示例3: Main
private static void Main(string[] args)
{
var contextSettings = new ContextSettings {
DepthBits = 32
};
var window = new RenderWindow(new VideoMode(640, 480), "JukeSaver spike: SFML Basic", Styles.Default, contextSettings);
window.SetActive();
window.Closed += OnClosed;
window.KeyPressed += OnKeyPressed;
int r = 0, g = 0, b = 0;
var shape = new CircleShape() {
Position = new Vector2f(320, 240),
};
while (window.IsOpen()) {
window.DispatchEvents();
window.Clear(new Color((byte)r, (byte)g, (byte)b));
shape.Radius = (float)(80.0 + GetPulse() * 40.0);
shape.Origin = new Vector2f(shape.Radius * 0.5f, shape.Radius * 0.5f);
shape.Position = new Vector2f(320 - shape.Radius * 0.5f, 240 - shape.Radius * 0.5f);
shape.FillColor = new Color(50, (byte)(160 + 80 * GetPulse()), (byte)(40 - (40 * GetPulse())));
window.Draw(shape);
window.Display();
}
}
示例4: Main
public static void Main(String[] args)
{
RenderWindow window = new RenderWindow(new VideoMode(1000, 700), "title");
RenderTexture tex = new RenderTexture(1000, 700);
Sprite texSprite = new Sprite(tex.Texture);
Fractal fractal = new Fractal();
fractal.CreateTreeFractal(500, 700, 3, 100, 0);
Console.WriteLine(fractal.Nodes.Count);
while (window.IsOpen())
{
window.Clear();
tex.Clear(new Color(0, 0, 0, 200
));
foreach (Shape s in fractal.Nodes)
{
window.Draw(s);
}
tex.Display();
window.Draw(texSprite);
window.Display();
Image img = window.Capture();
img.SaveToFile("C:/i.png");
Console.ReadLine();
}
}
示例5: Draw
public override void Draw(RenderWindow context, AController controller)
{
Controller c = (Controller)controller;
context.Clear ();
context.Display ();
}
示例6: Main
static void Main(string[] args)
{
game = new Game();
game.Start();
StartupForm startup = new StartupForm();
DialogResult startupResult;
do
{
startupResult = startup.ShowDialog();
if (startupResult == DialogResult.Abort)
{
Application.Exit();
Environment.Exit(1);
return;
}
}
while(startupResult == DialogResult.Cancel);
app = new RenderWindow(new VideoMode(800, 600), "FTLEdit: Ship Editor", Styles.Default);
app.Closed += new EventHandler(OnClosed);
app.KeyPressed += new EventHandler<SFML.Window.KeyEventArgs>(OnKeyPressed);
app.SetFramerateLimit(30);
while (app.IsOpen())
{
app.DispatchEvents();
app.Clear();
game.Draw(app);
game.Update();
app.Display();
if(game.cursorMode != CursorMode.PlacedBGCursor)
Application.DoEvents();
}
}
示例7: Main
static void Main(string[] args)
{
RenderWindow window = new RenderWindow(new VideoMode(800, 600), "Test01");
window.Closed += (object sender, EventArgs e) => { (sender as Window).Close(); };
Font font = new Font("SnowflakeLetters.ttf");
Text text = new Text("BALD IST WEIHNACHTEN!", font);
Color col1 = new Color(123, 12, 12);
text.Position = new Vector2f(200, 200);
CircleShape shape = new CircleShape(20, 8);
shape.FillColor = Color.White;
shape.Position = new Vector2f(50, 50);
float a, c;
a = c = 50f;
while (window.IsOpen())
{
window.Clear(col1);
window.Draw(text);
if (Keyboard.IsKeyPressed(Keyboard.Key.Left) && a > 0)
a -= 0.1f;
if (Keyboard.IsKeyPressed(Keyboard.Key.Right) && a < window.Size.X - shape.Radius * 2)
a += 0.1f;
if (Keyboard.IsKeyPressed(Keyboard.Key.Down) && c < window.Size.Y - shape.Radius * 2)
c += 0.1f;
if (Keyboard.IsKeyPressed(Keyboard.Key.Up) && c > 0)
c -= 0.1f;
window.Draw(shape);
shape.Position = new Vector2f(a, c);
window.Display();
window.DispatchEvents();
}
}
示例8: Run
public void Run()
{
window = new RenderWindow(new VideoMode(800, 480), "sfml-ui Examples", Styles.Default);
window.Closed += window_OnCloseRequest;
window.Resized += window_Resized;
uimanager = new UISceneManager();
uimanager.Init(window);
scene1 = new Scene(ScrollInputs.None);
scene1.Size = new Vector2f(window.Size.X, window.Size.Y);
scene1.AddComponent(new TextControl(new Font("font.ttf"), 50) { Size = new Vector2f(800, 100), Color = Color.White, Text = "Hello World", TextAlignment = Alignment.MiddleCenter, Anchor = AnchorPoints.Left | AnchorPoints.Right | AnchorPoints.Top, BackgroundColor = Colors.SteelBlue });
scene1.AddComponent(new TextControl(new Font("font.ttf"), 16) { Size = new Vector2f(600, 100), Position = new Vector2f(100, 150), Color = Color.Black, Text = "This is an example of sfml-ui, an ui library for SFML.Net", TextAlignment = Alignment.MiddleCenter, Anchor = AnchorPoints.Left | AnchorPoints.Right | AnchorPoints.Top });
scene1.AddComponent(new PictureControl("example-100.png") { Size = new Vector2f(100, 100), Position = new Vector2f(0, 0), Anchor = AnchorPoints.Left | AnchorPoints.Top });
scene1.AddComponent(new ButtonControl(new Font("font.ttf"), 16, "button.png", "button_hover.png", "button_pressed.png") { Size = new Vector2f(150, 49), Position = new Vector2f(50, 250), Anchor = AnchorPoints.Left | AnchorPoints.Top, Text = "Press Me :)" });
uimanager.CurrentScene = scene1;
while (window.IsOpen())
{
window.DispatchEvents();
window.Clear(Colors.WhiteSmoke);
uimanager.Render(window);
window.Display();
}
}
示例9: Main
// EINBINDEN VON SFML.NET
// - Projektmappen-Explorer öffnen
// - Rechtklick -> Verweis hinzufügen
// - In der Linkenspalte "Durchsuchen"
// - Ganz unten erneut auf "Durchsuchen"
// - SFML.NET Ordner öffnen -> Libs
// - Alle Auswählen und hinzufügen
// - Schauen ob alle markiert sind und OK
//
// - Rechtsklick -> Hinzufügen -> Vorhandenes Element
// - SFML.NET Ordner öffnen -> extlibs
// - ggf. "Alle Dateitypen (.*)" auswählen
// - Alle Auswählen und hinzufügen
// - Im Projektmappen-Explorer die 5 .dll auswählen
// - Rechtsklick -> Eigenschaften
// - Ins Ausgabeverzeichniskopieren -> "Immer kopieren" oder "Kopieren wenn neuer"
// KONSOLE AUSSCHALTEN
// - Projektmappen-Explorer öffnen
// - Rechtsklick auf das Projekt (Intro2D-02-Beispiel) -> Eigenschaften
// - In den Reiter "Anwendung" (automatisch offen) wechseln
// - Ausgabetyp -> "Windows-Anwendung"
// WICHTIG !!!!!!
// - WENN IHR DIESES PROJEKT WEITERVERWENDEN WOLLT, MÜSST IHR DIE VERWEISE (erster Teil) NEU HINZUFÜGEN
// Wird für Programm ablauf benötigt
static void Main()
{
//initialisiert ein RenderWindow
RenderWindow win = new RenderWindow(new VideoMode(800, 600), "Test Window");
//fügt die Close Methode dem Closed Event von dem RenderWindow hinzu
win.Closed += Close;
//fancy alternativen:
//win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };
//win.Closed += delegate { win.Close(); };
//solange das Window offen ist
while (win.IsOpen())
//in SFML2.2 while(win.IsOpen)
{
//hellblau oder so
win.Clear(new Color(40, 150, 200));
//trigger alle events
win.DispatchEvents();
//zeige alles gezeichnete an
win.Display();
}
}
示例10: Main
public static void Main(string[] args)
{
window = new RenderWindow(new VideoMode(800, 600), "SFML window");
window.SetVisible(true);
window.SetVerticalSyncEnabled(true);
window.Closed += OnClosed;
window.MouseMoved += OnMouse;
window.MouseLeft += Window_MouseLeft;
window.Resized += Window_Resized;
List<Button> buttons = new List<Button>();
for (int i = 0; i < 10; i++)
{
buttons.Add(new Button(new Vector2f(i*200, 100), new Vector2f(75, 20)));
}
while (window.IsOpen)
{
window.DispatchEvents();
window.Clear(new Color(50, 50, 50));
GUIManager.GuiManager.Update(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y);
foreach (var item in buttons)
{
window.Draw(item);
}
window.Display();
}
}
示例11: Main
public static void Main()
{
VideoMode videoMode = VideoMode.DesktopMode;
videoMode.Width = 800;
videoMode.Height = 600;
using (RenderWindow renderWindow = new RenderWindow(videoMode, "SFML Test"))
{
renderWindow.SetFramerateLimit(60);
Game.Window = renderWindow;
Game.Init();
renderWindow.Closed += (sender, e) =>
{
renderWindow.Close();
};
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (renderWindow.IsOpen)
{
renderWindow.DispatchEvents();
float dTime = stopwatch.ElapsedMilliseconds / 1000f;
stopwatch.Restart();
Game.ElapsedTime += dTime;
if (false && Game.Entities.OfType<Enemy>().Count() < 3)
{
Game.Entities.Add(new Enemy(Game.Player)
{
Position = Vector2.Random(renderWindow.Size.X, renderWindow.Size.Y)
});
}
if (Keyboard.IsKeyPressed(Keyboard.Key.Escape))
{
renderWindow.Close();
}
// Update code goes here
foreach (Entity entity in Game.Entities.ToArray())
{
entity.Update(dTime);
}
// Rendering code goes here
renderWindow.Clear();
foreach (Entity entity in Game.Entities.OrderBy(e => e.RenderPriority))
{
renderWindow.Draw(entity);
}
renderWindow.Display();
}
renderWindow.Close();
}
}
示例12: Draw
/// <summary>
/// clear the window
/// <para>draws all gameobjects in the window</para>
/// <para>displays all drawn objects</para>
/// </summary>
static void Draw(RenderWindow window)
{
window.Clear(new Color(50, 120, 190));
player.Draw(window);
enemy1.Draw(window);
enemy2.Draw(window);
window.Display();
}
示例13: Main
public static void Main(string[] args)
{
Window = new RenderWindow(new VideoMode(640, 480), "", Styles.Close);
Window.SetFramerateLimit(60);
Window.Closed += (sender, eventArgs) => Window.Close();
Window.Resized += (sender, eventArgs) =>
{
var view = new View();
view.Size = new Vector2f(eventArgs.Width, eventArgs.Height);
view.Center = view.Size / 2;
Window.SetView(view);
};
Machine = new VirtualMachine(512 * 1024);
var prog = File.ReadAllBytes("bios.bin");
for (var i = 0; i < prog.Length; i++)
Machine.Memory[i] = prog[i];
var kbd = new Devices.Keyboard(0x02, Window);
Machine.Attach(kbd);
var display = new Devices.Display(0x06, Machine, Window);
Machine.Attach(display);
var hdd = new Devices.HardDrive(0x08, "disk.img");
Machine.Attach(hdd);
var running = true;
var stepThread = new Thread(() =>
{
while (running)
{
Machine.Step();
}
});
stepThread.Start();
while (Window.IsOpen())
{
Window.DispatchEvents();
Window.Clear();
Window.Draw(display);
Window.Display();
}
running = false;
stepThread.Join();
Machine.Dispose();
}
示例14: Draw
/// <summary>
/// clear the window
/// <para>draws all gameobjects in the window</para>
/// <para>displays all drawn objects</para>
/// </summary>
static void Draw(RenderWindow window)
{
window.Clear(new Color(50, 120, 190));
window.SetView(Camera);
map.Draw(window);
Player.Draw(window);
enemy1.Draw(window);
enemy2.Draw(window);
window.Display();
}
示例15: StartSFMLProgram
public void StartSFMLProgram()
{
_window = new RenderWindow(new VideoMode(800, 600), "SFML window");
_window.SetVisible(true);
_window.Closed += new EventHandler(OnClosed);
while (_window.IsOpen)
{
_window.DispatchEvents();
_window.Clear(Color.Red);
_window.Display();
}
}