[.net] I spent last night converting to XNA

Started by
12 comments, last by FervInt 16 years, 1 month ago
And I would just like to say that I love love love XNA. I put off moving to XNA after MS deprecated Managed DX but I really shouldn't have. It took me all of 4 hours to move everything to the XNA framework and now I can play my game on my xbox. spectacular!
Advertisement
Ah, very cool to hear that you like it. I've been doing a little bit of playing around with it, but haven't had the time to dig into it as much as I would like to.
Any tips when moving from MDX 1.1 to XNA? How big was your project, and did you encounter any problems?
my project isn't HUGE but there is quite a bit of code.

and when I moved to XNA I removed a lot of the code that I had written because XNA does it all for you.

game loops
update loops
asset management
texture loading
converts ttf to bitmap fonts for you to use
wave bank and buffer handling


The only problems I had really was converting over to new syntax. It was quite a pain but once done my game looked a LOT cleaner.
I take that back..everything about xna is cool...

ACCEPT not being able to make an installer for my game...

what are they doin over there...how am I supposed to distribute my game???
Just curious, is this a xbox360 or a regular xbox?
Are you supposed to write different code for each system? (PC,xbox,xbox360)
Can you use either C++ or C# with XNA when porting to console?
"Just curious, is this a xbox360 or a regular xbox?"
Xbox 360 only

"Are you supposed to write different code for each system? (PC,xbox,xbox360)"
All you have to do differently (provided you use the mechanisms they give you for file io and what not) is code the input for the controllers.


"Can you use either C++ or C# with XNA when porting to console?"
XNA is Only c#
Quote:Original post by vrihai
Just curious, is this a xbox360 or a regular xbox?


That would be the 360, the XNA framework has no way of running on the original XBox, plus Microsoft havn't released anything for the original XBox in years.

Quote:Original post by vrihai
Are you supposed to write different code for each system? (PC,xbox,xbox360)


Most of the code for the different platforms use the same code. Some changes may be required for the different builds such as using the keyboard for the PC project and the game pad or rendering your game in the title safe area for SDTVs for the 360 release.

Quote:Original post by vrihai
Can you use either C++ or C# with XNA when porting to console?

The XNA framework has been developed with the C# language in mind. when running games on the 360 your in a managed environment. There are some hacks to getting XNA running with C++ on windows but you will loose alot of the frameworks functionality.
Can you use something like Inno Setup? I use to as my installer which will check to see if .NET 2.0 is installed and download and install it. You could modify it to check for the XNA runtimes. You need Inno Setup (http://www.jrsoftware.org/isinfo.php) as well as ISTool (http://www.istool.org/)

The script for checking for .NET 2.0 and downloading is below. Save it as DotNet.iss and compile it using Inno Setup. It will create a file called net.exe.

[Files]
Source: isxdl.dll; DestDir: {tmp}; Flags: dontcopy

[Icons]

[Setup]
AppName=NET Framework 2.0
DefaultDirName={pf}\MyProgram
DefaultGroupName=MyProgram
ShowLanguageDialog=no
AppCopyright=
AppVerName=MyProgram .NET 2.0 Install
SetupIconFile=
OutputBaseFilename=net
AllowUNCPath=false
MinVersion=4.1.2222,5.0.2195
AllowCancelDuringInstall=false
UsePreviousTasks=false
RestartIfNeededByRun=false
InternalCompressLevel=max
SolidCompression=true
Compression=lzma
WizardSmallImageFile=WizardSmallImage.bmp
WizardImageFile=WizardImage.bmp
WizardImageStretch=false
WizardImageBackColor=clWhite
ExtraDiskSpaceRequired=20000
DisableReadyPage=false
CreateAppDir=false
DisableProgramGroupPage=true
UsePreviousGroup=false
DisableFinishedPage=true
DisableStartupPrompt=true
DisableReadyMemo=false
OutputDir=.

[Run]
Filename: {tmp}\net.exe; WorkingDir: {tmp}; Flags: nowait skipifdoesntexist


function isxdl_Download(hWnd: Integer; URL, Filename: PChar): Integer;
external 'isxdl_Download@files:isxdl.dll stdcall';

procedure isxdl_AddFile(URL, Filename: PChar);
external 'isxdl_AddFile@files:isxdl.dll stdcall';

procedure isxdl_AddFileSize(URL, Filename: PChar; Size: Cardinal);
external 'isxdl_AddFileSize@files:isxdl.dll stdcall';

function isxdl_DownloadFiles(hWnd: Integer): Integer;
external 'isxdl_DownloadFiles@files:isxdl.dll stdcall';

procedure isxdl_ClearFiles;
external 'isxdl_ClearFiles@files:isxdl.dll stdcall';

function isxdl_IsConnected: Integer;
external 'isxdl_IsConnected@files:isxdl.dll stdcall';

function isxdl_SetOption(Option, Value: PChar): Integer;
external 'isxdl_SetOption@files:isxdl.dll stdcall';

function isxdl_GetFileName(URL: PChar): PChar;
external 'isxdl_GetFileName@files:isxdl.dll stdcall';

const neturl = 'http://www.mywebsite.com/dotnetfx.exe';

function NextButtonClick(CurPage: Integer): Boolean;
var
tmp: String;
hWnd: Integer;
begin
tmp := ExpandConstant('{tmp}\net.exe');
hWnd := StrToInt(ExpandConstant('{wizardhwnd}'));
isxdl_SetOption('title', 'Downloading dotnetfx.exe');
if isxdl_Download(hWnd, neturl, tmp) <> 0 then
begin
Result := true;
end;
end;

[CustomMessages]
dx=ewewweew
[Messages]
WelcomeLabel2=In order to install MyProgram, you must have [name] or above installed on your computer. MyProgram setup has detected that it is not present. To download and install [name] please continue. Once complete please re-run MyProgram setup. Note: [name] may require you to reboot your computer.
WelcomeLabel1=MyProgram requires that [name] is installed on your computer. Once installed you will need to re-run MyProgram setup.


Then in the installer for your actual game add the following code

[Files]
Source: "net.exe"; DestDir: "{app}"; CopyMode: alwaysoverwrite


function InitializeSetup(): Boolean;
var
NetFrameWorkInstalled : Boolean;
ErrorCode: Integer;
Begin
NetFrameWorkInstalled := RegKeyExists(HKLM,'SOFTWARE\Microsoft\.NETFramework\policy\v2.0');

if NetFrameWorkInstalled = false then
begin
ExtractTemporaryFile('net.exe');
ShellExec('open', ExpandConstant( '{tmp}\net.exe'),'','',SW_SHOWNORMAL, ewNoWait, ErrorCode);
End;
Result := true;
end;



So basically you will need to find a registry key to check if XNA exists. Then have a location where the runtimes can be downloaded. The rest of the installation is pretty much automatic using Inno Setup you will just have to get a script from the web and modify it for your game. Then I would find a PC without XNA and run a test on it.
thank you ill look into this :D

This topic is closed to new replies.

Advertisement