Structure of GridWorld classes Creating a GridWorld project without the jar file Modifying GridWorld classes Removing grid lines Changing the color of.

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Microsoft FrontPage Monday January 28, The Basic FrontPage Setup.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
Flappy bird guide for Scratch
EXCEL Spreadsheet Basics
The Story of Past Presidents. What is PhotoStory?  PhotoStory is a free program from Microsoft that allows you to create a digital story.  You can personalize.
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
Using a different image than normal Multiple images for a class Controlling the mouse click Controlling the keys pressed Launching an input dialog box.
© Anselm Spoerri Lecture 11 Flash –Build Flash Website with Animated Navigation Structure –Decide on Overall Navigation Layout, Import Images & Organize.
18-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Applets. An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from a browser You.
26-Jun-15 Applets. 2 An applet is a Panel that allows interaction with a Java program A applet is typically embedded in a Web page and can be run from.
28-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
PowerPoint 2007 © : The Power of Presentations How can Microsoft PowerPoint 2007 help you finalize a presentation for an audience?
Google Earth How to create a Google Earth Tour and place it in your Wiki.
Designing a Classroom Web Site Using NVU Beginning Level.
1 eclipse Tips. 2 What is eclipse? Eclipse is a popular IDE (Integrated Development Environment) that we will use to create, compile, execute, and test.
XP Tutorial 7 New Perspectives on Microsoft Windows XP 1 Microsoft Windows XP Working with Graphics Tutorial 7.
Copyright © Texas Education Agency, All rights reserved. 1 Web Technologies Website Development with Dreamweaver.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
Web Technologies Website Development Trade & Industrial Education
Click your mouse for next slide Flash – Introduction and Startup Many times on websites you will see animations of various sorts Many of these are created.
Exercise : Animated Navigation Structure in Flash 1.Develop Answers to “What did you learn in ITI program?” “What do you have to offer?” “What are your.
PowerPoint for teachers and students C MacFadyen, Dec 2008.
CIS 205—Web Design & Development Flash Chapter 1 Getting Started with Adobe Flash CS3.
Amber Annett David Bell October 13 th, What will happen What is this business about personal web pages? Designated location of your own web page.
Step 1: Import Pictures Step 2: Add Titles Step 3: Narrate Story & Customize Motion.
CIS—100 Chapter 15—Windows Vista 1. Parts of a Window 2.
To download PhotoStory: Go to On the left side under Product Resources, click on Downloads.
Website Development with Dreamweaver
The Story of Westward Development. What is PhotoStory?  PhotoStory is a free program from Microsoft that allows you to create a digital story.  You.
COMPREHENSIVE Windows Tutorial 7 Managing Multimedia Files.
1 k Jarek Rossignac,  2008 Processing  Install Processing  Learn how to edit, run, save, export, post programs  Understand.
CSE 219 Computer Science III Images. HW1 Has been posted on Blackboard Making a Game of Life with limited options.
Fall 2005 Using FrontPage to Enhance Blackboard - Darek Sady1 Using FrontPage to Enhance Blackboard 1.Introduction 2.Starting FrontPage 3.Creating Documents.
Java Applets. An applet is a Panel that allows interaction with a Java program. A applet is typically embedded in a Web page and can be run from a browser.
Program that runs in appletviewer (test utility for applets) Web browser (IE, Communicator) Executes when HTML (Hypertext Markup Language) document containing.
Photoshop Image Slicing. Reasons to Image Slide To create links out of sliced images To optimise different areas. (flat areas of colour, such as logos,
Paper 3 Unit 15 – Web Authoring Software Choices Graphics Exporting Graphics Creating CSS RGB Colour CSS – Body, Table and TD Border Collapse Tables -
Computer Science I Programming in Java (programming using Processing IN Java, using IntelliJ IDE) Classwork/Homework: copy your Processing projects over.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Photo Story. How to use Photo Story Photo Story 3 can be located in the Accessories folder on school computers. You will need to have your pictures already.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
CHAPTER Agenda Applets Servelets Browsers HelloWorld.
Building the CarryDrop simulation in Eclipse Creating a new project with existing code from John Murphy’s RePast tutorial.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Processing  Install Processing  Learn how to edit, run, save, export,
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Java With NetBeans First Project. Java Are language for this semester is Java The Development Environment is Netbeans.
Building a Website: Layout Fall Overall Structure: Home Page Title Section Title Frame Picture UNCP Math Menu Content Footer Contact Information.
{ How to Create a Flipchart in ActivInspire Lara Daniel.
Copyright © Texas Education Agency, All rights reserved.1 Web Technologies Creating a Navigation Bar.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
TechKnowlogy Conference August 2, 2011 Using GoogleDocs for Collaboration.
Flash Slideshow with Fade Transition Slideshow #1-Themed Images Slideshow #2-Instructional Images.
Prof. Anselm SpoerriMultimedia Production Rutgers Lecture 11 Flash –Build Flash Website with Animated Navigation Structure –Decide on Overall.
Modifying GridWorld Classes.
Contacts: Intro to game programming in Java (with almost-drawingpanel)
Flash Interface, Commands and Functions
Eclipse Navigation & Usage.
MS-Access (database) how to create blank data base.
Economist Report (Advanced)
DIRECTIONS: 1. Click Enable Editing in the yellow bar above.
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Windows Tutorial 7 Managing Multimedia Files
Lecture 7: Introduction to Processing
Photostory 3.
对 话 无 界 限 “对话是两个集合出现交集的一个刹那。” “对话是发现共同点的捷径。”.
Exercise : Animated Navigation Structure in Flash
Presentation transcript:

Structure of GridWorld classes Creating a GridWorld project without the jar file Modifying GridWorld classes Removing grid lines Changing the color of grid lines Changing the background color Using an image as the background Changing the text on a button Hiding a button Closing the world Changing the thickness of grid lines Bolding specific grid lines Zooming in automatically Making the world window fill the computer screen Customizing the dimensions of the world window

info\gridworld\actor – contains all the Actor classes and images info\gridworld\grid – contains the Location class and Grid classes, as well as their images info\gridworld\gui – contains classes related to the gui info\gridworld\world – contains the World class GridWorld source code has been saved to S:\StudentShare\AP Computer Science\GridWorldCode. The source code is saved in specific folders and subfolders. You should keep them in these same folders underneath your project if you are overriding them. For example, folders info\gridworld\actor corresponds to package info.gridworld.actor in eclipse:

If you eventually want to create an application or applet based on GridWorld, then you will want to use this approach. This will allow someone to play your game without launching eclipse or some other IDE. To do this you will need to include all the GridWorld source code/compiled code in your project. You should NOT add the external GridWorld jar file to your project. Here is how you can accomplish this: 1.Create a project in eclipse. Do not add the GridWorld jar file. 2.Open the GridWorldCode zip file from my website, select all files, and then press Extract. Extract them directly to the project you just created. Note: Do not extract them to a package. 3.Create another package in this project and this will be where you create your custom classes for your game.

If you don’t need to create an application or applet based on GridWorld, but you want to modify one of its classes, then use this approach. One example is if you want to change the grid lines by either making them disappear or modifying their color. Here is how you can accomplish this: 1.Create a project in eclipse. Add the external GridWorld jar file to the project as you normally do. 2.Identify the GridWorld class(es) that you want to modify. 3.Create a package in your project named just like the package that the class is in (see previous slide). For example, if you want to modify the Actor class, then create a package named info.gridworld.actor. 4.Copy the class you want to modify from GridWorldCode zip file from my website (see previous slide) and save it into this package. Modify the class as necessary. 5.Create another package in this project and this will be where you create your custom classes for your game.

To completely remove grid lines: 1.Make sure you have created the package info.gridworld.gui in your project. 2.Modify the GridPanel class as follows: In the paintComponent() method, comment out the line: drawGridlines(). 3.Save the class.

In certain situations, you may want to change the color of grid lines. For example, you may want the background to be red and if you also make the grid lines red, then the grid appears as one red background with no grid lines. Here is how you can do this: 1.Make sure you have created the package info.gridworld.gui in your project. 2.Modify the GridPanel class as follows: In the drawGridlines() method, change the line g2.setColor(Color.BLACK); to g2.setColor(Color.RED); 3.Save the class.

In certain situations, you may want to change the background color to something other than white. Here is how you can do this: 1.Make sure you have created the package info.gridworld.gui in your project. 2.Modify the GridPanel class as follows: set the backgroundColor instance variable to Color.BLACK or whatever color you want the background to be. 3.Save the class.

1.Make sure you have created the package info.gridworld.gui in your project. 2.Save the image file in the project folder (not the package folder) 3.Modify the GridPanel class as follows: In the paintComponent() method insert the following lines of code: ……... g2.setColor(backgroundColor); g2.fillRect(insets.left, insets.top, numCols * (cellSize + 1) + 1, numRows * (cellSize + 1) + 1); // Begin of code to use an image as the background BufferedImage img = null; try { img = ImageIO.read(new File("starfield.JPG")); } catch (IOException e) { } g2.drawImage(img, insets.left, insets.top, numCols * (cellSize + 1) + 1, numRows * (cellSize + 1) + 1, 0, 0, img.getWidth(), img.getHeight(), null); // End of code to use an image as the background drawWatermark(g2); ………

1.Make sure you have created the package info.gridworld.gui in your project. 2.Edit the file named WorldFrameResources.properties. This file contains information about buttons and menus used in GridWorld. 3.Modify the line for the button you want to change. For example here are the lines that represent the thre buttons for Step, Run, and Stop. button.gui.step=Step button.gui.run=Run button.gui.run=Play button.gui.stop=Stop slider.gui.slow=Slow slider.gui.fast=Fast

1.Make sure you have created the package info.gridworld.gui in your project. 2.Modify the makeControls() method in the GUIController class. Find the line of code that is adding the button to the panel and comment it out. The following hides the Step button: Dimension spacer = new Dimension(5, stepButton.getPreferredSize().height + 10); controlPanel.add(Box.createRigidArea(spacer)); //controlPanel.add(stepButton); //controlPanel.add(Box.createRigidArea(spacer)); controlPanel.add(runButton); controlPanel.add(Box.createRigidArea(spacer)); controlPanel.add(stopButton); runButton.setEnabled(false); stepButton.setEnabled(false); stopButton.setEnabled(false);

1.Make sure you have created the packages named info.gridworld.gui and info.gridworld.world in your project. 2.The frame that the World is based on will need to be closed. The frame is stored in the frame variable in the World class. There is currently no accessor method, so you will need to create one in the World class: public JFrame getFrame() { return frame; } 3.Now you can modify your world class (which extends World). In your logic, you will need to close the frame as follows: getFrame().dispose();

1.Make sure you have created the package named info.gridworld.gui. 2.You will need to change the stroke that is used before drawing the grid lines. Modify the drawGridLines() method in the GridPanel class. g2.setStroke(new BasicStroke(10)); //add this g2.setColor(Color.BLACK); for (int y = miny; y <= maxy; y += cellSize + 1) // draw horizontal lines g2.drawLine(minx, y, maxx, y); for (int x = minx; x <= maxx; x += cellSize + 1) // draw vertical lines g2.drawLine(x, miny, x, maxy);

1.Make sure you have created the package named info.gridworld.gui. 2.You will need to add the following code segment after drawing the grid lines at the bottom of the drawGridLines() method in the GridPanel class. g2.drawLine(146,miny,146,maxy); g2.drawLine(293,miny,293,maxy); g2.drawLine(145,miny,145,maxy); g2.drawLine(292,miny,292,maxy); g2.drawLine(minx,146,maxx,146); g2.drawLine(minx,293,maxx,293); g2.drawLine(minx,145,maxx,145); g2.drawLine(minx,292,maxx,292);

1.Make sure you have created the package named info.gridworld.gui. 2.Modify the setGrid() method in the GridPanel class to call the zoomIn() method. This should be done at the bottom of the method after it calculates the cell size: if (grid.getNumRows() == -1 && grid.getNumCols() == -1) { numRows = numCols = 2000; // This determines the "virtual" size of the pan world } else { numRows = grid.getNumRows(); numCols = grid.getNumCols(); } recalculateCellSize(MIN_CELL_SIZE); this.zoomIn(); // Zoom in at the beginning

1.Make sure you have created the package named info.gridworld.world. 2.Modify the show() method in the World class as follows. Add the line of code that is highlighted: public void show() { if (frame == null) { frame = new WorldFrame (this); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setVisible(true); } else frame.repaint(); }

1.Make sure you have created the packages named info.gridworld.gui and info.gridworld.world in your project. 2.The frame that the World is based on will need to be modified. The frame is stored in the frame variable in the World class. There is currently no accessor method, so you will need to create one in the World class: public JFrame getFrame() { return frame; } 3.Now you can modify your world class (which extends World). In your logic, you will need to customize the frame as follows: PokerGame game = new PokerGame(new BoundedGrid(6,3)); game.show(); game.getFrame().setSize(345, 750); Width in pixels Height in pixels