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 - Chocolatesheep

Pages: [1] 2
1
Graphics / Re: Drawing simple lines
« on: July 25, 2012, 07:49:48 pm »
Quote
If the beginning and end point get connected on your end then it's a problem in your mouse capture/vertex creating code.

Just tried the code given in the documentation. I guess I have an error in my code. I will look through it right now. Thanks for your help ;D

2
Graphics / Re: Drawing simple lines
« on: July 25, 2012, 07:05:17 pm »
Quote
Just switch them out and you get individual lines
I tried that, but it seems to create a dotted line instead of a continuous one.

3
Graphics / Drawing simple lines
« on: July 25, 2012, 06:26:16 pm »
is there a simple way to draw lines/paths with SFML. Let's say I wanted to move the mouse around the window and make it leave a trail. I tried using vertecies and vertex arrays, but they always seem to connect the first and last point  creating a convex shape. The same, of course happens with sf::ConvexShape. So is there a simple way of doing this or should I move on and think of a different way using rectangles and directional quotients.
With vertexes drawing them using sf::LineStrip.
Sorry if I sound nooby, or ignorant.
Thanks in advance

4
Graphics / noob help with drawing shapes and lines
« on: July 05, 2012, 01:46:04 am »
So I have this sprite moving around the screen, and I wanted to draw the path it is taking, sort of like a trail that it's leaving behind. It's not going in a straight line, it's moving in irregular curved paths. I tried drawing it with sf::ConvexShape, but when I do that it connects the first and last point with a line creating a polygon. Well, no surprise there, it is called convexshape after all. I also played around with vertex arrays but I didn't manage to get it to work properly. Does someone have a simple solution for this. Basicly I need the convexshape without it being convex. Oh, and a follow up question. What are the primitives called quads? I get the lines and linestrip, but what are quads?

EDIT: I'm using SFML 2.0 on Windows

5
General / How was SFML made?
« on: May 16, 2012, 01:50:56 pm »
I just have another stupid question as I often do. How was SFML made? What language was the API coded in? Was it made using only C++?

6
Graphics / Re: SFML 2.0 Sprite sizes
« on: May 12, 2012, 10:29:45 pm »
Thank you

7
Graphics / SFML 2.0 Sprite sizes
« on: May 12, 2012, 02:02:48 am »
I couldn't find this in the documentation. How do I get the width and height of a sprite? In 1.6 it was just Sprite.GetSize();
And how is the Sprite.getGlobalBounds(); function used?

8
General discussions / SFML 2.0 Sprites, Textures, Images and Clock
« on: May 01, 2012, 02:17:17 pm »
Just needed to ask some some questions, I'm quite new to SFML and I only used 1.6, but now I switched over to 2.0
To load an image onto a sprite I normally would have used Sprite.SetImage(Image);
But now due to the lack of the SetImage(); function I have to use Sprite.setTexture(Texture);
What I'm asking is what's the difference between Images and Textures in SFML?
And why does the Clock.getElapsedTime() no longer return a number but a sf::Time class type?

9
Graphics / Sprite keeps moving to the top left corner of the window
« on: January 09, 2012, 02:57:21 am »
I'm dumb :)

10
Graphics / Sprite keeps moving to the top left corner of the window
« on: January 08, 2012, 08:30:25 pm »
I used
Code: [Select]
Sprite.SetPosition(Event.MouseMove.X, Event.MouseMove.Y);
So basically the the sprite moves along with my mouse(because it's in a while loop). Anyway, every time i click something, like the space bar or the mouse button(anything at all) the sprite teleports to the top left corner of the window, and comes back to the mouse pointer after the button is released. How can I stop this, it's very annoying.

11
General / Advantages of switching to SFML 2.0
« on: January 05, 2012, 05:30:32 pm »
What are the advantages of switching to SFML 2.0
I just started learning SFML 1.6, would it be easier/better if I switched to 2.0?

12
SFML projects / First SFML game (snakes and apples)
« on: January 03, 2012, 01:13:23 pm »
Made it in a day. It's very simple, just a bit over 200 line long. The sourcecode is here. Don't think I did a great job with it, but oh well.
DOWNLOAD LINK: http://www.mediafire.com/?hfa7bcgbuufcxu5

Code: [Select]


#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
#include "windows.h"
#include <ctime>
using namespace std;

sf::VideoMode VMode(640,480,32);
sf::RenderWindow Screen(VMode,"The Game");

void UpdateScreen()
{
    Screen.Display();
}

int main()
{
    sf::Image Apple;
    if(!Apple.LoadFromFile("Apple.png"))
       return 2;

    sf::Image Background;
    Background.LoadFromFile("Background.png");

    sf::Image Worm;
    Worm.LoadFromFile("worm.png");

    sf::Image Start;
    Start.LoadFromFile("start.png");

    sf::Image Exit;
    Exit.LoadFromFile("exit.png");

    sf::SoundBuffer Buffer;
    Buffer.LoadFromFile("click.ogg");

    sf::Music Music;
    Music.OpenFromFile("music.ogg");

    sf::Sound Sound;
    Sound.SetBuffer(Buffer);

    sf::Clock Clock;
    sf::Clock Timer;

    sf::Sprite Sprite; // apple
    sf::Sprite Sprite2; // background
    sf::Sprite Sprite3; // worm
    sf::Sprite Sprite4; // second worm
    sf::Sprite Sprite5; // third worm
    sf::Sprite ExitSprite;
    sf::Sprite StartSprite;

    Sprite.SetImage(Apple);
    Sprite2.SetImage(Background);
    Sprite3.SetImage(Worm);
    ExitSprite.SetImage(Exit);
    StartSprite.SetImage(Start);

    Sprite3.SetCenter(0,Sprite3.GetSize().y/2);
    Sprite3.SetPosition(640,240);

    Screen.ShowMouseCursor(false);

    Sprite4 = Sprite3;
    Sprite5 = Sprite3;
    Sprite.SetCenter(Sprite.GetSize().x/2, Sprite.GetSize().y/2);

    StartSprite.SetPosition(100,220);
    ExitSprite.SetPosition(100,300);

    Screen.Draw(Sprite2);
    Screen.Draw(Sprite);
    Screen.Draw(Sprite3);
    Screen.Draw(Sprite4);
    Screen.Draw(Sprite5);
    Screen.Draw(StartSprite);
    Screen.Draw(ExitSprite);
    Screen.Display();

    int StartGame = 0;
    while(StartGame == 0) // MENU
    {
        sf::Event GayEvent;
        Sprite.SetPosition(GayEvent.MouseMove.X, GayEvent.MouseMove.Y);
        Screen.Draw(Sprite2);
        Screen.Draw(StartSprite);
        Screen.Draw(ExitSprite);
        Screen.Draw(Sprite);
        Screen.Display();

        while(Screen.GetEvent(GayEvent))
        {
             if(GayEvent.Type == sf::Event::Closed)
                Screen.Close();

/*startgame*/if(Sprite.GetPosition().x > StartSprite.GetPosition().x && Sprite.GetPosition().x < StartSprite.GetPosition().x + StartSprite.GetSize().x, Sprite.GetPosition().y > StartSprite.GetPosition().y && Sprite.GetPosition().y < StartSprite.GetPosition().y + StartSprite.GetSize().y)
              {
                if(GayEvent.Type == sf::Event::MouseButtonPressed)
                {
                 Sound.Play();
                 Sleep(500);
                 StartGame = 2;
                }
              }

              if(Sprite.GetPosition().x > ExitSprite.GetPosition().x && Sprite.GetPosition().x < ExitSprite.GetPosition().x + ExitSprite.GetSize().x, Sprite.GetPosition().y > ExitSprite.GetPosition().y && Sprite.GetPosition().y < ExitSprite.GetPosition().y + ExitSprite.GetSize().y)
              {
                  if(GayEvent.Type == sf::Event::MouseButtonPressed)
                  {
                   Sound.Play();
                   Sleep(500);
                   Screen.Close();
                   return EXIT_SUCCESS;
                  }
              }


            else{/* nothing */ }
        }
    }

    Clock.Reset();
    Timer.Reset();

    Music.Play();
    while(Screen.IsOpened() && StartGame == 2)
    {
        int RandomNumber = sf::Randomizer::Random(20,460);
        sf::Event Naruto;

        Sprite.SetPosition(Naruto.MouseMove.X, Naruto.MouseMove.Y);

        if (Clock.GetElapsedTime() > 0.01f)
        {
            Sprite4.Move(-6,0);
            Sprite5.Move(-15,0);
            Sprite3.Move(-10,0);
            Clock.Reset();

            if(Sprite3.GetPosition().x < -240)
            {
                Sprite3.SetPosition(640, RandomNumber);
            }

            if(Sprite4.GetPosition().x < -240)
            {
                Sprite4.SetPosition(640, RandomNumber);
            }

            if(Sprite5.GetPosition().x < -245)
            {
                Sprite5.SetPosition(640, RandomNumber);
            }
        }

        else{/*Nothing*/}

        Screen.Draw(Sprite2);
        Screen.Draw(Sprite);
        Screen.Draw(Sprite3);
        Screen.Draw(Sprite4);
        Screen.Draw(Sprite5);
        Screen.Display();

        if(Sprite3.GetPosition().x < Sprite.GetPosition().x+15.f && Sprite3.GetPosition().x > Sprite.GetPosition().x-15.f && Sprite3.GetPosition().y > Sprite.GetPosition().y-20.f && Sprite3.GetPosition().y < Sprite.GetPosition().y+20.f)
           {
               int x = Timer.GetElapsedTime();
               cout << "YOU LASTED " << x << " SECONDS\n\n\n\n\n";
               Screen.Close();
               system("pause");
               return 1;
           }

        if(Sprite4.GetPosition().x < Sprite.GetPosition().x+15.f && Sprite4.GetPosition().x > Sprite.GetPosition().x-15.f && Sprite4.GetPosition().y > Sprite.GetPosition().y-20.f && Sprite4.GetPosition().y < Sprite.GetPosition().y+20.f)
           {
               int x = Timer.GetElapsedTime();
               cout << "YOU LASTED " << x << " SECONDS\n\n\n\n\n";
               Screen.Close();
               system("pause");
               return 1;
           }

        if(Sprite5.GetPosition().x < Sprite.GetPosition().x+15.f && Sprite5.GetPosition().x > Sprite.GetPosition().x-15.f && Sprite5.GetPosition().y > Sprite.GetPosition().y-20.f && Sprite5.GetPosition().y < Sprite.GetPosition().y+20.f)
           {
               int x = Timer.GetElapsedTime();
               cout << "YOU LASTED " << x << " SECONDS\n\n\n\n\n\n\n";
               Screen.Close();
               system("pause");
               return 1;
           }


        else{/*Nothing*/}

        while(Screen.GetEvent(Naruto))
        {
            if(Naruto.Type == sf::Event::Closed)
               Screen.Close();

            else{/* nothing */ }
        }


    }//end of game loop


    return 0;
}

13
Audio / OpenAL32.dll is missing from your computer
« on: January 03, 2012, 12:46:01 pm »
lol I actually did search this after I posted this.
Thanks anyway

14
Audio / OpenAL32.dll is missing from your computer
« on: January 03, 2012, 12:30:32 pm »
I tired to load and play music from a .ogg file and my program gets an error.
OpenAL32.dll is missing from your computer

15
Graphics / Is there a function that clears a specific sprite
« on: December 17, 2011, 08:20:51 pm »
Instead of using window.Clear(); (window being the name of my window) is there any way I can clear a specific sprite from the window instead of clearing the whole window then drawing all the sprites on it again?


-Edit
Ok, if I must clear all and rendraw everything then how do I prevent flickering?

Pages: [1] 2
anything