Git Product home page Git Product logo

cpanzer's Introduction

CPanzer

Overview

This is a rewrite of panzer in C using libSDL. It isn't a full 1:1 recreation, think of it more as a demo of the game instead. I wrote it because I wanted to get more familiar with how programs are written in C and as a fun way to learn SDL as well. It also paves the way for more ports to other systems as well, not just desktops.

Requirements

Make sure you have the following in order to both build and run the game on your system:

gcc, make, SDL2, SDL2_image, SDL2_ttf, SDL2_mixer

These packages vary by Linux distro, so here are the common ones:

  • Fedora:
SDL2 SDL2_image SDL2_mixer SDL2_ttf SDL2-devel SDL2_mixer-devel SDL2_image-devel SDL2_ttf-devel
  • Ubuntu:
libsdl2 libsdl2-dev libsdl2-mixer libsdl2-mixer-dev libsdl2-image libsdl2-image-dev libsdl2-ttf libsdl2-ttf-dev

Note that macOS and Windows aren't supported right now; all development work is focused on Linux.

However, nothing is really preventing the game from running on Windows or Mac, just get the aforementioned libraries installed and compile

Compiling and Running the Game

Clone this git repository, change directory into it and run make

$ git clone <repo-url>
$ cd cpanzer/
$ make

To run the game, run ./panzer

Controls

Key Action
W or up arrow key Moves player up
A or left arrow key Moves player left
S or down arrow key Moves player down
D or right arrow key Moves player right
Q Rotates nozzle slightly counter-clockwise
E Rotates nozzle slightly clockwise
Space bar Fires a projectile in the direction the nozzle is facing
P Pauses the game
Esc Exits the game

Source code structure

File/Folder Description
constants.h Specifies constants like player speed, window name, dimensions etc. and also imports all the library functions we need
input.h Abstracts away all input and returns a custom struct detailing the effects of input (like how much should player move up/down or left/right, if player pressed pause button etc.
objects.h Creates the unfortunately named textures struct which contains all the information about each object, like player, object, base etc, as well as related functions
audio.h Abstracts away audio stuff in order to simply play sound effects
window.c Renders the window and brings all this together
assets/ Contains all the sprites, font files etc. for the game

Observed bugs

  • valgrind reports ~6kb missing, it goes all the way back to the beginning of this game, so find bug and fix it (UPDATE: this is probably an SDL issue, so there's nothing I can do here except create a bug report)

  • nozzle freaks out sometimes whenever someone collides with it

  • movement is not as smooth as in original panzer

Implemented Features

  • Player's basic movement

  • Collision detection

  • HUD Space

  • Pausing

  • HUD info

  • Enemy AI

  • Rotating player when they move a certain way

  • Enemy auto respawn when player kills some of them off

  • Nozzle

  • Base

  • Projectile

  • Sound effects

  • A better pause menu than the original Panzer

Roadmap

  • Cleaning up code

  • Adding comments etc.

  • Fixing bugs

Things to be left out

  • MySQL integration for keeping track of scores; this could be added in the form of SQLite but it seems unlikely.

  • Game menu screen

  • Rage mode

  • Map and player tank options

  • Fancy HUD with a health bar

  • Powerups, such as those for speed or getting more ammo

  • A debug mode which gives you God mode in the game

Info about Assets Used in the Game

The font used in the game HUD is Ubuntu Regular

The sprites are all taken from panzer

cpanzer's People

Contributors

gotlougit avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.