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

Pages: 1 [2] 3 4 ... 9
16
General / Help me optimize my game
« on: March 27, 2011, 10:57:28 am »
Start with compiling it in Release-mode instead of Debug - and you'll see rather nice space savings. :)

17
Window / IsMouseButtonDown freezing problem
« on: March 27, 2011, 10:55:24 am »
You're not pumping events while inside the while-loop.

Edit: to clarify a bit. Set a boolean variable when you get a mousedown event, then unset it when you get the mouseup event - and do the dragging while the variable is set, instead of doing loops like the one you posted.

18
Graphics / Different outputs for GetPosition
« on: March 27, 2011, 08:56:39 am »
Quote from: "JAssange"
. Anyway, #ifndef is easier then bothering with defined.

Unless of course you want to combine it with anything else.

Code: [Select]
if !defined(_DEBUG) && !defined(_BETA)

as an example.

19
Graphics / Different outputs for GetPosition
« on: March 26, 2011, 06:57:07 pm »
or wrap them in:

#if !defined(_DEBUG).

Or make a function that does nothing when in Release mode - but debuggy-stuff when in Debug. :)

20
Window / Load texture
« on: March 26, 2011, 07:44:38 am »
If you just want to bind the image, use the Image::Bind function.

However, (and this is for Laurent) - perhaps it would be an idea to set the internals to protected, rather than private - to allow others to make their own decorated subclass that can return and/or work on "myTexture" and the others for other purposes.

21
Audio / Audio Path
« on: March 26, 2011, 07:33:48 am »
Not only that, but if you use normal backslashes for some reason, you'll have to escape them ( '\\', instead of '\' ), unless you use C# in which case you can use @"\". But like Nexus said, use forward-slashes instead, it works on all platforms.

22
General / joysticks with more than 7 axis
« on: March 25, 2011, 06:08:39 pm »
Only problem is that Microsoft themselves have more or less deprecated DirectInput. They recommend against it in their own documentation. (suggesting to use normal window messages and XInput instead)

23
Graphics / sprite moving out of view!!
« on: March 23, 2011, 07:06:42 pm »
If you want to contain the sprite within the bounds of the window - and have a non-scrolling game, but rather a single screen game - you basically do this.

Figure out the width and height of the window. (there are functions for this).

Check your sprites position + sprite width and compare it with the window width. If it's above the window width, adjust the position.x to window.width - sprite.width.

Use a similar approach for height.

24
General / GetInput() trouble
« on: March 23, 2011, 07:04:03 pm »
I would separate the conditions into something like this:

(this below is pseudocode written without checking syntax etc - but you should get the idea of it)

Code: [Select]

    const sf::Input & myInput = Target.GetInput();

    if(myInput.IsKeyDown(sf::Key::Down))
            m_movespeed.y += 5.f;

    if(myInput.IsKeyDown(sf::Key::Up))
            m_movespeed.y -= 5.f;

    if(myInput.IsKeyDown(sf::Key::Left))
            m_movespeed.x -= 5.f;

    if(myInput.IsKeyDown(sf::Key::Right))
            m_movespeed.x += 5.f;

    sf::Vector2f newPos(splayer.GetPosition().x + m_movespeed.x, splayer.GetPosition().y + m_movespeed.y);

    newPos.x = min(newPos.x, 780);  // or replace with a proper clamp function
    newPos.x = max(newPos.x, 240);  //
    newPos.y = min(newPos.y, 730);  //
    newPos.y = max(newPos.y, 40);   //

    splayer.SetPosition(newPos);

25
General discussions / My plans for the website tools
« on: March 21, 2011, 06:07:16 pm »
You don't even need that if you're using windows and a decent editor. There's stuff like GitExtensions that handles everything for you (MSVC).

26
Graphics / Error displaying, pointer to Sprite
« on: March 21, 2011, 01:45:20 pm »
That is correct.

It's the way which means the least changes for you.

27
Graphics / Error displaying, pointer to Sprite
« on: March 21, 2011, 01:06:45 pm »
The easiest way for you would most likely be to include "iBall" inside the Ball class as a member of that class, instead of declaring it inside the constructor.

And please, don't make it a pointer like everything else. ;)

Like this:

Code: [Select]

class Ball
{
/* removed for easier reading */
private:
     sf::Image iBall;
};

Ball::Ball(float xP, float yP)
{
   if(! iBall.LoadFromFile("pilka.bmp") )
   {
/* removed for easier reading */

28
Graphics / Error displaying, pointer to Sprite
« on: March 21, 2011, 12:35:42 pm »
Ugh - apart from abusing pointers everywhere even when not needed - and a static renderwindow, your image file goes out of scope when leaving the Ball::Ball constructor. Thus, the image is no longer available when you're trying to draw the sprite.

Please read the documentation here:
http://www.sfml-dev.org/documentation/2.0/classsf_1_1Sprite.htm

Especially this part:
Quote
It is important to note that the sf::Sprite instance doesn't copy the image that it uses, it only keeps a reference to it. Thus, a sf::Image must not be destructed while it is used by a sf::Sprite (i.e. never write a function that uses a local sf::Image instance for creating a sprite).

29
General discussions / ATI fix
« on: March 21, 2011, 08:59:28 am »
Excellent news!

I'll make sure to give it a try after work ;)

30
General / App.Draw() trouble
« on: March 20, 2011, 06:28:44 pm »
Ehm, of course it never makes it to FDisplay?

You have an infinite loop in FEvent - until your program closes.

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