Hey
So, in this chapter we covered basic input via devices. I was wandering, is it possible to use files (e.g a .txt file) that hold textual content, and then extract that content and use it in our game? For example, if we have an intelligent agent that takes random actions depending on the situation, would it be possible to create a file that contains names or ID of those actions (of course there would be a code for that action). I think that using these file(s) would be "cleaner" to trigger these actions (randomly or sequentially) then using endless if-then or switch-case block's. This is fairly simple in C#, but can anyone tell me how to do it in XNA.
Input possibilities
Best way to do that kind of thing, unless you want to use files generated after release, is to integrate a custom data structure to the content pipeline that tells your AI what to do.
It's not just cleaner, for any project beyond a certain complexity it is pretty much an establish standard that your code should only handle logic and you should provide the parameters for that logic through content.
This is one of the most useful Game Programming Gems.
However integrating data through content can be quite time consuming (in hours of work), so if your game is fairly simple you might want to avoid it.
It's not just cleaner, for any project beyond a certain complexity it is pretty much an establish standard that your code should only handle logic and you should provide the parameters for that logic through content.
This is one of the most useful Game Programming Gems.
However integrating data through content can be quite time consuming (in hours of work), so if your game is fairly simple you might want to avoid it.
Best way to do that kind of thing, unless you want to use files generated after release, is to integrate a custom data structure to the content pipeline that tells your AI what to do.
It's not just cleaner, for any project beyond a certain complexity it is pretty much an establish standard that your code should only handle logic and you should provide the parameters for that logic through content.
This is one of the most useful Game Programming Gems.
However integrating data through content can be quite time consuming (in hours of work), so if your game is fairly simple you might want to avoid it.
Well, this is the actual problem. As my master thesis, I am creating an interactive simulation of an assembly line. This is actually a 2 part thesis, my colleague is making a compiler from STL (PLC programming language) to some instructions. The idea is that the code translated from STL is written into a file. My part is to create the simulation of the assembly line (the graphical displaying), but certain elements (like 'STOP' and 'START' buttons) need to be controllable by the instructions written into the file. Please advise.
P.S I know that this is probably not the place to ask this question, but I couldn't find a better (or more specialized) forum, so if you have any suggestion, I would appreciate it.
In theory you should have asked something like this in the DirectX and XNA forum, but over there is mostly DirectX, people there seem to ignore XNA.
Anyway, the key point that will define your options is wether the STL files will come in during or after development, if you want to be able to introduce new files after the XNA app is released, these files cant be part of the content pipeline (or at least I have not found a way to do that so far) since XNA compiles every content file into a uniform XNB format, but you need VS for that.
If your content comes in after, you have no much other choice than to write a parser for your data structure, you can use BinaryWriter & BinaryReader to parse the file, although XML can be easier to work with, for that you have the XmlSerializer, which does both reading and writing.
Your data structure must have public member variables or private variables with corresponding properties (get set methods) in order to be automatically parsed by XmlSerializer, this also works just fine with the generic ContentSerializer of the content pipeline as long as the variables are simple and don't require additional processing like loading external assets, in that case you would need a more case specific serializer which you can extend.
Hope this points you in the right direction
Anyway, the key point that will define your options is wether the STL files will come in during or after development, if you want to be able to introduce new files after the XNA app is released, these files cant be part of the content pipeline (or at least I have not found a way to do that so far) since XNA compiles every content file into a uniform XNB format, but you need VS for that.
If your content comes in after, you have no much other choice than to write a parser for your data structure, you can use BinaryWriter & BinaryReader to parse the file, although XML can be easier to work with, for that you have the XmlSerializer, which does both reading and writing.
Your data structure must have public member variables or private variables with corresponding properties (get set methods) in order to be automatically parsed by XmlSerializer, this also works just fine with the generic ContentSerializer of the content pipeline as long as the variables are simple and don't require additional processing like loading external assets, in that case you would need a more case specific serializer which you can extend.
Hope this points you in the right direction
Anyway, the key point that will define your options is wether the STL files will come in during or after development, if you want to be able to introduce new files after the XNA app is released
This project was proposed to me by my mentor because they intend to replace the PLC's with this simulator (at least for the basic training). Future users will need to write the STL code (for functionality requested by the specific exercise) then the compiler should write a set of instructions into a file from which the simulator reads them, and triggers animations accordingly. I think that file does not need to be created every time, but it's content will certainly change many times. The instructions are simple starting and stopping the line, alarm in case multiple objects are on the line at the same time and turning on the necessary signal lights (so there probably won't be more then 15 functions and their respective animations).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement