polymarsdev / twini-golf Goto Github PK
View Code? Open in Web Editor NEWA (broken) SDL2 game made in 48 hours
A (broken) SDL2 game made in 48 hours
Should I add a static build workflow for linux? This would make it so people aren’t forced to install sdl themselves
Not sure how you manage to run the program as you cannot return stack variable and use it ???
Anyway a temp fix is to allocate a global variable and then return the allocate string :
std::string s;
const char* getStrokeText()
{
int biggestStroke = 0;
if (balls[1].getStrokes() > balls[0].getStrokes())
{
biggestStroke = balls[1].getStrokes();
}
else
{
biggestStroke = balls[0].getStrokes();
}
//std::string
s = "";
s = std::to_string(biggestStroke);
s = "STROKES: " + s;
return s.c_str();
}
const char* getLevelText(int side)
{
int tempLevel = (level + 1)*2 - 1;
if (side == 1)
{
tempLevel++;
}
// std::string
s = "";
s = std::to_string(tempLevel);
s = "HOLE: " + s;
return s.c_str();
}
mouse cant set ball power properly because of edge of screen maybe cursor needs to be set to false during shots ?
Just came across your video on this - love it! High5 for the work and putting this together.
libgcc_s_seh-1.dll
libstdc++-6.dll
I think you left out the source code license or forgot to choose one
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
So I compiled this on macos. And it immediately crashed after clicking to start a game.
However after some debugging I found the issue is your getStrokeText and getLevelText functions return a pointer to a std::string that is destructed in the function. A quick hack/fix for this, was to define them as globals so they stay in memory. Then the game works also on my macbook on catelina ;)
Here's the patch:
//reserve string in memory that does not get deleted
//as were returning char* from this!
std::string stroke_text="";
std::string level_text="";
const char* getStrokeText()
{
stroke_text="";
int biggestStroke = 0;
if (balls[1].getStrokes() > balls[0].getStrokes())
{
biggestStroke = balls[1].getStrokes();
}
else
{
biggestStroke = balls[0].getStrokes();
}
std::string s = std::to_string(biggestStroke);
stroke_text = "STROKES: " + s;
return stroke_text.c_str();
}
const char* getLevelText(int side)
{
int tempLevel = (level + 1)*2 - 1;
if (side == 1)
{
tempLevel++;
}
std::string s = std::to_string(tempLevel);
level_text = "HOLE: " + s;
return level_text.c_str();
}
Another smaller issue was I was always getting a ttf error because the check did not work correctly.
This I patched as follows:
bool init()
{
if (SDL_Init(SDL_INIT_VIDEO) > 0)
std::cout << "HEY.. SDL_Init HAS FAILED. SDL_ERROR: " << SDL_GetError() << std::endl;
if (!(IMG_Init(IMG_INIT_PNG)))
std::cout << "IMG_init has failed. Error: " << SDL_GetError() << std::endl;
if (TTF_Init()==-1){
std::cout << "TTF_init has failed. Error: "<< TTF_GetError() << std::endl;
}
std::cout<<"Opening audio now!"<<std::endl;
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048);
return true;
}
Ideally however you could better return a std::string or a smart pointer instead.
Now everything works except the sounds are not playing. But I do see its a nice game. Well done in 2 days ;).
i installed both sdl1.2 and sdl2 and get errors on all lines involving sdl
fatal error: SDL2/SDL_image.h: No such file or directory
How about a build system like GNU/Make or CMake?
The title says it all I guess.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.