Build a 2D Platformer

Total Page:16

File Type:pdf, Size:1020Kb

Build a 2D Platformer March 8, 2014 [BUILD A 2D PLATFORMER - JAVA] inputparallaxscrollingsoundsenmiesobstac lesrgbjumpingrunningblocksvideogameav atarplatformsgameloopslick2Dmousesides crollingdoublejumpsinglescreenvectorjoys tickspritecollisiondetectionbackgroundfraBuild a 2D Platformer merategravityanimationprojectsinmovemeUsing Java ntpaddlescriptingrolep03/08/2014layingobjectsmusic keyboardgameengineimagespaint.netrendnyguerrillagirl@brainycode.com eringgrapicspageflippingprototypenetwor kprogrammingmutltiplayeraudioshadowst ransparencyalphadonkeykonggamemaker mechanicsartificialintelligencepuzzlesgam eplayactionshumpresourcestileslevelscont rolscoreclockapispritesheetrasterraycastin gphysicslevelbuilderdatauihuddesigncode1 March 8, 2014 [BUILD A 2D PLATFORMER - JAVA] Note: This is a working/draft version Copyright © 2014 brainycode.com All rights reserved. Permission is not granted to copy and distribute an electronic version of this document. Please direct links to this website or request permission. Permission is NOT granted for commercial use. 2 March 8, 2014 [BUILD A 2D PLATFORMER - JAVA] Contents Chapter 1 – Getting Started/Introduction ...................................................................................................... 6 Purpose ...................................................................................................................................................... 6 Prerequisites .............................................................................................................................................. 7 The Plan .................................................................................................................................................... 7 Why build your game engine? .............................................................................................................. 7 Best Practices ........................................................................................................................................ 8 Quick History of 2D Platformers .............................................................................................................. 8 How can I play older games (no longer available for sale) or in the arcades? .................................... 11 Writing a Design Document ................................................................................................................... 17 Game Design Document Outline ................................................................................................................ 17 Using Best Practices ............................................................................................................................... 19 What is JUnit? ..................................................................................................................................... 19 What is Ant and Maven? ..................................................................................................................... 19 What’s the plan for learning how to use these tools? .......................................................................... 20 Game Engines ......................................................................................................................................... 20 Does it make sense to develop games using Java? ................................................................................. 22 Overview of the Plan .............................................................................................................................. 22 Exercises ................................................................................................................................................. 23 Directory Setup ................................................................................................................................... 23 Imports ................................................................................................................................................ 25 Creating a test case .............................................................................................................................. 26 Chapter 2 – Graphics .................................................................................................................................. 46 Applications vs. Applets ......................................................................................................................... 46 Organizing the code ............................................................................................................................ 46 Lab 2-1: Creating a program that displays a window and runs as either an application or applet ...... 47 Drawing .................................................................................................................................................. 62 Color ................................................................................................................................................... 62 drawstring() ......................................................................................................................................... 63 Centering the Text ............................................................................................................................... 64 Lab 2-1: continued .............................................................................................................................. 65 Drawing Lines ..................................................................................................................................... 66 Fonts .................................................................................................................................................... 67 3 March 8, 2014 [BUILD A 2D PLATFORMER - JAVA] Lab 2-2: Drawing a Star Field ............................................................................................................. 68 Random Number Generation .............................................................................................................. 70 Drawing Ellipses and Circles .............................................................................................................. 71 Drawing Rectangles ............................................................................................................................ 71 Additional draw methods ........................................................................................................................ 72 drawArc............................................................................................................................................... 72 Lab 2-3: Draw a Happy Face .............................................................................................................. 74 Drawing Polygons ............................................................................................................................... 75 Drawing Images .................................................................................................................................. 77 Lab 2-4: Drawing an Image ................................................................................................................ 78 Clipping............................................................................................................................................... 80 Graphics2D ......................................................................................................................................... 81 Making changes to the objects we draw ................................................................................................. 81 Alpha ................................................................................................................................................... 81 Anti-aliasing ........................................................................................................................................ 81 Scaling Images .................................................................................................................................... 81 Chapter 3 - Introducing the Game Loop ..................................................................................................... 81 Process Input ....................................................................................................................................... 82 Simulate Game World ......................................................................................................................... 82 Render ................................................................................................................................................. 82 What are Threads? .................................................................................................................................. 83 Why do we need Threads in our game program? ............................................................................... 83 Creating a Thread ................................................................................................................................ 85 Lab 3-1: A Quick Introduction to Using Ant ...................................................................................... 87 Lab 3-2: Bouncing Ball ....................................................................................................................... 92 Lab 3-3: Displaying an animated GIF ..............................................................................................
Recommended publications
  • Creating Java Applications Using Netrexx
    SG24-2216-00 Creating Java Applications Using NetRexx September 1997 IBML International Technical Support Organization SG24-2216-00 Creating Java Applications Using NetRexx September 1997 Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix B, “Special Notices” on page 273. First Edition (September 1997) This edition applies to Version 1.0 and Version 1.1 of NetRexx with Java Development Kit 1.1.1 for use with the OS/2 Warp, Windows 95, and Windows NT operating systems. Because NetRexx runs on any platform where Java is implemented, it applies to other platforms and operating systems as well. SAMPLE CODE ON THE INTERNET The sample code for this redbook is available as nrxredbk.zip on the ITSO home page on the Internet: ftp://www.redbooks.ibm.com/redbooks/SG242216 Download the sample code and read “Installing the Sample Programs” on page 4. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. QXXE Building 80-E2 650 Harry Road San Jose, California 95120-6099 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation 1997. All rights reserved. Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Figures . xi Tables . xv Preface . xvii How This Document is Organized ................................ xviii The Team That Wrote This Redbook ...............................
    [Show full text]
  • Installing the Educational Combo Disks
    Installing the Educational Combo Disks Print this page out for reference while installing the emulator program and the Educational Combo Disks. Install AppleWin (Apple II Emulation Program for Windows) You may skip this page if you already have AppleWin properly installed. 1 - In your Documents Library create a new folder named “AppleWin” 2 - Click to follow this link: https://github.com/AppleWin/AppleWin 3 - Click download Version 1.25.0.3 (or latest version) 4 - When asked whether to download or save, click on “save.” The program will be saved in your Downloads file. 5 - Click “open” – a zipped folder will open 6 - Click “Extract all files”” – this will create a sub-folder AppleWin (+ version #) in your Documents folder. 7 - From this folder you may right-click the AppleWin application and then pin it to your start menu or Taskbar. You could also copy the shortcut and paste it to your desktop. 8 - Launch AppleWin by double-clicking on the AppleWin application. 9 - Read the GNU Public License information and click “I accept.” Install Educational Combo Disk Image 1 - In your AppleWin folder, open a new folder named “Educational Combo.” 2 - Use your Internet browser to go to http://www.Bible- prophecy.com/ron/software/educationalcombo/ 3 - A remote folder will open displaying two disk files. 4 - Click on the file (innerglo_educationalcombo_s1_dos33.dsk) 5 - A dialog box will open on the bottom of the page. Use the down-arrow next to “Save” to select “Save as.” 6 - Navigate to your Educational Combo folder and open it. Click “Save.” 7 - Return to the remote folder to transfer the other disk file.
    [Show full text]
  • Gbbs-Tcpser-Howto-01
    This is a basic how-to on setting up an Internet-connected BBS using GBBS Pro and either a real or emulated Apple IIe or IIgs computer. For AppleWin users, the minimum required version is 1.26.3.0 – this version has an ACIA behavior fix that’s needed for GBBS Pro (or any other BBS package) to operate properly. You can find the latest version of AppleWin here: https://github.com/AppleWin/AppleWin In order to connect your real or virtual Apple IIe to the Internet, you’re going to need to set up a “modem emulator”. There’s a number of different choices out there, but for this how-to I’m going to cover one called tcpser. What tcpser does is act as a bridge between the Internet and your Apple IIe (or other vintage computer). As far as your Apple IIe is concerned, it’s talking to a real modem. Setting up a host for tcpser is pretty simple. I’m going to cover two methods that I’ve used myself. Note that tcpser can be built for Linux, Windows, and pretty much any BSD-derived operating system (OpenBSD, FreeBSD, NetBSD, Darwing, etc.) First will be a Raspberry Pi configuration and the second will be a Windows configuration. For the Raspberry Pi option, you’ll need the following items: • Raspberry Pi 3 • USB to Serial adapter – units that use the Prolific PL-2303 chipset are preferred and are known to work well. You can search Amazon for “Prolific PL2303” to see some good examples from the likes of Sabrent and Trendnet.
    [Show full text]
  • Pipelines Guide and Reference
    Pipelines Guide and Reference Ed Tomlinson Jeff Hennick René Jansen Version 4.01-GA of March 20, 2021 THE REXX LANGUAGE ASSOCIATION NetRexx Programming Series ISBN 978-90-819090-3-7 Publication Data ©Copyright The Rexx Language Association, 2011- 2021 All original material in this publication is published under the Creative Commons - Share Alike 3.0 License as stated at http://creativecommons.org/licenses/by-nc-sa/3.0/us/legalcode. The responsible publisher of this edition is identified as IBizz IT Services and Consultancy, Amsteldijk 14, 1074 HR Amsterdam, a registered company governed by the laws of the Kingdom of The Netherlands. This edition is registered under ISBN 978-90-819090-3-7 ISBN 978-90-819090-3-7 9 789081 909037 I Contents The NetR Programming Series i 1 Introduction 1 2 The Pipeline Concept 2 2.1 What is a Pipeline? 2 2.2 Stage 2 2.3 Device Driver 3 3 Running pipelines 4 3.1 Configuration 4 3.2 From the NetREXX Workspace (nrws) with direct execution 5 3.3 From the command line with direct execution 6 3.4 Precompiled Pipelines 6 3.5 Compiled from an .njp file 7 3.6 Compiled from an .njp file with additional stage definitions in NetREXX 7 4 Example Session 8 5 Write your own Filters 12 6 More advanced Pipelines 14 7 Device Drivers 15 8 Record Selection 17 9 Filters 18 10 Other Stages 19 11 Multi-Stream Pipelines 20 12 Pipeline Stalls 22 13 How to use a pipe in a NetR program 24 II 14 Giving commands to the operating system 27 14.1 Built-ins 27 15 TCP/IP Networking 28 16 Selecting from relational databases 30 17 The Pipes Runner 31 18 The Pipes Compiler 32 19 Built-in Stages 33 20 Differences with CMS Pipelines 34 Index 83 III The NetR Programming Series This book is part of a library, the NetR Programming Series, documenting the NetREXX programming language and its use and applications.
    [Show full text]
  • VM/ESA Network Computing with Java and Netrexx
    IBML VM/ESA Network Computing with Java and NetRexx Kris Buelens ** Bengt Heijnesson ** Dave Jones ** Salvador Torres International Technical Support Organization http://www.redbooks.ibm.com This book was printed at 240 dpi (dots per inch). The final production redbook with the RED cover will be printed at 1200 dpi and will provide superior graphics resolution. Please see “How to Get ITSO Redbooks” at the back of this book for ordering instructions. SG24-5148-00 IBML International Technical Support Organization SG24-5148-00 VM/ESA Network Computing with Java and NetRexx November 1998 Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix C, “Special Notices” on page 161. First Edition (November 1998) This edition applies to Virtual Machine/Enterprise Systems Architecture (VM/ESA), Version 2 Release 3.0, Program Number 5654-030, and subsequent releases. Note This book is based on a pre-GA version of a product and may not apply when the product becomes generally available. We recommend that you consult the product documentation or follow-on versions of this redbook for more current information. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. HYJ Mail Station P099 522 South Road Poughkeepsie, New York 12601-5400 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation 1998. All rights reserved. Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp.
    [Show full text]
  • Building Netrexx Systems.Pdf
    Building NetRexx Systems 21st International Rexx Language Symposium René Vincent Jansen 2010-12-13 maandag, 13 december 2010 Agenda Commandline builds nrc ant make maandag, 13 december 2010 Agenda IDE builds Emacs JEdit Eclipse maandag, 13 december 2010 NetRexx The other Object Oriented successor to Classic Rexx 1995, Mike Cowlishaw Runs on the Java VM Compiles NetRexx to Java classes Added an interpreter in 2000 Will be open sourced, probably this next year maandag, 13 december 2010 Command line Aka Shell aka Prompt Unix vs Windows differences java Com.ibm.netrexx.process.NetRexxC resolves dependencies when classes are compiled together maandag, 13 december 2010 Make 1977, Stuart Feldman, Bell’s Labs. ACM Software award 2003 make is a utility that automatically builds executable programs and libraries from source code by reading files called makefiles which specify how to derive the target program The standard version nowadays is GNU Make maandag, 13 december 2010 Make 1977, Stuart Feldman, Bell’s Labs. ACM Software award 2003 make is a utility that automatically builds executable programs and libraries from source code by reading files called makefiles which specify how to derive the target program The standard version nowadays is GNU Make maandag, 13 december 2010 A makefile (called makefile) will be explained in the next few slides maandag, 13 december 2010 Variables and Rules maandag, 13 december 2010 Suffixes and Targets maandag, 13 december 2010 Take care not to remove sources that only have a *.java version Enables the class-in-source model maandag, 13 december 2010 Ant - Another Neat Tool Java based - Cross Platform - Building utility James Duncan Davidson, July 19, 2000 The most immediately noticeable difference between Ant and Make is that Ant uses XML to describe the build process and its dependencies, whereas Make uses Makefile format.
    [Show full text]
  • REXX Portability and Tips Share Session 1570, Boston August, 2010
    IBM Software REXX Portability and Tips Share Session 1570, Boston August, 2010 W. David Ashley [email protected] © 2010 IBM Corporation IBM Software Important REXX Compiler Disclaimer The information contained in this presentation is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this presentation, it is provided “as is”, without warranty of any kind, express or implied. In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this presentation or any other documentation. Nothing contained in this presentation is intended to, or shall have the effect of: • creating any warranty or representation from IBM (or its affiliates or its or their suppliers and/or licensors); or • Altering the terms and conditions of the applicable license agreement governing the use of IBM software. 2 REXX Portability and tips, Share Boston, August 2010 © 2003 IBM Corporation IBM Software Agenda o REXX Compiler o ooRexx o REXX Hints and Tips • Variable Names • Style Tips • Execution Optimization 3 REXX Portability and tips, Share Boston, August 2010 © 2003 IBM Corporation IBM Software REXX History . Rexx (Restructured eXtended eXecutor) . 1979mar29 Mike Cowlishaw (IBM Fellow) publishes initial specification . Late 1979 first implementation internal to IBM on VM/CMS. Available to the general public in 1983 VM (3rd release) – 25 years ago, Winter 1983 Share (San Francisco), Mike Cowlishaw and Rich McGuire demonstrated Rexx to the public.
    [Show full text]
  • Adapting Existing Technologies for Digitally Archiving Personal Lives Digital Forensics, Ancestral Computing, and Evolutionary Perspectives and Tools
    Adapting Existing Technologies for Digitally Archiving Personal Lives Digital Forensics, Ancestral Computing, and Evolutionary Perspectives and Tools Jeremy Leighton John Department of Western Manuscripts, Directorate of Scholarship and Collections, The British Library 96 Euston Road, LONDON NW1 2DB, United Kingdom [email protected] Abstract The project is also addressing in tandem the digitisation of The adoption of existing technologies for digital curation, the conventional papers in personal archives (and in that most especially digital capture, is outlined in the context of sense is also concerned with digital manuscripts beyond personal digital archives and the Digital Manuscripts eMSS). Among other benefits, this will make it easier for Project at the British Library. Technologies derived from researchers to work with an entire personal archive in an computer forensics, data conversion and classic computing, integrated way; but this work along with cataloguing and and evolutionary computing are considered. The practical resource discovery is beyond the scope of the present imperative of moving information to modern and fresh paper, which aims to focus on the curatorial role in digital media as soon as possible is highlighted, as is the need to acquisition, examination and metadata extraction. retain the potential for researchers of the future to experience the original look and feel of personal digital objects. The importance of not relying on any single technology is also emphasised. Theoretical and Practical Considerations The challenges of technological obsolescence, media degradation and the behaviour of the computer user (eg Introduction failure to secure and backup information including Archives of ‘personal papers’ contain letters, notebooks, passwords) are long familiar to the digital preservation diaries, draft essays, family photographs and travel cine community.
    [Show full text]
  • Comparative Programming Languages CM20253
    We have briefly covered many aspects of language design And there are many more factors we could talk about in making choices of language The End There are many languages out there, both general purpose and specialist And there are many more factors we could talk about in making choices of language The End There are many languages out there, both general purpose and specialist We have briefly covered many aspects of language design The End There are many languages out there, both general purpose and specialist We have briefly covered many aspects of language design And there are many more factors we could talk about in making choices of language Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important For example, can you easily join together code written in Java and C? The End Or languages And then the interopability of languages becomes important For example, can you easily join together code written in Java and C? The End Or languages Often a single project can use several languages, each suited to its part of the project For example, can you easily join together code written in Java and C? The End Or languages Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important The End Or languages Often a single project can use several languages, each suited to its part of the project And then the interopability of languages becomes important For example, can you easily
    [Show full text]
  • Apple Ii Emulator Download
    Apple ii emulator download click here to download Apple II emulator for Windows. Contribute to Find file. Clone or download . Download latest (stable) release: AppleWin v Release Notes: v Results 1 - 12 of 12 Sweet16 is the most capable Apple IIgs emulator for computers running Mac OS X. Based on the BeOS version of Sweet16, which was in turn. emutopia | emulation news and files. AppleWin runs Apple II programs from disk images, which are single files that contain the contents of an entire Apple. Sep 19, AppleWin is an Apple II emulator for Windows that is able to emulate an Apple II, II+ and IIe. It emulates the Extended Keyboard IIe (also known. microM8 is an enhanced Apple IIe emulator that allows you to "upcycle" classic games using 3D graphics Download microm8 for macOS, Windows or Linux. AppleWin is an open source software emulator for running Apple II programs in Download Applewin (K) Some emulators may require a system. Apple ][js and Apple //jse - An Apple ][ Emulator and them so no need to download & upload roms. Apple - II Series emulators on Windows and other platforms, free Apple - II Series emulator downloads, as well as savestates, hacks, cheats, utilities, and more. AppleWin is the best Apple IIe emulator we have encountered so far to play Apple II Search for and download an Apple IIe game file and copy it to the game. KEGS - Kent's Emulated GS. An Apple IIgs emulator for Mac OS X, Win32, Linux, and Unix/X Download version - Virtual Modem support. Download. apple ii emulator free download.
    [Show full text]
  • The Universal Language the Universal Language
    Rexx The Universal Language By Howard Fosdick EVERYONE WHO WORKS WITH MAINFRAMES KNOWS ABOUT REXX. IT’S THE command or “scripting” language that’s been shipped with all main- Classic frames for years. It’s versatile, flexible, and powerful. Somehow it still procedural Rexx manages to be very easy to learn and use. Runs on any In recent years, Rexx has spread its wings. It now runs as an open platform source language on virtually every platform and operating system. Object-oriented Moreover, it comes in object-oriented and Java-compatible forms. This Rexx article gives you a quick tour of modern Rexx. We’ll summarize the Runs on Windows, different versions of Rexx. We’ll describe the many free Rexx inter- Linux, Unix Java-compatiable preters and tools that are available, and tell you where you can down- NetRexx load them. Before we proceed, you might ask: why should I care? The answer Runs on any Java Virtual Machine comes down to two key benefits: Figure 1: Three Rexx Flavors ▼ Transferability of skills Interpreter Platforms Quick Profile ▼ Transportability of code Regina All major operating The most popular free procedural Rexx. Its large user community systems means good support and it interfaces to most free tools and inter- If you know Rexx, you know a universal pro- faces. Comes with many extra built-in functions and excellent, pro- gramming language. Since it runs everywhere, fessional documentation. Download from: this makes your Rexx skills transferable to http://regina-rexx.sourceforge.net/ other platforms. For example, you work on the Rexx/imc Linux, Unix, BSD Unix, Linux, and BSD -oriented with nice extensions for Unix pro- mainframe but use a PC.
    [Show full text]
  • Call-A.P.P.L.E. Magazine ISSN 8755-4909 1705-4109
    Call–A.P.P.L.E. World’s Largest Apple User Group Magazine Volume 26 Number 1 December 2016 www.callapple.org KansasFest 2016 Keynote Speaker Mike Harvey: The Complete Interview Castles of Darkness Woz Speaks Sneak Preview Australian Apple Review Redux Wendell Sander's Apple-1 Project Turtlesoft Returns Making Basic Behave: User Input Washington Apple Pi Newsletters And More... Apple PugetSound Program Library Exchange Volume 26 Number 1 December 2016 www.callapple.org A.P.P.L.E. Board of Directors A.P.P.L.E. Staff Chairman – Bill Martens Editor-in-Chief – Bill Martens Director – Brian Wiser Managing Editor – Brian Wiser Director – Jim Maricondo Staff Writer – Javier Rivera Data Digitization – Antoine Vignau Production & Design Bill Martens Contributing Authors Brian Wiser Quinn Dunkie Rick Sutcliffe Cover Photo Brian Wiser Call-A.P.P.L.E. Magazine ISSN 8755-4909 1705-4109 Subscriptions Submissions Subscriptions to Call-A.P.P.L.E. magazine can be attained by Call-A.P.P.L.E. is always looking for new and interesting articles. joining the Apple Pugetsound Program Library Exchange If you are a writer or hacker who would like to submit an article (A.P.P.L.E.) user group, founded in 1978. The magazine is or idea for possible inclusion in the magazine, please email your one of the premium benefits. For more information, please proposal to [email protected]. By submitting materials visit the membership page at: www.callapple.org/members to us, you agree to give A.P.P.L.E. the royalty-free, perpetual, non-exclusive right to publish and reuse your submission in any form in any media and to use your name with the submission.
    [Show full text]