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 - Austin J

Pages: 1 [2]
16
General / Re: A way to cobble sprites?
« on: April 09, 2014, 11:34:12 pm »
@Squasher, it's not the best way of doing it in our case however.

I'm looking around some more, sf::RenderTexture may be what I need actually.

17
General / Re: A way to cobble sprites?
« on: April 09, 2014, 09:57:50 pm »
Joseph, I'm not sure you read what I said with full effort.

We are not going to use a big sprite sheet(s), as it makes what we need/want a lot harder. The only time we use a sprite sheet is when we want random variants of a tile. For example, we have a spritesheet with several versions of an ice tile. Of course it's all loaded as one texture, but when the brush puts ice down, the selected sprites randomly select which version of the ice tile in the sheet to use.

  We will not however, keep every single tile of the entire game in one monstrous sprite sheet, for us that's simply a horrible idea.

  I may just be out of luck here?

18
General / Re: A way to cobble sprites?
« on: April 09, 2014, 06:35:08 pm »
Erm, actually, I may still have an issue here, sorry :/

  The problem I see with this is that it seems to only work if all of your tiles are within a single spritesheet. For our game this simply was not viable. I.e a tile can load random variants in a spritesheet dedicated to that tile, automatically keeping terrain from looking homogeneous. Using a giant sprite sheet for this wasn't viable.

  Is there a way I can get around this dilemna of using different png's rather than just using texture rects?

19
General / Re: A way to cobble sprites?
« on: April 08, 2014, 09:56:20 pm »
That's a perfect tutorial, thank's exploitr ;)

20
General / A way to cobble sprites?
« on: April 08, 2014, 07:00:11 pm »
  I have a map editor, which uses a sprite for each tile. Obviously since it's a map editor it needs to be ready to change the tiles etc. and I just keep all the tiles to themselves.

  However, in the game itself, I don't want to have to do this. The tiles aren't going to need changes or do anything but be displayed really, and so I'd prefer not to have to make that many draw calls (which leads to lower performance). My maps can have a lot of tiles, so it would certainly be beneficial in my opinion to simply have some big (or maybe even just one?) cobbled together textures to reduce the amount of draw calls.

  Is this correct, and if so, is there a means to do so? I haven't been able to find anything on the subject.

21
Feature requests / Re: Ostream operators << for SFML classes
« on: March 20, 2014, 04:36:57 am »
  I don't believe that libraries should serialize their objects for you in vast majority of cases. I don't know maybe serializing simple things like sf::Vector2 would be ok, but why on earth would someone ever want to save a whole sprite, or even worse a texture directly to a file?

22
Feature requests / File/Directory Detection
« on: March 19, 2014, 01:59:01 am »
  Forgive me if this has been requested before, but I couldn't find anything related to this so I'm going ahead making this request.

  I don't think SFML needs to handle much file I/O for you. It already loads major file formats like bitmaps and .png's, .wav etc... Other things are up to the user of SFML to do.

  One thing that I think would be really handy though...

  If you wanted to do something like go in a folder and detect what files are there (say the players different saves) you have to use OS specific code to do so. This adds some complexity to keeping your game cross platform.

  Personally just think it would be neat if SFML had a solution to detecting files and directories.

23
SFML projects / Re: Space - Level Editor
« on: March 04, 2014, 07:42:49 am »
The reason I chose against using a library like Qt was because I knew the vast majority of it I would never use. My GUI needs are very small, that is why I went with "reinventing the wheel". In my case the wheel was really small. I appreciate the input however  ;D .

24
SFML projects / Space - Level Editor
« on: March 04, 2014, 06:40:37 am »
  Space - Level Editor is the level editor I've been working on for a game called *drumroll* Space. (Well the name isn't set in stone, that's just what it is right now). The game itself has minimal functionality currently (I said I wasn't going to work on it without levels to test on)

  The level editor has various neat features (in my opinion anyways):

- Full screen compatibility on practically any monitor
- Fast level saving/loading. You can save and load hundreds of thousands of tiles in 0.5-2 seconds currently.
- A lightweight GUI with mostly clean functionality (I'd be lying if I said it was all clean  ::) ) Includes buttons, 3 windows sizes (small,medium,large), and text entry fields will be coming in a little bit
- Good performance in general ( I.e no lag when painting on tiles)
- Simple tile rotation

Intend to add in the future:
-A scripting system (after making myself go bald and crying a river or two most likely)
-Easy entity and tile creation (I want the game to be highly moddable. The user will be able to create their own kind of entities(space ships, tanks etc.) and import textures for tiles.
- Brush sizes (I just haven't done it yet for some reason)
-Hopefully some more advanced file I/O to prevent accidentally overwriting files etc + one slight issue (currently I don't write the rotation state of the tiles down  :( )







General rule: If somethings looks nice my artist designed it. If something looks horrible I designed it then pray every day afterwards that my artist will actually work this week. I.e that window in the bottom left corner, that would be mine.


25
General / Re: Help applying line algorithm
« on: February 13, 2014, 02:29:40 am »
Nice, it even has an example using SFML type grid. Thanks, wish I had seen this before.

26
General / Help applying line algorithm
« on: February 13, 2014, 01:44:02 am »
  I really wish I could just solve this myself but working with non-Cartesian coordinate system plus a few other things can confuse the hell out of me :(

  I'm working on a map editor that I want to be able to handle quite a few tiles. I've already set it up so that it won't render anything that is outside the view of the window. I can also get the tile the mouse is on by some simple math. (Use the mouses position to know what the index should be). However holding the mouse and moving it more than medium speed will still leave many gaps. I've been wanting to use a line algorithm to solve this, however I'm confusing the hell out of myself I feel like.

  Current implementation I have going it seems like it sort of does what its supposed to, but horribly. If I move the mouse just somewhat fast it's not that big a deal but if I move the mouse very fast it does odd things like this.



The most top right tile and the very bottom left tile, I went in a mostly straight diagonal line between the two, never releasing the mouse. So yeah what I'm doing now definitely doesn't work.

Here's the code I've got trying to deal with this. Note that I'm not worried about views yet, it's not on my to do list currently.

void Map::handleClick(sf::RenderWindow & WINDOW,std::string tile)
{
        sf::Vector2i mp = sf::Mouse::getPosition(WINDOW);
        sf::Vector2f mousePosition = static_cast<sf::Vector2f>(mp);
        if(lastTile != NULL) // When the mouse is released lastTile gets reset to NULL
        {
                int x= lastTile->getPosition().x;
                int y = lastTile->getPosition().y;
                int x2 = Map::getTileByCoords(mousePosition).getPosition().x;
                int y2 = Map::getTileByCoords(mousePosition).getPosition().y;
                int dx = x - x2; int dy = y - y2;
                for(int i = x/16; i != x2/16;)
                {
                        int cy = (i*(dy/dx))*16;
                        Map::assignTile(Map::getTileByCoords(i*16,y),tile);
                        if(i > x2/16)
                        {
                                i --;
                        }
                        else{ i++; }
                }
        }
        Map::assignTile(Map::getTileByCoords(mousePosition),tile);
        Map::lastTile = &Map::getTileByCoords(mousePosition);
}
 



27
General / Re: How to make a button in SFML?
« on: November 18, 2013, 11:31:51 pm »
You kind of have the right idea. I actually have a Button class in my current project that so far works pretty well. I'll share a bit of the idea behind it.

First off, make a button class. There isn't any reason for this box within obj deal you have going on. Your button needs to know its width, its height, and its position. I also give the Button class a boolean "mouseIsHovering". This makes things more organizational. As far as checking if the mouse is hovering over the button goes, you're on the right track. (Assuming you don't want to use
bool sf::FloatRect::contains(<mouse coords here>)
)

I find it better for the button to constantly know 4 values. Xmin, Xmax, Ymin, and Ymax. As you already
figured out, the min is the position and the max is the min + the width or height.

sf::Vector2f mp;
mp.x = sf::Mouse::getPosition(<window here>).x;
mp.y = sf::Mouse::getPosition(<window here>).y;
if(mp.x > button.Xmin && mp.x < button.Xmax && mp.y > button.YMin && mp.y < button.Ymax)
{
     button.setHoveringTrue();
}
 

Then basically at some point inside sf::Event::mouseButtonReleased
if(button.isHovering() == true)
{
     button.perform(); // or whatever function you use on click
}
 




28
General / sf::String::erase() troubles.
« on: November 18, 2013, 04:45:13 am »
SFML 2.1 - Static
Windows 7 - 64 bit

No matter how I go about it, sf::String::erase() doesn't work properly for me. Whenever I use it rather than erase the character it just replaces it with a box.

(I am filtering out backspace)

sf_string.erase(sf_string.getSize()-1,1); // Results in box first press then nothing afterwards(No size change)
 

std_string1 = sf_string;
std_string1.erase(std_string1.size()-1,1);
sf_string = std_string1; // Same results
 

I've tried other ways and it doesn't matter how I go about it I get this damned box.

Any help appreciated, thanks.

29
Graphics / Help needed with drawing sprite?
« on: September 26, 2013, 07:04:26 am »
It involves a white box, and no, believe it or not it's not because the sprite loses a reference to a texture  ;)

In SDL, when you're drawing tanks, spaceships, monsters, whatever, you had to write some code to get rid of that annoying background.

When I draw a sprite, it has that annoying background, a good example would be my custom mouse cursor.



I haven't been able to find anything regarding SFML on how to keep this from happening. This is the second game I'm working on. Last game was very simple, just an altered version of Battleship, so I could just make the background color for a sprite texture match the board. I can't do that now though.

Can someone be a pal and tell me how to handle this?

Pages: 1 [2]
anything