本文整理汇总了C#中SFML.Graphics.RenderWindow.IsOpen方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.IsOpen方法的具体用法?C# RenderWindow.IsOpen怎么用?C# RenderWindow.IsOpen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.IsOpen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
示例3: 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();
}
}
示例4: 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();
}
}
示例5: 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();
}
}
示例6: Main
static int Main(string[] args)
{
// The Screen or Window
VideoMode videoMode = new VideoMode(1024, 768);
RenderWindow window = new RenderWindow(videoMode,
"Learn SFML");
window.Closed += new EventHandler(window_Closed);
window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(window_MouseButtonPressed);
window.MouseMoved += new EventHandler<MouseMoveEventArgs>(window_MouseMoved);
window.KeyPressed += new EventHandler<KeyEventArgs>(window_KeyPressed);
Start();
Console.Out.WriteLine("Engine Started Successfully!");
while (window.IsOpen()
&& !quit)
{
window.DispatchEvents();
// Draw
currentScreen.Draw(window);
window.Display();
}
window.Close();
return 0;
}
示例7: Main
public static void Main(string[] args)
{
var win = new RenderWindow(new VideoMode(800, 600), "Some Crappy Zombie Thing");
win.Closed += (sender, e) => win.Close ();
var curtime = DateTime.Now;
double dt = 0;
double frametime;
win.SetVisible (true);
EntityManager.Add (new RectangleTestEntity(true));
EntityManager.Add (new DebugInfo());
EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", 0, 1));
EntityManager.Add (new TileEntity("data/graphics/test_tileset.xml", "45down", new Vector2f(35, 40), 1));
Entity ent = new Entity();
ent.OnDraw += (sender, e) => e.Surface.Draw (new Text("Loooooonnnnggg Teeeexxxttt") {Position = new Vector2f(700, 500)});
EntityManager.Add (ent);
EntityManager.InitializeWindow (win);
while(win.IsOpen ())
{
win.DispatchEvents();
EntityManager.Draw (win);
win.Display ();
frametime = (DateTime.Now-curtime).TotalMilliseconds;
dt += frametime;
while (dt >= EntityManager.TimeStep)
{
//Console.WriteLine (dt.ToString ());
EntityManager.Update (dt, frametime);
dt -= EntityManager.TimeStep;
}
curtime = DateTime.Now;
}
}
示例8: Main
static void Main(string[] args)
{
Files.log("Game started.");
Console.Title = "Asialaide";
new Character("Player", 1, 200, 300);
Drawing.initialise();
window = Drawing.window; // A local reference.
// Create events.
window.Closed += new EventHandler(Program.OnClose);
window.KeyPressed += new EventHandler<KeyEventArgs>(Input.OnKeyPressed);
// Load files.
Files.load("data\\graphics\\crf_char.png");
// The game loop.
while (window.IsOpen())
{
// Process events.
window.DispatchEvents();
// Draw everything.
Drawing.drawWindow();
}
}
示例9: 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();
}
}
示例10: 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));
}
}
示例11: 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();
}
示例12: Main
static void Main(string[] args)
{
RenderWindow win = new RenderWindow(new VideoMode(900,900), "Intro-2D-Project",Styles.Default);
win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };
Initialize();
while (win.IsOpen()){
Update();
Draw(win);
win.DispatchEvents();
}
}
示例13: StartSFMLProgram
public void StartSFMLProgram()
{
_window = new RenderWindow(new VideoMode(800, 600), "SFML window");
_window.SetVisible(true);
_window.Closed += new EventHandler(OnClosed);
tests = new Tests(_window);
Stopwatch watch = new Stopwatch();
watch.Start();
Stopwatch pauseWatch = new Stopwatch();
pauseWatch.Start();
while (_window.IsOpen())
{
_window.DispatchEvents();
_window.Clear();
if (watch.ElapsedMilliseconds > 500)
{
if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Left) && currentTest > 0)
{
--currentTest;
watch.Reset();
watch.Start();
tests.TestCounter = 1;
tests.Paused = false;
}
else if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Right) && currentTest < 6)
{
++currentTest;
watch.Reset();
watch.Start();
tests.TestCounter = 1;
tests.Paused = false;
}
}
if (pauseWatch.ElapsedMilliseconds > 250)
{
if (SFML.Window.Keyboard.IsKeyPressed(Keyboard.Key.Space))
{
tests.Paused = !tests.Paused;
pauseWatch.Reset();
pauseWatch.Start();
}
}
RunCurrentTest();
_window.Display();
}
}
示例14: Main
public static void Main()
{
#region Initialize Variables
window = new RenderWindow(new VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Reflexes For Friends", Styles.Default, new ContextSettings(32, 0));
timer = new Stopwatch();
world = new GameWorld(new Texture("resources/background-grass.png"));
player = new Player(new Texture("resources/player.png"));
friend = new Friend(new Texture("resources/friend.png"));
enemies = new List<Enemy>();
gameOver = false;
#endregion
#region Register Event Handlers
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
window.KeyReleased += new EventHandler<KeyEventArgs>(OnKeyReleased);
#endregion
#region Setup Modules
keyboardModule = new KeyboardModule();
#endregion
RegisterKeyBindings();
GenerateEnemies();
timer.Start();
long timeSinceLastUpdate = 0;
window.SetVerticalSyncEnabled(true);
window.SetActive();
while (window.IsOpen())
{
window.DispatchEvents();
if (!gameOver)
{
timeSinceLastUpdate += timer.ElapsedMilliseconds;
timer.Restart();
if (timeSinceLastUpdate >= UPDATE_FREQUENCY_IN_MS)
{
UpdateGame(UPDATE_FREQUENCY_IN_MS);
timeSinceLastUpdate -= UPDATE_FREQUENCY_IN_MS;
}
}
DrawGame();
window.Display();
}
timer.Stop();
}
示例15: Main
static void Main(string[] args)
{
RenderWindow win = new RenderWindow(new VideoMode(1200, 1000), "Intro2D-04-Beispiel-Player-Enemy");
win.Closed += (sender, e) => { ((RenderWindow)sender).Close(); };
Initialize();
while (win.IsOpen())
{
Update();
Draw(win);
win.DispatchEvents();
}
}