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

Pages: 1 [2] 3
16
Graphics / Re: Origins and positions
« on: May 16, 2013, 03:03:11 pm »
May I enquire why you would reimplement the SFML ?

If you want to do so, you can look at SFML code directly

17
Graphics / Re: Origins and positions
« on: May 15, 2013, 04:17:18 pm »
As far as SFML is concerned, the origin gives the origin of the texture in the sprite.

For example, let's assume we have a square :

doing
square.setOrigin(width/2, height/2);
will mean that our texture won't be displayed from position, but from position-origin, meaning that our square image will have it's center at the "position" indicated, and no longer its left-top corner.

The origin is also the rotation center.

18
Graphics / Re: questions about Dots game project
« on: May 15, 2013, 07:33:25 am »
I'd add brackets to avoid ambiguity, but it's the idea, ya

19
top, left, width and height are 4 attributes of sf::Rect, which is contained by sf::RectangleShape and can be accessed from it with getGlobalBounds().

I guess you want to check the position of this shape by playing with intersects() of sf::Rect, but you will want to rectify the position of sf::RectangleShape

20
let's assume you display images of this 1024x768 and your screen size is 1920x1080.

I'd guess that you want a view that goes the maximum size, but of the right ratio.

So in this case i'd go with a view of 1365x768, to keep the right size but to go to the right ratio.

where 1365 = 1024 * (16/9) / (4/3)

and with being extra careful about not drawing anything on the borders (or to overwrite too black rectangles)

21
I'd say it's all the same,

create a View, get the size of your window, get the maximum considering your ratio and create the View of the right size. However changing the view this way will only result in having more or less entities printing on your screen depending on your screen resolution

22
Graphics / Re: SFML 2.0 - Move in direction faced
« on: May 12, 2013, 07:50:28 pm »
I can't see why it wouldn't work. Looks like math.h is included (or else you'd have an error) plus it works for me.
Be careful with the minus ("-") in the middle of an equation. I've had issue with it when accessing variables (it inverted the address value and not the value contained by the variable.

Sorry I couldn't of more help.

23
System / Re: My Game is lagging
« on: May 12, 2013, 07:20:16 pm »
http://www.sfml-dev.org/tutorials/2.0/system-time.php
would be a good way to start

In the main loop while(window.isOpen())
you get the time the last frame took, and you use this frameTime to multiply every change in position.
this is a classic way of handling positions and you should be able to find many good tutorials with Google

24
System / Re: My Game is lagging
« on: May 12, 2013, 06:55:41 pm »
I took a look at your code and my first reaction was.. OMG

Understanding another's code is not the simplest thing but you make it a lot harder !

First you need to use object in C++ and not put everything in the main or in the file main.cpp

Your indenting is not the simplest either.

Considering all that, I'd consider using events differently.

Since you get the keyboard status in each frame, you shouldn't put verifications INTO the pollEvent loop, but outside, and making it time dependent.

Finally, you should try and follow a few basic tutorials about C++ to write it differently, I'm not really surprised by the fact you're managing to find where the problem is from with that code.

Hope I'm not being too harsh but people can correct me if I'm wrong.

25
Graphics / Re: SFML 2.0 - Move in direction faced
« on: May 12, 2013, 06:43:38 pm »
I don't know in which direction is your original sprite is, but my code is for an image that is facing up.

Works perfectly fine for me (your code did too however, but out of the pollEvent loop

26
Graphics / Re: SFML 2.0 - Move in direction faced
« on: May 12, 2013, 06:38:03 pm »
what does "compass direction" means ? I've tried your code and it works just fine, however you can only turn by multiples of 7 degrees.

Perhaps what you want to do is depend on the frame.

        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
            Ship_s.rotate(-30*frameTime);
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
            Ship_s.rotate(30*frameTime);
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
            Ship_s.move(500*sin(Ship_s.getRotation()*3.14159265/180)*frameTime, -500*cos(Ship_s.getRotation()*3.14159265/180)*frameTime);
        if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
            Ship_s.move(-500*sin(Ship_s.getRotation()*3.14159265/180)*frameTime, 500*cos(Ship_s.getRotation()*3.14159265/180)*frameTime);
 

where i get frameTime by mesuring how long did the last image to get printed.

Note that I make these calls outside of the pollEvent function.

27
System / Re: My Game is lagging
« on: May 12, 2013, 06:12:52 pm »
Hi,

I'm probably gonna answer before anyone else does, but this is not the right way to procede I fear.

This topic http://en.sfml-dev.org/forums/index.php?topic=5559.0 will help you understand how to resolve your problem.

You have to search by yourself and try and debug on your own before asking others to dig in your code.

The simplest thing is to try and comment out some parts of your code and/or to put a clock to see which part takes time.

Once you've got something isolated you can try and resolve it and if you can't, we'll be more than happy to try and understand why some lines take time.

Another way would be to try and create a minimal code that replicates the issue for us to see quickly what is the issue. Everything is explained in the link I put before.

Some developers use profilers to try and find what poses a problem at a lower level.


28
Graphics / Re: ViewPort not working correctly?
« on: May 11, 2013, 07:40:53 pm »
Hi,

First I'm wondering why you type
miniMap.setViewport(sf::FloatRect(0, 0, 1, 1));
since the default behavior of a View is taking all the window. Plus, calling
mWindow.setView(miniMap);
in the main loop is not essential, you can do it once.

My first reflex would have been to call
sf::View::reset()
or directly use the constructor

sf::View miniMap(0, 0, imageWidth, imageHeight);

Hope this helps you.

29
Graphics / Re: Issues with intersects
« on: May 11, 2013, 01:44:27 pm »
You seem to work with SFML 2.0, so the constructor for Rect takes 4 arguments which are not the same as for SFML 1.6 :

left, top, width, height and NOT
left, top, right, bottom

30
Audio / Re: Recording speaker output rather than microphone input
« on: May 02, 2013, 11:38:34 pm »
Did a little research on google and found out a few things.

It seems you can get what you want by using the WASAPI library, which would be the MSDN audio library.

The following link gives a few examples of how to use and code in this kind of area
http://www.codeproject.com/Articles/3094/Audio-Mixer-Functions-Demo

I believe that with a bit more googling one could find some intersting things to do.

Sorry I can't help you more, I don't have a lot of knowledge either.

Pages: 1 [2] 3