我想用C#编写游戏。
我使用以下代码。
using System;
using System.Runtime.InteropServices;
using SFML.Graphics;
using SFML.System;
using SFML.Window;
namespace opengl
{
static class Program
{
static void Main()
{
RenderWindow app = new RenderWindow(VideoMode.DesktopMode,"Game");
app.SetFramerateLimit(60);
while (app.IsOpen)
{
app.Clear();
drawQuad(app, Color.Green, 500, 500, 200, 500, 300, 100);
app.Display();
}
}
static void drawQuad(RenderWindow w ,Color c,int x1,int y1,int w1,int x2,int y2,int w2)
{
ConvexShape shape = new ConvexShape(4);
shape.FillColor = c;
shape.SetPoint(0, new Vector2f(x1 - w1, y1));
shape.SetPoint(1, new Vector2f(x2 - w2, y2));
shape.SetPoint(2, new Vector2f(x1 + w1, y1));
shape.SetPoint(3, new Vector2f(x2 + w2, y2));
w.Draw(shape);
}
}
}
但我面临以下错误。
System.BadImageFormatException:'无法加载文件或程序集'sfmlnet-window-2,Version = 2.4.0.0,Culture = neutral,PublicKeyToken = null'或其依赖项之一。试图加载格式不正确的程序。
问题解决了。我不应该使用64位版本,我应该使用32位版本。