SDL problem

Ok so im trying to make a basic 2d game engine but when i put a piece of code in the class it givs me errors i dont know how to fix, the errors arent even inside my code, what do i do.

Engine.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "Thunder_Engine.h"
#include <SDL.h>

Thunder_Engine::Thunder_Engine()
{
    //ctor
}

Thunder_Engine::~Thunder_Engine()
{
    //dtor
}

inline void Thunder_Engine::Controls()
{
    Uint8 *keyStates = SDL_GetKeyState(0);

    //Basic WASD Controls
    if(keyStates[SDLK_w])
    {
        Player_Offset.y -= 1;
    }
    if(keyStates[SDLK_a])
    {
        Player_Offset.x -= 1;
    }
    if(keyStates[SDLK_s])
    {
        Player_Offset.y += 1;
    }
    if(keyStates[SDLK_d])
    {
        Player_Offset.y += 1;
    }

    //Side scroller jump controls
    //These need to be fixed
    /*
    if(keyStates[SDLK_SPACE])
    {
        offset.y -= 2;
    }
    if(offset.y < 570)
    {
        offset.y += gravity;
    }
    if(offset.y < 500)
    {
        offset.y += gravity;
        keyStates[SDLK_SPACE] = SDL_RELEASED;
    }
    */

}

inline void Thunder_Engine::Collision()
{

}

inline void Thunder_Engine::Gravity()
{

}

inline void Thunder_Engine::Sound()
{
    //None for now
}

inline void Thunder_Engine::Images()
{
    //Loading Player Image
    Player = SDL_LoadBMP("Images/Placeholder.bmp");

    Player_Offset.x = 50;
    Player_Offset.y = 50;
}

int Thunder_Engine::Game()
{
    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_Surface *MainScreen;
    MainScreen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
    Images();

    while(running)
    {
        start = SDL_GetTicks();
        while(SDL_PollEvent(&event))
        {
            switch(event.type)
            {
                case SDL_QUIT:
                    running = false;
                    break;
            }
        }
        SDL_FillRect(MainScreen, NULL, NULL);
        SDL_BlitSurface(Player, NULL, MainScreen, &Player_Offset);
        SDL_Flip(MainScreen);

        if(1000/FPS>SDL_GetTicks()-start)
        {
            SDL_Delay(1000/FPS-(SDL_GetTicks()-start));
        }
    }

    SDL_FreeSurface(Player);
    SDL_Quit();

    return 0;
}


Engine.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef THUNDER_ENGINE_H
#define THUNDER_ENGINE_H
#include <SDL.h>

class Thunder_Engine
{
    public:
        Thunder_Engine();
        virtual ~Thunder_Engine();
        void Controls();
        void Collision();
        void Gravity();
        void Sound();
        void Images();
        int Game();

    private:
        bool running;
        float gravity;
        int FPS;
        SDL_Event event;
        Uint32 start;
        SDL_Surface *Player;
        SDL_Rect Player_Offset; //Problem

};

#endif // THUNDER_ENGINE_H 


errors

C:\Users\Chay\Desktop\Thunder Engine\Thunder_Engine.cpp||In member function 'int Thunder_Engine::Game()':|
C:\Users\Chay\Desktop\Thunder Engine\Thunder_Engine.cpp|103|warning: comparison between signed and unsigned integer expressions|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcat'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcat'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_GetError'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_SetModuleHandle'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_main'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_getenv'|
C:\Program Files (x86)\CodeBlocks\MinGW\lib\libSDLmain.a(SDL_win32_main.o):SDL_win32_main.c|| undefined reference to `SDL_strlcpy'|
||=== Build finished: 10 errors, 1 warnings ===|
Last edited on
Could you copy and paste the exact errors you are getting?
Just going to throw it out there, lol.

Main has to look like:
int main( int argc, char* args[] )

For SDL to work. (:
I have that but it still gives me thiose errors.
bump
How are you linking?
Topic archived. No new replies allowed.