Interesting... I've never used WPF, but I wonder if this is that much faster because drawing is faster or because it's not looping through all the open windows every frame...
Well, WPF is also hardware-accelerated. In the backend they use Direct3D to render it, with software rendering as a fallback. In any case, I can't imagine it taking a lot of time to loop through open windows. I mean, normally the number of open windows isn't very high, compared to how many loop iterations a modern CPU can chew through. Then again, I don't know the inner-workings of Win32 API calls.
I don't know much about the internals of Win32 API stuff either, but getting the list itself didn't take too long when I was doing it myself. Can I convert WindowsZone to WPF in-place or would I need to start a new project?
Far as I know, WinForms projects cannot be converted automatically. Manually, it'd probably take more work than just starting a new project and copying some of your code over. One nice thing is that .xaml files can transfer over directly—for those, it doesn't matter whether the project is C# or VB.NET. You'll have to translate .xaml.cs files though.
GTK# seems to also offer a similar capability. GTK# drawing functions are assisted by Cairo, which can be hardware accelerated. The GTK# package for Microsoft's .NET Framework as well as Mono seem to allow mixing with WinForms, so you could hybridize between the two.... And as for Window enumeration and position APIs, Linux has wnck-sharp, while you may need to use WinForms/WPF/ManagedWinapi for Windows. Mac OS X has nothing currently. It seems you don't actually use much of the ManagedWinapi, so ripping that out for a Linux version might be easier than reimplementing the ManagedWinapi. I don't seem to have time right now to do anything though... I've got an argument paper and a speech due next week. And a test next week....
I'm getting nowhere with WPF, I have to try to reimplement everything and I can't figure out how to get the objects to draw themselves like they do currently.
I've updated WindowsZone so that you can give it an INI file as an argument or drop it onto the EXE. I've also fixed the animation editor so that it saves frame times now. I've also added a sprite set for Amy, although she uses (Pink) Sonic's sprites for braking and pushing. I don't think that I'll be able to get WPF figured out, but is there a way I could use Direct3D with a transparent BG or something?
I separated out the Cairo binding source code from the rest of the Mono tree and provided an archive containing the Cairo library, the C headers and dev libs, the .NET binding library source code, and the source code of the original Cairo library. The archive is available here. Documentation of the Cairo binding is available <a href="http://www.go-mono.com/docs/index.aspx?tlink=18@N:Cairo" target="_blank">here</a>. If you want to try Cairo to accelerate it with Winforms, this can let you try it without grabbing the whole GTK# package. I found a blog post about using Cairo with OpenGL here. The links referring to the Tao Framework website go to a broken site though, here's a link to the SourceForge project page for the Tao Framework.
This program is great. Fun to fool around with when you're bored. I also put together a Sonic 2 version of Sonic for it so I can use either Sonic 3 Sonic or Sonic 2 Sonic. I hope to see some cool updates to it in the future.
I think your link my be broken, or at least it won't let me download. EDIT: Ah, mistake. This is about the best thing, incredible work!
It works fine for me. Make sure to right-click the link and use "Save Target As" or "Save Link As" because the server reports the file as a text file for some reason. Also, I've made an INI that allows you to play as Motobug, inspired by Polygon Jim's hack.
Update with an entirely different collision method that checks for the intersection of the bounding rectangle rather than checking if Sonic has moved through the bounds of an object. A major benefit of this is that Sonic will be pushed by a window moving through him. I've also introduced a vertical speed limit to prevent Sonic from simply falling through things because he's going too fast. Also, there is now an option to stand on the bottom of the screen rather than just dying, and "Show Collision" is now "Show Debug Info", and includes Sonic's position and speed in the upper left corner along with a frame timer.
Well, at least the old version could load up! Code (Text): See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ************** Exception Text ************** System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DirectX.DirectInput, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.DirectX.DirectInput, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at WindowsZone.Controller.UpdateControllerData() at WindowsZone.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\Users\Mike\Documents\Visual Studio 2008\Projects\WindowsZone\WindowsZone\Form1.vb:line 40 at System.Windows.Forms.Timer.OnTick(EventArgs e) at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. ************** Loaded Assemblies ************** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3603 (GDR.050727-3600) CodeBase: file:///c:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll ---------------------------------------- WindowsZone Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///C:/Documents%20and%20Settings/Daniel/My%20Documents/WindowsZone/WindowsZone.exe ---------------------------------------- Microsoft.VisualBasic Assembly Version: 8.0.0.0 Win32 Version: 8.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll ---------------------------------------- System Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll ---------------------------------------- System.Windows.Forms Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll ---------------------------------------- System.Drawing Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll ---------------------------------------- System.Runtime.Remoting Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll ---------------------------------------- System.Core Assembly Version: 3.5.0.0 Win32 Version: 3.5.30729.1 built by: SP CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll ---------------------------------------- Rat234 Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///C:/Documents%20and%20Settings/Daniel/My%20Documents/WindowsZone/Rat234.DLL ---------------------------------------- System.Web Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.3082 (QFE.050727-3000) CodeBase: file:///C:/WINDOWS/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll ---------------------------------------- ManagedWinapi Assembly Version: 0.3.0.0 Win32 Version: 0.3 CodeBase: file:///C:/Documents%20and%20Settings/Daniel/My%20Documents/WindowsZone/ManagedWinapi.DLL ---------------------------------------- ************** JIT Debugging ************** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled. For example: <configuration> <system.windows.forms jitDebugging="true" /> </configuration> When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box.
Same happens to me on Windows 7, even my custom made character does it. When they push windows, they levitate a bit off the ground and fall back down when they stop.
Yes, this happens for me too. I think I'll have to go back to the old method. In fact, I think I can start adding objects. I'll get gliding/climbing and flying in eventually, I promise!
Update, but this time I had to drop a feature. Sonic can no longer interact with the inside borders of windows. But, I have added the first object, a ring. Currently 10 of them spawn at random points on startup, and another one spawns every time you collect one. I've also added a HUD with time and ring counters, and a non-functioning score counter. Edit: bugfix, now you can let go of the rings and they can spawn properly if you have a screen with a negative position.
Here's another update: Debug Mode! Press 'X' on the keyboard and you'll turn into a ring. Use the direction buttons or the mouse to move and press the jump button to place a ring. A minor note about this is that the character will always use the image at "ring\spin1.png" when in debug mode, so make sure there's an image there (there should be unless you changed ring.ini). Also, with debug info enabled, the screen you're currently in will be surrounded by an aqua rectangle. I've also improved the sound code a bit, eliminated the pause when it loads the audio and preventing it from trying to play a sound if a sound is already playing.