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

Pages: [1]
1
How do you pack the textures into one image in the tutorials Laurent?

any picture editor

2
Graphics / Re: C++ white boxes displaying
« on: April 02, 2014, 11:23:54 pm »
#include <iostream>
#include <vector>
#include <SFML/Graphics.hpp>

class SpriteDatabase
{
public:
    SpriteDatabase();
    ~SpriteDatabase();
    sf::Sprite & getSpriteId(unsigned int id);
private:
    void loadSprite(sf::Sprite *sprite);
    bool preloadDatabase();
    std::vector<sf::Sprite*> spriteIndex;
    sf::Texture texture;
};

sf::Sprite & SpriteDatabase::getSpriteId(unsigned int id)
{
    std::cout << "Returning Sprite\n" << std::endl;
    return (*spriteIndex[id]);
}

void SpriteDatabase::loadSprite(sf::Sprite *sprite) /* Push into vector container */
{
    std::cout << "Loading Sprite\n" << std::endl;
    spriteIndex.push_back(sprite);
}

bool SpriteDatabase::preloadDatabase()
{
    sf::Sprite *sprite;

    if(!spriteIndex.empty())
        return false;

    if(!texture.loadFromFile("gfxPack.png"))
        return false;

    sprite = new sf::Sprite(texture, sf::IntRect(0,0,89,90));
    loadSprite(sprite);
    sprite = new sf::Sprite(texture, sf::IntRect(90,0,89,90));
    loadSprite(sprite);
    sprite = new sf::Sprite(texture, sf::IntRect(180,0,89,90));
    loadSprite(sprite);
    sprite = new sf::Sprite(texture, sf::IntRect(270,0,89,90));
    loadSprite(sprite);
    sprite = new sf::Sprite(texture, sf::IntRect(360,0,89,90));
    loadSprite(sprite);

    return true;
}

SpriteDatabase::~SpriteDatabase()
{
    for (int = 0; i < spriteIndex.size(); i++)
    {
        delete spriteIndex[i];
    }
    spriteIndex.clear();
}

it work?


ADD:

Oh, Fuck...
You use sprite.setTextureRect(sf::IntRect(360,0,449,90));

1 parametr start texture rect x
2 parametr start texture rect y
3 parametr width texture rect
4 parametr height texture rect

    sprite.setTextureRect(sf::IntRect(0,0,89,90));    /* Lime Grass */
    loadSprite(sprite);
    sprite.setTextureRect(sf::IntRect(90,0,89,90));  /* Rough Sand */
    loadSprite(sprite);
    sprite.setTextureRect(sf::IntRect(180,0,89,90)); /* Pure Sand */
    loadSprite(sprite);
    sprite.setTextureRect(sf::IntRect(270,0,89,90)); /* Shallow Water */
    loadSprite(sprite);
    sprite.setTextureRect(sf::IntRect(360,0,89,90)); /* Dirt */
    loadSprite(sprite);

3
SFML projects / Re: My First project SpaceKiller2D
« on: March 30, 2014, 02:15:58 pm »
Updated the link in the first post to the new version and add video...
Fraps not record more 30 seconds (

This game random 90%, if you win, you 10% good gamer and 90% lucky...

4
Graphics / Re: multiple tex per sprite problem
« on: March 27, 2014, 10:13:38 am »
 s.setTexture(bullets_tex[grid[x+i][y+j].bullets[k].id], true);
use true for reset texture rects

5
SFML projects / My First project SpaceKiller2D
« on: March 21, 2014, 05:10:32 pm »
Hi people.
I want to share with you my first project on SFML.
This game 2D space shooter...
Waiting for your criticism and suggestions.

New version...
SpaceKiller2D_v0.0.5.zip

Control:
Arrow to move.
Space to shoot.
Left Alt to Rocket.
Enter to max weapon power - this for test.

P.S. Sorry for my english. Google Translate help me )



Pages: [1]