Chong-wei Xu
Kennesaw State University, Kennesaw, GA, USA
ISBN 978-3-319-72885-8 e-ISBN 978-3-319-72886-5
https://doi.org/10.1007/978-3-319-72886-5
Library of Congress Control Number: 2018933068
Springer Nature Switzerland AG 2018
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, express or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
Developing innovative teaching approaches have been one of the important topics in developing computer science curriculum. An innovative teaching approach has two important aspects. One is that the teaching method should be able to let students see the effects of their programming efforts immediately so that programming will engage students and attract their attention; the other is that the contents of materials would have a connection with the real world, especially with the industry setting.
In order for students to easily see the effects of their programming efforts, many different approaches have been developed, such as the robot approach, the multimedia approach, the gaming approach, the virtual reality approach, and the like. For connecting with the real world, the more industry-oriented materials have emerged. In order to support these new teaching approaches, we would like to develop teaching materials that emphasize on visualization and animation with practical flavor. Hence, video game development is our choice.
A video game is an integration of humanity, mathematics, physics, arts, artificial intelligence, graphics, visualization, animation, sounds, images, programming, and so on. Therefore, discussing all these fields in the video game context will further encourage students to have a passion for sciences, especially for mathematics and physics. In addition, game industry is developing rapidly. Video game development connects with industry setting ever more so than before. The size and complexity of a video game can be tailored for students to handle and a video game can be further extended by imagination without boundaries. For implementing a video game, all features of object-oriented programming (OOP) and component-oriented programming (COP) can be applied. Consequently, video game development is not only for creating games with fun but also a well pedagogical method for teaching OOP and COP.
Video game development is a vast topic covering many areas. We would like to focus ourselves to the 2D video games with the purpose of teaching OOP programming technologies. Video game development is challenging because it is really a problem solving process. It really is a great topic for training brainstorming and logic thinking. Meanwhile, learning programming is by doing. Consequently, the key approach for solving problems is practice. As people say, Practices make perfect. Fortunately, video games have a special key feature: interactivity. Interactively talking with a video game and interactively developing and ultimately playing the developed video game will engage students imagination and keep their attention fully.
Specifically, this book intends to teach Java programming through the developments of video games. That is, learning Java programming is the goal and video games are the topic. In addition, the book tries to build up software architecture for video games so that after students finish this book, they will be able (1) to familiarize themselves with the Java language for programming; (2) to develop a general architecture for video games; (3) to increase the ability forward analyzing problems and solving problems. Usually games are decorated with many beautiful images. In order to reduce the complexity, the book is not going to use many images, but concentrates on the technical aspects of programming.
Organization of the Book
The book has 24 chapters that are divided into four parts.
Part I Foundation with Games In-Text: Chaps.
Java is an object-oriented programming language. That is, the language takes objects as its building units and through the interactions among objects to perform a certain function. A video game is a program in general, which consists of multiple objects. A video game always has an interesting story in particular, which is full of dynamic interactions among objects. Therefore, Java language features are very suitable for realizing video games and video games will fully demonstrate the features of Java language. This part introduces the concepts and essential programming elements of Java language through examples of games-in-text.
Chapter Java Programming and Game Development: A project HelloWorld
Video games are programs. The interesting and engagement of game programming would release tedious feeling of the program writing. Games fulfill objects and interactions among objects that fit with the Java object-oriented features. Furthermore, game promotes experiential learning, inquiry-based learning, self-efficacy, goal setting, and cooperation. All of these encourage us to study Java through the construction of games.
Chapter Basics of Java Programming: A Project PrintXmasCard
The simplest program HelloWorld is developed to introduce the fundamental concepts and practices of variables, methods, and classes. And then, the project PrintXmasCard demonstrates user input mechanism, file accesses, and exception handling. Further, primitive data types are summarized and the built-in class String is taken as an example of reference data type. These essentials support the basics of Java programming.
Chapter OO Programming Principle: A Game In-Text GuessInt
Games in-text are simple games since they deal with Strings only. A game GuessInt is played by two players. An initializer thinks of an integer in mind; a player guesses what it is. Java operators are employed to form assignment, if-then-else, and loop statements to support the actions of the initializer and the player in the format of methods. Meanwhile, the reactions among methods accomplish the communications between them.