Code Monkey home page Code Monkey logo

sdl2-pong's Introduction

SDL2-Pong

header

About

This is a pong clone written in c++ and SDL2. This is my first real project with SDL2 or even c++, so please excuse that the code is quite stinky.

How to play

This game is unfortunately local multiplayer only : once you press P in the main menu to play, the left player controls their paddle up and down movement with W and S, while the player on the right can use the up and down arrows or O and L keys.

Screenshots

click to view screenshots

Screenshot (42) Screenshot (43) Screenshot (48)

Pre built binary

here is the pre built binary for windows

Build instructions

Step 0: Dependencies

To compile this you will need to download

Step 1: git clone

First, clone the repository

$ git clone --depth 1 https://github.com/Dr-McFish/SDL2-Pong.git SDL2-Pong && cd SDL2-Pong

Step 2: Compile

Compile with with the following flags:

-std=c++17
-O3
-Wall
-m64
-I include
-o game.exe
-lSDL2main
-lSDL2
-lSDL2_image
-lSDL2_mixer

On Windows, also use

-mwindows
-lmingw32

Note: You may need to indicate the include paths for the SDL2 and SDL2_mixer dependencies using the -I <dirname> flag, as well as the lib/linker directory using -L <dirname> flag.

Note: for some god forsaken reason SDL2_mixer expects you to include
.../sdl2_folder/include/SDL2/
instead of
.../sdl2_folder/include/
so you have to include both.

For example, the command may look like something like this:

$ g++ src/*.cpp -std=c++17 -O3 -Wall -m64 -I include -I <SDL2 include folder> -I <SDL2mixer include folder> -o game.exe -mwindows -L <SDL2 lib folder> -L <MinGW-w64 lib folder> -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer

Step 3: Dynamically-Linked/Runtime libraries

To run the game, runtime libraries need to be be present inside the folder of the executable

Coppy all the .dlls from the .../SDL2/bin/ and .../SDL2_mixer/bin/ into the current folder.

Step 4: (Optional) res/ folder

If you want to delete the source files / move the executable to another location, note that the res/ folder is needed for the game to function.

Step 5: DONE!

Enjoy!

Credit

  • Thanks to codergopher, who's YouTube series for being helpful on this topic,
  • All dlls in the binary folder are not my own, I am only redistributing them, they are part of the SDL2 project

sdl2-pong's People

Contributors

dr-mcfish avatar

Watchers

 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.