ebook img

DarkBASIC programming for the absolute beginner PDF

427 Pages·2008·17.45 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview DarkBASIC programming for the absolute beginner

DarkBASIC Programming for the Absolute Beginner Jerry Lee Ford, Jr. Course Technology PTR A part of Cengage Learning Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States Publisher and General Manager, Course © 2008 Course Technology, a part of Cengage Learning. Technology PTR: Stacy L. Hiquet ALL RIGHTS RESERVED. No part of this work covered by the copyright Associate Director of Marketing: herein may be reproduced, transmitted, stored, or used in any form or by Sarah Panella any means graphic, electronic, or mechanical, including but not limited to photocopying, recording, scanning, digitizing, taping, Web distribution, Manager of Editorial Services: information networks, or information storage and retrieval systems, except Heather Talbot as permitted under Section 107 or 108 of the 1976 United States Copyright Marketing Manager: Mark Hughes Act, without the prior written permission of the publisher. Acquisitions Editor: Mitzi Koontz Project Editor: Jenny Davidson For product information and technology assistance, contact us at Cengage Learning Academic Resource Center, 1-800-354-9706 Technical Reviewer: Keith Davenport For permission to use material from this text or product, submit all PTR Editorial Services Coordinator: requests online at cengage.com/permissions Erin Johnson Further permissions questions can be emailed to Interior Layout Tech: Value Chain [email protected] Cover Designer: Mike Tanamachi DarkBASIC is a copyright of The Game Creators Ltd, all rights reserved. Indexer: Sharon Shock All other trademarks are the property of their respective owners. Proofreader: Sara Gullion Library of Congress Catalog Card Number: 2007923317 ISBN-13: 978-1-59863-385-6 ISBN-10: 1-59863-385-6 eISBN-10: 1-59863-662-6 Course Technology 25 Thomson Place Boston, MA 02210 USA Cengage Learning is a leading provider of customized learning solutions with office locations around the globe, including Singapore, the United Kingdom, Australia, Mexico, Brazil, and Japan. Locate your local office at: international.cengage.com/region Cengage Learning products are represented in Canada by Nelson Education, Ltd. For your lifelong learning solutions, visit courseptr.com Purchase any of our products at your local college store or at our preferred online store www.ichapters.com Printed in the United States of America 1 2 3 4 5 6 7 11 10 09 08 To my mother and father for always being there, and to my wonderful children, Alexander, William, and Molly, and my beautiful wife, Mary. A CKNOWLEDGMENTS T here are a number of individuals who deserve credit for their work on this book. I would like to thank Mitzi Koontz who served as the book’s acquisitions editor. Special thanks also go to Jenny Davidson and Keith Davenport for serving as the book’s project and technical editors. In addition, I would like to thank everyone else at Course Technology for all their hard work. A A BOUT THE UTHOR J erry Lee Ford, Jr. is an author, educator, and an IT professional with over 18 years’ experience in information technology, including roles as an automation analyst, technical manager, technical support analyst, automation engineer, and security analyst. He is the author of 24 other books and co-author of two additional books. His published works include AppleScript Studio Programming for the Absolute Beginner, Microsoft Windows PowerShell Programming for the Absolute Beginner, Microsoft Visual Basic 2005 Express Edition Programming for the Absolute Beginner, VBScript Professional Projects, Microsoft Windows Shell Scripting and WSH Administrator’s Guide, Microsoft Windows Shell Script Programming for the Absolute Beginner, Learn JavaScript in a Weekend, and Microsoft Windows XP Professional Administrator’s Guide. Jerry has a master’s degree in business administration from Virginia Commonwealth University in Richmond, Virginia, and has more than five years’ experience as an adjunct instructor teaching networking courses in information technology. This page intentionally left blank Table of Contents Part I Introducing DarkBASIC Professional................... 1 Chapter 1 Introducing DarkBASIC Professional................... 3 Project Preview: The Dark Jokes Game............................................................................. 4 A Quick Overview of DarkBASIC Professional................................................................ 8 DarkBASIC Versus DarkBASIC Professional..................................................................... 8 Setting Up DarkBASIC Professional................................................................................ 10 Installing DarkBASIC Professional.......................................................................... 10 Updating DarkBASIC Professional.......................................................................... 11 Installing DirectX 9.0c............................................................................................... 11 Activating DarkBASIC Professional........................................................................ 12 A Quick DarkBASIC Demonstration................................................................................ 15 Creating a New DarkBASIC Project......................................................................... 16 Configuring Project Settings.................................................................................... 18 Adding Program Code................................................................................................ 18 Saving and Compiling Your Application.............................................................. 19 Executing Your New Creation.................................................................................. 20 A Few Basic Scripting Commands................................................................................... 21 Commenting Your Program Code........................................................................... 22 Displaying Text on the Screen................................................................................. 23 Pausing Program Execution..................................................................................... 24 Terminating Program Execution............................................................................ 24 Other Game Building Tools Provided by the Game Creators................................... 25 DarkMATTER................................................................................................................. 25 SkyMATTER................................................................................................................... 26 SoundMATTER.............................................................................................................. 26 Other Game Creation Resources............................................................................. 26 Other DarkBASIC Resources.............................................................................................. 27 The Game Creator Forums........................................................................................ 27 DarkBASIC Tutorials................................................................................................... 28 DarkBASIC Professional’s Architecture.......................................................................... 29 The DarkBASIC Professional Scripting Language............................................... 29 The DarkBASIC Game Engine................................................................................... 29 viii DarkBASIC Programming for the Absolute Beginner DirectX........................................................................................................................... 30 Putting All the Pieces Together............................................................................... 31 Back to the Dark Jokes Game................................................................................... 32 Designing the Game................................................................................................... 33 The Final Result........................................................................................................... 40 Running the Dark Jokes Application..................................................................... 42 Summary................................................................................................................................ 43 Chapter 2 Getting Comfortable with the DarkBASIC Professional Integrated Development Environment............................................................ 45 Project Preview: The Fortune Teller Game.................................................................... 46 Mastering the DarkBASIC Professional IDE.................................................................. 50 Major IDE Components.............................................................................................. 51 Creating New Projects........................................................................................................ 63 Alternate Integrated Development Environments..................................................... 64 CodeSurge...................................................................................................................... 65 Synergy IDE................................................................................................................... 67 BlueIDE........................................................................................................................... 69 Operational Differences Between the IDEs.......................................................... 72 Text, Color, and Graphics.................................................................................................. 72 Pixels and Text Placement........................................................................................ 73 Working with Text Commands............................................................................... 74 Executing Font Commands...................................................................................... 76 Working with Color Commands............................................................................. 78 Clearing the Screen..................................................................................................... 79 Erasing Text.................................................................................................................. 79 Executing Opaque and Transparency Commands............................................. 80 Back to the Fortune Teller Game..................................................................................... 82 Designing the Game................................................................................................... 82 The Final Result........................................................................................................... 90 Summary................................................................................................................................ 94 Part II Learning How to Write DarkBASIC Applications............................................................. 95 Chapter 3 Working with Data Types, Variables, and Arrays....................................................................... 97 Project Preview: The Number Guessing Game............................................................. 98 Storing and Manipulating Data..................................................................................... 102 Keeping Track of Your Program’s Data................................................................ 103 Contents ix Working with Integers, Real Numbers, and Strings........................................ 103 Working with Variables................................................................................................... 106 Defining New Variables........................................................................................... 106 Assigning Data to Your Variables.......................................................................... 107 Controlling Access to Variables............................................................................. 107 Rules for Naming Variables.................................................................................... 109 Converting Between Numbers and Strings........................................................ 110 Doing a Little Arithmetic........................................................................................ 111 Manipulating String Contents............................................................................... 112 Storing Data That Never Changes................................................................................. 114 Embedding Data in Your Code File............................................................................... 115 Storing and Retrieving Collections of Data................................................................ 117 Defining an Array...................................................................................................... 118 Accessing Data Stored in an Array........................................................................ 118 Deleting an Array...................................................................................................... 119 Emptying an Array.................................................................................................... 120 Increasing the Size of an Array...................................................................................... 120 Inserting an Element into the Middle of an Array................................................... 122 Deleting an Array Element............................................................................................. 123 Creating User-Defined Data Types................................................................................ 124 Back to the Number Guessing Game............................................................................ 125 Designing the Game................................................................................................. 125 The Final Result......................................................................................................... 130 Summary.............................................................................................................................. 130 Chapter 4 Implementing Conditional Logic.......................... 131 Project Preview: The Rock, Paper, Scissors Game...................................................... 132 Developing Games That Can Adapt Their Execution............................................... 135 Working with the IF Statement............................................................................. 137 Working with the SELECT Statement.................................................................. 142 Working with Different Relational Operators........................................................... 144 Performing Numeric Comparisons...................................................................... 145 Comparing Text Strings........................................................................................... 145 Doing a Little Math........................................................................................................... 146 Working with Different Arithmetic Operators................................................. 147 Incrementing and Decrementing Values........................................................... 147 Understanding the Order of Operator Precedence.......................................... 148 Overriding the Order of Precedence.................................................................... 149 Streamlining Code Using Comparison Operations.................................................. 150 Back to the Rock, Paper, Scissors Game....................................................................... 152 Designing the Game................................................................................................. 152 The Final Result......................................................................................................... 157 Summary.............................................................................................................................. 157

Description:
Looking for an inexpensive way to learn the fundamentals of game programming? Look no further! DarkBASIC Programming for the Absolute Beginner will provide you with a fun, gentle learning curve for learning DarkBASIC-- no prior programming experience required! DarkBASIC is an inexpensive programming
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.