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

Pages: 1 [2] 3 4 ... 6
16
General / Tutorial "Opening a window" code doesn't work righ
« on: November 18, 2011, 11:23:58 pm »
Actually, the methods you are likely to call on the RenderWindow in your render method are likely going to be Draw, and Display, both of which are not const methods. Thus, you should not pass a reference to const, but just a reference, as a reference to const will not allow you to call any methods that are not const-qualified.

Use

Code: [Select]
void render(sf::RenderWindow& Window);

basically any time you want to pass a non-integral type (not an int, float, etc) for example (std::vector, sf::RenderWindow, sf::Texture, etc), you should be passing by reference, not by copy. When you write

Code: [Select]
void someMethod(sf::Texture Texture);

you are copying ALL of the data that is held in the instance you are passing as a parameter, and you should opt to pass by reference


Code: [Select]
void someMethod(sf::Texture& Texture);

However, passing by reference allows you to change the original object that was passed in. To promise you wont change anything, you can pass a reference to const

Code: [Select]
void someMethod(const sf::Texture& Texture);

but then you are limited to using methods of sf::Texture that are const qualified for example

Code: [Select]
unsigned int GetWidth () const

however you would not be allowed to call

Code: [Select]
void Update (const Uint8 *pixels)

17
General / FindSFML.cmake - broken on OS X
« on: November 18, 2011, 10:58:55 pm »
This should probably be documented in a README file or in a comment in FindSFML.cmake

18
General / FindSFML.cmake - broken on OS X
« on: November 18, 2011, 12:44:21 pm »
https://github.com/sbroadfoot90/cmaketest

Also, I'm not sure if I'm doing it right, but setting

Code: [Select]
set(CMAKE_FIND_FRAMEWORK "NEVER")

does not force the module to find the .dylib files instead of the .framework.

19
General / Tutorial "Opening a window" code doesn't work righ
« on: November 18, 2011, 08:46:41 am »
Probably this line here.

Code: [Select]
     states.back()->render(Window);

I'm guessing the signature for render is

Code: [Select]
void render(sf::RenderWindow Window);

or something like that. Change it to

Code: [Select]
void render(const sf::RenderWindow& Window);

20
General / FindSFML.cmake - broken on OS X
« on: November 18, 2011, 08:43:52 am »
@Laurent @Hiura,

the FindSFML.cmake doesn't work very well for OS X. It basically sets

SFML_INCLUDE_DIR to /Library/Frameworks/SFML.framework

and

SFML_LIBRARIES isn't set to anything.

I have a feeling SFML_INCLUDE_DIR should be set to /Library/Frameworks/SFML.framework/Headers, and SFML_LIBRARIES definitely shouldn't be blank.

21
General / Tutorial "Opening a window" code doesn't work righ
« on: November 17, 2011, 03:03:20 am »
unrecognised symbol usually means that you aren't linking to the necessary libraries

22
Graphics / Failed to load image "". Reason : Unable to open f
« on: November 06, 2011, 10:24:43 pm »
Quote from: "praetoriaen"
Quote from: "Laurent"
Can you provide a complete and minimal example that reproduces the problem?


I'll post the whole code, without obfuscation:


He wanted less code, not more, keyword "minimal". Most of the time people don't have time to read through other people's code in details so you need to keep it brief if you have a chance of getting help.

23
Graphics / trying to make enemy walk in a specific direction
« on: November 02, 2011, 12:11:21 am »
There are a lot of posts like this in the graphics section that really don't have anything to do with graphics. It has to do with people not being able to write sufficient control statements to get the behaviour they expect. What you need to do is step through your code line by line and work out why it's not working.

Basically on each frame you tell it to

Move right,
if you're far enough right, move down and left
if you're far enough down, move left and up

this is a pretty bad way of doing it if you ask me. What you should do is include a private member that keeps track of the state the AI is in, so it would be something like

Code: [Select]
class mov {
private:
   state myState
}


where state is an enum

Code: [Select]
enum state {
    RIGHT, DOWN, LEFT, UP
};


this way, you can code your ai with a switch statement



Code: [Select]
switch myState
case RIGHT

   move right
   if you are far enough right, change myState to DOWN
   break

case DOWN

   move DOWN
   if you are far enough down, change myState to LEFT
   break
etc

24
General / OSX / Ecplipse Symbol not Found
« on: October 23, 2011, 07:17:53 am »
It looks like you aren't linking to the libraries properly

25
Graphics / [SOLVED] atan2 ineffective when Rotating x to face y?
« on: October 23, 2011, 07:11:49 am »
Reading through all your posts, you kinda never really explain what sort of behaviour you want. Everything you say is really confusing. Perhaps you should just start over, draw a simple diagram and let us know what you want to do.

This is not a programming problem, it's a maths problem.

26
Graphics / [SOLVED] atan2 ineffective when Rotating x to face y?
« on: October 21, 2011, 11:31:29 pm »
Dude, it's not the programming you have wrong. It's the maths. You're trying to do the wrong thing... You need something like this

Code: [Select]

float angleBetweenVectors(sf::Vector2f lhs, sf::Vector2f rhs)
{
    return 57.2957795f * (atan2(lhs.x, lhs.y) - atan2(rhs.x, rhs.y));
}


Next time draw a diagram and work out the formula properly instead of trying to copy and paste things from tutorials. Nexus even told you what to do and instead of listening, you randomly multiplied the x and y components of the vectors together and shoved them into a function. Just take a step back and think about what you are doing.

27
Graphics / sprite/texture/image bending
« on: October 21, 2011, 11:25:11 pm »
I think the easiest solutions is just to produce the images as curved already and use some trigonometry to place them. Manual tweaking shouldn't be an issue if you get your maths right

28
General / Re: Closing window causes access violation
« on: October 21, 2011, 12:35:44 am »
Quote from: "Beta_Ravener"
I'm still not sure if it's bug in my code or SFML


care to show your code?

29
General / Installing on Mac (Xcode)
« on: October 21, 2011, 12:30:10 am »
OK, basically what I did,

1) Clone the git repository.

You can do this two ways:

a) by clicking here and then clicking on Clone in Mac. You will need to download the github app.

Screenshot

Choose to save it in ~/SFML (or any other folder).

b) Alternatively, if you have git installed in your bash terminal, simply type

$ cd ~
$ git clone https://github.com/SFML/SFML.git

2) Download and install C-make. Open it.

- Building release
Where it says "Where is the source code?", type ~/SFML
Where it says "Where to build the binaries", type ~/SFML/build-release
Then click configure, choose Unix makefile and default compiler and OK.... then wait a bit.

There will be a bunch of options in red. Tick all of them (if you don't have doxygen then leave BUILD_DOC unticked), and make sure CMAKE_BUILD_TYPE is Release.

Click configure again, and then click generate.

- Building debug
Do everything the same, but build in  ~/SFML/build-debug, and change CMAKE_BUILD_TYPE to Debug.

3) Compiling and installing

Open up a terminal and type

$ cd ~/SFML/build-release
$ make clean
$ sudo make install

Enter your password

then type

$ cd ../debug
$ make clean
$ sudo make install

Everything should be installed properly now.

4) Making a project with Xcode4!

Open up Xcode4, then click File > New > New Project. The screen should now look like this. Choose either one, and there you go!

If the templates didn't come up, then you probably forgot to tick INSTALL_XCODE4_TEMPLATES in cmake, OR, you didn't click configure the second time.

Any problems with this, just ask :)


EDIT: Made the instructions a bit clearer based on some replies

30
General / Installing on Mac (Xcode)
« on: October 20, 2011, 03:10:16 am »
Hey man, I'm using Xcode4 and I managed to get it working in under 20 minutes with the tutorial here and modifying it a bit for mac.

Are you using Xcode 3 or 4? I'll be happy to help if it's 4 :)[/url]

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