Original Post
Hey guys, I need some help here. 1. No matter what I set delay or targetfps to, I always get exactly 1 frame per second. It ruins half the reason I went with .net as opposed to the C version. If only Torque2D didn't need networking kludged in (and a TGE license for the code to be kludged)... 2. When I close the application, I get 2 different errors. The first time I get "illegal access at 0x00000000 could not be 'written'" from Windows and the second time I just get a similar error from Visual Studio's debugger. I guess it could be complaining about the screen/sprite/bitmap context but I have no idea how to appease it or where to do so. 3. Sort of related, Alt+F4 won't cause a quit event on this or regular SDL. Am I supposed to check the keyboard handler for Alt+F4 manually? I didn't find anything in their 10 pages of very sparse docs and Google didn't point anywhere but their site. Using .net 2.0 on Windows 2000 SP4 with over a GB of RAM, so it can't be the system.
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using SdlDotNet;
using SdlDotNet.Sprites;
using SdlDotNet.Windows;
namespace WindowsApplication2
{
public class Program
{
SdlDotNet.Sprites.AnimatedSprite Hero = new SdlDotNet.Sprites.AnimatedSprite();
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main ()
{
Program Application = new Program();
Application.Run();
}
public Program ()
{
SdlDotNet.Video.SetVideoModeWindow(320, 240, 16, false);
SdlDotNet.Video.WindowCaption = "RRK - C# 2005 - Windows 2000 - SDL 4.0";
SdlDotNet.SurfaceCollection MainFile = new SdlDotNet.SurfaceCollection("./graphics/SmallFoot.png", new System.Drawing.Size(64, 64));
SdlDotNet.Sprites.Animation Temporary;
Temporary = new SdlDotNet.Sprites.Animation();
Temporary.Add(MainFile[0]);
Temporary.Add(MainFile[32]);
Temporary.Add(MainFile[0]);
Temporary.Add(MainFile[40]);
Temporary.Delay = 1000;
Hero.Animations.Add("MS", Temporary);
Temporary = new SdlDotNet.Sprites.Animation();
Temporary.Add(MainFile[1]);
Temporary.Add(MainFile[33]);
Temporary.Add(MainFile[1]);
Temporary.Add(MainFile[41]);
Temporary.Delay = 1000;
Hero.Animations.Add("ME", Temporary);
Temporary = new SdlDotNet.Sprites.Animation();
Temporary.Add(MainFile[2]);
Temporary.Add(MainFile[34]);
Temporary.Add(MainFile[2]);
Temporary.Add(MainFile[42]);
Temporary.Delay = 1000;
Hero.Animations.Add("MW", Temporary);
Hero.CurrentAnimation = "MS";
Hero.Animate = true;
}
public void Run()
{
SdlDotNet.Events.TargetFps = 30;
SdlDotNet.Events.KeyboardDown += new SdlDotNet.KeyboardEventHandler(this.OnKeyboardDown);
SdlDotNet.Events.Tick += new SdlDotNet.TickEventHandler(this.OnTick);
SdlDotNet.Events.Quit += new SdlDotNet.QuitEventHandler(this.OnQuit);
SdlDotNet.Events.Run();
}
private void OnKeyboardDown(System.Object Sender, SdlDotNet.KeyboardEventArgs Arguments)
{
//if (e.Key == Key.Escape || e.Key == Key.Q)
//{
// Events.QuitApplication();
//}
}
private void OnTick(System.Object Sender, SdlDotNet.TickEventArgs Arguments)
{
//screen.Fill(Color.Black);
//screen.Blit(surface);
//screen.Flip();
Video.Screen.Fill(System.Drawing.Color.Black);
Video.Screen.Blit(Hero);
Video.Screen.Flip();
}
private void OnQuit(System.Object Sender, SdlDotNet.QuitEventArgs Arguments)
{
Hero.Kill();
SdlDotNet.Events.QuitApplication();
}
}
}
[Edited by - RKillian on June 28, 2006 11:47:58 AM]