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

Pages: 1 ... 29 30 [31] 32 33 34
451
General / Collision detection(Pong game)
« on: February 08, 2012, 10:21:38 pm »
Quote
It's not detecting the paddles

Sorry, I misunderstood your sentence. I thought you meant that the problem did not lie with detecting the paddles.


Quote
the major problem is I can not detect collision.

You should be able to locate the problem a little better.
Debug your program: Is the detectCollision function returning NO_COLLISION? If so then check the values of the variables while performing the check.

452
General / Collision detection(Pong game)
« on: February 08, 2012, 08:29:30 pm »
I still think that your formula is wrong. Lets just use numbers as an example.
leftRacketPosition.x = 10
bouncerPosition.x = 12
racketWidth = 5

If I understand it correctly then the fraction would have to be 3.
You are doing 12 - 10 + 5 = 7   (bouncerPosition.x - leftRacketPosition.x + racketWidth)
My code does 10 + 5 - 12 = 3   (leftRacketPosition.x + racketWidth - bouncerPosition.x)

453
Graphics / [SOLVED]Text printing across the screen ?
« on: February 08, 2012, 07:44:49 pm »
I don't see anything wrong with that code, but are u calling getScore before draw?
I would call the SetPosition function inside draw so that the position is set to the correct place before drawing. If getScore isn't called before draw then the position will be wrong.

Also this line doesn't do much:
Code: [Select]
scoreText.Move(0.f,0.f);

I don't know what could be causing your problem, but try debugging (maybe you already tried those things):
- You should only see one 0 instead of a whole list of them, so is pScore still correct in the getScore function or does it already contain all those 0's?
- You are drawing scoreText together with scoreB, so if the text is drawn multiple times then the background would be drawn multiple times too. (I guess you would have noticed this so the problem does not lie with calling the draw function multiple times)
- You should try calling GetPosition inside the draw function and make sure that it is still (0, 320).


This has nothing to do with your problem, but you can replace the first line (which you use in your code) with the second one.
Code: [Select]
scoreB = sf::Sprite(scoreboardIMG);
scoreB.SetImage(scoreboardIMG);
.

454
General / Collision detection(Pong game)
« on: February 08, 2012, 07:06:17 pm »
Quote
I just don't get where the mistake is...
What exactly is going wrong? Does the ball go too far?


I think your fraction is wrong with the left panel. I think you have to add racketWidth instead of subtracting it.
Code: [Select]
fraction = leftRacketPosition.x + racketWidth - bouncerPosition.x;


Why are you adding 1 when colliding with the left paddle? You don't substract 1 when colliding with the right paddle.

455
Graphics / SFML 2.0: RenderWindow::GetFrameTime() missing?
« on: February 07, 2012, 09:17:26 pm »
This question has been asked before: http://www.sfml-dev.org/forum/viewtopic.php?t=6831

456
General / Sharing variable in different files
« on: February 06, 2012, 09:35:16 pm »
You shouldn't use it as extern.

Do as Nexus said: pass the variable with the function or put all your variables in a class.
I would do the second thing. Make an instance to the class in your main function and from then you only work with the functions and variables inside that class.

457
General / Where does everyone get their .ttf files for text in SFML?
« on: February 04, 2012, 07:46:17 pm »
Just google "download tff font" and you will find tons of those files.

You don't really need to load it from a file: you can just use the default font.
Take a look at the tutorial, it mentions the GetDefaultFont function.
If you use the default font then read this first: http://www.sfml-dev.org/forum/viewtopic.php?t=4741

458
SFML projects / Falling Rocks! (demo inside)
« on: February 02, 2012, 08:11:18 pm »
Very nice game.
I just got a score of 1585 in impossible.

Apparently it's not for windows only: it runs perfectly on my linux with wine.

459
Graphics / Line shape
« on: January 30, 2012, 11:22:13 pm »
After searching a few minutes (it was harder to find than I thought) I found it here: http://www.sfml-dev.org/forum/viewtopic.php?p=42814&highlight=rectangleshape#42814

Quote
Quick question: now that sf::Shape::Line is gone, how can I easily draw a line from point A to point B ?

Quote
If your line has a thickness, it's a rectangle and you can use sf::RectangleShape.

If it has no thickness, you can draw two vertices in sf::Lines mode.

460
General / messing up with key events <_<
« on: January 29, 2012, 02:32:05 pm »
Quote
Event.KeyEvent.Code

This should be "Event.Key.Code".

KeyEvent is the name of the struct, while Key is defined like this:
KeyEvent Key;

461
General / How do I create speed=0 when no key is pressed? (SOLVED)
« on: January 29, 2012, 12:52:30 pm »
Quote
If I make a Windows program, I can use key down and key up commands, but SFML seems to only have key down.

When IsKeyDown returnes false then your key is up. You don't need a IsKeyUp function.

For your problem, just add something like this:
- Check if both left and right key are up (check if IsKeyDown returns false)
- If speed is negative then add a value to the speed until it is 0
- If speed is positive then reduce the speed until it is 0.

462
Window / [SFML 2.0] sf::Keyboard::IsKeyPressed LNK2019 error
« on: January 29, 2012, 10:12:07 am »
You don't have to define it inside your classes.
Take a look at the Getting started tutorials.
The only difference is that you will have to define SFML_STATIC while in the tutorial they show how to define SFML_DYNAMIC.

463
General / Distributing SFML games on other websites.
« on: January 28, 2012, 09:02:53 pm »
Quote
The problem is that when i used sf::Texture::LoadFromFile it only looks in the game directory, not the sub folders.

You can just call LoadFromFile("subfolder/filename").

Quote
you can have resource inside .exe, how do you do that?

It is a long time ago I did this, you should just search information about using resources in Visual Studio.

464
General / Distributing SFML games on other websites.
« on: January 28, 2012, 12:49:47 pm »
Quote from: "Viruses"
How do i encrypt my files?

You will probably want a unique encryption so that nobody knows how to decode it.
The problem is that you will have to do this completely by yourself.

Start with writing a simple encryptor program: read the file and add 1 to every byte. Then save the file with a different extension.
Nobody will be able to open it now. Only your game can read it, because it reads the file and decrements every byte before is starts.

For a stronger and more secure encryption you will have to make a better formula (not just adding 1). You do this by adding, subtracting and multiplying bytes with each other.
Eventually you can even use more bytes for your file (original is e.g. 1kb while the encrypted version is 2kb).
But always make sure that the encryption can be reversed by your game.


Although the above will give you a little bit more protection, I completely agree with what the other people already told you: nothing is completely secure.
I wouldn't waste my time in writing a good encryption and I would want my game to be good: not letting it start slower because it first has to decode every file.

465
Graphics / Dragging Sprite outside original position
« on: January 26, 2012, 08:34:43 pm »
Quote
So that if Sprite1 is being dragged over Sprite2, then Sprite2 is also not dragged along with Sprite1.

You should have a variable to store which sprite is being dragged.
It is e.g. 0 when you aren't dragging, 1 when dragging Sprite1, ...
When you start dragging Sprite1 the value will become 1. You then move over Sprite2 and it must check if the variable is 2.
This is not the case so Sprite2 will not be moved.

I hope this makes any sense.

Pages: 1 ... 29 30 [31] 32 33 34