Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Engborg

Pages: [1] 2
1
Graphics / Comments on first game.
« on: January 14, 2011, 11:50:32 pm »
Well, thoose example are'nt really in the same experience group as my last project as you can see above.
Dont think i could pull of a project like that..

Appreciate the reply though!

Btw, if someone that reads this have a little time over maby you can rewrite my "game" how it should look, maby with some classes or extra functions.

2
Graphics / Comments on first game.
« on: January 13, 2011, 01:52:43 pm »
That's why i posted it here, wanted feedback, negative feedback is what makes us better. "learn from your misstakes" ^^

thanks again, btw you got any new ideas on a "game" i can start with? kinda dry on ideas...
nothing too complicated though (;

3
Graphics / Comments on first game.
« on: January 08, 2011, 06:50:03 am »
Okey, thanks for the comment, i will start using classes more often so i learn what when and how to use them properly.

4
Graphics / Comments on first game.
« on: January 08, 2011, 05:41:05 am »
It's not that I don't know how to use them, just haven't done it that much..

5
Graphics / Comments on first game.
« on: January 07, 2011, 06:21:34 pm »
You can find that file here on the SFML website.
I'll remember to use for functions/classes, although i'm not that strong on classes...

Well, thanks alot for your reply!

6
Graphics / Comments on first game.
« on: January 07, 2011, 04:48:54 pm »
Hi, I just started with SFML and would like some comments on my first project.

Code: [Select]
#include <SFML/Graphics.hpp>
#include "collision.h"
#include <iostream>

int main()
{
int random = sf::Randomizer::Random(50, 750);
int i, o, t, lvl, u, score, timeover;
double count, speed;
i = 3;
o = 4;
t = 0;
u = 3;
lvl = 5;
score = 0;
count = 1;
speed = -0.3;
timeover = 1000000;

sf::RenderWindow game(sf::VideoMode(1000, 800, 32), "Game Window");

sf::Image land;
if(!land.LoadFromFile("land.png"))
return EXIT_FAILURE;

sf::Sprite bg;
sf::Sprite bg2;

bg.SetImage(land);
bg2.SetImage(land);

bg.SetPosition(0, 0);
bg2.SetPosition(900, 0);

sf::Image Image;
    if (!Image.LoadFromFile("Engborg.png"))
        return EXIT_FAILURE;

sf::Sprite Bild(Image);

    Bild.SetPosition(50.f, 400.f);
Bild.Scale(.3, .3);

sf::Image bildbox;

if (!bildbox.LoadFromFile("box.png"))
return EXIT_FAILURE;

sf::Sprite Box[5];

for(int i = 0; i < 5; i++){
Box[i].SetImage(bildbox);
Box[i].SetPosition(1000.f, random);
Box[i].Scale(.5, .5);
}
sf::Clock Time;

sf::Font MyFont;
MyFont.LoadFromFile("WhiskeyTown.ttf", 50);

    sf::String gameover;
    gameover.SetText("Gameover!");
    gameover.SetFont(MyFont);
    gameover.SetColor(sf::Color(0, 128, 128));
    gameover.SetPosition(1000.f, 1000.f);
    gameover.SetRotation(15.f);
    gameover.SetSize(100.f);

sf::String win;
    win.SetText("You won!");
    win.SetFont(MyFont);
    win.SetColor(sf::Color(0, 128, 128));
    win.SetPosition(1000.f, 1000.f);
    win.SetRotation(15.f);
    win.SetSize(100.f);

while(game.IsOpened())
{

sf::Event Event;
while (game.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                game.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                game.Close();

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

if(Bild.GetPosition().y > 0)
{
if(game.GetInput().IsKeyDown(sf::Key::Up))
Bild.Move(0, -0.3);
}
if(Bild.GetPosition().y < 670)
{
if(game.GetInput().IsKeyDown(sf::Key::Down))
Bild.Move(0, 0.3);
}

if(Collision::PixelPerfectTest(Bild, Box[0]) || Collision::PixelPerfectTest(Bild, Box[1]) ||
Collision::PixelPerfectTest(Bild, Box[2]) || Collision::PixelPerfectTest(Bild, Box[3]) ||
Collision::PixelPerfectTest(Bild, Box[4]))
{
gameover.SetPosition(200.f, 200.f);
i = 0;
o = 0;
timeover = Time.GetElapsedTime();
}
if(Time.GetElapsedTime() > (timeover + 1))
{
speed = 0;
for(int i = 0; i < 5;i++)
{
Box[i].SetPosition(1000, 1000);
}
}

random = sf::Randomizer::Random(100, 700);

if(Time.GetElapsedTime() > i && Time.GetElapsedTime() < o)
{
Box[t].SetPosition(1000, random);
i = i + 1;
o = o + 1;
t++;
if(t > 4)
t = 0;
}

if(Time.GetElapsedTime() > lvl)
{
lvl = lvl + 10;
speed = speed - 0.1;
}

if(floor(Time.GetElapsedTime()) == count)
{
if(i != 0)
{
score++;
std::cout << "You score is: " << score << std::endl;
count++;
}
}

game.Clear(sf::Color(255, 255, 255));

game.Draw(bg);
game.Draw(bg2);
game.Draw(Bild);
game.Draw(gameover);
for(int i = 0; i < 5; i++)
{
game.Draw(Box[i]);
Box[i].Move(speed, 0);
}

bg.Move(speed, 0);
bg2.Move(speed, 0);

if(bg.GetPosition().x < -900)
bg.SetPosition(900, 0);
if(bg2.GetPosition().x < -900)
bg2.SetPosition(900, 0);

game.Display();
}

}


All comments appreciated!

7
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 08:34:25 pm »
Ofc, thanks for your help, was really helpfull!
My programming can begin!

8
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 06:37:21 pm »
That worked, thank you!

9
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 06:29:27 pm »
Can you be a little more specific where i should put them?
i tried the "Windows\system32" but it didn't work.

10
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 05:49:19 pm »
Now i can compile it but when it runs i get:
"The program can't start becouse sfml-system-d.dll is missing from your computer. Try reinstalling the program to fix this problem."

11
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 04:12:22 pm »
I've included that lib now too and it took away most of the errors!
Now I only get:
"1>main.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function _main"

12
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 04:07:37 pm »
I've fixed that now but i still get the same error.
The reason i had it that way was from some youtube tutorial i saw.

13
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 03:50:31 pm »
i have theese linked : "sfml-system-s-d.lib;sfml-graphics-d.lib;sfml-window-d.lib"


here's the errors:
Code: [Select]
1>  main.cpp
1>main.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: float __thiscall sf::Clock::GetElapsedTime(void)const " (__imp_?GetElapsedTime@Clock@sf@@QBEMXZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glDepthMask@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Clock::Clock(void)" (__imp_??0Clock@sf@@QAE@XZ) referenced in function _main


and here's the code i'm trying to compile:
Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>


////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML OpenGL");

    // Create a clock for measuring time elapsed
    sf::Clock Clock;

    // Set color and depth clear value
    glClearDepth(1.f);
    glClearColor(0.f, 0.f, 0.f, 0.f);

    // Enable Z-buffer read and write
    glEnable(GL_DEPTH_TEST);
    glDepthMask(GL_TRUE);

    // Setup a perspective projection
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(90.f, 1.f, 1.f, 500.f);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();

            // Escape key : exit
            if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
                App.Close();

            // Resize event : adjust viewport
            if (Event.Type == sf::Event::Resized)
                glViewport(0, 0, Event.Size.Width, Event.Size.Height);
        }

        // Set the active window before using OpenGL commands
        // It's useless here because active window is always the same,
        // but don't forget it if you use multiple windows or controls
        App.SetActive();

        // Clear color and depth buffer
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // Apply some transformations
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(0.f, 0.f, -200.f);
        glRotatef(Clock.GetElapsedTime() * 50, 1.f, 0.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 30, 0.f, 1.f, 0.f);
        glRotatef(Clock.GetElapsedTime() * 90, 0.f, 0.f, 1.f);

        // Draw a cube
        glBegin(GL_QUADS);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f( 50.f,  50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);

            glVertex3f(-50.f, -50.f, 50.f);
            glVertex3f(-50.f,  50.f, 50.f);
            glVertex3f( 50.f,  50.f, 50.f);
            glVertex3f( 50.f, -50.f, 50.f);

            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f(-50.f,  50.f, -50.f);
            glVertex3f(-50.f,  50.f,  50.f);
            glVertex3f(-50.f, -50.f,  50.f);

            glVertex3f(50.f, -50.f, -50.f);
            glVertex3f(50.f,  50.f, -50.f);
            glVertex3f(50.f,  50.f,  50.f);
            glVertex3f(50.f, -50.f,  50.f);

            glVertex3f(-50.f, -50.f,  50.f);
            glVertex3f(-50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f, -50.f);
            glVertex3f( 50.f, -50.f,  50.f);

            glVertex3f(-50.f, 50.f,  50.f);
            glVertex3f(-50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f, -50.f);
            glVertex3f( 50.f, 50.f,  50.f);

        glEnd();

        // Finally, display rendered frame on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


hope that helps you to help me! (;

14
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 03:30:11 pm »
I'm using the 1.6 version. Yes i have defined that i'm using the "SFML_DYNAMIC".

15
General / Can't find how to include the "lib" and "incl
« on: January 02, 2011, 03:07:22 pm »
I've donw the tutorial several times, and watch others on you tube but nothing seems to work..
just keep getting the "error LNK2019: unresolved external symbol..." error.

Pages: [1] 2
anything