Java Game Programming – Ouch!

Project-based learning approach (Google) : PBL

PBL video : https://youtu.be/hnzCGNnU_WM

Topic or Learning Goal: Create a PC game using Java

Intro: The goal this summer was to overcome my fear a game programming. I teach Python and Java and I wanted to develop a “How to develop a PC game” resource guide for teachers and students. The task of breaking down, chunking or scaffolding the software design/development process (SDP) for programming a PC game can be overwhelming. I discovered that a “blended learning” approach worked best; reading articles on game design, researching game programming concepts like collision and physics engines, watching YouTube videos (ex. Mr Java Help) and reviewing tutorials featuring source code and OOP design (ex. Zetcode). Students play computer and video games and that creates an authentic learning opportunity for computer science educators. Some will be motivated by the “fun factor” to overcome complexities of programming a game.

I have spent a lot of time reading the source code of other game programmers. By restricting the study to programmers who use object-oriented design, I began seeing some patterns that may be helpful to teachers. I recommend starting with the Java 2D games tutorial on Zetcode.com website. I would spend time studying and reverse engineering code for Collision detection (Alien and Craft space shooter game) and Snake (similar to Nibbles). Next, I would take the time to watch all of the Java 2D side scrolling videos on Mr Java Help’s Youtube channel (https://youtu.be/NIUKHHVF9ek ). He does a nice job of demonstrating the coding skills required to assemble a game. A good task for teachers and students is to use the source code and Mr Java Help’s comments during the video to learn and to insert comments throughout the program listing to document the learning (ex. he mentions how casting (polymorphism) is used in graphics (g => g2d)). Students should take notes while watching the video! A metacognative approach to video study could help students chunk the learning.

Game design involves programming objects, GUI, media assets (ex. graphics, audio files, sprites), events, collision detection, perhaps the use of a physics engine and other design elements. I believe a teacher can introduce some of the gaming concepts to a whole class but may want to explore the use of project-based learning (PBL) to explore game design further with the group.

Next, I started to Google the Internet for “game design templates” and not surprisingly people are using said tools to organize the software design process. Game programming offers a rich learning experience for teachers and students and can give them the confidence to approach other challenging programming tasks (ex. Big Data, analytics, connecting the mysql databases using Connector/J or Derby).

Finally, it is more important to try than to succeed. Are we sheep or goat programmers (ex. double hump)? The game may not work or the students may get frustrated with the levels of abstraction but it is the journey that will support growth and ensure that students have a positive experience with coding. It can be a nightmare to troubleshoot code if it gets too involved so perhaps we need to consider “requirements” for success. Maybe a student will get a Level 3 for moving around a sprite, a Level 4- for demonstrating collision, a Level 4 for some clever innovation and a Level 4+ for demonstrating talent in game design. Talent can be defined as getting it done. A gifted programmer has the talent to juggle many balls at once (ex. OOP design, GUI, interface, sprites, math theory in game design (ex. collision), threads, compiler nuances and so on) and can complete a program.

TOC
– What is the world (ex. background or map)?
– What characters or sprites are required? Can we use Alice to introduce game design?
– What is the game play? How do we score? How do we achieve the next level? How do we keep the user engaged?
– How does collision work in the game? Do the collisions trigger scoring, reduction of health or response to world?
– How do the events of keystrokes and mouse movements affect animation (ex. dx, dy)?
– How do we use code to build the GUI (ex.frame, panel) to support the game? In most of the games the coders use Frame, Board and sprite classes to fire the game. The Board class contains the panel and most of the widgets that we see when game is running. What programming structures are used to manage animation (loops, decision, recursion)?
– Use the game design unit as an opportunity to discuss the software development process (SDP) and software development life cycle (SDLC).
– How is designing a game similar to writing a movie script? How can we shape computer science learning to address all learners (ex. left vs right brain, males and females)?

http://www.edu4java.com/en/game/game2.html

http://zetcode.com/tutorials/javagamestutorial/

https://youtu.be/NIUKHHVF9ek
https://www.youtube.com/watch?v=NIUKHHVF9ek

 

Java-Logo

Published by

kmcdaniel

Content is king!