Tomas Varaneckas - Developing Games With Ruby


Tomas Varaneckas - Developing Games With Ruby

Developing Games With Ruby

Год: 2014

Автор: Tomas Varaneckas

Издательство: Leanpub


Язык: Английский


Качество: Изначально компьютерное (eBook) (Converted)

Интерактивное оглавление: Да

Количество страниц: 254


Once there was a boy who fell in love with this magical device that could bring things to life inside a glaring screen. He spent endless hours exploring imaginary worlds, fighting strange creatures, shooting pixelated spaceships, racing boxy cars. The boy kept pondering. "How is this made? I want to create my own worlds...".

Then he discovered programming. "I can finally do it!" - he thought. And he tried. And failed. Then he tried harder. He failed again and again. He was too naive to realize that those worlds he was trying to create were too sophisticated, and his knowledge was too limited. He gave up creating those worlds.

What he didn't give up is writing code for this magical device. He realized he isn't smart enough to create worlds, yet he found out he could create simpler things like small applications - web, desktop, server side or whatnot. Few years later he found himself getting paid to make those.

Applications got increasingly bigger, they spanned across multiple servers, integrated with each other, became pats of huge infrastructures. The boy, now a grown man, was all into it. It was fun and challenging enough to spend over 10000 hours learning and building what others wanted him to build.

Some of these things were useful, some where boring and pointless. Some were never finished. There were things he was proud of, there were others that he wouldn't want to talk about, nonetheless everything he built made him a better builder. Yet he never found the time, courage or reason to build what he really wanted to build since he was a little boy - his own worlds.

Until one day he realized that no one can stop him from following his dream. He felt that equipped with his current knowledge and experience he will be able to learn to create worlds of his own. And he went for it.

This boy must live in many software developers, who dream about creating games, but instead sell their software craftsmanship skills to those who need something else. This boy is me, and you. And it's time to set him free.

Welcome to the world of game development that was waiting for you all these years.

A Boy Who Wanted To Create Worlds

Why Ruby?

What You Should Know Before Reading This Book

What Are We Going To Build?


Game Development Library

Theme And Mechanics

Preparing The Tools

Getting Gosu to run on Mac Os X

Getting The Sample Code

Other Tools

Gosu Basics

Hello World

Screen Coordinates And Depth

Main Loop

Moving Things With Keyboard

Images And Animation

Music And Sound

Warming Up

Using Tilesets

Integrating With Texture Packer

Combining Tiles Into A Map

Using Tiled To Create Maps

Loading Tiled Maps With Gosu

Generating Random Map With Perlin Noise

Player Movement With Keyboard And Mouse

Game Coordinate System

Prototyping The Game

Switching Between Game States

Implementing Menu State

Implementing Play State

Implementing World Map

Implementing Floating Camera

Implementing The Tank

Implementing Bullets And Explosions

Running The Prototype

Optimizing Game Performance

Profiling Ruby Code To Find Bottlenecks

Advanced Profiling Techniques

Optimizing Inefficient Code

Profiling On Demand

Adjusting Game Speed For Variable Performance

Frame Skipping

Refactoring The Prototype

Game Programming Patterns

What Is Wrong With Current Design

Decoupling Using Component Pattern

Simulating Physics

Adding Enemy Objects

Adding Bounding Boxes And Detecting Collisions

Catching Bullets

Implementing Turn Speed Penalties

Implementing Terrain Speed Penalties

Implementing Health And Damage

Adding Health Component

Inflicting Damage With Bullets

Creating Artificial Intelligence

Designing AI Using Finite State Machine

Implementing AI Vision

Controlling Tank Gun

Implementing AI Input

Implementing Tank Motion States

Wiring Tank Motion States Into Finite State Machine

Making The Prototype Playable

Drawing Water Beyond Map Boundaries

Generating Tree Clusters

Generating Random Objects

Implementing A Radar

Dynamic Sound Volume And Panning

Giving Enemies Identity

Respawning Tanks And Removing Dead Ones

Displaying Explosion Damage Trails

Debugging Bullet Physics

Making Camera Look Ahead

Reviewing The Changes

Dealing With Thousands Of Game Objects

Spatial Partitioning

Implementing A Quadtree

Integrating ObjectPool With QuadTree

Moving Objects In QuadTree

Implementing Powerups

Implementing Base Powerup

Implementing Powerup Graphics

Implementing Powerup Sounds

Implementing Repair Damage Powerup

Implementing Health Boost

Implementing Fire Rate Boost

Implementing Tank Speed Boost

Spawning Powerups On Map

Respawning Powerups After Pickup

Implementing Heads Up Display

Design Considerations

Rendering Text With Custom Font

Implementing HUD Class

Implementing Game Statistics

Tracking Kills, Deaths and Damage

Making Damage Personal

Tracking Damage From Chain Reactions

Displaying Game Score

Building Advanced AI

Improving Tank Navigation

Implementing Demo State To Observe AI

Visual AI Debugging

Making AI Collect Powerups

Seeking Health Powerups After Heavy Damage

Evading Collisions And Getting Unstuck

Wrapping It Up

Lessons Learned

Special Thanks