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

Pages: 1 [2] 3 4 ... 9
16
General / Re: text doesn't draw
« on: February 03, 2016, 07:41:31 am »
That's interesting.

It appears as if adding the following line:

glBindBuffer(GL_ARRAY_BUFFER, 0);
 

Before drawing the text fixes it. Not sure why you binding a buffer effects SFML, though.

17
General / Re: C++ Lua scripting tutorial
« on: February 02, 2016, 02:34:13 am »
You can find the manual here: http://www.lua.org/manual/5.3/

If you're looking for an easy beginners guide, you can just search google for a tutorial. There's plenty of them out there.

Yes, or make a game, I would like to see how to implement them togheter.

But what are you wanting to do, and why do you believe Lua is the answer? Don't get me wrong, it's a great library, but using Lua "just because" is a very bad idea.

18
General / Re: Possible overflow when using window.setView()
« on: January 27, 2016, 01:26:57 am »
The window does not hold a pointer to a view, it holds a view object. When you set the view, it's simply copying the data. Setting the view does not allocate or free any memory.

19
General / Re: Implementing the Projectiles in a Sidescroller Game
« on: January 24, 2016, 10:36:39 pm »
I thought of using a list or vector to contain all of the possibly shot projectiles

Use an std::vector, not an std::list. The std::list class is usually implemented using linked lists, which will have a terrible effect on performance.

20
General / Re: deltaTime changes drastically when window is resized ?
« on: January 20, 2016, 12:45:58 pm »
I wanted the game to be something new so i added a feature where you can resize the window to resize the camera

case sf::Event::Resized:
                                window.setView(view = sf::View(sf::FloatRect(0.f, 0.f,
                                        static_cast<float>(window.getSize().x),
                                        static_cast<float>(window.getSize().y))));
                                break;
 

This is a very naive approach for what you want to achieve. The problem is that if you have a 640x480 window and then resize to a 1920x1080 window you will see x3 more horizontally and x2.25 more vertically. So if your character fits "nicely" in one resolution it will be either way too big or way too small on another.

A common approach is to have a fixed vertical or horizontal size and have the other axis vary depending on the aspect ratio.

For a fixed height and variable width:

float height = 10.0f; //fixed height
float width = height * ((float)window.getSize().x / (float)window.getSize().y); //13.3 on 640x480 & 17.7 on 1920x1080
 

but the problem is that when i resize the window deltaTime changes drastically, and i don't want that because it changes the gameplay(like the jumpheight, speed, etc)

You are not being very clear as to what the problem is (also, don't post your entire code, narrow it down to the individual piece of code that's causing problems and then if you still can't figure it out ask).

One thing to note is that if you drag the window and your application tries to poll for the event it will freeze the thread until the dragging has stopped, which is turn will give a sudden increase in your delta. Not sure if this is related to the problem you're having, though.

21
What eXpl0it3r said.

2D graphics doesn't take up a whole lot of processing power, but a lot of unnecessary draw calls do. Probably one of the simplest yet very effective improvement you could begin with is to simply not draw what you cannot see.

22
To start, I'm a game developer

You don't say.  :P

What I need is for an inventory system, items are randomly created and can look different so for example:
"bloodied oak baseball bat" - "scratched steel baseball bat" would both look different, both would use a baseball bat blank sprite, then the first would use the oak texture, the problem is bloodied is an extra condition, I would need to layer it on top of the oak texture. Perhaps using a sprite sheet with some transparency and then having a bloodied texture on the sheet that is blood splatters among transparent space, but how do I layer that on top of the other texture? do I create a second sprite and place it directly above the existing one?
Thanks a bunch for reading

I'm not sure if SFML provides anything that will directly solve the problem, but there is transparency (as you've mentioned), so you should be able to draw another texture over it (via a Sprite or RectangleShape placed right above what you want to apply the overlay to). You can make the overlaying image transparent by setting the sprite or shape's color to a color with the appropriate alpha value.

Example:
sf::Texture weapon_tex;
base_image.loadFromFile("weapon.png");

sf::Texture blood_tex;
blood_overlay.loadFromFile("blood.png");

sf::RectangleShape weapon_slot;
weapon_slot.setPosition(sf::Vector2f(0, 0));
weapon_slot.setSize(sf::Vector2f(80, 80));

sf::RectangleShape weapon_slot_overlay;
weapon_slot_overlay.setPosition(sf::Vector2f(0, 0));
weapon_slot_overlay.setSize(sf::Vector2f(80, 80));
weapon_slot_overlay.setFillColor(sf::Color(255, 255, 255, 128)); //128 is half transparency

weapon_slot.setTexture(&weapon_tex);
weapon_slot_overlay.setTexture(&blood_tex);

window.draw(weapon_slot);
window.draw(weapon_slot_overlay);
 

23
General / Re: New to SFML, creating my own game and guidelines needed!
« on: December 05, 2015, 02:00:51 am »
I will create a class for the cards that can be used for both the backside of the cards and showing the front. How do I create that in a simple way for my project?

You could just use a bool or an enum to keep track if it's up or down facing.

Do I need to keep track of the x and y coordinates of every card?

That really depends. Can the cards be located anywhere, or only in fixed locations? It's entirely reasonable to just keep your cards in some sort of container and have the graphics code deduce where they should be drawn and your input code to deduce which one you've clicked on. Or you could store the position in the cards. Whichever works best for you.

Also, how do I keep track of which card I've clicked on?

There's no one way to do this. You could use pointers, integer handles, etc. I'd really need to see how your cards are implemented to make any helpful suggestions.

Also, please use English in your code. There are a lot of programmers that speak English as a secondary language, but only use English in their code. Why? Because reasons. That and if everybody used their native languages, nobody would be able to read each others code.

24
General / Re: Tiled to SFML using lua.
« on: November 26, 2015, 06:49:25 am »
You can't assign a value to a number in Lua.

While what you're asking is not clear (since it's impossible), assuming what you're looking for is to get the value in a table using a number as an index:

lua_getglobal(L, "global_table"); //Push the table to the top of the stack

/*
    The following three lines are equivalent to this in Lua:

    global_table[4] = 2000
*/

lua_pushinteger(L, 4);
lua_pushinteger(L, 2000);
lua_settable(L, -3);

//Push global_table[4] to the top of the stack
lua_pushinteger(L, 4);
lua_gettable(L, -2);

std::cout << lua_tonumber(L, -1) << std::endl; //Should print 2000

lua_pop(L, 2); //Remove the value and table from the stack
 


25
General / Re: Gravitational lensing shader
« on: November 24, 2015, 11:55:26 pm »
It does not appear to be the same shading language as what SFML uses (which is whatever versions of GLSL OpenGL 2.0 and 2.1 use). You're going to have to re-write it in GLSL.

26
General / Re: SFML shooting help!
« on: November 24, 2015, 07:07:09 pm »
You can't pass a vector of objects to SFML. You're going to have to iterate through each one and check which ones are active to see if they need to be drawn.

Like so:

void Weapon::draw(sf::RenderTarget& rt)
{
    for (auto& bullet : m_vBullets)
    {
        if (bullet.isBulletActive())
        {
            rt.draw(bullet);
        }
     }
}
 

Also, your design is quite bad. Don't mix rendering code and gameplay code. And bullets are not owned by the gun that they were fired from, the gun is not owned by the player that's holding it; make your code actually represent this.

It's not perfect, but I highly recommend you read this book (completely free): http://gameprogrammingpatterns.com/contents.html. It may help you write better code.

27
Feature requests / Re: SoundRecorder improvments
« on: November 17, 2015, 09:03:47 am »
As for your comment. I think it's highly unlikely that we will support more that recording 2 channels, because OpenAL doesn't, but I can change the interface to this:
void setChannelCount(unsigned int channelCount);
unsigned int getChannelCount() const;
But what should I do if the user sets a channelCount > 2 ? Fallback to 2? Return an error?

I find that using an unsigned int is a bit misleading for something that only has two possible values.

Like:

void setStereoSoundEnabled(bool enabled);
bool isStereoSoundEnabled() const;
 

Or:

enum class RecordingMode
{
    MONO,
    STEREO
};

void setRecordingMode(RecordingMode recording_mode);
RecordingMode getRecordingMode();
 

28
General / Re: How to determine system requirements for my game?
« on: November 17, 2015, 08:28:41 am »
If your game is trivial, there's no real reason to specific system requirements aside from operating system.

- OS
How do you not know how to determine this? If you compile and run a build on your platform, that means that the output is for your platform. So if I build a program with MSVC on Windows, and it outputs EXEs, and I can run them, it's obvious in multiple ways that I am in fact creating binaries for Windows.

- Graphics card
In terms of driver support, if you're using SFML's graphics module, I might be wrong, but I believe it requires OpenGL 2.1 or newer. If you're using OpenGL directly, you should know what version you're using, in which case that's what's required.

In terms of performance, If you can, test it out on some really other computers and see how well it works with them (if you can, determine their specifications and how they compare in terms of raw performance compared to other computers tested, which may give you a better idea of just how much performance your game demands).

- CPU
Much harder to measure. It's not as simple as "2ghz or more" because there can be a huge performance gap between two processors at the same speed with the same amount of cores. Plus, things like RAM speed, cache, and even background applications running on the computer can have an impact.

While you can use a virtual machine to test this to some extent, I recommend just testing it out of various computers, see how much performance it takes up (look at task manager or something), and giving a generously-high requirement.

- RAM
Track your allocations, look at task manager, etc. It's pretty easy to determine how much RAM your game takes up. But keep in mind that you're suggesting the amount of RAM their whole system should have at a minimum for playing your game, so suggest just that and not the amount of RAM your game uses (such as if your game uses 80mb RAM, say you need at least 1GB, or if your game takes 2GB, say you need 4GB).

- Storage Space
You're generally just suggesting how much free space they should have for the game, not how big their drives should be. Just take the size of your game (including all the assets) and add a bit more for any files the game may create (such as save files).

- Sound Card
I don't know what SFML uses or what it's compatible with, but I'm fairly certain that this isn't any serious compatibility issue for most computers.

29
using namespace std;
using namespace sf;
 

No.

//C++ Feature template allows us to create a generic funtion to check if two shapes are intersecting or colliding.
template <class T1, class T2>
bool isIntersecting(T1& mA, T2& mB)
{
        return mA.right() >= mB.left() && mA.left() <= mB.right() &&
                mA.bottom() >= mB.top() && mA.top() <= mB.bottom();
}
 

Using templates like this can be problematic. Aside from the fact that you'll probably end up with cryptic compiler errors at one point or another, you could just do something like this:

struct CollisionShape
{
    CollisionShape(float left, float right, float top, float bottom) : left(left), right(right), top(top), bottom(bottom) { }
    CollisionShape() { }
    float left, right, top, bottom;
};

operator CollisionShape(const Paddle& paddle)
{
    return CollisionShape(paddle.left(), paddle.right(), paddle.top(), paddle.bottom());
}

bool isIntersecting(const CollisionShape& l, const CollisionShape& r)
{
        return l.right >= r.left && l.left <= r.right &&
                l.bottom >= r.top && l.top <= r.bottom;
}
 

//Here we use an unconditiional goto statement to allow the user to restart the game.  
restart:
 

Using a goto to restart the game is just bad program structure.

30
General / Re: Overlapping windows/menus
« on: November 08, 2015, 10:24:38 am »
Not sure what you're asking for, but you could do something like this:

void GuiManager::onClick(Vector2i position)
{
    for (auto it = menus.begin(); it != menus.end(); it++) //Iterator from front to back
    {
        if (it->doesMenuCoverPosition(position)) //Check if mouse is over the menu's covered area
        {
             it->onClick(position); //Dispatch event to the appropriate menu
             break;
        }
    }
}
 

This assumes your vectors are sorted to where the top menu menus[0] is "in front" of the other menus and menus[size-1] is "behind" the other menus. If you want, you could also swap the first element with the element containing menu that's clicked on (if it's not already the first menu) so if it's hidden behind another menu (or more) and you click on a small piece of it it will bring itself to the top and display over the over menus.

Pages: 1 [2] 3 4 ... 9
anything