Tutorials

Tutorials for getting started with programming on Linux

Introduction

Invaders clone which introduce simple behavior and explosion

Published
Liked the article? Share it!

Simple Invaders clone using Kenney’s Space Shooter redux pack. In this tutorial we will include sprites to make a more complete looking game, but it will still be fairly simple in nature. We have a group of enemies that fire at the player while moving down the screen and a player that can fire back. We use static arrays to create a very simple bullet management system. And use the pythagorean theorem for basic hit detection.

Sprite Reference

In this tutorial we will be using the following sprites from Kenney’s Space Shooter pack. You are free to replace them with other colors or assets from the pack, or replace them with your own images.

Player

Player for DashGL Invader Tutorial

Player Bullet

Bullet for DashGL Invader Tutorial

Enemy

Enemy for DashGL Invader Tutorial

Enemy Bullet

Enemy Bullet for DashGL Invader Tutorial

Background

Background for DashGL Invader Tutorial

Gameover

Gameover for DashGL Invader Tutorial

Install Dependencies

Run the following command to get the dependencies for this tutorial.

Debian / Ubuntu

$ sudo apt-get install libgtk-3-dev libegl1-mesa-dev libepoxy-dev libpng-dev git

Fedora / Red Hat

$ sudo yum install epel-release
$ sudo yum install gtk3-devel mesa-libGL-devel libepoxy-devel libpng-devel git

Approach

We will implement our project one step at a time. All of the source code will be displayed for the main.c file each step. Other files will only be displayed when they are created or changed. If you need to check for what the project folder looks like at any given step, you can follow the Github links on each page to view the file layout.

If you have a specific coding style approach then feel free to use that. If you are new to programming, then this guide recomends separating each step into it’s own folder, copying the previous folder each time. That will allow you to go back and double-check a working version in case something breaks.