Sign in to follow this  
superman3275

[SFML] I Finished Pong! I Can't Believe It!

Recommended Posts

superman3275    2061
I fixed it so the game ends automatically when the ball hits the top or bottom of the screen, and fixed the dropbox link :)
[url="https://www.dropbox.com/sh/zrhgtq26e0gsvbs/X2offHcfHG"][Fixed] Project[/url]

Share this post


Link to post
Share on other sites
LennyLen    5717
Congratulations.

[quote name='superman3275' timestamp='1348796023' post='4984554']
(Sorry, I don't know how to release it! If someone could message me on how to, I would be Happy
[/quote]

I don't use VS myself, but: https://www.google.com.au/search?q=how+to+deploy+vc%2B%2B

Share this post


Link to post
Share on other sites
arthurviolence    1621
Theres a click once deployment feature that even has autoupdate! You can use it too directly to dropbox, so that we can download updates to stuff you put there, search for click once publish visual studio.

And gratz!

Share this post


Link to post
Share on other sites
Bacterius    13165
[quote name='superman3275' timestamp='1348796023' post='4984554']
I did it! Yes! I did it! I finished pong, and it works. I'm so happy! I just, can't believe it. I did it. Wow, after that much time, it's just amazing.
[/quote]
It is only the beginning. You will be amazed at what you produce in a few months' time!! Congratulations.

Share this post


Link to post
Share on other sites
Xirion    292
Congratulations!!, you've made the first step towards a new fascinating world.
Good luck on your trip [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
GlenDC    549
Awesome man, always fun to create your first game.
Btw if you share a vs project then you can delete the following files:[list]
[*]debug
[*]ipch
[*]a big file with the extentsion .sdf
[/list]
Good luck on your next project!

Share this post


Link to post
Share on other sites
Gratz!

[b]To change to release just click on:[/b]
Build -> Configuration Manager -> Click on 'Debug' change it to 'Release'. -> Rebuild your code which will create a new folder names Release.


[b]If you want people to test your game when you have an .exe and image/sounds folders like you have now you can do this:[/b]
- Create a new folder on your desktop or anywhere you like: example "Pong_Game"
- Copy the .exe from the Release folder into your new folder: example "Pong_Game/Pong.exe"
- Copy your images/sounds/SFML/videos into your new folder: example "Pong_Game/Images/..."

Click on the .exe and you should be able to play your game. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] If not, a folder has wrong placed wrong in the folder "Pong_Game".
So you don't need all the headers, cpp's, sdf, debug/release folder, ipch files. Those files aren't needed anyway to be able to play your game. [img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]


~EngineProgrammer

Share this post


Link to post
Share on other sites
superman3275    2061
I just spent some time trying to get text working, but I have a problem:
I have a variable in my ball class that keeps the amountofhits, whenever I hit the paddle this increments. But, I don't know how to set my text equal to this variable:
MyString.SetText(variable);
doesn't work. Any Ideas?
(At the moment I am just displaying the number in the console.)

Share this post


Link to post
Share on other sites
[quote name='superman3275' timestamp='1348876526' post='4984899']
I just spent some time trying to get text working, but I have a problem:
I have a variable in my ball class that keeps the amountofhits, whenever I hit the paddle this increments. But, I don't know how to set my text equal to this variable:
MyString.SetText(variable);
doesn't work. Any Ideas?
(At the moment I am just displaying the number in the console.)
[/quote]

Is SetText a function u created or is it built into whatever game library ur using, if its one u created make sure ur returning the data properly in the function and that your function has the right datatype of string like this

[CODE]
class MyClass{
public:
string SetText();
};
[/CODE]

im just assuming ur using a class this goes the same with plain old c++ functions though without a class declaration Edited by GameC++Expert93

Share this post


Link to post
Share on other sites
First you store the variable as a integer, and that's what you increment when the paddle is hit.

Then, when ready to draw, you MyString.SetText() a std::string, not an integer directly.[CODE]
//When paddle is hit...
score++; //Update the score.

//Convert the score to text.
std::string scoreAsText = convert_a_int_to_a_string(score); //'convert_a_int_to_a_string' is an imaginary function that doesn't exist.

//Set the new text.
MyString.SetText(scoreAsText);

//When ready to draw each frame
RenderWindow.Draw(MyString); //Or whatever...
[/CODE]

To convert an int to a string, you could use [url="http://www.cplusplus.com/reference/iostream/stringstream/"]std::stringstream[/url].
std::stringstream is used to format text, similar to how std::cout works (same interface).
[code]std::stringstream formattedText;
formattedText << "Score: " << score;

std::string convertedToText = formattedText.str(); //Turn the data stream into a std::string.
MyString.SetText(convertedToText);[/code]

Share this post


Link to post
Share on other sites
[quote name='Servant of the Lord' timestamp='1348882959' post='4984926']
First you store the variable as a integer, and that's what you increment when the paddle is hit.

Then, when ready to draw, you MyString.SetText() a std::string, not an integer directly.[CODE]
//When paddle is hit...
score++; //Update the score.

//Convert the score to text.
std::string scoreAsText = convert_a_int_to_a_string(score); //'convert_a_int_to_a_string' is an imaginary function that doesn't exist.

//Set the new text.
MyString.SetText(scoreAsText);

//When ready to draw each frame
RenderWindow.Draw(MyString); //Or whatever...
[/CODE]

To convert an int to a string, you could use [url="http://www.cplusplus.com/reference/iostream/stringstream/"]std::stringstream[/url].
std::stringstream is used to format text, similar to how std::cout works (same interface).
[code]std::stringstream formattedText;
formattedText << "Score: " << score;

std::string convertedToText = formattedText.str(); //Turn the data stream into a std::string.
MyString.SetText(convertedToText);[/code]
[/quote]

mm i could be wrong as to how pong works, but why would you update the score when the paddle is hit? i thought in pong the score should only be updated if that persons paddle does not end up hitting the ball

Share this post


Link to post
Share on other sites
[quote name='GameC++Expert93' timestamp='1348890535' post='4984949']
mm i could be wrong as to how pong works, but why would you update the score when the paddle is hit? i thought in pong the score should only be updated if that persons paddle does not end up hitting the ball
[/quote]
You're correct - I wasn't sure why the OP requested that either. I didn't know what to call the variable, so I just called it "score". Perhaps "bounces" would be a better name, but it depends on the OP's intent.

"[i]I have a variable in my ball class that keeps the amountofhits, whenever I hit the paddle this increments. But, I don't know how to set my text equal to this variable: MyString.SetText(variable); doesn't work. Any Ideas?[/i]" Edited by Servant of the Lord

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this