CS 201 Advanced Object-Oriented Programming Lab 3, Asteroids Part 1 Due: February 17/18, 11:30 PM

Size: px
Start display at page:

Download "CS 201 Advanced Object-Oriented Programming Lab 3, Asteroids Part 1 Due: February 17/18, 11:30 PM"

Transcription

1 CS 201 Advanced Object-Oriented Programming Lab 3, Asteroids Part 1 Due: February 17/18, 11:30 PM Objectives to gain experience using inheritance Introduction to the Assignment This is the first of a 2-part lab to create a program to play the video game Asteroids, a classic Atari game first introduced in In writing this program you will gain experience using inheritance. In particular, you will write some classes that extend others, as well as creating a superclass to capture similarities between some classes in your program. For Part 1 of the Asteroids assignment, you will create a ship that you can control with the keyboard. At this point, there will be no asteroids to shoot. We will add those next week. Here are some snapshots from this program: Here is the starting screen. The ship is in the center and pointing up. The user can use the up arrow key to accelerate and the down arrow key to decelerate. The left and right arrow keys are used to rotate the spaceship. The Program Design This project will have 3 classes, 1 of which I provide to you in its entirety. These classes are: Animation - the class that provides the framework for animation. I provide this class. 1

2 AsteroidsGame - this class extends Animation. You will put the functionality that is specific to Asteroids in this class. Ship - a class to manipulate the spaceship that the user controls You can download Animation.java from the course website. This class is completely written for you. YOU SHOULD NOT CHANGE IT! The API for this class is attached at the end of this document. You will also be using some classes and interfaces that Java provides that you are not yet familiar with. These are described briefly below. KeyListener. KeyListener is an interface that allows you to write methods that react to the user typing on a keyboard. Your AsteroidsGame class will implement KeyListener and define the keypressed method to handle the key input the user uses to move and rotate the ship. Polygon. Polygon is a class that defines a closed shape consisting of multiple straight lines joined at corners. Your ship will have an instance variable whose type is Polygon. Graphics2D. This is a subclass of the Graphics class we have previously used that provides a few extra methods that are very useful for this lab: public void translate (x, y) public void rotate (double theta) public void draw (Shape s) Writing the Program Create a new Eclipse project called Asteroids. You should download Animation.java from the course website and import it into your project. YOU SHOULD NOT CHANGE THIS CLASS. To import Animation.java into your project, do the following. Create a new project for Asteroids. Open the project and select the src folder. Open the File menu and select Import. In the window that comes up, open General and select File System. Click Next. Then click the Browse button and select the folder that contains the Animation.java file that you downloaded. Select Animation.java in the right column and click Finish. Step 0: Experiment with Translate and Rotate If you observe how Asteroids works, you will notice that the ship both moves and rotates. To draw a ship, you might think that you would need to calculate where the corners of the ship 2

3 are to determine where they should appear on the screen. This would involve doing some trigonometry. (I heard that groan!) Fortunately, using the Graphics2D class, it is much simpler. Instead of rotating the shape, you essentially rotate the axes you are drawing on, something like the drawing shown at the right. (The axes are displayed just so you can understand what is happening. They do not normally appear.) Moving the ship works in a similar way. You move the axes rather than the ship. The advantage of doing this is that you always draw your shapes the same way, independent of where they appear on the screen or how they are oriented. In particular, you should draw your shapes with their center at (0, 0). For example, if the shape is 20 pixels wide and 40 pixels tall, its 3 corners are (-10, 20), (0, -20), and (10, 20), like in the image at the right. To draw the ship with its center at (x, y) and rotated 45 degrees to the right as in the rotated figure below, we would say: g2d.translate (x, y); // Move the axes so the origin is at (x, y) g2d.rotate (Math.PI/4); // Rotate the axes 45 degrees clockwise g2d.draw (shipshape); // Draw the ship The argument to rotate is given in radians. A complete rotation (360 degrees) is 2π radians. shipshape is the Polygon instance variable inside the Ship class. It defines the 3 corners of the ship. After you draw the shape, you should reverse the transformation by calling rotate and translate in the reverse order and with negated values from the original calls. In this case, you would add these lines after the lines above: // Undo the rotation g2d.rotate (-Math.PI/4); // Undo the translation g2d.translate (-x, -y); Do the lab preparation worksheet if you have not already to gain a better understanding of how translation and rotation work before beginning Asteroids. Step 1: Draw a spaceship (0, 0) Now, you are ready to begin the Asteroids project. Create a class AsteroidsGame that extends Animation, which extends JComponent. In this lab, the drawing we will be doing is similar to the drawing that you did for the IdCard lab. In particular, you should define a main method that creates a JFrame and a paintcomponent method to paint the various shapes on the display. So, begin by creating a blank window of an appropriate size with a black background. You should place the code to do this in the AsteroidsGame class that you create. You should notice that you have a compiler error in your AsteroidsGame class, saying The type AsteroidsGame must implement the inherited abstract method Animation.nextFrame(). In the next step, there will be instructions about what should go in this method. For now, you should declare the method, but keep its body empty. Run your program. You should see a window with a black background. Next, create a Ship class with an instance variable of type Polygon, which you will use to hold the triangular ship shape. The Ship constructor should take parameters that identify the coordinates where the middle of the ship should start. Save these in instance variables so that 3

4 they can be passed to the translate method when you paint the ship. Then, call the addpoint method defined in the Polygon class to add the endpoints of the lines that make up the ship: public void addpoint(int x, int y) Remember that the values you pass in here should have (0,0) in the center of the ship as in our example above. They should not use the center values passed in to the Ship constructor; those are used in your call to translate. Finally, define a paint method in the Ship class that draws the ship. This method should be very similar to the paintcomponent method that you played with in Step 0. This method should take a Graphics object as a parameter. The first thing that it should do is cast the graphics object into a Graphics2D object using this code: Graphics2D g2d = (Graphics2D) g; Then, you can use this code to draw your shape. g2d.translate (centerx, centery); g2d.draw(shipshape); g2d.translate (-centerx, -centery); This will draw your ship with the center at (centerx, centery). Change the constructor in AsteroidsGame to construct a Ship and save it in an instance variable. Change the paintcomponent method in AsteroidsGame to call the paint method in Ship in addition to drawing the black background. Now, when you run your program there should be a ship in the middle of the window. Step 2: Make your ship move Let s add a move method to the Ship class. This is the method we will call to animate the ship, so each time it is called, the ship should move just a short distance. Since the ship is pointing up, let s write the move method so that the ship moves up. To cause it to move up, simply decrease the value of centery a small amount. Now, we will need to call this method inside the animation loop. Recall that the animation loop simply calls nextframe repeatedly. So, in the AsteroidsGame class, change the nextframe method to call the ship s move method. As the last step, you need to start the animation. To do this add a call to start() at the bottom of AsteroidGame s main method. Run your program. You should see the ship move up at a constant speed until it flies out of the window! Your first animation! Step 3: Get the ship to re-enter at the bottom of the screen What you want to do next, is cause the ship to wrap around so that if it goes off the top, it should reappear at the bottom. How can you write code to check when it has gone off the top? Where should it reappear? Write the code to do that. Step 4: Control the speed of your spaceship The user will use the up-arrow and down-arrow keys to move the ship. Up-arrow will accelerate the ship up to some maximum speed. Down-arrow will slow it down and eventually stop it. The ship cannot go in reverse. To handle the user typing on the keys, your AsteroidsGame class must implement KeyListener. This interface requires you to declare 3 methods: public void keypressed (KeyEvent event) public void keyreleased (KeyEvent event) 4

5 public void keytyped (KeyEvent event) The only one you need to define is keypressed. The other two need to be declared, but their bodies should be empty. As with other listeners, you will need to add a listener so that these methods get called. The method that you need to call is: public void addkeylistener (KeyListener l) To determine which key a user has typed, call getkeycode from the KeyEvent class: public int getkeycode() The values of interest for this lab are: KeyEvent.VK_UP KeyEvent.VK_DOWN up arrow key - used to accelerate down arrow key - used to decelerate KeyEvent.VK_LEFT left arrow key - used to rotate left (step 5) KeyEvent.VK_RIGHT right arrow key - used to rotate right (step 5) If the user types the up arrow key, you should call a method in the Ship class to increase the speed of the ship, but don t go above some maximum value. If the user types the down arrow key, decrease the ship s speed, but don t go below 0. Remember that speed is controlled by how far a ship moves on consecutive frames. So, to make the ship move faster, you will increase this distance. To go slower, decrease it. Remember to add a key listener to the AsteroidsGame in its constructor. In addition, add this line to the constructor: setfocusable(true); This is required for your game to accept any input. Now, when you run your program and type the up arrow key, the ship should move up the window, going faster each time you hit up-arrow. Also, test that the down-arrow key slows the ship down and eventually stops it. Step 5: Add controls to rotate the spaceship Next add the controls to rotate the ship. Right-arrow should rotate the ship right. Left-arrow should rotate the ship left. You will need an instance variable in your ship to remember the amount of rotation. You will also need to add the call to the Graphic2D s rotate method to cause the rotation to happen as described in the introduction to this lab. Test your right and left arrow keys. Step 6: Move a rotated ship in the direction it points Now, let s see what happens if we try to move a rotated ship. Yikes! It still goes straight up and straight down, not in the direction the ship is pointing! Unfortunately, we can t avoid doing some trig here. Essentially, we need to take the ship s speed and apply some of it vertically and some of it horizontally. Here is a method that will do that. Speed is the number of pixels that you would want to move if it was going straight up. rotation is the amount of rotation, centery is where the vertical middle of the ship is before it moves and centerx is its horizontal middle before it moves. centerx and centery here are the same values that you would pass to the translate method of Graphics2D. This method updates centerx and centery to cause the ship to move in the direction it is pointing. Try it. 5

6 " protected void calculatexy() { " " double xoffset = speed * Math.sin(rotation); " " double yoffset = -speed * Math.cos(rotation); " " centery = centery + yoffset; " " centerx = centerx + xoffset; " } Now, you may also notice that if the ship moves off the screen on the left, right or bottom, it is gone forever. You need to adjust your move method to have the ship wraparound in any direction. Extra credit ideas You should not work on extra credit until you have all the steps above working well and you have added comments and used good style. You will not receive extra credit points if you have not done a good job on the basic assignment. Get the ship to wrap properly if the user resizes the window. Add a button to allow the user to restart the game. After handling the button click, you will need to call requestfocusinwindow() in your AnimationGame class to allow arrow presses to continue to work. Allow the user to hyperspace the ship. This should cause the ship to disappear and reappear at a random location on the screen. (Don t use the space bar as the input key as we will use that next week to shoot bullets.) Grading 10 Step 1: Draw a spaceship 10 Step 2: Make your ship move 5 Step 3: Get the ship to re-enter at the bottom of the screen 10 Step 4: Control the speed of your spaceship 5 Step 5: Add controls to rotate the spaceship 10 Step 6: Move the rotated ship in the direction it points 25 Comments (including javadoc comments) 25 Style 5 each Extra credit Turning in Your Work Here are instructions that will create a jar file that you can double-click on. Use the Export..Jar command as for. Instead, click Next and click Next again on the following window. Then you should see a window that says JAR Manifest Specification at the top. The last field in that window says Main class. Click the Browse button and select AsteroidGame. Then click Finish. You should now have a jar file that you can double-click on. Please submit your jar file on Ella. 6

7 API for the Animation class Class Animation Animation provides the basic functionality to create games involving animation. Subclasses should define the nextframe method. This method is called every 30 milliseconds, giving the game an opportunity to update the display and do whatever operations it needs to during the animation. Animation public Animation() Constructs a new Animation. public void run() Runs the animation. This method should not be called directly. Instead, to start the animation, call the start() method. public void start() Starts the animation public void stop() Stops the animation. 7

CS 201 Advanced Object-Oriented Programming Lab 4 - Asteroids, Part 2 Due: February 24/25, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 4 - Asteroids, Part 2 Due: February 24/25, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 4 - Asteroids, Part 2 Due: February 24/25, 11:30 PM Introduction to the Assignment In this lab, you will complete the Asteroids program that you started

More information

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 6 - Sudoku, Part 2 Due: March 10/11, 11:30 PM Introduction to the Assignment In this lab, you will finish the program to allow a user to solve Sudoku puzzles.

More information

IT101. Graphical User Interface

IT101. Graphical User Interface IT101 Graphical User Interface Foundation Swing is a platform-independent set of Java classes used for user Graphical User Interface (GUI) programming. Abstract Window Toolkit (AWT) is an older Java GUI

More information

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM Objectives The objectives of this assignment are: to get your first experience with Java to become familiar with Eclipse Java

More information

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM Introduction to the Assignment In this assignment, you will get practice with recursion. There are three parts

More information

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM Objectives The objectives of this assignment are: to refresh your Java programming to become familiar with

More information

CS 134 Test Program #2

CS 134 Test Program #2 CS 134 Test Program #2 Sokoban Objective: Build an interesting game using much of what we have learned so far. This second test program is a computer maze game called Sokoban. Sokoban is a challenging

More information

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help CS 2110 Fall 2012 Homework 4 Paint Program Due: Wednesday, 12 November, 11:59PM In this assignment, you will write parts of a simple paint program. Some of the functionality you will implement is: 1. Freehand

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 34 April 13, 2017 Model / View / Controller Chapter 31 How is the Game Project going so far? 1. not started 2. got an idea 3. submitted design proposal

More information

Java Foundations John Lewis Peter DePasquale Joe Chase Third Edition

Java Foundations John Lewis Peter DePasquale Joe Chase Third Edition Java Foundations John Lewis Peter DePasquale Joe Chase Third Edition Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Visit us on the

More information

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API Agenda Coordinate systems Colors Fonts Drawing shapes Graphics2D API By: dr. Amal Khalifa 1 Programming Seminar @12:30 13:30 pm on Wednesday 9/4/2014 Location : 2.505.01 Painting components 2 Every component

More information

CISC 1600, Lab 2.3: Processing animation, objects, and arrays

CISC 1600, Lab 2.3: Processing animation, objects, and arrays CISC 1600, Lab 2.3: Processing animation, objects, and arrays Prof Michael Mandel 1 Getting set up For this lab, we will again be using Sketchpad. sketchpad.cc in your browser and log in. Go to http://cisc1600.

More information

1 Getting started with Processing

1 Getting started with Processing cis3.5, spring 2009, lab II.1 / prof sklar. 1 Getting started with Processing Processing is a sketch programming tool designed for use by non-technical people (e.g., artists, designers, musicians). For

More information

CS 201 Advanced Object-Oriented Programming Lab 5 - Sudoku, Part 1 Due: March 3/4, 11:30 PM

CS 201 Advanced Object-Oriented Programming Lab 5 - Sudoku, Part 1 Due: March 3/4, 11:30 PM CS 201 Advanced Object-Oriented Programming Lab 5 - Sudoku, Part 1 Due: March 3/4, 11:30 PM Introduction to the Assignment This is the 1 st part of a 2 week lab. When done, you will have a game that allows

More information

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved. Java How to Program, 9/e Copyright 1992-2012 by Pearson Education, Inc. All Rights Reserved. Overview capabilities for drawing two-dimensional shapes, controlling colors and controlling fonts. One of

More information

ICOM 4015 Advanced Programming Laboratory. Chapter 3 Introduction to Graphical Applications in Java using Swing

ICOM 4015 Advanced Programming Laboratory. Chapter 3 Introduction to Graphical Applications in Java using Swing ICOM 4015 Advanced Programming Laboratory Chapter 3 Introduction to Graphical Applications in Java using Swing University of Puerto Rico Electrical and Computer Engineering Department by Juan E. Surís

More information

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM

CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM CS 315 Software Design Homework 3 Preconditions, Postconditions, Invariants Due: Sept. 29, 11:30 PM Objectives Defining a wellformed method to check class invariants Using assert statements to check preconditions,

More information

Session 4 Starting the Air Raid Game

Session 4 Starting the Air Raid Game Session 4 Starting the Air Raid Game Authored by Brian Cullen (bcullen@rossettschool.co.uk/@mrbcullen) (c) Copyright 2011 Computing At School. This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike

More information

Object-oriented programming in Java (2)

Object-oriented programming in Java (2) Programming Languages Week 13 Object-oriented programming in Java (2) College of Information Science and Engineering Ritsumeikan University plan last week intro to Java advantages and disadvantages language

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 36 November 30, 2018 Mushroom of Doom Model / View / Controller Chapter 31 Announcements Game Project Complete Code Due: Monday, December 10th NO LATE

More information

Assignment 2. Application Development

Assignment 2. Application Development Application Development Assignment 2 Content Application Development Day 2 Lecture The lecture covers the key language elements of the Java programming language. You are introduced to numerical data and

More information

Programming Assignment 4 ( 100 Points )

Programming Assignment 4 ( 100 Points ) Programming Assignment 4 ( 100 Points ) Due: 11:59pm Thursday, October 26 START EARLY!! In PA4 you will continue exploring the graphical user interface (GUI) and object oriented programming. You will be

More information

Be sure check the official clarification thread for corrections or updates to this document or to the distributed code.

Be sure check the official clarification thread for corrections or updates to this document or to the distributed code. Com S 228 Spring 2011 Programming Assignment 1 Part 1 (75 points): Due at 11:59 pm, Friday, January 28 Part 2 (225 points): Due at 11:59 pm, Monday, February 7 This assignment is to be done on your own.

More information

CS Problem Solving and Object-Oriented Programming

CS Problem Solving and Object-Oriented Programming CS 101 - Problem Solving and Object-Oriented Programming Lab 5 - Draw a Penguin Due: October 28/29 Pre-lab Preparation Before coming to lab, you are expected to have: Read Bruce chapters 1-3 Introduction

More information

Event Driven Programming

Event Driven Programming Event Driven Programming 1. Objectives... 2 2. Definitions... 2 3. Event-Driven Style of Programming... 2 4. Event Polling Model... 3 5. Java's Event Delegation Model... 5 6. How to Implement an Event

More information

Solution Notes. COMP 151: Terms Test

Solution Notes. COMP 151: Terms Test Family Name:.............................. Other Names:............................. ID Number:............................... Signature.................................. Solution Notes COMP 151: Terms

More information

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline

GUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example

More information

Programming: You will have 6 files all need to be located in the dir. named PA4:

Programming: You will have 6 files all need to be located in the dir. named PA4: PROGRAMMING ASSIGNMENT 4: Read Savitch: Chapter 7 and class notes Programming: You will have 6 files all need to be located in the dir. named PA4: PA4.java ShapeP4.java PointP4.java CircleP4.java RectangleP4.java

More information

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM

CS 215 Software Design Homework 3 Due: February 28, 11:30 PM CS 215 Software Design Homework 3 Due: February 28, 11:30 PM Objectives Specifying and checking class invariants Writing an abstract class Writing an immutable class Background Polynomials are a common

More information

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing BRIDGES TO COMPUTING General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. This work is licensed under the Creative Commons Attribution-ShareAlike

More information

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1

Block I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1 Block I Unit 2 Basic Constructs in Java M301 Block I, unit 2 1 Developing a Simple Java Program Objectives: Create a simple object using a constructor. Create and display a window frame. Paint a message

More information

CS Programming Exercise:

CS Programming Exercise: CS Programming Exercise: An Introduction to Java and the ObjectDraw Library Objective: To demonstrate the use of objectdraw graphics primitives and Java programming tools This lab will introduce you to

More information

Use the Move tool to drag A around and see how the automatically constructed objects (like G or the perpendicular and parallel lines) are updated.

Use the Move tool to drag A around and see how the automatically constructed objects (like G or the perpendicular and parallel lines) are updated. Math 5335 Fall 2015 Lab #0: Installing and using GeoGebra This semester you will have a number of lab assignments which require you to use GeoGebra, a dynamic geometry program. GeoGebra lets you explore

More information

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15

Eclipse Setup. Opening Eclipse. Setting Up Eclipse for CS15 Opening Eclipse Eclipse Setup Type eclipse.photon & into your terminal. (Don t open eclipse through a GUI - it may open a different version.) You will be asked where you want your workspace directory by

More information

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

FrontPage 98 Quick Guide. Copyright 2000 Peter Pappas. edteck press All rights reserved. Master web design skills with Microsoft FrontPage 98. This step-by-step guide uses over 40 full color close-up screen shots to clearly explain the fast and easy way to design a web site. Use edteck s QuickGuide

More information

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing. COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

Excel Basics Fall 2016

Excel Basics Fall 2016 If you have never worked with Excel, it can be a little confusing at first. When you open Excel, you are faced with various toolbars and menus and a big, empty grid. So what do you do with it? The great

More information

Principles of Computer Game Design and Implementation. Lecture 6

Principles of Computer Game Design and Implementation. Lecture 6 Principles of Computer Game Design and Implementation Lecture 6 We already knew Game history game design information Game engine 2 What s Next Mathematical concepts (lecture 6-10) Collision detection and

More information

Instructions for Crossword Assignment CS130

Instructions for Crossword Assignment CS130 Instructions for Crossword Assignment CS130 Purposes: Implement a keyboard interface. 1. The program you will build is meant to assist a person in preparing a crossword puzzle for publication. You have

More information

CS 134 Programming Exercise 9:

CS 134 Programming Exercise 9: CS 134 Programming Exercise 9: Nibbles Objective: To gain experience working with 2 dimensional arrays. The Problem Nibbles is a snake. Nibbles moves around a field, looking for food. Unfortunately, Nibbles

More information

Curves & Splines. Assignment #3. Overview & Objectives. Due Dates. CPSC 453 Fall 2018 University of Calgary

Curves & Splines. Assignment #3. Overview & Objectives. Due Dates. CPSC 453 Fall 2018 University of Calgary Curves & Splines Assignment #3 CPSC 453 Fall 2018 University of Calgary Overview & Objectives The main objective of this third assignment in CPSC 453 is to learn to work with Bézier curves and splines.

More information

Programming Project 1

Programming Project 1 Programming Project 1 Handout 6 CSCI 134: Fall, 2016 Guidelines A programming project is a laboratory that you complete on your own, without the help of others. It is a form of take-home exam. You may

More information

FrontPage. Directions & Reference

FrontPage. Directions & Reference FrontPage Directions & Reference August 2006 Table of Contents Page No. Open, Create, Save WebPages Open Webpage... 1 Create and Save a New Page... 1-2 Change the Background Color of Your Web Page...

More information

pygame Lecture #2 (Examples: movingellipse, bouncingball, planets, bouncingballgravity)

pygame Lecture #2 (Examples: movingellipse, bouncingball, planets, bouncingballgravity) pygame Lecture #2 (Examples: movingellipse, bouncingball, planets, bouncingballgravity) MOVEMENT IN PYGAME I. Realizing the screen is getting redrawn many times. Let's take a look at the key portion of

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

2. Getting Started When you start GeoGebra, you will see a version of the following window. 1

2. Getting Started When you start GeoGebra, you will see a version of the following window. 1 Math 5335 Fall 2018 Lab #0: Installing and using GeoGebra This semester you will have a number of lab assignments which require you to use GeoGebra, a dynamic geometry program. GeoGebra lets you explore

More information

Programme. Introduction to Animation Shop

Programme. Introduction to Animation Shop HEART Trust NTA Vocational Training Development Institute Programme Course Animations Learning Objectives: Use the animation tools Prepare for an animation Create an animation with animation

More information

Structured Programming

Structured Programming CS 170 Java Programming 1 Objects and Variables A Little More History, Variables and Assignment, Objects, Classes, and Methods Structured Programming Ideas about how programs should be organized Functionally

More information

CISC 1600, Lab 3.2: Interactivity in Processing

CISC 1600, Lab 3.2: Interactivity in Processing CISC 1600, Lab 3.2: Interactivity in Processing Prof Michael Mandel 1 Getting set up For this lab, we will be using OpenProcessing, a site for building processing sketches online using processing.js. 1.1.

More information

HOW TO. In this section, you will find. miscellaneous handouts that explain. HOW TO do various things.

HOW TO. In this section, you will find. miscellaneous handouts that explain. HOW TO do various things. In this section, you will find miscellaneous handouts that explain do various things. 140 SAVING Introduction Every time you do something, you should save it on the DESKTOP. Click Save and then click on

More information

I think this assignment should have 8 objectives but we should still mark it out of 10. The Mean TA.

I think this assignment should have 8 objectives but we should still mark it out of 10. The Mean TA. Chapter 1 CS488/688 F17 A1: Introduction I think this assignment should have 8 objectives but we should still mark it out of 10. The Mean TA. This assignment is due Thursday, September 28th [Week 3]. 1.1

More information

C# Programming for Developers Course Labs Contents

C# Programming for Developers Course Labs Contents C# Programming for Developers Course Labs Contents C# Programming for Developers...1 Course Labs Contents...1 Introduction to C#...3 Aims...3 Your First C# Program...3 C# The Basics...5 The Aims...5 Declaring

More information

CIS 121 Data Structures and Algorithms with Java Spring 2018

CIS 121 Data Structures and Algorithms with Java Spring 2018 CIS 121 Data Structures and Algorithms with Java Spring 2018 Homework 2 Thursday, January 18 Due Monday, January 29 by 11:59 PM 7 Required Problems (85 points), and Style and Tests (15 points) DO NOT modify

More information

Global Gomoku Lab 4 in D0010E

Global Gomoku Lab 4 in D0010E Luleå University of Technology February 20, 2012 Computer Science Håkan Jonsson Global Gomoku Lab 4 in D0010E 1 Introduction Modern forms of communication are more and more carried out over the Internet,

More information

+ Abstract Data Types

+ Abstract Data Types Linked Lists Abstract Data Types An Abstract Data Type (ADT) is: a set of values a set of operations Sounds familiar, right? I gave a similar definition for a data structure. Abstract Data Types Abstract

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 32 April 9, 2018 Swing I: Drawing and Event Handling Chapter 29 HW8: Spellchecker Available on the web site Due: Tuesday! Announcements Parsing, working

More information

Outline. Introduction Surface of Revolution Hierarchical Modeling Blinn-Phong Shader Custom Shader(s)

Outline. Introduction Surface of Revolution Hierarchical Modeling Blinn-Phong Shader Custom Shader(s) Modeler Help Outline Introduction Surface of Revolution Hierarchical Modeling Blinn-Phong Shader Custom Shader(s) Objects in the Scene Controls of the object selected in the Scene. Currently the Scene

More information

ISY00245 Principles of Programming. Module 7

ISY00245 Principles of Programming. Module 7 ISY00245 Principles of Programming Module 7 Module 7 Loops and Arrays Introduction This week we have gone through some of the concepts in your lecture, and will be putting them in to practice (as well

More information

CS 134 Programming Exercise 3:

CS 134 Programming Exercise 3: CS 134 Programming Exercise 3: Repulsive Behavior Objective: To gain experience implementing classes and methods. Note that you must bring a program design to lab this week! The Scenario. For this lab,

More information

CSE1720. Objectives for this class meeting 2/10/2014. Cover 2D Graphics topic: displaying images. Timer class, a basic ActionListener

CSE1720. Objectives for this class meeting 2/10/2014. Cover 2D Graphics topic: displaying images. Timer class, a basic ActionListener CSE1720 Click to edit Master Week text 05, styles Lecture 09 Second level Third level Fourth level Fifth level Winter 2014! Tuesday, Feb 4, 2014 1 Objectives for this class meeting Cover 2D Graphics topic:

More information

Computer Games Development Spring Practical 3 GameCore, Transforms & Collision Detection

Computer Games Development Spring Practical 3 GameCore, Transforms & Collision Detection In this practical we are going to look at the GameCore class in some detail and then move on to examine the use of transforms, collision detection and tile maps. Combined with the material concerning sounds

More information

GRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation

GRAPHICS PROGRAMMING. LAB #3 Starting a Simple Vector Animation GRAPHICS PROGRAMMING LAB #3 Starting a Simple Vector Animation Introduction: In previous classes we have talked about the difference between vector and bitmap images and vector and bitmap animations. In

More information

Using the API: Introductory Graphics Java Programming 1 Lesson 8

Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using the API: Introductory Graphics Java Programming 1 Lesson 8 Using Java Provided Classes In this lesson we'll focus on using the Graphics class and its capabilities. This will serve two purposes: first

More information

CS211 Spring 2007 Assignment 5 Pacman Due Thursday, 3 May 2007, 11:59:59pm. 1 General Instructions. 2 Overview. 2.1 Background. 2.

CS211 Spring 2007 Assignment 5 Pacman Due Thursday, 3 May 2007, 11:59:59pm. 1 General Instructions. 2 Overview. 2.1 Background. 2. CS211 Spring 2007 Assignment 5 Pacman 1 General Instructions In this assignment, you will develop a Java implementation of the famous interactive game Pacman. This assignment will involve GUI programming,

More information

Spring CS Homework 3 p. 1. CS Homework 3

Spring CS Homework 3 p. 1. CS Homework 3 Spring 2018 - CS 111 - Homework 3 p. 1 Deadline 11:59 pm on Friday, February 9, 2018 Purpose CS 111 - Homework 3 To try out another testing function, check-within, to get more practice using the design

More information

CS 134 Programming Exercise 7:

CS 134 Programming Exercise 7: CS 134 Programming Exercise 7: Scribbler Objective: To gain more experience using recursion and recursive data structures. This week, you will be implementing a program we call Scribbler. You have seen

More information

Affine Transformations. Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes

Affine Transformations. Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes Affine Transformations Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes Reacll: Shape Models We can think of widgets as shape models

More information

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Graphics. Lecture 18 COP 3252 Summer June 6, 2017 Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple

More information

Isometries: Teacher Notes

Isometries: Teacher Notes Isometries: Teacher Notes Henri Picciotto Acknowledgments Vinci Daro, Ann Shannon, and Celia Stevenson helped me with the original version of this document. Zalman Usiskin offered valuable feedback, some

More information

Comp Assignment 4: Commands and Graphics

Comp Assignment 4: Commands and Graphics Comp 401 - Assignment 4: Commands and Graphics Date Assigned: Thu Sep 12, 2013 Completion Date: Fri Sep 20, 2013 Early Submission Date: Wed Sep 18, 2013 This assignment has two parts having to do with

More information

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM

CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM CS100J, Fall 2003 Preparing for Prelim 1: Monday, 29 Sept., 7:30 9:00PM This handout explains what you have to know for the first prelim. Terms and their meaning Below, we summarize the terms you should

More information

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I Electrical and Computer Engineering Object-Oriented Topic : Graphics GUI Part I Maj Joel Young Joel.Young@afit.edu 15-Sep-03 Maj Joel Young A Brief History Lesson AWT Abstract Window Toolkit Implemented

More information

CS116X Midterm Review Winter 2015

CS116X Midterm Review Winter 2015 CS116X Midterm Review Winter 2015 This review will most likely not cover everything that could possibly be on the exam. The following is intended to help you study but remember that you may be tested on

More information

Blocky: A Game of Falling Blocks

Blocky: A Game of Falling Blocks ECE220: Computer Systems and Programming Machine Problem 6 Spring 2018 Honors Section due: Thursday 1 March, 11:59:59 p.m. Blocky: A Game of Falling Blocks Your task this week is to implement a game of

More information

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal Objectives: To gain experience with the programming of: 1. Graphical user interfaces (GUIs), 2. GUI components, and 3. Event handling (required

More information

REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB!

REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB! CS 1033 Multimedia and Communications Lab 07: Introduction to Animation using Photoshop REMEMBER TO BRING YOUR MEMORY STICK TO EVERY LAB! LAB #7 - Exercise 1 Objectives: Upon completion of Exercise 1 you

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

Our second exam is Thursday, November 10. Note that it will not be possible to get all the homework submissions graded before the exam.

Our second exam is Thursday, November 10. Note that it will not be possible to get all the homework submissions graded before the exam. Com S 227 Fall 2016 Assignment 3 300 points Due Date: Wednesday, November 2, 11:59 pm (midnight) Late deadline (25% penalty): Thursday, November 2, 11:59 pm General information This assignment is to be

More information

Using Flash Animation Basics

Using Flash Animation Basics Using Flash Contents Using Flash... 1 Animation Basics... 1 Exercise 1. Creating a Symbol... 2 Exercise 2. Working with Layers... 4 Exercise 3. Using the Timeline... 6 Exercise 4. Previewing an animation...

More information

LCC 6310 The Computer as an Expressive Medium. Lecture 9

LCC 6310 The Computer as an Expressive Medium. Lecture 9 LCC 6310 The Computer as an Expressive Medium Lecture 9 Overview Course pace Programming questions related to project 2? (due Friday 5pm!) Programming concepts super and this Java SDK classes Lists Reading

More information

SHAPES & TRANSFORMS. Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ.

SHAPES & TRANSFORMS. Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. SHAPES & TRANSFORMS Chapter 12 of Pro WPF : By Matthew MacDonald Assist Lect. Wadhah R. Baiee. College of IT Univ. of Babylon - 2014 Understanding Shapes The simplest way to draw 2-D graphical content

More information

CS 170 Java Programming 1. Week 12: Creating Your Own Types

CS 170 Java Programming 1. Week 12: Creating Your Own Types CS 170 Java Programming 1 Week 12: Creating Your Own Types What s the Plan? Topic 1: A Little Review Work with loops to process arrays Write functions to process 2D Arrays in various ways Topic 2: Creating

More information

Our second exam is Monday, April 3. Note that it will not be possible to get all the homework submissions graded before the exam.

Our second exam is Monday, April 3. Note that it will not be possible to get all the homework submissions graded before the exam. Com S 227 Spring 2017 Assignment 3 300 points Due Date:, Wednesday, March 29 11:59 pm (midnight) Late deadline (25% penalty): Thursday, March 30, 11:59 pm General information This assignment is to be done

More information

Programming graphics

Programming graphics Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it

More information

Chapter 3: Inheritance and Polymorphism

Chapter 3: Inheritance and Polymorphism Chapter 3: Inheritance and Polymorphism Overview Inheritance is when a child class, or a subclass, inherits, or gets, all the data (properties) and methods from the parent class, or superclass. Just like

More information

We will start our journey into Processing with creating static images using commands available in Processing:

We will start our journey into Processing with creating static images using commands available in Processing: Processing Notes Chapter 1: Starting Out We will start our journey into Processing with creating static images using commands available in Processing: rect( ) line ( ) ellipse() triangle() NOTE: to find

More information

Notes from the Boards Set BN19 Page

Notes from the Boards Set BN19 Page 1 The Class, String There are five programs in the class code folder Set17. The first one, String1 is discussed below. The folder StringInput shows simple string input from the keyboard. Processing is

More information

Soda Machine Laboratory

Soda Machine Laboratory Soda Machine Laboratory Introduction This laboratory is intended to give you experience working with multiple queue structures in a familiar real-world setting. The given application models a soda machine

More information

Create a memory DC for double buffering

Create a memory DC for double buffering Animation Animation is implemented as follows: Create a memory DC for double buffering Every so many milliseconds, update the image in the memory DC to reflect the motion since the last update, and then

More information

Project #1 Seamcarve

Project #1 Seamcarve Project #1 Seamcarve Out: Thursday, January 24 In: This is real, this is me Im exactly where I m supposed to be, now Gonna let the light, shine on me Now I ve found, who I am There s no way to hold it

More information

CS 170 Java Programming 1. Week 15: Interfaces and Exceptions

CS 170 Java Programming 1. Week 15: Interfaces and Exceptions CS 170 Java Programming 1 Week 15: Interfaces and Exceptions Your "IC" or "Lab" Document Use Word or OpenOffice to create a new document Save the file as IC15.doc (Office 97-2003 compatible) Place on your

More information

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different

More information

This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units.

This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units. This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units. Introduction Overview Advancements in technology are

More information

Lesson 10: Quiz #1 and Getting User Input (W03D2)

Lesson 10: Quiz #1 and Getting User Input (W03D2) Lesson 10: Quiz #1 and Getting User Input (W03D2) Balboa High School Michael Ferraro September 1, 2015 1 / 13 Do Now: Prep GitHub Repo for PS #1 You ll need to submit the 5.2 solution on the paper form

More information

CS18000: Programming I

CS18000: Programming I CS18000: Programming I Data Abstraction January 25, 2010 Prof. Chris Clifton Announcements Book is available (Draft 2.0) Syllabus updated with readings corresponding to new edition Lab consulting hours

More information

Assignment 4. Aggregate Objects, Command-Line Arguments, ArrayLists. COMP-202B, Winter 2011, All Sections. Due: Tuesday, March 22, 2011 (13:00)

Assignment 4. Aggregate Objects, Command-Line Arguments, ArrayLists. COMP-202B, Winter 2011, All Sections. Due: Tuesday, March 22, 2011 (13:00) Assignment 4 Aggregate Objects, Command-Line Arguments, ArrayLists COMP-202B, Winter 2011, All Sections Due: Tuesday, March 22, 2011 (13:00) You MUST do this assignment individually and, unless otherwise

More information

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points. Java for Non Majors Final Study Guide April 26, 2017 The test consists of 1. Multiple choice questions 2. Given code, find the output 3. Code writing questions 4. Code debugging question 5. Short answer

More information

Remaining Enhanced Labs

Remaining Enhanced Labs Here are some announcements regarding the end of the semester, and the specifications for the last Enhanced Labs. Don t forget that you need to take the Common Final Examination on Saturday, May 5, from

More information