Page 1 of 1
Lookign for C++ Guide- Making a grahpical platformer game
Posted: Sun Sep 08, 2013 4:24 pm
by mrpi64
Is there a nice, simple beginners guide somewhere for making a Graphical C++ platformer/sandbox 2d game? Thanks.
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Sun Sep 08, 2013 6:53 pm
by topguy
Choosing a "game engine" or at least a "graphics engine" that you can work with is a good start. Then you can search for guides related specifically to those tools.
SDL (
http://www.libsdl.org/) is probably the most widely used/known engine that has good multiplatform support and there should be plentyful of tutorials and example code out there. (
http://www.sdltutorials.com/ )
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Mon Sep 09, 2013 12:47 pm
by mrpi64
topguy wrote:Choosing a "game engine" or at least a "graphics engine" that you can work with is a good start. Then you can search for guides related specifically to those tools.
SDL (
http://www.libsdl.org/) is probably the most widely used/known engine that has good multiplatform support and there should be plentyful of tutorials and example code out there. (
http://www.sdltutorials.com/ )
I tied install sdl, I don't think it worked. Is there any way to put it in a folder in the same location as the .cpp file, so i can use it as:
#include "SDL/SDL_FILE"
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Mon Sep 09, 2013 1:02 pm
by topguy
When you say "install" what exactly did you do ?
This is what you should have done:
Code: Select all
sudo apt-get install libsdl1.2-dev
NOTE: there are two versions of SDL available( 1.2 and 2.0 ), if you installed libsdl2-dev instead I guess the header files is "SDL2/*.h"
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Tue Sep 10, 2013 12:26 pm
by mrpi64
topguy wrote:When you say "install" what exactly did you do ?
This is what you should have done:
Code: Select all
sudo apt-get install libsdl1.2-dev
NOTE: there are two versions of SDL available( 1.2 and 2.0 ), if you installed libsdl2-dev instead I guess the header files is "SDL2/*.h"
Is there some way that, instead of installing SDL, I can put it in the same folder as the .cpp file, so I can #include it like this?
#include "SDL/
SDL_FILE"
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Tue Sep 10, 2013 8:38 pm
by topguy
mrpi64 wrote:
Is there some way that, instead of installing SDL, I can put it in the same folder as the .cpp file, so I can #include it like this?
#include "SDL/SDL_FILE"
Yes, but it would be much work and totally unnecessary, and if you ever wanted to test some code written by other persons you whould have to edit their files or at least their makefiles.
You will gain nothing more than extra problems for yourself while at the same time trying to learn a language and a graphics-engine.
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Fri Sep 13, 2013 10:04 am
by mrpi64
I think that Minecraft Pi Edition ues the SDL library...
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Sun Sep 22, 2013 4:15 pm
by mrpi64
When I try to compile a 2d platformer source for the Pi, to see if SDL works, I get this error message when I use the command 'c++ Main.cpp -o rpi-game' (the file I try to compile is called Main.cpp):
/tmp/ccT60CzQ.o: In function `app_image(SDL_Surface*, SDL_Surface*, SDL_Rect, bool)':
Main.cpp:(.text+0x380): undefined reference to `SDL_UpperBlit'
/tmp/ccT60CzQ.o: In function `app_image(SDL_Surface*, SDL_Rect, SDL_Surface*, SDL_Rect, bool)':
Main.cpp:(.text+0x48c): undefined reference to `SDL_UpperBlit'
/tmp/ccT60CzQ.o: In function `app_image(int, int, SDL_Surface*, SDL_Surface*, bool)':
Main.cpp:(.text+0x59c): undefined reference to `SDL_UpperBlit'
/tmp/ccT60CzQ.o: In function `app_image(int, int, SDL_Rect, SDL_Surface*, SDL_Surface*, bool)':
Main.cpp:(.text+0x6b0): undefined reference to `SDL_UpperBlit'
/tmp/ccT60CzQ.o: In function `load_image(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int)':
Main.cpp:(.text+0x700): undefined reference to `IMG_Load'
Main.cpp:(.text+0x71c): undefined reference to `SDL_DisplayFormat'
Main.cpp:(.text+0x778): undefined reference to `SDL_MapRGB'
Main.cpp:(.text+0x790): undefined reference to `SDL_SetColorKey'
Main.cpp:(.text+0x798): undefined reference to `SDL_FreeSurface'
/tmp/ccT60CzQ.o: In function `load_image(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int)':
Main.cpp:(.text+0x7e8): undefined reference to `IMG_Load'
Main.cpp:(.text+0x804): undefined reference to `SDL_DisplayFormat'
Main.cpp:(.text+0x83c): undefined reference to `SDL_MapRGB'
Main.cpp:(.text+0x854): undefined reference to `SDL_SetColorKey'
Main.cpp:(.text+0x86c): undefined reference to `SDL_SetAlpha'
Main.cpp:(.text+0x874): undefined reference to `SDL_FreeSurface'
/tmp/ccT60CzQ.o: In function `startup()':
Main.cpp:(.text+0x894): undefined reference to `SDL_Init'
Main.cpp:(.text+0x8cc): undefined reference to `SDL_SetVideoMode'
Main.cpp:(.text+0x90c): undefined reference to `SDL_WM_SetCaption'
/tmp/ccT60CzQ.o: In function `Timer::start()':
Main.cpp:(.text+0x3044): undefined reference to `SDL_GetTicks'
/tmp/ccT60CzQ.o: In function `Timer::pause()':
Main.cpp:(.text+0x30dc): undefined reference to `SDL_GetTicks'
/tmp/ccT60CzQ.o: In function `Timer::unpause()':
Main.cpp:(.text+0x3134): undefined reference to `SDL_GetTicks'
/tmp/ccT60CzQ.o: In function `Timer::get_ticks()':
Main.cpp:(.text+0x31a8): undefined reference to `SDL_GetTicks'
/tmp/ccT60CzQ.o: In function `main':
Main.cpp:(.text+0x4770): undefined reference to `SDL_PollEvent'
Main.cpp:(.text+0x5c68): undefined reference to `SDL_PollEvent'
Main.cpp:(.text+0x5ce4): undefined reference to `SDL_Flip'
Main.cpp:(.text+0x5d4c): undefined reference to `SDL_Delay'
Main.cpp:(.text+0x5d68): undefined reference to `SDL_Quit'
/tmp/ccT60CzQ.o: In function `img::~img()':
Main.cpp:(.text._ZN3imgD2Ev[_ZN3imgD5Ev]+0x4c): undefined reference to `SDL_FreeSurface'
/tmp/ccT60CzQ.o: In function `animate::End_This()':
Main.cpp:(.text._ZN7animate8End_ThisEv[animate::End_This()]+0x40): undefined reference to `SDL_FreeSurface'
collect2: ld returned 1 exit status
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Sun Sep 22, 2013 6:55 pm
by AndrewS
You're getting that error because you've not setup the appropriate include or linker flags - I suggest you check the SDL / compiler documentation.
And maybe have a look at
http://wiki.libsdl.org/SDL1.2Tutorials in general, and
http://www.wildbunny.co.uk/blog/2011/12 ... me-part-1/
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Mon Sep 23, 2013 12:59 pm
by mrpi64
How do I set them up?
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Wed Sep 25, 2013 12:59 pm
by topguy
mrpi64 wrote:When I try to compile a 2d platformer source for the Pi, to see if SDL works, I get this error message when I use the command 'c++ Main.cpp -o rpi-game' (the file I try to compile is called Main.cpp):
Did you download this code from somewhere ? Where ? Did it come with a Makefile or similar its these things that set up the compiler parameters correctly. Did it come with some compiling/installing instructions ?
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Wed Sep 25, 2013 2:09 pm
by mrpi64
I followed the instructions on the README file that I got when I downloaded the source code from the SDL website.
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Fri Sep 27, 2013 9:10 am
by topguy
I find it strange if any official example didnt include instructions on how to link with the library.
.. should work according to this:
http://lazyfoo.net/SDL_tutorials/lesson ... /index.php
Re: Lookign for C++ Guide- Making a grahpical platformer gam
Posted: Sat Sep 28, 2013 4:31 pm
by mrpi64
Thanks. I guess that if I could import the thing directly from usr/include/sdl