5 Pages
1324 Words
Introduction of Scala Eclipse Programming Assignment
Get free written samples from subject experts and Assignment Writing in UK.
The concerned work provides an in-depth analysis of various aspects of designing a game which is based on a grid having coins and walls present in it. The game has been designed using Scala in an eclipse environment. The concerned work provides a detailed view of the various aspects of game development in the given environment. The work has been divided into different sections such as an introduction, description of the game and conclusion. The work covers the explanation of the different aspects which are related to the concerned game and how different classes have been formed to perform the required operations in an adequate manner.
Description of the Game
The game consists of a grid of size 10*10 which is shown in the figure. There are two dimensions of the given game which are x and y as can be seen in the figure. As can be observed from the figure below, the position of player 1 is represented as p and there are different numbers of walls present in the system which are represented by w. The complete system has been shown in the form of x and y coordinates (Sajina and Orehovacki, 2018). In the system, the player can either move left and right along the x plane or up and down along the y plane. The complete game has been designed by creating a class called Game. The position of the player is stored in two variables called positionX and positionY. The game has a constraint that the player cannot move diagonally in the given system.
Game View
In the given system, there is a variable called field which is a type of Array[Array(int)] which is a grid and it has three types of values stored in it which are -1 which means an empty cell, a wall which is given by 0 and a coin containing a positive number. In the given system, if the player encounters a wall, then it is unable to move further in the system and if the player has moved right once, then it will be unable to move again in the right direction (van Dam, 2018). In the given work, symbols have been used for showing empty cells, w is used for showing walls and coin is used for showing positive numbers (Shen et al. 2021). The coins present in the system provide points to the users. If a player encounters a particular coin, then the point is given based on the value of the particular coin. After this action, the place becomes empty (-1). This code has been included in the checkpoint method in the given system.
Codes
(Source: Self-Created)
The presence of walls and coins in the system is determined using the if statement. The current position of the player can also be saved in saveX and saveY using the function called save(). If the player continues to move in the same direction, the distance that is being covered is saved by checkCoins methods. If the player reaches the 9th position in the system, then the game is reset to -1, -1 which indicates that no position in the system has been saved and all the coins that are present in the system (Fayed et al. 2020). After the completion of the game, the final score of the player is calculated based on the number of coins that are being earned by them. The walls present in the system are counted as covered positions but the player cannot move through them.
The method move present in the system takes the input as up, left, down and right which are to be encoded by letters w, a, s, d. There is another method called suggestMove which returns the string in the same manner as the move method. This method moves the player from its current location to a new one which is x,y (Politowski et al. 2021). If a move is performed in the system, which leads to an encounter with a wall in the path, then a move which is the reverse of the specified move would be executed. If the reverse move also encounters a wall, then this step returns an empty string (Krishnamurthy and Serrano, 2021). The game thus provides a very simple view in which various aspects of point collection and movement of players in the given grid have been explained in a clear manner. With the help of this work, a proper understanding of the various aspects of game designing using the Scala in the Eclipse environment can be obtained (Margaria et al. 2021). Therefore, a proper path has been shown by forming different classes and methods with the help of which the functions of the game can be performed adequately.
Conclusion
The concerned work provides an in-depth analysis of various aspects of game development using Scala in the Eclipse environment. The work contains the description of a game in which a grid system of 10*10 is present and a player starts from the 0th position and moves in the grid to earn points. There are also walls present in the system which block the movement of the player and then the player is required to move on a different path. In this way, all the actions present in the system are performed and points are earned by the player. The work has been done by forming numerous numbers of methods and a class called Game. The concerned work provides a very detailed analysis of designing a simple game with the help of which, different operations as per the requirements can be done. The game can be played in a very simple manner as the players are only required to move in four directions which are up and down or left and right. The players along the line of movement collect points until the end. After this, the summation of the score is done and whichever player scores the maximum points becomes the winner. These are the required functions that have been included in the given work.
References
Fayed, M.S., Al-Qurishi, M., Alamri, A., Hossain, M.A. and Al-Daraiseh, A.A., 2020. PWCT: a novel general-purpose visual programming language in support of pervasive application development. CCF Transactions on Pervasive Computing and Interaction, 2(3), pp.164-177.
Krishnamurthy, J. and Serrano, M., 2021, September. Causality Error Tracing in HipHop. js. In 23rd International Symposium on Principles and Practice of Declarative Programming (pp. 1-13).
Margaria, T., Chaudhary, H.A.A., Guevara, I., Ryan, S. and Schieweck, A., 2021, October. The interoperability challenge: building a model-driven digital thread platform for CPS. In International Symposium on Leveraging Applications of Formal Methods (pp. 393-413). Springer, Cham.
Politowski, C., Petrillo, F., Montandon, J.E., Valente, M.T. and Guéhéneuc, Y.G., 2021. Are game engines software frameworks? a three-perspective study. Journal of Systems and Software, 171, p.110846.
Sajina, R. and Orehovacki, T., 2018, May. User experience evaluation of 2D side-scrolling game developed using Overlap2D game editor and LibGDX game engine. In 2018 41st International Convention on Information and Communication Technology, Electronics and Microelectronics (MIPRO) (pp. 1580-1585). IEEE.
Shen, L., Chen, X., Liu, R., Wang, H. and Ji, G., 2021. Domain-specific language techniques for visual computing: a comprehensive study. Archives of Computational Methods in Engineering, 28(4), pp.3113-3134.
van Dam, A., 2018. Reflections on an introductory CS course, CS15, at Brown University. ACM Inroads, 9(4), pp.58-62.