DOC PREVIEW
Duke CPS 004 - Applets & Video Games

This preview shows page 1-2-3-4-5-6 out of 19 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 19 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Applets & Video GamesThe PlanAppletsDefinitionApplet vs. ApplicationRunning an AppletHTML for AppletJar filesDemoVideo GamesVideo Game as SimulationMeasurement UnitsDiscrete vs. Continuous TimeMonitor Frame RateModel Frame RateUser Interaction RateHow it happens “all at once”SummarySlide 19CompSci 46.1Applets & Video GamesApplets & Video GamesCompSci 46.2Applets & Video GamesThe PlanAppletsDemo on making and running a simple applet from scratchDemo on making and running a simple application from scratchVideo GamesMeasurements Frame ratesThreadsCompSci 46.3Applets & Video GamesAppletsDefinitionDifferences from applicationsDownload processUse of htmlUse of jar filesExampleCompSci 46.4Applets & Video GamesDefinitionFrom the Java 5.0 APIAn applet is a small program that is intended notto be run on its own, but rather to be embeddedinside another application.The name Applet is derived from the name Application.CompSci 46.5Applets & Video GamesApplet vs. ApplicationAppletsRun in web browserOften downloaded from untrusted siteRestricted from file system accessRestricted from outside network communicationApplicationsRun independentlyTypically obtained through trusted sourceAllow creation and modifications of filesAllow outside network communicationMust have a main methodCompSci 46.6Applets & Video GamesRunning an Applet1. Load a web page with an <applet> tag embedded in the HTML2. Load the compiled applet from website to local machine3. Run the compiled applet on the local machineCompSci 46.7Applets & Video GamesHTML for Applet<applet code=“pong/Pong.class” archive=“pong.jar” width=200 height=200></applet>code is the name of the class that extends JAppletarchive is the name of the jar file containing all classesCompSci 46.8Applets & Video GamesJar filesJar is short for Java ArchiveCompresses files and directories into a single fileCan be executed in compressed formatFiles and directories can be extractedCan contain any combination of source code, byte code, and other filesCompSci 46.9Applets & Video GamesDemoApplet DemoMake an applet in EclipseMake the html in composerSave both to network driveView from the webApplication DemoMake an application in EclipseRun in EclipseCompSci 46.10Applets & Video GamesVideo GamesSimulationMeasurement unitsDiscrete/ContinuousMonitor frame rate limitationModel frame rate limitationUser interaction rateThreads overviewCompSci 46.11Applets & Video GamesVideo Game as SimulationVideo games are simulations of the real world and worlds that do not exist. These simulations are built for our pleasure, but may serve other purposes as well.ExamplesFlight simulatorOregon trailPinballCompSci 46.12Applets & Video GamesMeasurement UnitsInitial setup in coordinate system with origin at top left and (1, 1) at bottom rightAllows simple scaling to varying screen resolutionsCan be done hierarchicallyDistances in pixelsTime in secondsVelocity in pixels/secondCompSci 46.13Applets & Video GamesDiscrete vs. Continuous TimeDiscreteUsed to approximate continuousSimple conceptually for good rough estimatesCauses problems when modeling continuous functions with too coarse grain estimatesContinuousRequires abstract representation or infinite precisionRequires analytical reasoningConceptually difficult to model directlyCompSci 46.14Applets & Video GamesMonitor Frame RateWhy 75-85 Hz (Frames/second)?Because we don’t actually visually process continuouslySmooth fast movement?Consider a rate of 1 pixel a second would take more than 8 seconds to move across the screen.For fast movement there must be jumps in location.CompSci 46.15Applets & Video GamesModel Frame RateModel is continuous.Frame rate is discrete.The granularity of frame rate is too coarse for our continuous model.How do we solve this problem? Two separate rates:Monitor frame rateModel frame rateCompSci 46.16Applets & Video GamesUser Interaction RateDevices such as the keyboard and mouse must also be polled at regular intervals.At what rate should they be polled?Depends on:Available compute powerIn contention with monitor frame rateIn contention with model frame rateWhich thread has priorityCompSci 46.17Applets & Video GamesHow it happens “all at once”Threads!Threads are like programs within programsSeem to run all at once, but typically share resources, primarily the processorCost overhead for switching the thread runningCompSci 46.18Applets & Video GamesSummaryUser interaction, model frame rate, and monitor frame rate all contend for the processor.Threads enable programs to behave as if several sub-programs (threads) were running at once.Continuous events can be modeled discretely.Careful selection of measurement units can simplify program modifications.Video games can be viewed as simulations.CompSci 46.19Applets & Video GamesSummaryApplets are like small applications run from a web browser.have security restrictions.require HTML code to be executedare downloaded from a remote site and executed locallyuse jar files to compress and combine all compiled code and supporting


View Full Document

Duke CPS 004 - Applets & Video Games

Documents in this Course
Lecture

Lecture

18 pages

Chapter 7

Chapter 7

18 pages

Chapter 9

Chapter 9

15 pages

Java 1

Java 1

24 pages

Java 3

Java 3

11 pages

Lecture

Lecture

10 pages

Chapter 4

Chapter 4

28 pages

Chap 2

Chap 2

16 pages

Graphics

Graphics

20 pages

Lecture

Lecture

12 pages

HTML

HTML

16 pages

Java 1

Java 1

6 pages

Chapter 4

Chapter 4

16 pages

The Plan

The Plan

25 pages

Lecture

Lecture

16 pages

Chapter 6

Chapter 6

21 pages

Lecture

Lecture

18 pages

Lecture

Lecture

23 pages

Lecture

Lecture

16 pages

Lecture

Lecture

19 pages

Lecture

Lecture

12 pages

Lecture

Lecture

5 pages

Lecture

Lecture

26 pages

Lecture

Lecture

16 pages

Chapter 7

Chapter 7

23 pages

Lecture

Lecture

21 pages

Lecture

Lecture

4 pages

Lecture

Lecture

4 pages

Lecture

Lecture

8 pages

Lecture

Lecture

4 pages

Lecture

Lecture

10 pages

Chapter 4

Chapter 4

32 pages

Java

Java

4 pages

CompSci 4

CompSci 4

18 pages

Lecture

Lecture

26 pages

CompSci 4

CompSci 4

12 pages

HTML

HTML

17 pages

Lecture

Lecture

16 pages

Chapter 5

Chapter 5

22 pages

Lecture

Lecture

4 pages

Chapter 4

Chapter 4

10 pages

Chapter 2

Chapter 2

15 pages

Chapter 8

Chapter 8

14 pages

Lecture

Lecture

15 pages

Load more
Download Applets & Video Games
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Applets & Video Games and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Applets & Video Games 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?