Hey all,
So there are many text-based games out there, but what is the framework of which you are using to organize your code? Is it just built off of a directory structure? All the files mashed into one area? No organization or framework?
Within the past couple weeks, I have just started to work with a fellow programmer whose name is Kyle (shout-out to his site: https://toplistedgames.com/) to work on building a small example of a text-based game using a framework called MVC.
So, what is MVC?
MVC is a framework that separates different interfaces in order to give not only a complete organization of your code base, but also encourages re-use of most of the code base with the exception of what the user sees.
What does MVC mean?
MVC stands for Model-View-Controller.
How does MVC work?
MVC works by separating the interfaces, yet having a link to connect the three interfaces together.
The controller is your base code. Basically, this code will run on most, if not all, pages in order to run the necessary background logic. Most of the time, this code is used to define functions which can be used in the models as well as create the very base layout which will be used throughout your site or application.
The model is the code that layers over top of the controller and makes a connection between the view and the controller. The model has some background code as well, but it uses functions that can be utilized in the views. The model usually displays most of the site or application-wide layout to the user.
The view is code that is specific to the page of which you are viewing. The view will display the page-specific layout to the user.
Is MVC specific to a programming language?
No it is not! MVC is an organizational technique, which is not limited to any language. I have seen these done in C++, C#, and PHP before, but MVC can be done in many other languages.
Any examples of MVC?
Of course! Here are a couple MVC exmples:
- NerdDinner: http://nerddinner.codeplex.com/ – Uses C# MVC
- Panique MVC: https://github.com/panique/php-mvc – Uses PHP MVC
What are your opinions on MVC? Is this a good framework to use for text-based games? Why or why not?
That’s all for now, until next time…keep that tech gear ticking.
~Goliath7470
