User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Lookign for C++ Guide- Making a grahpical platformer game

Sun Sep 08, 2013 4:24 pm

Is there a nice, simple beginners guide somewhere for making a Graphical C++ platformer/sandbox 2d game? Thanks.
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Sun Sep 08, 2013 6:53 pm

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/ )

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Mon Sep 09, 2013 12:47 pm

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"
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Mon Sep 09, 2013 1:02 pm

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"

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Tue Sep 10, 2013 12:26 pm

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"
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Tue Sep 10, 2013 8:38 pm

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.

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Fri Sep 13, 2013 10:04 am

I think that Minecraft Pi Edition ues the SDL library...
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Sun Sep 22, 2013 4:15 pm

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
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
AndrewS
Posts: 3625
Joined: Sun Apr 22, 2012 4:50 pm
Location: Cambridge, UK
Contact: Website

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Sun Sep 22, 2013 6:55 pm

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/

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Mon Sep 23, 2013 12:59 pm

How do I set them up?
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Wed Sep 25, 2013 12:59 pm

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 ?

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Wed Sep 25, 2013 2:09 pm

I followed the instructions on the README file that I got when I downloaded the source code from the SDL website.
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Fri Sep 27, 2013 9:10 am

I find it strange if any official example didnt include instructions on how to link with the library.

Code: Select all

c++ Main.cpp -o rpi-game -lSDL
.. should work according to this: http://lazyfoo.net/SDL_tutorials/lesson ... /index.php

User avatar
mrpi64
Posts: 931
Joined: Sat Feb 16, 2013 5:13 pm

Re: Lookign for C++ Guide- Making a grahpical platformer gam

Sat Sep 28, 2013 4:31 pm

topguy wrote:I find it strange if any official example didnt include instructions on how to link with the library.

Code: Select all

c++ Main.cpp -o rpi-game -lSDL
.. should work according to this: http://lazyfoo.net/SDL_tutorials/lesson ... /index.php
Thanks. I guess that if I could import the thing directly from usr/include/sdl
I'm happy to help.
https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 - List of games that work on the Pi.

Return to “C/C++”