A (broken) SDL2 game made in 48 hours

Related tags

Game Twini-Golf
Overview

Twini-Golf

Twini-Golf is a game created in 48 hours for the 2021 GMTK Game Jam using C++ and SDL2. It can be played on itch.io.

Screenshots

Background

Twini-Golf is an experimental mini golf game where you play on multiple golf courses at once, simultaneously controlling each ball. More information on how to play is available on the game's itch.io page.

Compiling

Windows

After installing Mingw64, SDL2, SDL_Image, SDL_TTF, and SDL_Mixer, execute the following command in the project's root directory:

g++ -c src/*.cpp -std=c++14 -O3 -Wall -m64 -I include -I C:/SDL2-w64/include && g++ *.o -o bin/release/main -s -L C:/SDL2-w64/lib -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer && start bin/release/main

The compiled .exe is located in ./bin. For it to run, you must copy the ./res folder as well as all .dll files from your SDL installation to its directory.

Linux

After installing the dev packages of SDL2 for your distribution, execute the following command in the project's root directory:

g++ -c src/*.cpp -std=c++14 -O3 -Wall -m64 -I include && mkdir -p bin/release && g++ *.o -o bin/release/main -s -lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer

The compiled binary main is located in ./bin. For it to run, you must copy the ./res folder to its directory.

Web (Untested)

Install emscripten and execute the following command in the project's root directory:

emcc src/main.cpp src/entity.cpp src/renderwindow.cpp src/ball.cpp src/tile.cpp src/hole.cpp -I include -O2 -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s \"SDL2_IMAGE_FORMATS=['png']\" -s USE_SDL_TTF=2 -s USE_SDL_MIXER=2 --preload-file res -o index.html

The compiled .js, .wasm, .data, and .html files are located in the project's root.

Contributing

Pull requests are welcome! For major refactors, please open an issue first to discuss what you would like to improve. Feel free to create a fork of this repository or use the code for any other noncommercial purposes.

Comments
  • distribution is still hard (can't launch on Win11)

    distribution is still hard (can't launch on Win11)

    Just came across your video on this - love it! High5 for the work and putting this together.

    • Downloaded latest zip from Itch.io page
    • Attempted to run binary
    • Missing libgcc_s_seh-1.dll
    • Missing libstdc++-6.dll
    • Game execution halts there

    Screenshot 2022-01-01 093031

    Screenshot 2022-01-01 093131

    • I'll attempt to build the source in something like Visual Studio to see if that helps? 🤷
    opened by erikyuzwa 3
  • fix UB

    fix UB

    The original code returned a pointer using std::string s on the stack. ~~This worked fine in g++ but the text rendered was garbage with MSVC, because it's UB~~ EDIT: this bug only happens in debug compilation it seems, not a big deal. <3 you Polymars!!

    opened by nottnottloop 2
  • Fixed stroke text, splashbg

    Fixed stroke text, splashbg

    Hi, I had a problem, I couldn't see the number of the strokes, the reason is that you were returning pointer to std::string but the string is defined on the stack and will be released when the function returns. so I changed the function to return std::string and use c_str when rendering the text with SDL, with gcc I was getting "Strokes: " with no number, with clang I was getting "Strokes: 0" and it worked correctly, I think it's due to the optimizations the compiler does, because when compiling without the -O3 flag the game will crash, also there was a typo with the splashbg.png. I'm new to c++ so if my understanding is wrong please correct me, Thanks

    opened by mohad12211 2
  • Update main.cpp

    Update main.cpp

    Compiled the source code and found getStrokeText and getLevelText to have some undefined behavior. Seems to be a dangling pointer returning memory allocated on a stack. Please recompile the source code to check for any errors.

    opened by joshuang321 0
  • Game is missing some DLL's

    Game is missing some DLL's

    The itch.io download has some dll's missing, more specifically: libstdc++-6.dll libgcc_s_seh-1.dll You can find them at the bin directory of mingw64.

    Edit: it works normally on pc's with mingw installed because the dlls are in the system path

    opened by Undefine-Unity 0
  • Add Cmake Build system

    Add Cmake Build system

    I install SDL2 by Pacman package manager in msys2 for mingw-w64 and simply use Cmake for add libraries ,compile and run for VSCode in Windows11. The SDL2_image mixer ttf don't have CMake Locate library Script ! , i add that as submodule . Also simple linking way commented in CMakeLists.txt but it's different for any system!

    opened by liyanboy74 0
  • Making use of Visual Studio 2019 community

    Making use of Visual Studio 2019 community

    • Updated folder structure to include VS2019 compatible solution file
    • Small reorganization of header files

    Screenshot 2022-01-01 100015

    • I copied the res assets into a test folder along with the release build of the binary and everything launched ok for me
    • Just hope it helps someone else who might want to play with this
    opened by erikyuzwa 0
  • Multiple fixes...

    Multiple fixes...

    • Fixed init() printing out SDL Errors instead of TTF/IMG Errors.
    • Fixed init() printing out "TTF_init has failed. Error: " everytime TTF_Init initalized correctly.
    • Fixed crash on startup by changing char* to std::string on levelText and strokeText getter functions.
    • Fixed splashBg not being loaded. These are all the bugs I noticed while trying to compile on Linux with g++.
    opened by opsuu 1
Owner
PolyMars
PolyMars
A mini-game written solo in 48 hours for Ludum Dare 49 Compo

AIROBICS A mini-game written solo in 48 hours for Ludum Dare 49 Compo (https://ldjam.com) Finished 23rd overall!

Piotr K 21 Dec 8, 2022
Project 1945 is a top down scroller game made with SDL2, CMake and programmed in C as a project of study for the Italian Videogames Academy for the 3rd year course of Videogames programming.

Project 1945 is a top down scroller game made with SDL2, CMake and programmed in C as a project of study for the Italian Videogames Academy for the 3rd year course of Videogames programming. The game is based on the old videogame 1945: The Final Front of the 2002.

null 19 Dec 30, 2022
A tester for game controller written in C, using SDL2.

SDL2 Controller Tester This little application has been made while I was attending a tutorial to make games in C using SDL2. Since my purpose will be

Michele Righi 16 Jan 4, 2023
A blank for a SDL2-based platformer game

A blank for a SDL2-based platformer game Attention, this repository does not contain (and never will) a playable game. The goal is to show basic princ

Dmitry V. Sokolov 39 Dec 30, 2022
A game called Lavendachrysanth. I am working on using SDL2 and C++(Originally ran on windows 10)

Lavendachrysanth A game called Lavendachrysanth. I am working on using SDL2 and C++(Originally ran on windows 10) MinGW 6.3.0-1 Vscode 1.61.2 GNU Make

Sitanshu Shrestha 0 Aug 29, 2022
Game engine in c++ and SDL2

Netune game engine How to build As said, all work is in progress, if you want to run it you need to have SDL2 configured on your machine. This makefil

Pedro Lucas 4 May 24, 2022
Implementation of Conway's Game of Life in C++ with SDL2

Conway's Game of Life Implementation of Conway's Game of Life in C++ with SDL2. Usage make sure SDL2 is well configured. make run click on screen to m

Juni May 2 Feb 12, 2022
A game made for the Game (Engineless) Jam using Raylib

Fastest Pizza Delivery A fun little 3D game made for the Game (Engineless) Jam. It is still is development but the basic gameplay is something l

Ryuzaki 2 Apr 3, 2022
SDL2 example games

SDL games Just a repository for make retro and new games with SDL and C++... Snake The classic game that everyone in our life has played, be a Snake a

Juan Salazar 1 Nov 16, 2021
Chessclone with SDL2

Chess Description Links Repo Screenshots Built With C++ Visual Studio 2019 SDL2 SDL2_Image Build process Clone the repository copy "sdl2-config.cmake"

Julian Unland 62 Dec 28, 2022
Super Mario Bros in C++ under SDL2

Super Mario Bros DEMO! Super Mario Bros in C++ under SDL2. This game is a DEMO with his first world! How to compile Code::Blocks is needed (although w

Gastón Martínez 1 Aug 22, 2022
A good & simple gameplay loop for C and SDL2.

FPSLoop A good & simple gameplay loop for C and SDL2. Dependencies A C compiler SDL2 Building The easiest way is just to run make, which will build th

Silent Tower Games 7 Jan 10, 2022
sdl4cpp, header-only C++ wrapper around SDL2.

sdl4cpp sdl4cpp, header-only C++ wrapper around SDL2 (heavily work-in-progress) An example: #include "sdl4cpp/sdl4.hpp" #include "sdl4cpp/timer.hpp" #

Ferhat Geçdoğan 1 Nov 28, 2021
Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World.

OpenXRay OpenXRay is an improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. S

null 2.2k Jan 1, 2023
Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve external game process read/write with minimum footprint.

Launcher Abuser Stealthy way to hijack the existing game process handle within the game launcher (currently supports Steam and Battle.net). Achieve ex

Ricardo Nacif 80 Nov 25, 2022
Game Boy, Game Boy Color, and Game Boy Advanced Emulator

SkyEmu SkyEmu is low level cycle accurate GameBoy, GameBoy Color and Game Boy Advance emulator that I have been developing in my spare time. Its prima

Sky 321 Jan 4, 2023
Third-person survival game for Unreal Engine 4 made entirely in C++.

Third-person survival game for Unreal Engine 4 made entirely in C++. Originally built as a 6 section tutorial series, now available as open-source C++ sample project.

Tom Looman 2.8k Dec 30, 2022
A simple snake game made in C language.

My-snake-game This is my first game more to come! to play the game execute the snake.exe and press X to start. W to go up / D to go right / A to go le

Ayman Baioumy 4 Aug 31, 2022
Multiplayer ludo game made in Unity

LUDO Multiplayer ludo game made in Unity This a multi-plaayer game. But due to lack of budget I am not able to make it online multi-player. So users h

Soumavo Dey 26 Sep 23, 2022