本文整理汇总了C#中SFML.Graphics.View类的典型用法代码示例。如果您正苦于以下问题:C# View类的具体用法?C# View怎么用?C# View使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
View类属于SFML.Graphics命名空间,在下文中一共展示了View类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapRenderer
public MapRenderer(IntPtr mapRenderWindowHandle, IntPtr tileSetRenderHandle, MapEditor.MapEditorProperties mapEditorProperties)
{
_mapRenderWindow = new RenderWindow(mapRenderWindowHandle);
_tileSetRenderWindow = new RenderWindow(tileSetRenderHandle);
_mapRenderWindow.MouseButtonPressed += mapRenderWindow_MouseButtonPressed;
_mapRenderWindow.MouseMoved += mapRenderWindow_MouseMoved;
_tileSetRenderWindow.MouseButtonPressed += tileSetRenderWindow_MouseButtonPressed;
_tileSetRenderWindow.MouseMoved += tileSetRenderWindow_MouseMoved;
_tileSetRenderWindow.MouseButtonReleased += tileSetRenderWindow_MouseButtonReleased;
_mapEditorProperties = mapEditorProperties;
_mapEditorProperties.CurrentLayer = World.Map.Layers.Ground;
_mapEditorProperties.MapView = new View(this._mapRenderWindow.DefaultView);
_mousePositionText = new Text("", new Font(AppDomain.CurrentDomain.BaseDirectory + "/Data/Graphics/Fonts/MainFont.ttf"), 20);
this.LoadTileSets();
_tileSetView = this._tileSetRenderWindow.DefaultView;
this.Running = true;
this._mapRenderWindow.SetActive(false);
this._tileSetRenderWindow.SetActive(false);
new Thread(UpdateLoop).Start();
}
示例2: 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));
}
}
示例3: SetupGrid
private void SetupGrid(Vector2u mapSize)
{
const int gridSize = 16;
_gridTexture = new RenderTexture(2000, 2000);
var col = new Color(120, 120, 120);
var verticies = new List<Vertex>();
for (int x = 0; x < mapSize.X; x += gridSize)
{
verticies.Add(new Vertex(new Vector2f(x, 0), col));
verticies.Add(new Vertex(new Vector2f(x, mapSize.Y), col));
}
for (int y = 0; y < mapSize.Y; y += gridSize)
{
verticies.Add(new Vertex(new Vector2f(0, y), col));
verticies.Add(new Vertex(new Vector2f(mapSize.X, y), col));
}
_gridlines = verticies.ToArray();
_gridTexture.Clear(new Color(190, 190, 190));
//_view = new View(new FloatRect(0,0,displaySize.X, displaySize.Y));
_view = new View(new FloatRect(0, 0, DisplayView.Size.X, DisplayView.Size.Y));
DisplayView = _view;
//_gridTexture.SetView(_view);
_gridTexture.Draw(_gridlines, PrimitiveType.Lines);
_gridTexture.Display();
_grid = new Sprite(_gridTexture.Texture);
AddItemToDraw(_grid, 0);
}
示例4: CluwneView
public CluwneView(CluwneWindow window)
{
this._window = window;
_worldView = new View(new FloatRect(0.0f, 0.0f, window.Size.X, window.Size.Y));
_interfaceView = new View(new FloatRect(0.0f, 0.0f, window.Size.X, window.Size.Y));
window.SetView(_worldView);
}
示例5: Init
public override void Init(Entity entity)
{
base.Init(entity);
camera = new View(Target.Transform.Position, Global.Screen);
camera.Zoom(2f);
//camera.Rotate(45f);
}
示例6: Camera
public Camera(GameWindow mGameWindow, int mWidth, int mHeight)
{
Debug.Assert(mGameWindow != null);
_renderWindow = mGameWindow.RenderWindow;
View = new View(new FloatRect(0, 0, mWidth, mHeight));
}
示例7: ViewAnimateSprite
public ViewAnimateSprite(IntPtr handle)
{
_animatedSpriteViewer = new RenderWindow(handle);
_view = new View(new FloatRect(0, 0, Editor.Instance.curGame.TileX, Editor.Instance.curGame.TileY));
_curFrame = 0;
_animatedSpriteViewer.SetView(_view);
}
示例8: Camera
public Camera(View view)
{
View = new View(view);
Position = View.Size / 2;
originalSize = View.Size;
ActualPosition = Position;
}
示例9: RenderImage
////////////////////////////////////////////////////////////
/// <summary>
/// Create the render image with the given dimensions and
/// an optional depth-buffer attached
/// </summary>
/// <param name="width">Width of the render image</param>
/// <param name="height">Height of the render image</param>
/// <param name="depthBuffer">Do you want a depth-buffer attached?</param>
////////////////////////////////////////////////////////////
public RenderImage(uint width, uint height, bool depthBuffer) :
base(sfRenderImage_Create(width, height, depthBuffer))
{
myDefaultView = new View(sfRenderImage_GetDefaultView(This));
myImage = new Image(sfRenderImage_GetImage(This));
GC.SuppressFinalize(myDefaultView);
GC.SuppressFinalize(myImage);
}
示例10: RenderTexture
////////////////////////////////////////////////////////////
/// <summary>
/// Create the render-texture with the given dimensions and
/// an optional depth-buffer attached
/// </summary>
/// <param name="width">Width of the render-texture</param>
/// <param name="height">Height of the render-texture</param>
/// <param name="depthBuffer">Do you want a depth-buffer attached?</param>
////////////////////////////////////////////////////////////
public RenderTexture(uint width, uint height, bool depthBuffer) :
base(sfRenderTexture_create(width, height, depthBuffer))
{
myDefaultView = new View(sfRenderTexture_getDefaultView(CPointer));
myTexture = new Texture(sfRenderTexture_getTexture(CPointer));
GC.SuppressFinalize(myDefaultView);
GC.SuppressFinalize(myTexture);
}
示例11: ExploringState
public ExploringState()
{
//Pretty loading here
map = new TileMap();
player = new PlayerCharacter(map, new Vector2i(15,15));
exploringView = new View(Program.Window.GetView());
defaultView = Program.Window.DefaultView;
}
示例12: IngameShipState
public IngameShipState(WindowManager WM)
: base(WM)
{
CurrentMap = new IngameObjects.NetworkWorld(this);
GameView = new View();
//WM.AddWindow(new Windows.MainMenu(WM, this, 100, 100, 250, 200));
Chat = new Windows.ChatBox(WM, this, 100, 100, 250, 200);
WM.AddWindow(Chat);
}
示例13: Run
public void Run()
{
TextureLoader.Init();
Window = new RenderWindow(videoMode, title, Styles.Close);
States = new RenderStates(RenderStates.Default);
Window.Closed += (s, e) =>
{
Console.WriteLine("Closing...");
Window.Close();
};
Window.SetVerticalSyncEnabled(true);
defaultView = Window.DefaultView;
gameView = Window.DefaultView;
gameView.Viewport = new FloatRect(0, 0, .85f, .85f);
BackgroundColor = new Color(100, 149, 237); // dat cornflower blue
Tilemap = new Tilemap(this);
SelectedTileID = 1;
var timer = new Stopwatch();
while (Window.IsOpen)
{
timer.Restart();
Window.DispatchEvents();
var mouse = Mouse.GetPosition(Window);
//if (Mouse.IsButtonPressed(Mouse.Button.Right))
// gameView.Move(new Vector2f(prevMouse.X - mouse.X, prevMouse.Y - mouse.Y));
Tilemap.Update(Frametime);
Window.Clear(BackgroundColor);
Window.SetView(gameView);
Tilemap.Draw(Window, States);
Window.SetView(defaultView);
Debug.Draw(Window);
Window.Display();
prevMouse = mouse;
timer.Stop();
Frametime = (float)timer.Elapsed.TotalMilliseconds;
Window.SetTitle($"{title} ({(1d / timer.Elapsed.TotalSeconds):0}fps)");
}
}
示例14: 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();
}
示例15: Initialize
public void Initialize()
{
world = (LayeredWorld)WorldManager.Worlds["first_world"];
view = new View(new Vector2f(100, 0), new Vector2f(50, 50));
view.Zoom(10);
player = new Player(world.PlayerStartPosition);
Program.RenderWindow.KeyPressed += RenderWindow_KeyPressed;
}