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

Author Topic: A few Questions..  (Read 21780 times)

0 Members and 1 Guest are viewing this topic.

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #30 on: October 31, 2010, 07:53:29 pm »
So were would:

1) Ball movement
2) Enemy Logic
3) Player Movement
4) Collision
5) Detecting Whether it scored or not
6) also I see you do not declare the sprite's before drawing them, or is that me misreading it?

Go?

Thanks - could I have a reply in the next hour

Thank you ever so much

Simon

Canadadry

  • Hero Member
  • *****
  • Posts: 1081
    • View Profile
A few Questions..
« Reply #31 on: October 31, 2010, 08:12:20 pm »
You have to think about your main loop, what does it do, in what order what for. The question you is basic question of a program design.

Fisrt, the event loop, that will allow you to know what user had done. You could simplify your program by using Input.

Then there is the update phase. depending on time and user input you will trying to move object and testing collision then removing them according to it.

And finally draw you object.

The best way you have to succeed, is trying failling and trying and failling.. Until you succeed. Even if you don't really know what to do, try... You also should read code from other people, start with the sfml's sample, especially the pong one. You could also read the wiki.

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #32 on: October 31, 2010, 08:19:40 pm »
Thanks ALOT!!!!

Simon

p.s. I genuinely thank you as much as I can... Thanks  :D

priomsrb

  • Newbie
  • *
  • Posts: 38
    • View Profile
A few Questions..
« Reply #33 on: October 31, 2010, 09:34:41 pm »
@Disch

Lol. Haha. Yeah it's only for pong. But thanks for the explanation though. I might find it handy in the future.

@Father_Sloth

Hope everything is going well. Just some tips:

- If you get stuck on some logic or something, try using pen and paper. Don't worry if you can't think of a solution immediately. Problem solving takes time.

- If you get stuck between a few choices on how to do something (like how to detect scores), just try one way and see if it works. Making mistakes and trial and error are good ways to learn.

- Build up incrementally. Don't worry about spacebar and scores yet. First try to get a ball moving on the screen. Then add paddles that can move. Then add collisions, etc. This will make things easier and much less daunting.

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #34 on: October 31, 2010, 10:15:51 pm »
Thanks Priomsrb for your real interest. You can't believe me how much paper I've gone through in the last week. Luckily I'm getting a whiteboard soon  :P .

So could you help me logically. Mooglwy helped loads but I still don't know a few things that i'm stumped on. first of how do I declare a function. It say's I have not declared it in the scope which is true - because i dont know how.

Also where does player + enemy score go. I've finally got a scoring system that i'm pleased with but i don't know where to put it. Would I be correct in thinking that it would be best in the while loop.

Thanks Priomsrb.

Simon

priomsrb

  • Newbie
  • *
  • Posts: 38
    • View Profile
A few Questions..
« Reply #35 on: October 31, 2010, 11:04:21 pm »
Hehe nice. I prefer paper actually since my ideas stay there forever. Also I don't have to rub it clear every so often ;)

If a function isn't in scope then declare it at the top. For example:

Code: [Select]
void myFunction(); // This is the declaration

int main() {
    ...
    myFunction(); // We can call our function here now
    ...
}

void myFunction() {
     // Code for myFunction goes here
     ...
}



Quote
Also where does player + enemy score go. I've finally got a scoring system that i'm pleased with but i don't know where to put it. Would I be correct in thinking that it would be best in the while loop.

I'm not sure what you mean by this. I'd make some variables for player and enemy score. Then if player scores then increment his score.

Btw I won't be able to reply as much now because my exams are starting. In fact my first one starts in 3 hours ;)

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #36 on: October 31, 2010, 11:12:23 pm »
Sorry bout that, it's 10pm in the uk  :D . Thanks for that I think I've got it sorted though, but I did the declaration thing before and:

Code: [Select]
void play();


returns: "too many arguments to function 'void play()"

Code: [Select]
void play(App);


returns: "Variable or field 'void' declared void" - well duh you stupid compiler!

Thanks and Good Luck on the exam

Simon

Canadadry

  • Hero Member
  • *****
  • Posts: 1081
    • View Profile
A few Questions..
« Reply #37 on: October 31, 2010, 11:51:34 pm »
You declare your function has "void play(void)" but you called a "void play(sf::RenderWindow)"

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #38 on: November 01, 2010, 05:42:38 pm »
even with the syntax correction it's reads - " error: too many arguments to function 'void play()' "

Simon

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #39 on: November 06, 2010, 03:20:28 pm »
Hey Guys

Haven't Posted in a while, but I've still got this function problem. I keep on getting the same error on the play function mooglwy suggested.


Here is when I try to declare it (In the exact place mooglwy suggested):



Here is when I try to use it:




Thanks ever so much. I've tried every thing I can think of and after scouring the internet nothing has helped.

Simon

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
A few Questions..
« Reply #40 on: November 06, 2010, 03:35:26 pm »
Man, You should read book before programming, especially if You want to program games.

Canadadry

  • Hero Member
  • *****
  • Posts: 1081
    • View Profile
A few Questions..
« Reply #41 on: November 06, 2010, 03:45:19 pm »
it's a bit rough but he's right. You really need to learn some basics. Like how to declare a function. Especially for this problem, you already ask and i already answered it.

I don't know what to tell you either learn C, you could start here.

Father_Sloth

  • Newbie
  • *
  • Posts: 48
    • View Profile
A few Questions..
« Reply #42 on: November 06, 2010, 04:08:54 pm »
Hey

I have read the Michael Dawson C++ through game programming and also a few websites on c++ functions and none of them answered it.

Just saying

Simon

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
A few Questions..
« Reply #43 on: November 06, 2010, 04:41:18 pm »
They would... It's very simple.

You've for instance declared a prototype for a function that doesn't seem to exist and you are trying to pass an argument to it even though it doesn't take any arguments.

This is basic syntax. You should practice more on just writing C++ code before trying to wrestle with a library like SFML.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

Canadadry

  • Hero Member
  • *****
  • Posts: 1081
    • View Profile
A few Questions..
« Reply #44 on: November 06, 2010, 05:47:29 pm »
Quote from: "Father_Sloth"
I have read the Michael Dawson C++ through game programming and also a few websites on c++ functions and none of them answered it.


It's because it's too looking too high, your error is really really basic if you have read my 2 post you will have found your answer.

Quote from: "mooglwy"
You declare your function has "void play(void)" but you called a "void play(sf::RenderWindow)"


Isn't that clear enough ? What do you want more ? We can't program for you. You will have to learn C and C++ by yourself before.

I also strongly advise you read the link i gave you. That's my last post for this problem, you've got all the card you need. Think be yourself.  :wink:

 

anything