Java Resources. CSC2007 Code Repository (including NetBeans and Java 7 setup)

Similar documents
Introduction to IntelliJ

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

Introduction to Computation and Problem Solving

Eclipse Environment Setup

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

User Manual. Introduction. About this release. For existing MacroScope users

Embedding Graphics in JavaDocs (netbeans IDE)

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

Running Java Programs

Basic Texturing Tutorial by Gary Wu

Module Road Map. 7. Version Control with Subversion Introduction Terminology

Setting up your Computer

Code::Blocks Student Manual

The first program: Little Crab

Introduction to Windows

NetBeans IDE Java Quick Start Tutorial

Auslogics BOOSTSPEED USER MANUAL. auslogics.

Recording for the Blind Part One

Purpose. Why use Java? Installing the Software. Java

Checking Out and Building Felix with NetBeans

Designing Your Teacher Page. Medora Community School Corporation

Without further ado, let s go over and have a look at what I ve come up with.

Getting Started. In this chapter, you will learn: 2.1 Introduction

IAT 445 Lab 10. Special Topics in Unity. Lanz Singbeil

Getting Up and Running

Lab 2. CSE 3, Summer 2010 In this lab you will learn about file structures and advanced features of Microsoft Word.

Getting Started with Eclipse/Java

Assignment 1. Application Development

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

Introducing Thrive - The Ultimate In WordPress Blog Design & Growth

Web-enable a 5250 application with the IBM WebFacing Tool

Pong in Unity a basic Intro

Introduction to Alice. Computer Science for High School (CS4HS)

How to Archive s in Outlook 2007

Code::Blocks Student Manual

Javadocing in Netbeans (rev )

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

Getting Started (1.8.7) 9/2/2009

Windows XP. A Quick Tour of Windows XP Features

Handout Objectives: a. b. c. d. 3. a. b. c. d. e a. b. 6. a. b. c. d. Overview:

POOSL IDE Installation Manual

Making use of other Applications

Java Program Structure and Eclipse. Overview. Eclipse Projects and Project Structure. COMP 210: Object-Oriented Programming Lecture Notes 1

FrontPage 98 Quick Guide. Copyright 2000 Peter Pappas. edteck press All rights reserved.

Setting Up the Development Environment

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod

Table of Contents. 1 Introduction Downloads Eclipse SDK Installation Eclipse Workspace Eclipse Preferences...

SOS 2009 User Manual. Student Basics. Alpha Omega Publications

Installation Guide - Windows

This is the opening view of blender.

Download and Installation Instructions. Java JDK Software for Windows

Part 1: Understanding Windows XP Basics

Student Success Guide

Scorebook Navigator. Stage 1 Independent Review User Manual Version

Adding Existing Source Code in NetBeans CS288, Autumn 2005 Lab 002

Storing Your Exercise Files

Photoshop World 2018

Code Check TM Software Requirements Specification

Blackfin Online Learning & Development

Tabbing Between Fields and Control Elements

GIS LAB 1. Basic GIS Operations with ArcGIS. Calculating Stream Lengths and Watershed Areas.

Mehran Sahami Handout #5 CS 106A September 26, 2018 Downloading Eclipse

CHECK OUT THESE CHANGES IN BUILD 1703

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

IntelliJ IDEA Getting Started Guide for FIRST Robotics Competition

Configuring Directories in an ICVERIFY Master / Substation Setup

1 Installation (briefly)

Lutheran High North Technology The Finder

Section 1. System Technologies and Implications. Modules. Introduction to computers. File management. ICT in perspective. Extended software concepts

SecureAssist Rulepack Configurator v User Guide December 2015

Introduction to Events

Dreamweaver Handout. University of Connecticut Prof. Kent Golden

Dialog XML Importer. Index. User s Guide

FILE ORGANIZATION. GETTING STARTED PAGE 02 Prerequisites What You Will Learn

Authoring World Wide Web Pages with Dreamweaver

EvaluNet XT v1.2. Setup Guide

Architectural Engineering Senior Thesis CPEP Webpage Guidelines and Instructions

Creating a Double IK Chain in Lightwave

Choose OS and click on it

- 1 - Handout #33 March 14, 2014 JAR Files. CS106A Winter

The purpose of this tutorial is to introduce you to the Construct 2 program. First, you will be told where the software is located on the computer

Scorebook Navigator. Stage 1 Independent Review User Manual Version

Moving Materials from Blackboard to Moodle

COS 116 The Computational Universe Laboratory 10: Computer Graphics

Chapter The Juice: A Podcast Aggregator

Minerva. Quick Start Guide

Chapter One: Getting Started With IBM SPSS for Windows

How to Get Started. Figure 3

Setting up A Basic Scene in Unity

Digital Content e-reader Features Overview

The MPC Renaissance & MPC Studio Bible - Demo Tutorial (For MPC Software 2.x)

How to get started with Theriak-Domino and some Worked Examples

Mehran Sahami Handout #5 CS 106A September 27, 2017 Downloading Eclipse

NEXTGEN PAQ (PROVIDER APPROVAL QUEUE) DEMONSTRATION

Installation Guide - Mac

Module 1: Introduction RStudio

Prototyping a Swing Interface with the Netbeans IDE GUI Editor

Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity

Creating a multilingual site in WebPlus

Introducing Your Sun Desktop

Transcription:

33 Java Resources CSC2007 Code Repository (including NetBeans and Java 7 setup) The code repository is, well, a repository of code. Title aside, the repository provides a number of example programs and code snippets that you can study, use, adapt, extend, etc. basically you are free to employ the code in whatever way you want. The idea behind the repository is to provide a number of example classes that illustrate some of the game programming concepts you will explore during the course. You can also employ the code within your project (if desired), e.g. using one of the example programs as a springboard from which to develop your own game. The purpose of this document is twofold. Firstly, the steps needed to install and setup NetBeans and Java will be defined. Once setup, you will be able to easily view the repository and create new projects of your own (I do recommend that you develop your game using NetBeans; it is a very nice and powerful integrated development environment - IDE). Secondly, the structure and core classes within the repository will be defined. I appreciate that this might be the first time you ve got your hands dirty installing and configuring a Java environment. It will be a useful experience (and hopefully not too traumatic). If you do run into problems that you can t resolve please do contact me (contact details can be found at the back of the Module Handbook).

Software Requirements You will need the following: Latest version of Java SE bundled with NetBeans (about 50MB in size) available from http://www.oracle.com/technetwork/java/javase/downloads/index.html At the time of writing this is JDK 7 with NetBeans 7.0. The CSC2007 Code Repository available from the CSC2007 course page on Queen s On-line Java and NetBeans Installation / Setup Please note: If you are using the machines available within the First Floor BCB Lab then you don t need to worry about installing either NetBeans or Java (it is already installed) and can skip forward to the next section. In other words, steps and 2 are really only intended for you to install the software on your own machine. Step : Install JDK 7 with NetBeans bundle (the default installation options will likely suffice) Step 2 (Optional): Check that NetBeans is using JDK 7 Start NetBeans Once NetBeans has loaded, select the Tools menu and then pick the Java Platforms option. A dialog box will appear. Confirm that JDK.7 is the default platform that will be used by NetBeans (we ll get onto how we can change this shortly). If for some reason JDK.7 is not listed, you can add it by clicking on the Add Platform button and navigating to the directory where JDK 7.0 was installed. Click on the JDK 7.0 folder and then hit Next (Aside: on my computer this was C:\Program Files\Java\jdk.7.0) Click Finish 2

CSC2007 Code Repository Installation Step : Download and unzip the code repository from Queen s Online (for example onto your own computer or onto a memory key if you are going to use the computers in the lab). Step 2: Start NetBeans. From the File menu, select Open Project. Step 3: Navigate to where you unzipped the code repository. Go inside the Code Repository folder. Within this you should see a total of five projects that you can open. To open a project, click on its name (you don t need to go inside the project folder) and once the folder is highlighted, click on the Open Project Folder button. You should open all five projects (i.e. when one project has been opened, repeat this step for the next project although, have a read of Step 4 first!) Step 4: Important: The first time you open the project you may get an error message about conflicts in the project. If you do get an error, it simply means that the JDK6.0 installed name and directory needs to be updated (i.e. the project comes along with *my* JDK6.0 locations, which may not be the same on the machine you are using). To correct this, right click on the project name in the Projects window (e.g. Core, ZoMA, etc.). At the bottom of the pop-up menu, click on Properties. This will open a dialog. Click on the Libraries category and then select Java.6 JDK to be the platform for this project. Problem solved. Step 5: Before you can run any programs within the repository you will need to build the project (i.e. compile the Java files, copy the image and sound assets into the correct build directories, etc.). In order to build the project, select the Clean and Build Main Project option from the Build menu. If all goes well, you should see something similar to the following message BUILD SUCCESSFUL (total time: 4 seconds). 2

What s within the Code Repository? When all the CSC2007 projects have been opened within NetBeans you should be able to see a total of five different projects. Each project can be expanded (click on the + icon) to show the Source Packages which, in turn, can be expanded to show the packages within the project (this is where our code and graphics, etc. will reside). Below, I ve provided a brief overview of the contents of each project over the course of the module you will hopefully become familiar with a lot of the code that is contained within the repository, although please don t worry if all of this appears somewhat daunting at the moment I purposefully wish to provide you with exposure to larger, more complex programs that you will likely have encountered during Level one modules. Aside: In the following screenshots I ve setup NetBeans to view packages in a tree-like manner (which helps when the project is large). If you wish to use this view, right click on the Projects tab and then select View Java Packages as: and finally select Tree. The Core Project The Core project does not contain any runnable programs, instead it provides a number of packages that hold the core classes which the example games build upon. As such, it is better regarded as a library of classes and methods that can be used to help build a game. Lectures will explore different aspects of the core classes from both algorithmic and functional perspectives. An overview of the different packages can be found below: game.assets this package contains all the various graphical and sound asset classes, including an asset loader and asset manager game.engine this package contains the game engine and other key classes, e.g. game layer, game object, etc. game.physics this package contains an impulse-based physics simulation that can enable game objects to collide and respond to collisions in a believable manner. game.geometry - this package contains a small number of classes that can be used to describe the geometry of a game object (the geometry is used to test for overlap between two game objects and is also used within the physics simulator). game.components - this package contains a number of useful extended game objects that can be used for providing buttons, textual elements, etc. 4

The TutorialsDemosAndExtras Project As you will doubtlessly pick-up from the unsubtle name of this project, the project contains a number of tutorials, demos and extra bits and bobs. In particular: demos.cpuandgpuloading This package provides a number of simple programs intended to measure timing and CPU/GPU performance. demos.graphicalassetdemos / demos.sound This package contains a number of programs that illustrate some of the graphical and sound asset classes contained within the core.assets package. 5

extras.physicsdemo This package provides a number of physics based demos of the classes contained within the core.physics package. The physics code is based on that developed by Erin Catto (http://www.gphysics.com/downloads) tutorials.isometricmap / tutorials.platformer / tutorials.topdownracer / tutorials.topdownscroller This package holds a number of tutorials that include four simple and common 2D game types: isometric tiled games, topdown racing car game, top-down scrolling shooter and side-on platform game. The games are really only intended to provide an illustrative starting point towards constructing the game type (other faster approaches exist). The code contained within the tutorial packages should be read in conjunction with the associated tutorial document which explores some of the issues involved in building the game. 6

The SpaceInvaders Project Surely you don t need to be told what s within this project? Suffice to say, we will be exploring Space Invaders within the lectures from the perspective of how we might go about designing and implementing the game. The ZoMA Project ZoMA is one of two larger example games provided within the code repository. The game, should you wish to classify it as a game, involves testing and measuring the player s mouse reaction, aiming and tracking skills. From an educational point of view, the code hopefully provides some examples of GUI construction and a design that facilitates the introduction of new test types. 7

The HappyFace Project The HappyFace project is the largest project contained within the repository (by a good margin). The game is a platformer that makes extensive use of destroyable scenery. A level editor is also included that can be used to create new levels. From an educational perspective the game provides an example of the physics classes in operation and a setup that involves loading in a number of different game levels. 8

Running Programs from the Code Repository A NetBeans project can contain any number of different Java classes with main methods, i.e. runnable Java programs. NetBeans will indicate that the file is runnable by including a small green arrow on the file icon. In order to execute the file, right click on the filename and then select Run File from the popup menu. As an aside: Each project can also have one main class (which will be automatically executed if you select the Run Main Project menu option from the Run menu). You can change the main class by right clicking on the project name, selecting Properties and then selecting the Main Class from within the Run tab. You will need to do this if you wish to setup your game so it can be automatically run from a JAR. Getting to grips with NetBeans My best advice is to start playing with NetBeans it s a proper IDE which means that it s both very powerful and will have an associated learning curve. However, once you do get to grips with it you will find that Java development becomes a lot more straightforward using the built in tools that NetBeans provides. You can view a Quick Start Guide by clicking on the Help menu. Additionally, a more comprehensive user guide is available (also accessible from http://www.netbeans.org/kb/index.html) Based on the feedback from last year, I ve included some hints and advice below that should hopefully resolve some of the common problems: Build/ Clean and Build : Whenever you clean and build a NetBeans project a build folder is created (in the same directory that contains the src folder). All Java files contained with the source folder are compiled and their class files copies across into a corresponding folder in the build directory. Any images, sounds, text files, etc. contained in the source folder are also copied across into the build folder. Hence, whenever you add new images, etc. into one of your source folders you should do a Clean and Build to make sure that the new image, etc. gets copied across into the build folder. If you don t, then whenever your code goes looking for the image, etc., it won t be able to find it! 9

JVM Parameters: The Java runtime (i.e. the thing that actually runs your Java programs) has a number of configuration options that control how the JVM uses memory, hardware, etc. You might hope that the default configuration options will suffice however, this may not be the case. All of the projects contained within the code repository set a number of JVM options. I ve provided details of some key options below: -Xms32m - Set the initial heap size to 32MB -Xmx024m - Set the maximum heap size to GB -Dsun.java2d.opengl=true - Force Java to use OpenGL rendering -Dsun.java2d.d3d=true - Force Java to use DirectDraw rendering You can view/set the JVM parameters of a project within NetBeans by right clicking on the project, then selecting Run and updating the VM Options field. Important: You should try setting both the OpenGL and DirectDraw options (although only one at a time!) to see which provides better performance. This is particularly true if you are using Windows 7/Vista where driver compatibility and the more stringent driver model may entail that performance differs considerably between the two options. Hint: Whenever you create a new project, copy across the settings used in another project (e.g. from one within the code respository). Java and Vista: You might experience some additional difficulties trying to use full screen exclusive mode (FSEM) if you are running Windows 7/Vista (this will depend on the particular type of video card / driver version you are using). If this is the case, firstly try changing between OpenGL and DirectDraw rendering to see if this helps. If neither works, then you will probably have to disable the Aero interface when you want to run in FSEM. You can turn the Aero interface on and off as follows: Right click on the desktop and then select Personalize Select Theme from the window which appears Change the theme to Windows Classic and then hit Apply Once you have finished with FSEM, you can redo the steps and select Windows Vista to turn Aero back on. Libraries: I ve been a bit naughty with the projects contained within the code repository. As indicated in the text, the Core project should really be regarded as a library that can be imported and used within other projects. It s actually very easy to do this within NetBeans, however, I ve opted to include a full copy of the contents in each project, i.e. each project has its own copy of the core game packages. Why? Well, it makes it easier to pursue the code as you see the complete codebase. 0

Core Game Class Structures I ve included UML class and composition diagrams below for the core packages Hopefully it will help direct any investigation of the classes. Asset GraphicalAsset SoundAsset MidiAsset SoundAssetClip SoundAssetAssembly ImageAsset ImageAssetRibbon ImageAssetSequence ImageAssetTile DrawnAssetMessage AssetLoader GameInputEventManager GameStatisticsRecorder AssetManager Asset 0...* GameObjectCollider GameEngine Box Circle GameObjectSerialiser...* 0...* GameLayer GameObject Shape GameObjectUtilities 0...* GameObjectCollection 0...* 0...*

GameObject Bar ToggleButton Button TextElement TextField GameLayer GameObject CollisionSpace Body Joint FixedJoint HingedJoint BodyBuilder 0...* Body Contact...* Arbiter 0...* CollisionSpace 0...* Joint Collider 2