Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Breakout Game  (Read 5569 times)

0 Members and 1 Guest are viewing this topic.

CodingNoob

  • Newbie
  • *
  • Posts: 2
    • View Profile
Breakout Game
« on: May 30, 2012, 02:32:54 pm »
Hi. I am working on a project for my College assignment. It is due in 6 weeks, which would roughly be the 6th of July. I am pretty new to programming, I am using C++ and SFML 2.0. This is basically the game that i will be making if you haven't played it http://www.play.vg/games/10-Breakout.html minus a few of the features such as the changing size of the paddle I will not include unless I have time too. I will probably need a fair bit of help. I already having one issue where I am creating the ball but it is not printing to the screen. I assumed that window.draw(ball) would make it appear on the screen but it does not.

This is the code I have so far
#include <SFML/Graphics.hpp>
#include <iostream>

using namespace std;

int main()
{
        sf::Vector2f BallSize(4,4);

        //Create ball
        sf::RectangleShape Ball;
        Ball.setSize(BallSize);
        Ball.setFillColor(sf::Color::Yellow);
        Ball.setOutlineColor(sf::Color::Blue);
        float x = 50;
        float y = 50;
        Ball.setOrigin(x,y);
       

        //Create Blank window
        sf::RenderWindow window(sf::VideoMode(1024,720), "Breakout");
        while (window.isOpen())
    {
               
        sf::Event event;
        while (window.pollEvent(event))
        {
                       
            if (event.type == sf::Event::Closed){
                                window.close();}
                        if (event.type == sf::Event::KeyReleased && event.key.code == sf::Keyboard::Escape)
                        { window.close();}

        }

                window.clear(sf::Color::Red);
                window.draw(Ball); // Shouldn't this make the ball appear???
                window.display();
    }

    return 0;
}
I will be splitting it up into separate files obviously just I want to get the simple aspects of the game done before I do that.
Any help will be appreciated. Thanks.

[attachment deleted by admin]
« Last Edit: May 30, 2012, 02:37:50 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Breakout Game
« Reply #1 on: May 30, 2012, 02:45:16 pm »
Next time, please post in one of the "Help" forums if you have problems. This section is only for showing projects.

Your problem is that you play with the origin of the shape without knowing what it does. I guess you want to play with the position instead.
Laurent Gomila - SFML developer

aBallofWin

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: Breakout Game
« Reply #2 on: May 31, 2012, 12:13:44 am »
Hey, I would have helped out, but I haven't familiarised myself with sfml2 :(

Maybe if you haven't made that much progress, consider moving to sfml 1.6? For a person new to programming that will really help as it has more tutorials than sfml2 does, and I found it very easy to pick up and started to use it within the first week.

I'd like to ask also, how new are you to programming? It could be a daunting task to start learning C++ and sfml2 within 6 weeks, plus making a graphical game :)

Rosme

  • Full Member
  • ***
  • Posts: 169
  • Proud member of the shoe club
    • View Profile
    • Code-Concept
Re: Breakout Game
« Reply #3 on: May 31, 2012, 02:58:29 am »
@aBallofWin: You got to be kidding? 1.6 is not supported anymore, and 2.0 is stable enough to be use. Most tutorials of 1.6 can be ported without much complication into 2.0. The documentation is clear enough to help.
The only thing I agree with you is the daunting task of learning C++ and SFML in 6 weeks.
GitHub
Code Concept
Twitter
Rosme on IRC/Discord

Th3Oth3r50

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Breakout Game
« Reply #4 on: May 31, 2012, 04:53:38 am »
Use SFML 2, it makes no sense to learn SFML 1.6 when its about to be outdated especially since the code for a game like this is well documented and fairly easy to grasp on the SFML side.

Learning C++ in that time frame as mentioned will be the more difficult part.

I would suggest you start by specifying exactly what you want to achieve - features etc and laying out how you plan to go about achieving those features then people can comment on those choices and help you with the code along the way so they don't feel they are doing your assignment for you and the planning will make it much easier.


CodingNoob

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Breakout Game
« Reply #5 on: May 31, 2012, 04:56:06 pm »
Sorry Laurent, I would delete this but for some reason it doesn't let me.
Thanks everyone else who has commented. I learnt C++ last trimester(12 weeks) just have to learn SFML2.0 and I should be fine. :D