TRIBHUWAN UNIVERSITY INSTITUTE OF ENGINEERING PULCHOWK CAMPUS THE C-MAN A Project Report On Object Oriented Programming Date: 2070-12-12 Submitted By: Submitted to: Bishal Heuju: 069BEX409 Bishal Lakha: 069BEX410 Dipkamal Bhusal: 069BEX414 Department of Electronics and Computer Engineering Acknowledgement We would like to express deepest gratitude to the Department of Electronics and Communication Engineering of IOE Pulchowk campus for providing us the opportunity to work on an object oriented project, which will likely to be very helpful for shaping our knowledge and career. We would like to express our deepest thanks to our subject teacher Dr. Basanta Joshi for his suggestions and influences. Though we couldn't mention all the names, we would like to thanks all the members of SDL forum who helped to solve our queries regarding SDL graphics and its implementation. Contents 1. Objectives 2. Introduction 3. Application 4. Literature survey 5. Existing System 6. Methodology 7. Implementation 1. Block diagram 8. Results 9. Problem Faced and Solutions 10. Limitations and future enhancement 11. Conclusion and recommendations 12. References Objectives 1. To gain experience on a Game Development in OOPs using C++. 2. To understand the Game Development Cycle and Game Logics. 3. To enhance our understanding of OOPs features using C++. 4. To learn to implement the features of OOPs in a project. 5. To learn about problems that can arise when creating a project. 6. To learn to tackle with the problems and conflicts accordingly. Introduction The C - Man is a Simple Role Playing Game (RPG). RPG is a game in which player assumes the roles of characters in a fictional setting. In this game, players control a character or a team who undertake quests, and may include capabilities that advance using statistical mechanics. RPG consists of events, characters and narrative structure. All RPGs differ in their storyline. The story is what makes the RPG successful. A RPG with complex storyline, characters and adventures is extremely difficult to develop and requires a large number of developers. Storyline The game is about a man searching and then punishing an evildoer who has been a continuous source of misery for the people. The player of the game will assume the role of the protagonist and he will need to find out where the antagonist is. For that he should talk with the people of that place and assure them of ending that chaos. And the main task is to face the villain, fight with him and kill him. Features of the game: The primary features of the game are: 1. Story development 2. Character interaction 3. Sound 4. Camera focus selection 5. Both mouse and keyboard control 6. Combat State Application: 1. Entertainment: This game is for fun. Gamers can enjoy quality RPG game playing experience while playing this game. 2. Game making: The codes of this game provide basic frame work for developing other games. Manipulating certain portion of code can lead to the creation of new games. Literature Survey: About RPG: A role-playing game (RPG) is a game in which players assume the roles of characters in a fictional setting. Players take responsibility for acting out these roles within a narrative, either through literal acting or through a process of structured decision-making or character development. Actions taken within many games succeed or fail according to a formal system of rules and guidelines. Types: There are several forms of RPG. The original form, sometimes called the tabletop RPG, is conducted through discussion, whereas in live action role-playing games (LARP) players physically perform their characters' actions. In both of these forms, an arranger called a game master(GM) usually decides on the rules and setting to be used and acts as referee, while each of the other players plays the role of a single character. Several varieties of RPG also exist in electronic media, such as multi-player textbased MUDs and their graphics-based successors, massively multiplayer online role-playing games (MMORPGs). Role-playing games also include singleplayeroffline role-playing video games in which players control a character or team who undertake quests, and may include capabilities that advance using statistical mechanics. These games often share settings and rules with tabletop RPGs, but emphasize character advancement more than collaborative storytelling. Despite this variety of forms, some game forms such as trading card games andwar games that are related to role-playing games may not be included. Role-playingactivity may sometimes be present in such games, but it is not the primary focus. The term is also sometimes used to describe role play games and exercises used in teaching, training, and academic research. Single-player Single player role-playing video games form a loosely defined genre of computer and console games with origins in role-playing games such as Dungeons & Dragons, on which they base much of their terminology, settings, and game mechanics. This translation changes the experience of the game, providing a visual representation of the world but emphasizing statistical character development over collaborative, interactive storytelling. Multi-player Online text-based role-playing games involve many players using some type of text-based interface and an Internet connection to play an RPG. Games played in a real-time way include MUDs, MUSHes, and other varieties of MU. Games played in a turn-based fashion includeplay-by-mail games and play-by-post games. Massively multi-player online role-playing games (MMORPGs) combine the large-scale social interaction and persistent world of MUDs with graphic interfaces. Most MMORPGs do not actively promote in-character role-playing, however players can use the games' communication functions to role-play so long as other players cooperate.The majority of players in MMORPGs do not engage in role-play in this sense. Computer-assisted gaming can be used to add elements of computer gaming to inperson tabletop role-playing, where computers are used for record-keeping and sometimes to resolve combat, while the participants generally make decisions concerning character interaction. Where Our Game Stands? So basically, The C-Man is single player offline role-playing game in which players control a character that undertakes quests, deal with NPCs and combat with villains. Existing system Role Playing Games (RPGs) originally existed as a Tabletop and pen-and-paper games which were conducted through discussion in a small social gathering. Later on, Tabletop RPGs were translated into electronic formats introducing computer RPGs. One of the earliest RPG on a computer was Dungeons n Dragons which was translated from Tabletop RPG. Being inspired by Tabletop and pen-and-paper RPGs, other computer RPGs such as Dragon Quest and Final Fantasy were launched which gained a massive popularity. With the increase of popularity of RPGs, later on MMORPGs (Massively Multiplayer Online RPGs) were developed which are now gaining popularity. They include a large number of players and is played online through internet. Methodology The game is created using C++ which allows us to use Object Oriented Programming (OOP) and SDL2.0 for graphics purpose. Object oriented approach is used to solve a particular problem such as handling characters, backgrounds, handling input, generalizing the loading of texture etc. Object Oriented Approaches: The few principle concepts of object-oriented programming used in making this game: Class: When you define a class, you define a blueprint for an object. This doesn't actually define any data, but it does define what the class name means, that is, what an object of the class will consist of and what operations can be performed on such an object. Use in the game: More than twenty classes were made for various purposes. For example ‘HeroFighter’ class and ‘VillianFighter’ class were made to define the features of hero and villain during fight. Object: This is the basic unit of object oriented programming. That is both data and function that operate on data are bundled as a unit called as object. Use in the game: Required objects of various classes were made. Abstraction: Data abstraction refers to, providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the details. For example, a database system hides certain details of how data is stored and created and maintained. Similar way, C++ classes provides different methods to the outside world without giving internal detail about those methods and data. Use in the game: Characters of our game have a lot of properties that seem to be common with each other but still are different in handling. So these are hided from rest in their respective class. Encapsulation: Encapsulation is placing the data and the functions that work on that data in the same place. While working with procedural languages, it is not always clear which functions work on which variables but object-oriented programming provides you framework to place the data and the relevant functions together in the same object. Use in the game: In classes, data and functions were encapsulated. Inheritance: One of the most useful aspects of object-oriented programming is code reusability. As the name suggests Inheritance is the process of forming a new class from an existing class that is from the existing class called as base class, new class is formed called as derived class. This is a very important concept of object-oriented programming since this feature helps to reduce the code size. Use in the game: Inheritance was widely used. The base class ‘GameObject’ was inherited by six other classes. Among them ‘Fighter’ class and ‘CharacterGameObject’ class were again inherited by two other classes. Polymorphism: The ability to use an operator or function in different ways in other words giving different meaning or functions to the operators or functions is called polymorphism. ‘Poly’ refers to many. That is a single function or an operator functioning in many ways different upon the usage is called polymorphism. Use in the game: The pointer of base class was used to call the functions of derived classSimilarly, ‘GameObject’ was declared virtual class. Overloading: The concept of overloading is also a branch of polymorphism. When the exiting operator or function is made to operate on new data type, it is said to be overloaded. Use in the game: Operator overloading was done to calculate sum, differences, multiplication between the objects of Vector2D class. Uses of SDL: Simple DirectMedia Layer (SDL) is a cross-platform multimedia library created by Sam Oscar Latinga. It provides low-level access to input (via mouse, keyboard, and gamepads/joysticks), 3D hardware, and the 2D video frame buffer. SDL is written in the C programming language, yet has native support for C++. The library also has bindings for several other languages such as Pascal, Objective-C, Python, Ruby, and Java. We used SDL for: Loading Textures Sound management Animation Dialogue Collision detection Implementations: System Block Diagram: Initialize the Game Handle Inputs Do Physics Render and Display Clear Memory and Exit Inheritance diagram: GameObject MapGameObject MenuButton CharacterGame Object HeroCharacter NPCCharacter Fighter HeroFighter VillianFighter Results: Problems Faced and Solutions: Throughout the months long programming and game developing process we had a lot of problems and setbacks. The foremost hurdle was the inadequate resources for developing an RPG. With the start of programming, we had a lot of errors while using the SDL functions in an Object Oriented approach. Logic for our certain feature did not go well in the beginning. It was a hit and trial method to develop a rigid common logic for various game features. Discussing with our project members was always beneficial for our game development. We could generate ideas and implement it later on. Similarly online forums, tutorials were a lot helpful for our works. Limitations and Future Enhancements: Limitations: There are a number of limitations in our game despite of the months long learning and programming. Our game is not long enough and only consists of one level. So user may find the story development insufficient. Due to insufficient time we couldn’t incorporate health icons, weapons and power. Future Enhancements: For a RPG game to gain popularity and success in the current competitions, it must have a strong story development, plot and characters interaction. If possible, we would try to create a new plot for the characters, add more conversations and interactions. Similarly, it will be better if we can add few levels and manage its difficulty to make it more entertaining. References a. b. c. d. e. www.lazyfoo.com www.youtube.com www.rpgmakers.com SDL Development programming by The Secrets of OOP in C++