Git Product home page Git Product logo

sdl2-game's Introduction

SDL2-Game

A small 2D, SDL2 Game written in C++ featuring destructive terrain, raycasts, tailphysics and more!

bsp_img

This is what it looks like: https://www.youtube.com/watch?v=upb3DJJbQIM

Only dependencies are the SDL2 and SDL2-image libraries. See here.

All code was written by me and is public domain.

Controls

  • WASD to move the player
  • LMB to fire a projectile that destroys terrain
  • RMB to create terrain

Healthbars and AI are missing, so you will have to control the boss/enemy yourself:

  • 1 for the Boss to shoot his laser
  • 2 for the Boss to shoot his rockets
  • 3 to toggle a continous rain of rockets

Sources for Artwork:

Documentation:

Root directory

The root directory contains what you might consider to be the 'game engine':

  • defs.h: All constant values used across other files, including file directories, window size etc.
  • random.h: Inline header file to generate random numbers.
  • main.cpp: Runs the start-method in gamemaster.cpp. That's all.
  • gamemaster.cpp/.h: Contains the base 'game-loop'. Continously clears, draws and updates all relevant objects.
  • base.cpp/.h: Fundamental classes/functions used and inherited throughout the project. This includes: Timer, Vector2, Camera, GameWindow, Object, Image, AdvImage. Object being the base class for all Objects drawn on screen.

Assets directory

Includes more specialized files. All of these inherit from either the Object or Image class.

  • animation: Class for a spritesheet-animation. Used by explosion or fire aniamtions, aswells as the player sprite.
  • background: Parallax background image that scrolls relative to player position and level size.
  • terrain: Actual level. Pixel collision and destructible terrain are handled here.
  • missile: The missiles that the boss spawns on his second attack.
  • physicsObj: Base class for all physics-based Objects.
  • player: The player.
  • projectile: Base class for physics-based projectiles.

assets/NAV directory

Point- and Path-classes used for the Navigation of the Boss. Paths can have ease-in/-out aswell as linear, bezier or sine-curve interpolations. nav_graph creates and includes preset paths for the boss to navigate along.

assets/BOSS directory

All classes concerning the boss.

  • boss_AI: Main wrapper for the entire thing. Looks at what attack the boss is doing and executes it by calling boss_Controller methods.
  • boss_Controller: Handles boss idle animations, laser animations etc. Second layer of complexity wrapping.
  • boss_Head: The main bulk of the boss' head.
  • boss_TailSegment: The small segments that constitute the boss' tail. Each segment has an angular and positional velocity aswell as an angular and positional acceleration. At a certain self-positonal-velocity the segments will accelerate towards the vector of said velocity. If this velocity is smaller than the given threshhold, the segments will accelerate towards their default position.
  • boss_TailSegmentConnector: The red connectors between segments.

Certain elements are heavily inspired by the Supreme Jeh'Oul bossfight from Wings of Vi (this one).

sdl2-game's People

Contributors

helliaca avatar krother 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.