NOTE: Although this series is aimed at small game developers, it is equally applicable to anyone wishing to learn how to use LightSwitch.
Most modern video games have an online component nowadays. For games with online leaderboards, stats tracking, world-viewable awards and achievements, online virtual currency and distributed non-real-time turn-based games (for a very simple example, play-by-mail chess), a server is required with a database to store the information, and some way of retrieving and updating the data in a secure manner.
A typical and traditional way to achieve this is by using PHP and MySQL: you merely create tables in the MySQL database for the information required, and provide a series of PHP scripts or endpoints which can be passed data via HTTP GET queries (standard browser URLs with no additional data except that in the query string), and return the results – typically either the requested data, or a flag indicating whether the data was updated successfully or not. Your game code calls these endpoints as required to query and update the server-side data. Read more…
Tetris: Adding polish with music, sound effects, backgrounds, game options, an intro sequence and other tweaks
Our previous version of SimpleTetris is working quite well as a single-player game, but lacks the professional touch. In this article, we’ll look at:
- how to make pausing and unpausing the game also pause and unpause all of its subsystems
- how to add music and sound effects and tie them into game events with SimpleFMOD (a library developed in another series on this web site which uses the well-known FMOD SoundSystem to produce audio – see the first part of the FMOD series for more information on how to use FMOD)
- how to make an event-triggered throw-away animation using Simple2D
- how to use bitmap images (sprites) as animated backgrounds
- how to add game options which can be loaded and saved
- how to add an intro sequence and a credits page
Most of these changes can be slotted in without any changes to the game logic, but there are a few gotchas and some little tweaks we can apply to make things better. I’ll note these below.
For comparison, also have on hand the executable for the previous version of the game (SimpleTetris 1.31).
I strongly recommend that you run both versions and do a side-by-side comparison of the behaviour while working through the sections below, then hopefully the changes described will make sense more easily. Read more…
A new major release of Simple2D is now available (the download link can be found at the bottom of the page).
Version 1.10 introduces improved scene management, improved scene objects and user interface objects, object groups, customizable window resize and full-screen behaviour, more logical event dispatch, new time-based animation functions and a number of bug fixes. Read more…
C++ Class Hierarchies Crash Course: Derivation (“is-a”) vs Composition (“has-a”), and Is a Square a Rectangle?
In this article I’m going to rattle over some basic design choice dilemmas you might face when trying to organize classes into a hierarchy. We’ll look at standard derivation (the “is-a” relationship), composition (the “has-a” relationship), when to use which, and also touch briefly on interfaces and private inheritance.
Pre-requisites you should know before reading:
- how to define a class in C++
- what a constructor is and how to define one
- the difference between public and private members
The “Is-a” Relationship
Is a square a type of rectangle? Is a rectangle a type of square? Or is a square merely a rectangle with a certain set of properties (identical width and height)? Are circles and rectangles both types of shape, or are they even related at all? The answers to these questions have nothing to do with your natural intuition or experience from the real world (although that helps sometimes), but rather, what you are planning to do with them in your code.