More Python Programming for the Absolute Beginner

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

What better way is there to learn a programming language than with a game-oriented approach? If you ask the many readers that have made this book's prequel, PYTHON PROGRAMMING FOR THE ABSOLUTE BEGINNER, a bestseller, they'll tell you there isn't one. MORE PYTHON PROGRAMMING FOR THE ABSOLUTE BEGINNER offers readers more practice, more exercises, and slightly more advanced instruction in Python programming, all while using the game-focused examples and projects that have proven to be both effective and fun. It picks up where its prequel leaves off, addressing data structures, file handling, exceptions, object oriented programming, GUI programming, multimedia programming, name spaces, and program planning. Following a deliberate, logical progression of topics that cover increasingly complex subject matter, this is a powerful resource that will arm readers with an in-depth knowledge of the Python language. Important Notice: Media content referenced within the product description or the product text may not be available in the ebook version.

Author(s): Jonathan Harbour
Publisher: Cengage Learning
Year: 2011

Language: English
Pages: 432

Cover
TABLE OF CONTENTS
Chapter 1 PYTHON HAS CLASS
Examining the Geometry Program
Getting Started with Python
Python Tools
Python Language
Objects in Python
What Came Before?
What's Coming Next?
OOP: The Python Way
Single Inheritance
Multiple Inheritance
Summary
Chapter 2 GETTING STARTED WITH PYGAME: THE PIE GAME
Examining The Pie Game
Using Pygame
Printing Text
Looping
Drawing Circles
Drawing Rectangles
Drawing Lines
Drawing Arcs
The Pie Game
Summary
Chapter 3 FILE I/O, DATA, AND FONTS: THE TRIVIA GAME
Examining The Trivia Game
Python Data Types
More Printing
Getting User Input
Handling Exceptions
The Mad Lib Game
File Input/Output
Working with Text Files
Working with Binary Files
The Trivia Game
Printing Text with Pygame
The Trivia Class
Loading the Trivia Data
Displaying the Question and Answers
Responding to User Input
Going to the Next Question
Main Code
Summary
Chapter 4 USER INPUT: THE BOMB CATCHER GAME
Examining The Bomb Catcher Game
Pygame Events
Real-Time Event Loop
Keyboard Events
Mouse Events
Device Polling
Polling the Keyboard
Polling the Mouse
The Bomb Catcher Game
Summary
Chapter 5 MATH AND GRAPHICS: THE ANALOG CLOCK DEMO
Examining The Analog Clock Demo
Basic Trigonometry
Circle Theory
Traversing a Circle's Perimeter
Circle Demo
The Analog Clock Demo
Getting the Time
Drawing the Clock
Summary
Chapter 6 BITMAP GRAPHICS: THE ORBITING SPACESHIP DEMO
Examining The Orbiting Spaceship Demo
Using Bitmaps
Loading a Bitmap
Drawing the Background
Drawing the Planet
Drawing the Spaceship
Orbiting the Planet
Orbiting
Rotating
Summary
Chapter 7 ANIMATION WITH SPRITES: THE ESCAPE THE DRAGON GAME
Examining The Escape The Dragon Game
Using Pygame Sprites
Custom Animation
Loading a Sprite Sheet
Changing the Frame
Drawing One Frame
Sprite Groups
MySprite Class
Sprite Animation to the Test
The Escape the Dragon Game
Jumping
Colliding
Source Code
Summary
Chapter 8 SPRITE COLLISION DETECTION: THE ZOMBIE MOB GAME
Examining The Zombie Mob Game
Collision Detection Techniques
Rectangle Collision Between Two Sprites
Circle Collision Between Two Sprites
Pixel-Perfect Masked Collision Between Two Sprites
Rectangle Collision Between a Sprite and a Group
Rectangle Collision Between Two Groups
The Zombie Mob Game
Creating Your Own Module
Advanced Directional Animation
Colliding with Zombies
Getting Health
Game Source Code
Summary
Chapter 9 ARRAYS, LISTS, AND TUPLES: THE BLOCK BREAKER GAME
Examining The Block Breaker Game
Arrays and Lists
Lists with One Dimension
Creating a Stack-like List
Creating a Queue-like List
Lists with More Dimensions
Tuples
Packing a Tuple
Unpacking a Tuple
Searching for Elements
Counting Elements
Tuples as Constant Arrays
The Block Breaker Game
Block Breaker Levels
Loading and Changing Levels
Initializing the Game
Moving the Paddle
Moving the Ball
Hitting the Paddle
Hitting the Blocks
Main Code
MySprite Update
Summary
Chapter 10 TIMING AND SOUND: THE OIL SPILL GAME
Examining The Oil Spill Game
Sound
Loading an Audio File
Playing an Audio Clip
Building The Oil Spill Game
Gameplay
Source Code
Summary
Chapter 11 PROGRAM LOGIC: THE SNAKE GAME
Examining The Snake Game
Building The Snake Game
Hatching a Snake—the SnakeSegment Class
Raising a Snake—the Snake Class
Feeding the Snake—the Food Class
Initializing the Game
Program Main
Growth by Eating Food
Biting One's Self Is Not Advisable
Falling off the World
Teaching the Snake to Move Itself
Moving Automatically
Getting the Current Direction
Moving Toward the Food
Other Code Changes
Summary
Chapter 12 TRIGONOMETRY: THE TANK BATTLE GAME
Examining The Tank Battle Game
Angular Velocity
Calculating Angular Velocity
Pygame's Goofy Rotation
Moving Forward and Backward at Any Angle
Improved Angle Wrapping
Building The Tank Battle Game
The Tanks
The Bullets
Main Code
Summary
Chapter 13 RANDOM TERRAIN: THE ARTILLERY GUNNER GAME
Examining The Artillery Gunner Game
Creating the Terrain
Defining the Height Map
Smoothing the Terrain
Locating Grid Points
Artillery Cannons
Placing the Cannons
Drawing the Turrets
Firing the Cannons
Shots Are A'Flyin
Computer Firing
Scoring a Hit
The Complete Game
Summary
Chapter 14 MORE OF EVERYTHING: THE DUNGEON ROLE-PLAYING GAME
Examining The Dungeon Game
Review of Classic Dungeon RPGs
Rogue
NetHack
AngBand
Sword of Fargoal
Kingdom of Kroz
ZZT
Creating a Dungeon Level
Understanding ASCII Characters
Simulating a Text Console Display
Generating Random Rooms
Generating Random Hallways
Populating the Dungeon
Adding the Entrance and Exit Portals
Adding Gold
Adding Weapons, Armor, and Health Potions
Adding Monsters
Complete Dungeon Class
Adding the Player's Character
Advanced Gameplay
Picking Up Items
Fighting Monsters
Moving Monsters
Visibility Range
Exiting the Level
Wrapping Up the Gameplay
Summary
Appendix A: INSTALLING PYTHON AND PYGAME
Installing Python
Installing Pygame
Appendix B: PYGAME KEY CODES
INDEX