ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

How to bundle a game's source file and its interpreter into a single EXE

<< < (7/7)

kyrathaba:
Yeah, I'll upload the entire dummy project.

hollowlife1987:
Ok, you have the code to compile an exe now all you need to do is add a the script to that exe as a resource.

Then when you run the newly created exe you use open the resource and run the script directly from memory

Here are some code snippets on how to do what I just explain (note I don't know much about compiling .net code from .net so your on your own on how to use a resource file when you compile it)

To make the .resources file that you compile into the newly created exe

--- Code: C# ---ResourceWriter rw = new ResourceWriter("app.resources");byte[] data = File.ReadAllBytes(scriptFile); rw.AddResource("script", data);rw.Close();
And to read the resource and do something with it

--- Code: C# ---ResourceManager rm = new ResourceManager("app", Assembly.GetExecutingAssembly());byte[] data = (byte[])rm.GetObject("script"); UTF8Encoding encoder = new UTF8Encoding();string text = encoder.GetString(data); Console.WriteLine(text);
Hope that is of some help if you still need help I'll write a sample program I couldn't do it tonight because something came up.

kyrathaba:
Very helpful.  Thanks Hollowlife :>

hollowlife1987:
Your very welcome :)

Navigation

[0] Message Index

[*] Previous page

Go to full version