O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Slick2D Game Development

Book Description

Another title for this book could be "How to go from game programmer to game developer without really trying". It’s the complete step-by-step guide to developing simple, entertaining games with the Slick2D engine.

  • Work with Slick2D game workflow
  • Learn how to develop game components with hands-on examples
  • Get to grips with game analysis and enhancement

In Detail

Most of the game development enthusiasts are ‘tinkerers’—people who are good at programming and know a lot about programming methods; however, they may have never written a complete game program, but would like to know how to create a program. Transitioning from programming to game development can often be difficult, however, Slick2D helps developers to create amazing games without having to deal with low level programming, and it simplifies many of the daunting tasks, such as rendering and window creation.

This practical guide will help you to understand the different components of Slick2D. Throughout the course of this book, you will develop different components, and by the end of the book you will combine all of these components to assemble a complete game.

Enabling you to add life to your games, this book will focus on the Slick2D game library. Starting with the installation and configuration of a game library, you will then move onto understanding the structure of a game. Throughout the book, you will be involved in developing different sections of a single game, which will help you to gain hands- on experience in understanding the Slick Workflow. Following on from this, you will be shown how to add additional features to your game such as adding input and music, while taking a detailed look at the render method.

Table of Contents

  1. Slick2D Game Development
    1. Table of Contents
    2. Slick2D Game Development
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book
        3. Errata
        4. Piracy
        5. Questions
    8. 1. Setting Up Slick2D
      1. What is Slick2D?
      2. Downloading the Slick2D and LWJGL files
      3. Setting up an eclipse project
      4. Native files
        1. What if I want my game to be platform-specific?
      5. Summary
    9. 2. Game Structure
      1. Game structures
        1. The basic game structure
          1. The first step to creating a basic game
          2. Next we need to add the Slick2D workflow
          3. Next we need to complete the main method
          4. Let's break down the main method
      2. State-based games
        1. The uses of a state-based game
        2. Game states
          1. Setting up a basic game state
        3. Switching between states
      3. Setting up a state-based game
      4. Customizing state switching
        1. Pre/Post state transition workflow
      5. The app game container in all its greatness
      6. Closing the window
      7. What we learned
      8. Starting our game
      9. Summary
    10. 3. The Slick2D Workflow
      1. Game workflow
      2. Using the workflow
      3. The initiation method
        1. Using the initiation method
      4. Initializing images
        1. Loading images using a sprite sheet
        2. Converting buffered images to Slick2D images
      5. The update method
        1. Using the update method
        2. Delta and how to utilize delta time
        3. Utilizing the delta variable in player movement
        4. Delta timers
        5. Input handling
      6. The render method
        1. Using the render method
        2. Uses for rendering
        3. Rendering is for another day!
      7. Workflow in a state-based game
        1. What we learned
        2. Adding to our game
        3. Adding the delta timer
        4. Loading an image
      8. Summary
    11. 4. A Deeper Look at Rendering
      1. Rendering
      2. How Slick2D makes rendering easy
      3. What can we render?
      4. Using the graphics parameter
        1. Drawing primitive shapes
      5. Drawing a line
      6. Drawing rectangles
        1. Rounded rectangles
      7. Drawing ovals and circles
        1. Alternative parameter list
      8. Drawing Arcs
        1. Alternative parameter list
      9. Drawing gradient lines
        1. Option 1 – Slick2D's color class
        2. Option 2 – define custom colors
      10. Drawing strings
      11. Altering the behavior of the graphics object
        1. Anti-Aliasing
        2. Color
        3. Line width
      12. Drawing textured shapes
      13. Drawing images
      14. Scaling images
      15. Applying a color filter to an image
      16. What have we learned?
      17. Adding to our game
      18. Summary
    12. 5. A Look at Input
      1. The importance of user input
      2. Uses of input
      3. Using input for movement
        1. Basic overview of vectors
          1. Vector position
          2. Vector direction
          3. Vector magnitude
          4. Vectors in Slick2D
        2. Keyboard input
          1. Single press
          2. Key down
        3. Key codes
          1. Using isKeyDown() to implement movement
        4. Mouse input
          1. Mouse location
          2. Mouse click
          3. Combining mouse location and mouse click
      4. What we learned
      5. Adding to our game
      6. Summary
    13. 6. Sound and Music
      1. The importance of sound and music
        1. Using music and sound as a game mechanic
      2. How to create sound effects and music
        1. Sound effect software
          1. SFXR
          2. BFXR
        2. Music creation software
          1. Musagi
          2. Fruity Loops studio
      3. Using music in Slick2D
        1. Music positioning
        2. Fading music
        3. Altering and reviewing music variables
      4. Using sound in Slick2D
      5. Utilizing sound in an example
      6. What have we learned?
      7. Adding to our game
      8. Summary
    14. 7. From Example to Game
      1. What we will cover
      2. The future of our game
      3. Utilizing our delta timer
      4. Adding lives and points
        1. Lives
        2. Point system
      5. Finishing the delta timer
      6. Checking for side collision
      7. Adding visual feedback
      8. Making the game unique
      9. Summary
    15. A. Full Source Code
      1. The use of this Appendix
      2. Full source code
    16. B. Packaging Our Game
      1. Exporting a Slick2D game
      2. Software
      3. Packaging our game
      4. Platform specific
    17. Index