37
240-492 Java Games. Prelim/0 Games Programming with Java Games Programming with Java Objective Objective to give some background on my pa to give some background on my pa rt of the course rt of the course 240-492, Special Topics in Comp. Eng. II Semester 1, 2002-2003 Who I am: Andrew Davison CoE, Info. Eng. Research Lab (Rm 101) [email protected] 0. Preliminar ies Please ask questions

240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

Embed Size (px)

Citation preview

Page 1: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 1

Games Programming with JavaGames Programming with Java

ObjectiveObjective– to give some background on my part of the coto give some background on my part of the co

urse urse

240-492, Special Topics in Comp. Eng. II Semester 1, 2002-2003

Who I am:Andrew DavisonCoE, Info. Eng. Research Lab (Rm 101)[email protected]

0. Preliminaries Please askquestions

Page 2: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 2

OverviewOverview

1. 1. Outline of the CourseOutline of the Course

2.2. PrerequistesPrerequistes

3.3. Main TopicsMain Topics

4. 4. Meeting Times / LocationsMeeting Times / Locations

5. 5. WorkloadWorkload

6. 6. Course MaterialsCourse Materials

continued

Page 3: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 3

7. 7. Java Games BooksJava Games Books

8.8. Other Games BooksOther Games Books

9.9. Java Games URLsJava Games URLs

10.10. Other Games URLs Other Games URLs

Page 4: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 4

1. Outline of the Course1. Outline of the Course

Highlight techniques that make Highlight techniques that make 2D games 2D games programming in Javaprogramming in Java easier and quicker easier and quicker– e.g. reusable game classes, standard gaming e.g. reusable game classes, standard gaming

frameworks, notation and coding rules for game frameworks, notation and coding rules for game behaviourbehaviour

Compare various game programming Compare various game programming techniques.techniques.

continued

Page 5: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 5

Develop arcade-style 'Develop arcade-style 'Alien AttackAlien Attack ' games which ' games which illustrates these techniques.illustrates these techniques.

Networking techniques for Java gamesNetworking techniques for Java games– e.g. sequential vs. multi-threaded servers, threaded I/O, server-e.g. sequential vs. multi-threaded servers, threaded I/O, server-

side shared data classes, N-person and 2-person network gamesside shared data classes, N-person and 2-person network games

Develop a networked Develop a networked 'Chat''Chat' system, a paint program and system, a paint program and a a 'Tic Tac Toe''Tic Tac Toe' game which illustrate these techniques. game which illustrate these techniques.

Page 6: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 6

2. Prerequistes2. Prerequistes

Enrolment in 240-424 "Introduction to Java Enrolment in 240-424 "Introduction to Java Programming" is Programming" is requiredrequired in this semester in this semester (semester 1) unless students have already (semester 1) unless students have already done the course. done the course.

Why?Why?

continued

Page 7: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 7

This subject will use many features of Java:This subject will use many features of Java:– classes, inheritance, threads, timers, 2D graphics, eveclasses, inheritance, threads, timers, 2D graphics, eve

nt listeners, GUI controls, layout managers, file manint listeners, GUI controls, layout managers, file manipulationpulation

– these will not be explained, or explained very brieflythese will not be explained, or explained very briefly

Any student who does not enrol in 240-424 will Any student who does not enrol in 240-424 will be be preventedprevented from enrolling in this course. from enrolling in this course.

Page 8: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 8

3. Main Topics3. Main Topics

Part 1.Part 1. Weeks 1 - 5Weeks 1 - 5– AI techniques: A*, neural networks, etc.AI techniques: A*, neural networks, etc.– taught by Aj. Montritaught by Aj. Montri

Part 2.Part 2. Weeks 6 - 16 (end of semester)Weeks 6 - 16 (end of semester)– taught by Aj. Andrewtaught by Aj. Andrew– a total of a total of 4747 hours but only 10 weeks! hours but only 10 weeks!

we must schedule some extra classeswe must schedule some extra classes

Page 9: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 9

Topics in Part 2Topics in Part 2

1. Preliminaries and Background (1 hour)1. Preliminaries and Background (1 hour)

2. Java Coding Style (2 hours)2. Java Coding Style (2 hours)– the coding style used for applications/applets in part the coding style used for applications/applets in part

2, summary of basic Java graphics, Java2D2, summary of basic Java graphics, Java2D

3. Basic Animations (3 hours)3. Basic Animations (3 hours)– two animation techniques: thread-based, timer-based, two animation techniques: thread-based, timer-based,

other approachesother approaches

continued

Page 10: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 10

4. Animation using Inheritance (2 hours)4. Animation using Inheritance (2 hours)

5. User Interaction (3 hours)5. User Interaction (3 hours)– utilising keyboard and mouse inpututilising keyboard and mouse input

6. Image Sprites (4 hours)6. Image Sprites (4 hours)– cannons, molecules, pongcannons, molecules, pong

7. Images Sprites (3 hours)7. Images Sprites (3 hours)– improving the sprite class in part 6improving the sprite class in part 6

continued

Page 11: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 11

8. Alien Attack v.1 (3 hours)8. Alien Attack v.1 (3 hours) 9. Alien Attack v.2 (2 hours)9. Alien Attack v.2 (2 hours)

10. More Complex Backgrounds (5 hours)10. More Complex Backgrounds (5 hours)– a background made up of ‘rooms’a background made up of ‘rooms’– a background that scrolls behind the spritea background that scrolls behind the sprite– a dynamically generated backgrounda dynamically generated background

11. Racing round a 2D maze11. Racing round a 2D maze (2 hours)(2 hours)

continued

Page 12: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 12

12. Isometric (tile-based) Games12. Isometric (tile-based) Games (3 hours)(3 hours)– basic ideas:basic ideas:

tile layout, movement of background, drawing layers, no-go areas, tile layout, movement of background, drawing layers, no-go areas, obstacles, things to pickupobstacles, things to pickup

– TileImagesSprite class (and subclasses)TileImagesSprite class (and subclasses)

– the alien classes implement different behaviours:the alien classes implement different behaviours: pickup guarding, player chasingpickup guarding, player chasing

– pathfinding using A*pathfinding using A*

continued

Page 13: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 13

13. Full-screen Games13. Full-screen Games (3 hours)(3 hours)– full-screen coding using Swingfull-screen coding using Swing– full-screen coding using features of J2SDK 1.4full-screen coding using features of J2SDK 1.4

full-screen exclusive mode, active rendering, and full-screen exclusive mode, active rendering, and double buffering/page flippingdouble buffering/page flipping

– checking the capabilities of your OS/hardwarechecking the capabilities of your OS/hardware– VolatileImages exampleVolatileImages example

continued

Page 14: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 14

14. Networking Basics (3 hours)14. Networking Basics (3 hours)– client/server networking using TCP and UDP client/server networking using TCP and UDP

sockets, sequential and multi-threaded serverssockets, sequential and multi-threaded servers

15. Networked Chat (3 hours)15. Networked Chat (3 hours) 16. Networked Paint Program (2 hours)16. Networked Paint Program (2 hours) 17. Networked Tic Tac Toe (3 hours)17. Networked Tic Tac Toe (3 hours)

Page 15: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 15

4. Meeting Times / Locations4. Meeting Times / Locations

MondayMonday 10.00-11.0010.00-11.00 R201R201 FridayFriday 10.00-11.0010.00-11.00 R201R201 FridayFriday 13.00-14.0013.00-14.00 R201R201

Times/locations may change if you Times/locations may change if you askask Aj. Montri or Aj. Andrew.Aj. Montri or Aj. Andrew.

Page 16: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 16

5. Workload (% of total score)5. Workload (% of total score)

Mid-tern Exam: 35%Mid-tern Exam: 35%– ?? (week 9, July 29th - August 4th); ?? (week 9, July 29th - August 4th); 2 hours2 hours

Project: 20%: arcade-style gameProject: 20%: arcade-style game– 2 weeks; probably weeks 13-142 weeks; probably weeks 13-14

Final Exam: 45%Final Exam: 45%– ?? (Sept. 23rd - Oct. 4th); ?? (Sept. 23rd - Oct. 4th); 3 hours3 hours

Page 17: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 17

Non-Attendence PenaltyNon-Attendence Penalty

I I maymay take registration at the start of a class. take registration at the start of a class.

If someone is not there, they lose If someone is not there, they lose 1%1% (unless they have a good excuse)(unless they have a good excuse)..

A maximum of A maximum of 10%10% can be lost can be lost– deducted from your final markdeducted from your final mark

Page 18: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 18

6. Course Materials6. Course Materials

I will hand out one copy of my slidesI will hand out one copy of my slides– you should make copies of themyou should make copies of them

Slides, code examples, background information will be made Slides, code examples, background information will be made available at:available at:

http://fivedots.coe.psu.ac.th/http://fivedots.coe.psu.ac.th/Software.coe/Java%20Games/Software.coe/Java%20Games/

– I’ll refer to this as the directory I’ll refer to this as the directory “Java Games/”“Java Games/”

Page 19: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 19

Software for this CourseSoftware for this Course

The software tools we will be using are The software tools we will be using are already here:already here:

ftp://ftp.coe.psu.ac.th/pub/ftp://ftp.coe.psu.ac.th/pub/jjava/ava/

Download (at least):Download (at least):– JDK 1.4JDK 1.4 j2sdk-1_4_0-rc-win.exej2sdk-1_4_0-rc-win.exe

– documentation documentation j2sdk-1_4_0-rc-doc.zipj2sdk-1_4_0-rc-doc.zip

– tutorial tutorial sun-java-tutorial.zipsun-java-tutorial.zip

continued

Page 20: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 20

I have also made a copy of the main Java I have also made a copy of the main Java software onto a CDsoftware onto a CD– see me if you want to borrow the CDsee me if you want to borrow the CD

Page 21: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 21

7. Java Games Books7. Java Games Books

Black Art of Java Game ProgrammingBlack Art of Java Game ProgrammingJoel Fan, Eric Ries, Calin TenitchiJoel Fan, Eric Ries, Calin TenitchiWaite Group Press, 1996Waite Group Press, 1996– very old: uses JDK 1.0very old: uses JDK 1.0

– coding techniques have coding techniques have changed since 1996 changed since 1996

In the CoElibrary

continued

Page 22: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 22

– some nice ideas for games: JAVAroids, some nice ideas for games: JAVAroids, Daleks, NetOthello, WordQuest, Magic Daleks, NetOthello, WordQuest, Magic Squares, Internet MahJong, slider puzzle, Squares, Internet MahJong, slider puzzle, worm worm

– I used the first few chapters as a source of I used the first few chapters as a source of ideas for my examplesideas for my examples

Page 23: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 23

Game for JavaGame for JavaKhun ChawisnachKhun ChawisnachSuccess Media, 2545Success Media, 2545– written in Thai; 95 Bahtwritten in Thai; 95 Baht– poorly coded, but uses JDK 1.3poorly coded, but uses JDK 1.3– simple examples: simple examples:

catch apples, sail a boat, UFO attack, catch apples, sail a boat, UFO attack, photo huntphoto hunt

– code, comments available at code, comments available at http://www.successmedia.com/index/http://www.successmedia.com/index/ bookcomment.asp?lngproductID=381 bookcomment.asp?lngproductID=381

Available from me, or local book shops

Page 24: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 24

Teach Yourself Internet Game Programming Teach Yourself Internet Game Programming With Java in 21 DaysWith Java in 21 DaysMichael MorrisonMichael MorrisonSams Publishing, September 1996Sams Publishing, September 1996– very old, uses JDK 1.0very old, uses JDK 1.0– discussion of game ideas is gooddiscussion of game ideas is good

continued

Page 25: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 25

The HTML version of the book is available online at a few The HTML version of the book is available online at a few places:places:– http://www.njnet.edu.cn/info/ebook/http://www.njnet.edu.cn/info/ebook/

java/javagame/ java/javagame/ but the images are missingbut the images are missing

– http://w3.softlookup.com/games/http://w3.softlookup.com/games/ but lots of pop-up window adsbut lots of pop-up window ads

I have downloaded the I have downloaded the source codesource code from the book; it is in: from the book; it is in:– ““Java Games/Background/Java Games/Background/

internetGames.zip”internetGames.zip”

Page 26: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 26

8. Other Games Books8. Other Games Books

We have bought several other games books We have bought several other games books for the CoE library, which are not directly for the CoE library, which are not directly related to Java.related to Java.

Most of them describe how to use MS Most of them describe how to use MS Visual C++ with DirectX (v. 8.0) or Visual C++ with DirectX (v. 8.0) or OpenGL.OpenGL.

Page 27: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 27

Game Programming Game Programming GemsGems We have volume 1 and 2We have volume 1 and 2

– edited by Mark DeLouraedited by Mark DeLouraCharles River Media, 2000, 2001Charles River Media, 2000, 2001

– excellent techniquesexcellent techniques maths, AI, geometry, display, audio, maths, AI, geometry, display, audio,

pixel effects, etc.pixel effects, etc.

– coded in C/C++; source on CDcoded in C/C++; source on CD– some emphasis on some emphasis on

DirectX and OpenGLDirectX and OpenGL

Page 28: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 28

เขี�ยนเกมอยางม�ออาชี�พด้�วย เขี�ยนเกมอยางม�ออาชี�พด้�วย Visual C+Visual C++ + และ และ Direct XDirect X

ผู้��แต่ง น�รุ�ธ อ�านวยศิ�ลป์� ผู้��แต่ง น�รุ�ธ อ�านวยศิ�ลป์� บรุรุณาธ�การุ สั#จจะ จรุ#สัรุ� งรุว�วรุ บรุรุณาธ�การุ สั#จจะ จรุ#สัรุ� งรุว�วรุ

http://www.infopress2000.com/update/http://www.infopress2000.com/update/ each.php?isbn=974-90142-9-4&type=book each.php?isbn=974-90142-9-4&type=book

– a simple introduction; ~300 pagesa simple introduction; ~300 pages– some poor code, but mostly oksome poor code, but mostly ok– no CD; I cannot find the source code onlineno CD; I cannot find the source code online

Page 29: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 29

Four English titles:Four English titles:– The Zen of Direct3D Game ProgrammingThe Zen of Direct3D Game Programming

explains basic windows programming, 2D, 3D mathsexplains basic windows programming, 2D, 3D maths

– Multiplayer Game ProgrammingMultiplayer Game Programming poorly written; good coding in DirectXpoorly written; good coding in DirectX

– OpenGL Game ProgrammingOpenGL Game Programming well written; explains the basics firstwell written; explains the basics first

– Isometric Game Programming with DirectX 7.0Isometric Game Programming with DirectX 7.0 very good; includes mazes, AI; hardly any 3D very good; includes mazes, AI; hardly any 3D

– very large: 800-900 pages each; includes CDvery large: 800-900 pages each; includes CD

Page 30: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 30

9. Java Games URLs9. Java Games URLs

CSC 490-12 CSC 490-12 Computer Game Design and Computer Game Design and ProgrammingProgramming– http://turing.sunyit.edu/dussauh/http://turing.sunyit.edu/dussauh/

csc490.htmcsc490.htm

– Heather Dussault, SUNY Institute of Tech.Heather Dussault, SUNY Institute of Tech.– Powerpoint slides, some codePowerpoint slides, some code– spends a lot of time introducing Javaspends a lot of time introducing Java

Page 31: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 31

JavaGaming.orgJavaGaming.org– http://www.javagaming.org/http://www.javagaming.org/

– sponsored by Sun Microsystemssponsored by Sun Microsystems– news, a few tutorials, news, a few tutorials, excellent linksexcellent links– code examples such as: isometric scrollercode examples such as: isometric scroller

the games style used in Civilization, Sim City, etcthe games style used in Civilization, Sim City, etc

– screenshots of commercial Java games in screenshots of commercial Java games in developmentdevelopment

Page 32: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 32

Game Developers Java Users Group Game Developers Java Users Group (GameJUG)(GameJUG)– http://gamejug.org/ http://gamejug.org/

– areas covered include: arcade, archive, books, areas covered include: arcade, archive, books, FAQ, sites, tutorialsFAQ, sites, tutorials

the links to sites and tutorials are goodthe links to sites and tutorials are good

Page 33: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 33

Java Game Development Center (JGDC)Java Game Development Center (JGDC)– http://www.electricfunstuff.com/jgdc/http://www.electricfunstuff.com/jgdc/

– sections include: tutorials, resources (e.g. sections include: tutorials, resources (e.g. books), mailing lists, galleries of Java games, books), mailing lists, galleries of Java games, links to useful sites. links to useful sites.

– good/ok tutorials: mazes, arcade games, basic good/ok tutorials: mazes, arcade games, basic animation, starfields, etc.animation, starfields, etc.

Page 34: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 34

I am collecting URLs to Java games and games I am collecting URLs to Java games and games engines (support code for building games). engines (support code for building games). They are in:They are in:– Java Games/Background/gameColls.txtJava Games/Background/gameColls.txt

pointers to game collectionspointers to game collections– Java Games/Background/gameEngines.txtJava Games/Background/gameEngines.txt

pointers to game engine sitespointers to game engine sites– Java Games/Background/sourceForge.txtJava Games/Background/sourceForge.txt

pointers to game and game engines maintained at the pointers to game and game engines maintained at the SourceForge Web siteSourceForge Web site

Page 35: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 35

10. Other Games URLs10. Other Games URLs

GameDev.netGameDev.net– http://www.gamedev.nethttp://www.gamedev.net

– 100’s of articles on games development100’s of articles on games development e.g. openGL, DirectX, networking, audio, AIe.g. openGL, DirectX, networking, audio, AI

– active forumsactive forums– news, code samples, reviews, games dictionarynews, code samples, reviews, games dictionary

Page 36: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 36

Game Development Search EngineGame Development Search Engine– http://www.gose.comhttp://www.gose.com

– includes news and links to smaller game includes news and links to smaller game development sitesdevelopment sites

FlipCodeFlipCode– http://www.flipcode.comhttp://www.flipcode.com

– news, articlesnews, articles

Page 37: 240-492 Java Games. Prelim/01 Games Programming with Java v Objective –to give some background on my part of the course 240-492, Special Topics in Comp

240-492 Java Games. Prelim/0 37

GamesutraGamesutra– http://www.gamasutra.comhttp://www.gamasutra.com

– content from content from Game Developer MagazineGame Developer Magazine and the Game and the Game Developer conferenceDeveloper conference

OpenGL official siteOpenGL official site– http://www.opengl.orghttp://www.opengl.org

DirectX official siteDirectX official site– http://msdn.microsoft.com/directxhttp://msdn.microsoft.com/directx