EZ Graphics

What is EZ?

  • "EZ is a multimedia library designed to make it easier for novice programmers to quickly build Java applications that incorporate graphics and sound."
  • This way, you can make cool animations and graphics easily with EZ
    • Normally, graphics are pretty insane for beginners to implement
  • Written and coded by Dylan Kobayashi

Obtaining EZ

http://www2.hawaii.edu/~dylank/ics111/

 

It is a Java file that you should save as EZ.java and import into your project package

Eclipse

  • Eclipse is the IDE we will be using
    • Great for (mostly) Java and other languages; tons of plugins!
  • Open Eclipse and select where your workspace directory will be

Your Project

  • Downloading the project:
    • https://github.com/junior-devleague/InteractiveStoryAppDevWorkshop16
    • Click on the green button "Clone or Download"
    • Choose "Download ZIP"
    • Extract the archive and drag & drop the resulting folder into your workspace directory
  • EZsound only works with .wav files!!!!!
  • Use GIMP to edit your images (Export to save as a new file type)
  • Use Audacity to edit and compress your sound files (MAKE SURE THEY'RE WAV)

Using EZ

  • For Eclipse, the EZ.java file should be in your package, while the supplementary image/sound files should be in the root project directory
    • In your workspace directory, EZ.java and your other .java files should be in the src directory, with the other files in your project directory
  • Read the copyright to avoid copyright infringement (which shouldn't be a problem for this class since we aren't using it commercially)

Using EZ

  • The JavaDocs (basically like documentation/comments in the code) are comprehensive and explain each method thoroughly, with examples of how to use it!
  • You create a variable of whatever type you need; Ex:
    • EZImage image = EZ.addImage("smile.png", 200, 300);
    • EZRectangle rect = EZ.addRectangle(200, 500);
  • The parameters are usually the file name, size of the graphic (widthxheight in pixels), and/or where it's centered (x by y)
  • Initialize EZ and create the window that the user sees/interacts with by using EZ.initialize(width, height)
    • Use actual numbers to represent pixels for width and height to set the window size
  • The origin is the upper left (x goes right, y goes down)
import java.awt.Color;
import java.awt.Rectangle;

public class HelloWorld {

    public static void main(String[] args) {
        // Creates a window of size 200x200
        EZ.initialize(200, 200);

        // Creates a (filled) rectangle
        // size 30x5, centered at 120, 100
        EZRectangle r;
        r = EZ.addRectangle(120,100,30,5,Color.BLACK,true);

        // Creates text on the window centered at 100, 100
        EZ.addText(100, 100, "Hello World", Color.BLACK);
    }

}

EZ Code to Change

  • Line 808 of EZ.java (in the initialize() method)
    • What do you think this does?
  • script.txt contains the script for the paths and image/sound files
  • DON'T touch anything except script.txt, ImageTransform.java, Window.java, and GameController.java
    • You must be extremely careful when changing Window.java, and if you do, change one thing at a time and test each change!!!!!!!!!!!!!!!!!!!

Running the Game for the First Time

  • In the Project Explorer, delete "InteractiveStorybook"
    • DON'T delete the local files saved to the hard disk
  • Then, click File > New > Java Project
  • Name it "InteractiveStorybook"
  • All of your files should be there
  • Open GameController.java and run
Made with Slides.com