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 - Linux Vs God

Pages: [1] 2
1
Graphics / SFML 2.0 Visual Studio sf::Sprite
« on: August 14, 2011, 10:06:48 am »
thank you.

2
Graphics / SFML 2.0 Visual Studio sf::Sprite
« on: August 14, 2011, 09:58:16 am »
So how would I set a sprites image? I read through the documentation and I still don't understand.

3
Graphics / SFML 2.0 Visual Studio sf::Sprite
« on: August 14, 2011, 09:29:19 am »
I compiled sfml 2.0 with nmake using this tutorial . Everything is fine and dandy until I want to work with sprites. My error "Error: class "sf::Sprite" has no member "SetImage"". On my old computer a few weeks ago I compiled sfml 2.0 the same way i just did and it worked. Now it doesn't. Was there a change in sfml? Please help

4
General / SFML 2.0 Keyrelease help
« on: August 09, 2011, 08:44:33 pm »
It works 100% now thanks

5
General / SFML 2.0 Keyrelease help
« on: August 09, 2011, 08:10:33 pm »
Anybody got ideas?

6
General / SFML 2.0 Keyrelease help
« on: August 09, 2011, 05:02:36 am »
Ok, I am making a Zelda game similar to a Link To The Past. I am trying to make my character animation's image default to 0 whenever i release one of the direction buttons on my keyboard. This works about 85% of the time. Is there something wrong with this code?

Code: [Select]
void Character::Movement()
{
if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Up))
{
currentView = UP;
spriteFrame++;

if(spriteFrame >= 9)
spriteFrame = 0;

for(int i=0; i < spriteFrame; ++i)
LinkSprite.SetImage(linkup[i], false);

LinkSprite.Move(0.f, -speed);
}
else if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Down))
{
currentView = DOWN;
spriteFrame++;

if(spriteFrame >= 9)
spriteFrame = 0;

for(int i=0; i < spriteFrame; ++i)
LinkSprite.SetImage(linkdown[i], false);

LinkSprite.Move(0.f, speed);
}
else if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Right))
{
currentView = RIGHT;
spriteFrame++;

if(spriteFrame >= 9)
spriteFrame = 0;

for(int i=0; i < spriteFrame; ++i)
LinkSprite.SetImage(linkright[i], true);

LinkSprite.Move(speed, 0.f);
}
else if(sf::Keyboard::IsKeyPressed(sf::Keyboard::Left))
{
currentView = LEFT;
spriteFrame++;

if(spriteFrame >= 9)
spriteFrame = 0;

for(int i=0; i < spriteFrame; ++i)
LinkSprite.SetImage(linkleft[i], true);

LinkSprite.Move(-speed, 0.f);
}
}

void Character::KeyRelease()
{
if(sf::Event::KeyReleased && sf::Keyboard::Right && currentView == RIGHT)
LinkSprite.SetImage(linkright[0]);
if(sf::Event::KeyReleased && sf::Keyboard::Left && currentView == LEFT)
LinkSprite.SetImage(linkleft[0]);
if(sf::Event::KeyReleased && sf::Keyboard::Up && currentView == UP)
LinkSprite.SetImage(linkup[0]);
if(sf::Event::KeyReleased && sf::Keyboard::Down && currentView == DOWN)
LinkSprite.SetImage(linkdown[0]);
}

7
Graphics / SFML 2 Tilemap issue
« on: August 03, 2011, 12:16:46 am »
Pixel Perfect is the only one that really works with my game. Bounding box and circle test just dont work correctly. is there just a way to use Pixel Perfect with Tilemaps without incredible lag?

8
Graphics / SFML 2 Tilemap issue
« on: August 02, 2011, 11:15:35 pm »
One more issue. When i set the pixel perfect collisions from the collision class from the wiki, my framerate drops all the way to 1. Any ideas?

9
Graphics / SFML 2 Tilemap issue
« on: August 02, 2011, 11:41:00 am »
Thanks it worked perfectly

10
Graphics / SFML 2 Tilemap issue
« on: August 02, 2011, 10:23:41 am »
ok heres Engine.cpp:

Code: [Select]


#include <iostream>
#include "Engine.h"
#include "Link.h"

template<typename T, int size>
int GetArrLength(T(&)[size]){return size;};

Engine::Engine()
:fps(0)
{

}

Engine::~Engine()
{

}

bool Engine::Init()
{
window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "Legend Of Zelda: A Link To The Future");
window->SetFramerateLimit(30);
window->EnableVerticalSync(false);

    if(!window)
        return false;

    return true;
}

void Engine::Render()
{
    window->Clear();
Load_Level();
    window->Display();
}

void Engine::ProcessInput()
{
    sf::Event Event;

    while(window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0, 0 },
};

    std::vector<sf::Image> images(3);
    images[0].LoadFromFile("grass.png");
    images[1].LoadFromFile("rock.png");

    // Create the sprite
    std::vector<sf::Sprite> tiles(3);
    tiles[0] = sf::Sprite(images[0]); // Grass
    tiles[1] = sf::Sprite(images[1]); // rock

for(int x=0; x < GetArrLength(map); ++x)
{
for(int y=0; y < GetArrLength(map[x]); ++y)
{
int tileId = map[x][y];
     
            const sf::Image* image = tiles[tileId].GetImage();
             
            int width = image->GetWidth();
            int height = image->GetHeight();
     
tiles[tileId].SetPosition(x * width, y * height);
            window->Draw(tiles[tileId]);
}
}
}

void Engine::Update()
{
link.Movement();
}

void Engine::FramesPerSecond()
{
    fps++;
    if(Clock.GetElapsedTime() >= 1.f)
    {
int Framerate = (1.f / Clock.GetElapsedTime()) * 1000;
std::cout << "FPS: " << Framerate<< std::endl;
Clock.Reset();
    }
}

void Engine::MainLoop()
{
    while(window->IsOpened())
    {
        ProcessInput();
FramesPerSecond();
Update();
        Render();
    }
}

void Engine::Run()
{
    if(!Init())
        throw "Could Not Initialize!";

    MainLoop();
}



and heres Engine.h:

Code: [Select]


#ifndef ENGINE_H
#define ENGINE_H

#include <SFML/Graphics.hpp>
#include "Link.h"

class Engine
{
    public:
        Engine();
        ~Engine();

        void Run();

sf::RenderWindow* window;
sf::Event Event;
    private:
        bool Init();
        void MainLoop();
        void ProcessInput();
        void Render();
void Load_Level();
void Update();
void FramesPerSecond();

sf::Clock Clock;
int fps;

Link link;
};

#endif // ENGINE_H


heres main.cpp:

Code: [Select]

#include <SFML/Graphics.hpp>
#include "Engine.h"
#include "Link.h"

int main(int argc, char* args[])
{
Engine* engine = new Engine();
engine->Run();

delete engine;

return 0;

}

11
Graphics / SFML 2 Tilemap issue
« on: August 02, 2011, 09:08:02 am »
Both images loaded fine actually

heres my map:

Code: [Select]

int map[25][25] = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};


my output would be like it should be:



now why would my output sometimes have white?

12
Graphics / SFML 2 Tilemap issue
« on: August 02, 2011, 05:38:45 am »
anybody??

13
Graphics / SFML 2 Tilemap issue
« on: August 02, 2011, 01:12:31 am »
Anyone know why this code
Code: [Select]


template<typename T, int size>
int GetArrLength(T(&)[size]){return size;};

int map[4][4] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
};

    std::vector<sf::Image> images(2);
    images[0].LoadFromFile("grass.png");
    images[1].LoadFromFile("water.png");

    // Create the sprite
    std::vector<sf::Sprite> tiles(2);
    tiles[0] = sf::Sprite(images[0]); // Grass
    tiles[1] = sf::Sprite(images[1]); // Water

for(int x=0; x < GetArrLength(map); ++x)
{
for(int y=0; y < GetArrLength(map[x]); ++y)
{
int tileId = map[x][y];
     
            const sf::Image* image = tiles[tileId].GetImage();
             
            int width = image->GetWidth();
            int height = image->GetHeight();
     
tiles[tileId].SetPosition(x * width, y * height);
            window->Draw(tiles[tileId]);
}
}


 produces this output  with SFML 2 on Visual Studio 2010 express?


14
Graphics / Tilemaps is ugly
« on: July 31, 2011, 08:56:54 pm »
That was a easy fix. Thank you

15
Graphics / Tilemaps is ugly
« on: July 31, 2011, 08:31:50 pm »
How would i get rid of the black lines between each tile in my tilemap?



Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <iostream>
#include <vector>

int main()
{
    std::vector< std::vector<int> > map(4, std::vector<int>(4));
    // Define the map
    map[0][0] = 0;
    map[0][1] = 1;
    map[0][2] = 0;
    map[0][3] = 0;
    map[1][0] = 0;
    map[1][1] = 0;
    map[1][2] = 0;
    map[1][3] = 0;
    map[2][0] = 0;
    map[2][1] = 0;
    map[2][2] = 0;
    map[2][3] = 0;
    map[3][0] = 0;
    map[3][1] = 0;
    map[3][2] = 0;
    map[3][3] = 1;
   
   
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(640, 480, 32), "SFML TileMap");

    // Load the sprite image from a file
    std::vector<sf::Image> images(2);
    if (!images[0].LoadFromFile("grass.png")) {
        return EXIT_FAILURE;
    }
    if (!images[1].LoadFromFile("water.png")) {
        return EXIT_FAILURE;
    }

    // Create the sprite
    std::vector<sf::Sprite> tiles(2);
    tiles[0] = sf::Sprite(images[0]); // Grass
    tiles[1] = sf::Sprite(images[1]); // Water

    // 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();
        }

        // Get elapsed time
        float ElapsedTime = App.GetFrameTime();

        // Clear screen
        App.Clear();
       
        for (int x = 0; x < map.size (); x++) {
            for (int y = 0; y < map[x].size (); y++) {
                int tileId = map[x][y];
                // Get the tile's image
                const sf::Image* image = tiles[tileId].GetImage();
                // Get the width and height of the image
                int width = image->GetWidth();
                int height = image->GetHeight();
                // Adjust the offset by using the width
                tiles[tileId].SetPosition(x * width, y * height);
                // Draw the tile
                App.Draw(tiles[tileId]);
            }
        }

        // Display window contents on screen
        App.Display();
       
       
        sf::Sleep(1.0f / 60.0f);
    }

    return EXIT_SUCCESS;
}

Pages: [1] 2
anything