Intermediate Challenge - Read/Write XML Config. For Game!

Competitions for Irrlicht or 3D in general.
Irrlicht Screenshot of the Month: Winner for January, vote for February, submit for March
Post Reply
Joe_Oliveri
Posts: 448
Joined: Tue Oct 05, 2004 3:24 am
Location: Boston, MA

Intermediate Challenge - Read/Write XML Config. For Game!

Post by Joe_Oliveri »

Ok time to start this contest.

What you have to do is create a Read/Write XML game config. Your game has to be able to read and write to an XML wiht out using any external program to create the config file.

Examples of what it could do are things like save, load, sound, and graphics adjustments.

It is ok to use IrrXML to boost the development time.

Your game dosn't have to be anything more then a blue screen and a model to show how your XML file works.

All code must be well commented.

C/C++/C# or anyother .NET language only please.

We will judge by how clean the code is, how well it works, and how many features it has.

Good luck! :)

and Have fun!
Irrlicht Moderator || Game Designer
Learn the basics at </dream.in.code>
Shakira22

Post by Shakira22 »

really ? :) :)
Joe_Oliveri
Posts: 448
Joined: Tue Oct 05, 2004 3:24 am
Location: Boston, MA

Post by Joe_Oliveri »

Yes really, :D All projects must be in by August 31st, 2006. Please send them to:

joliveri@h4games.com

Good luck to all!
Irrlicht Moderator || Game Designer
Learn the basics at </dream.in.code>
jam
Posts: 409
Joined: Fri Nov 04, 2005 3:52 am

Post by jam »

So how is the contest coming along? :D
system-independent, adj.:
Works equally poorly on all systems.
-- unknown
sgt_pinky
Posts: 149
Joined: Sat Oct 14, 2006 11:20 am
Location: Melbourne, Australia

Post by sgt_pinky »

**EDIT**
Whoops, I see the due date was 31st August. rofl - oh well.

-----------

Well, if you include .NET, here is my answer in VB.NET. Although, I would say that .NET is kinda cheating for XML, haha.

Code: Select all

Imports System.Xml.Serialization

Public Class Game

    Private Sub Game_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Dim GS As New GameSettings

        GS.KeyboardDelay = 30
        GS.PlayerName = "Sgt_Pinky_R0X0rz"
        GS.MouseSensitivity = 10
        GS.KeyMap = New Integer() {123, 152, 155}

        'save settings
        Dim xszSer As XmlSerializer = New XmlSerializer(GetType(GameSettings))
        Dim xmlWriter As Xml.XmlTextWriter = New Xml.XmlTextWriter("c:\gamesettings.xml", System.Text.Encoding.UTF8)
        xmlWriter.Formatting = Xml.Formatting.Indented
        xszSer.Serialize(xmlWriter, GS)
        xmlWriter.Close()

        'load settings
        Dim GSLoad As New GameSettings
        Dim xmlReader As Xml.XmlTextReader = New Xml.XmlTextReader("c:\gamesettings.xml")
        GSLoad = xszSer.Deserialize(xmlReader)
        xmlReader.Close()

    End Sub

End Class

<Serializable()> _
Public Class GameSettings
    Public PlayerName As String
    Public KeyMap() As Integer
    Public MouseSensitivity As Int16
    Public KeyboardDelay As Int16
End Class
And here is what the actual settings file looks like:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<GameSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <PlayerName>Sgt_Pinky_R0X0rz</PlayerName>
  <KeyMap>
    <int>123</int>
    <int>152</int>
    <int>155</int>
  </KeyMap>
  <MouseSensitivity>10</MouseSensitivity>
  <KeyboardDelay>30</KeyboardDelay>
</GameSettings>
Nice XML hey? So easy in .NET.

So, do I win? :D
Intellectuals solve problems - geniuses prevent them. -- Einstein
#irrlicht on irc.freenode.net
Rambus
Posts: 96
Joined: Thu Nov 24, 2005 4:56 pm
Location: Canada
Contact:

Post by Rambus »

I will be releasing said config code using tinyXML as part of my space invaders entry- If you are having issues with your entry, check back in the space invaders thread in about a week to snap up my code.

Edit: Wow, I didnt realise this thread was 5-6 mounths old... never mind
Post Reply