Original Post
After about an hour of reading through the numerous examples that come with the SdlDotNet API, SimpleExample and ImageExample to be exact, and I've run into a problem of trying to construct my own little demo of just blitting a background and a little space ship that you can move with the arrow keys. I've got the following source: And here are the images I'm using: bg.bmp
ship.jpg
The background blits and so does the ship but the magenta colored background is still visible save for some parts that are somehow missing. So basically its a space ship with magenta colored blots around it. I'm still pretty new to coding with SdlDotNet, it's a little hard to find a tutorial. And a full OOP approach is a lot different than procedural or using a custom wrapper class with C++. New language, new API, same old problems. [Edited by - Ekim_Gram on July 29, 2005 11:50:06 AM]
using System;
using System.Drawing;
using SdlDotNet;
namespace SDL_Test
{
public class App
{
private bool done;
private const int height = 480;
private const int width = 640;
private int xPos, yPos;
private Surface screen;
public App()
{
Events.KeyboardDown += new KeyboardEventHandler(this.KeyDown);
Events.Quit += new QuitEventHandler(this.Quit);
screen = Video.SetVideoModeWindow(width, height);
Video.WindowCaption = "C# with SDL.NET";
done = false;
xPos = 100;
yPos = 200;
}
private void KeyDown(object sender, KeyboardEventArgs e)
{
switch (e.Key)
{
case (Key.Escape):
{
done = true;
break;
}
case (Key.Q):
{
done = true;
break;
}
}
}
private void Quit(object sender, QuitEventArgs e)
{
done = true;
}
public void Run()
{
Surface background = new Surface("images/bg.bmp");
Surface spaceship = new Surface("images/ship.jpg");
spaceship.TransparentColor = System.Drawing.Color.Magenta; // R = 255 G = 0 B = 255
spaceship.Transparent = true;
while (done == false)
{
while(Events.Poll())
{
}
screen.Blit(background, new Rectangle(new Point(0,0), background.Size));
screen.Blit(spaceship, new Rectangle(new Point(xPos,yPos), spaceship.Size));
screen.Flip();
}
}
public static void Main()
{
App mainApp = new App();
mainApp.Run();
}
}
}
ship.jpg
The background blits and so does the ship but the magenta colored background is still visible save for some parts that are somehow missing. So basically its a space ship with magenta colored blots around it. I'm still pretty new to coding with SdlDotNet, it's a little hard to find a tutorial. And a full OOP approach is a lot different than procedural or using a custom wrapper class with C++. New language, new API, same old problems. [Edited by - Ekim_Gram on July 29, 2005 11:50:06 AM]